X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FNodeRequest.java;h=c9dfe893433d379b083fa40cbb6a1a559d62024c;hb=68ce0966a57f5153b133c6283fdbae10f683b745;hp=d9418db9947d482fecd4daf547d85359363bea5c;hpb=59e011d8d6e88ddebb7300cb60109c6bd43f5de8;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequest.java index d9418db99..c9dfe8934 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequest.java @@ -1,76 +1,50 @@ package org.simantics.document.server.request; -import java.util.ArrayList; -import java.util.Collection; -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.server.DocumentServerUtils.AttributesRequest; import org.simantics.document.server.JSONObject; -import org.simantics.utils.datastructures.Pair; +import org.simantics.threadlog.Task; +import org.simantics.threadlog.ThreadLog; public class NodeRequest extends VariableRead { public static final String ERRORS = "Errors"; public static final String PROPERTY_VALUE_EXCEPTIONS = "_PropertyValueExceptions"; - - public NodeRequest(Variable node) { - super(node); - } - @SuppressWarnings("unchecked") + public NodeRequest(Variable node) { + super(node); + } + + @SuppressWarnings("unchecked") @Override - public JSONObject perform(ReadGraph graph) throws DatabaseException { + public JSONObject perform(ReadGraph graph) throws DatabaseException { - long s = System.nanoTime(); + long s = System.nanoTime(); - Pair> attribs = graph.syncRequest(new AttributesRequest(variable)); + Task task = ThreadLog.BEGIN("NodeRequest " + variable.getURI(graph)); + + try { - JSONObject staticContent = attribs.first; - if(attribs.second.isEmpty()) { + JSONObject staticContent = graph.syncRequest(new AttributesRequest(variable)); - if(DocumentRequest.PROFILE) { - long dura = System.nanoTime()-s; - if(dura > DocumentRequest.PROFILE_THRESHOLD_NODEREQUEST * 1e3) { - System.err.println("NodeRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph)); - } - } + if(DocumentRequest.PROFILE) { + long dura = System.nanoTime()-s; + if(dura > DocumentRequest.PROFILE_THRESHOLD_NODEREQUEST * 1e3) { + System.err.println("NodeRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph)); + } + } + return staticContent; - } - - Map dynamicContent = graph.syncRequest(new NodeRequestDynamic(variable)); - if(dynamicContent.isEmpty()) { - return staticContent; - } - - JSONObject result = staticContent.clone(); - result.add(dynamicContent); - - if(dynamicContent.containsKey(ERRORS) || staticContent.getJSONField(ERRORS) != null) { - ArrayList errorList = new ArrayList<>(); - - if(dynamicContent.containsKey(ERRORS)) - errorList.addAll((List)dynamicContent.get(ERRORS)); - - if(staticContent.getJSONField(ERRORS) != null) - errorList.addAll((List)staticContent.getJSONField(ERRORS)); - - result.addJSONField(ERRORS, errorList); - } - if(DocumentRequest.PROFILE) { - long dura = System.nanoTime()-s; - if(dura > DocumentRequest.PROFILE_THRESHOLD_NODEREQUEST * 1e3) { - System.err.println("NodeRequest " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph)); - } - } - - return result; + } finally { + + task.end(); + + } }