]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.server/src/org/simantics/document/server/DocumentValue.java
Removed graph compilation nature from org.simantics.jdbc
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / DocumentValue.java
1 package org.simantics.document.server;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.exception.DatabaseException;
5 import org.simantics.db.layer0.request.VariableRead;
6 import org.simantics.db.layer0.variable.Variable;
7 import org.simantics.document.server.request.DocumentRequest;
8
9 public class DocumentValue extends VariableRead<Object> {
10
11         public DocumentValue(Variable variable) {
12                 super(variable);
13         }
14
15         @Override
16         public Object perform(ReadGraph graph) throws DatabaseException {
17                 if(DocumentRequest.PROFILE) return performProfiled(graph);
18                 return variable.getValue(graph);
19         }
20         
21         public Object performProfiled(ReadGraph graph) throws DatabaseException {
22                 long start = System.nanoTime();
23                 Object result = variable.getValue(graph);
24                 //System.err.println("DocumentValue " + result + " " + variable.getURI(graph));
25         long dura = System.nanoTime()-start;
26         if(dura > DocumentRequest.PROFILE_THRESHOLD_VALUEREQUEST * 1e3) {
27                 System.err.println("DocumentValue " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. "+ variable.getURI(graph));
28         }
29                 return result;
30         }
31         
32         @Override
33         public String toString() {
34                 return "DocumentValue[" + variable + "]";
35         }
36         
37 }