X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FNodeRequestDynamic.java;h=91b4d9e9708145cc9edff780b82852a2f4b7e38c;hb=6ff5e65793559d92443fcd1eb7e8d12a3bed9e9e;hp=299608f569c2d7bd17239486902ee76eb7fef5bf;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestDynamic.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestDynamic.java index 299608f56..91b4d9e97 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestDynamic.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestDynamic.java @@ -1,65 +1,65 @@ -package org.simantics.document.server.request; - -import gnu.trove.map.hash.THashMap; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.VariableRead; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.document.base.ontology.DocumentationResource; -import org.simantics.document.server.DocumentServerUtils; -import org.simantics.structural.stubs.StructuralResource2; - -class NodeRequestDynamic extends VariableRead> { - - public NodeRequestDynamic(Variable node) { - super(node); - } - - @Override - public Map perform(ReadGraph graph) throws DatabaseException { - - long s = System.nanoTime(); - - StructuralResource2.getInstance(graph); - DocumentationResource DOC = DocumentationResource.getInstance(graph); - - Collection attributes = DocumentServerUtils.getDynamicAttributes(graph, DOC, variable); - if(attributes.isEmpty()) return Collections.emptyMap(); - - Map result = new THashMap(); - for(Variable attrib : attributes) { - String name = attrib.getName(graph); - try { - Object value = DocumentServerUtils.getValue(graph, attrib); - result.put(name, value); - } catch (Throwable t) { - @SuppressWarnings("unchecked") - List errorList = (List) result.get(NodeRequest.ERRORS); - if(errorList == null) - errorList = new ArrayList(); - - String errorMessage = NodeRequestUtils.formatErrorMessage(name, t); - - errorList.add(errorMessage); - result.put(NodeRequest.ERRORS, errorList); - } - - } - - if(DocumentRequest.PROFILE) { - long dura = System.nanoTime()-s; - System.err.println("NodeRequestDynamic " + System.identityHashCode(this) + " " + variable.getURI(graph) + " in " + 1e-6*dura + "ms." + result); - } - - return result; - - } - +package org.simantics.document.server.request; + +import gnu.trove.map.hash.THashMap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.VariableRead; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.document.base.ontology.DocumentationResource; +import org.simantics.document.server.DocumentServerUtils; +import org.simantics.structural.stubs.StructuralResource2; + +class NodeRequestDynamic extends VariableRead> { + + public NodeRequestDynamic(Variable node) { + super(node); + } + + @Override + public Map perform(ReadGraph graph) throws DatabaseException { + + long s = System.nanoTime(); + + StructuralResource2.getInstance(graph); + DocumentationResource DOC = DocumentationResource.getInstance(graph); + + Collection attributes = DocumentServerUtils.getDynamicAttributes(graph, DOC, variable); + if(attributes.isEmpty()) return Collections.emptyMap(); + + Map result = new THashMap(); + for(Variable attrib : attributes) { + String name = attrib.getName(graph); + try { + Object value = DocumentServerUtils.getValue(graph, attrib); + result.put(name, value); + } catch (Throwable t) { + @SuppressWarnings("unchecked") + List errorList = (List) result.get(NodeRequest.ERRORS); + if(errorList == null) + errorList = new ArrayList(); + + String errorMessage = NodeRequestUtils.formatErrorMessage(name, t); + + errorList.add(errorMessage); + result.put(NodeRequest.ERRORS, errorList); + } + + } + + if(DocumentRequest.PROFILE) { + long dura = System.nanoTime()-s; + System.err.println("NodeRequestDynamic " + System.identityHashCode(this) + " " + variable.getURI(graph) + " in " + 1e-6*dura + "ms." + result); + } + + return result; + + } + } \ No newline at end of file