+
+ JSONObject staticContent = computeStatic(graph, variable, statics);
+
+ return new Pair<JSONObject, Collection<Variable>>(staticContent, Collections.emptyList());
+
+ }
+
+ JSONObject computeStatic(ReadGraph graph, Variable variable, ArrayList<Variable> statics) throws DatabaseException {
+
+ JSONObject base = graph.syncRequest(new org.simantics.document.server.request.DefaultFields(variable));
+ JSONObject object = base.clone();
+
+ for(Variable attrib : statics) {
+ String name = attrib.getName(graph);
+ try {
+ if (name.equals(NodeRequest.PROPERTY_VALUE_EXCEPTIONS)) {
+ @SuppressWarnings("unchecked")
+ Map<String, Exception> exceptions = (Map<String, Exception>)DocumentServerUtils.getValue(graph, attrib);
+
+ List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+ if(errorList == null)
+ errorList = new ArrayList<String>();
+
+ for (Map.Entry<String, Exception> entry : exceptions.entrySet()) {
+ String errorMessage = NodeRequestUtils.formatErrorMessage(entry.getKey(), entry.getValue());
+ errorList.add(errorMessage);
+ }
+ object.addJSONField(NodeRequest.ERRORS, errorList);
+
+ } else {
+ Object value = DocumentServerUtils.getValue(graph, attrib);
+ object.addJSONField(name, value);
+ }
+ } catch (Throwable t) {
+ List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+ if(errorList == null)
+ errorList = new ArrayList<String>();
+
+ String errorMessage = NodeRequestUtils.formatErrorMessage(name, t);
+
+ errorList.add(errorMessage);
+ object.addJSONField(NodeRequest.ERRORS, errorList);
+ }
+
+ }
+
+ return object;
+