+
+ JSONObject computeStatic(ReadGraph graph, Variable variable, DocumentProperties statics) throws DatabaseException {
+
+ JSONObject base = graph.syncRequest(new org.simantics.document.server.request.DefaultFields(variable));
+ JSONObject object = base.clone();
+
+ for(String name : statics.getKeys(graph, variable)) {
+ try {
+ if (name.equals(NodeRequest.PROPERTY_VALUE_EXCEPTIONS)) {
+ @SuppressWarnings("unchecked")
+ Map<String, Exception> exceptions = (Map<String, Exception>)statics.getValue(graph, variable, name);
+
+ List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+ if(errorList == null)
+ errorList = new ArrayList<>();
+
+ 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.addJSONField(name, statics.getValue(graph, variable, name));
+ }
+ } catch (Throwable t) {
+ List<String> errorList = object.getJSONField(NodeRequest.ERRORS);
+ if(errorList == null)
+ errorList = new ArrayList<>(1);
+
+ String errorMessage = NodeRequestUtils.formatErrorMessage(name, t);
+ errorList.add(errorMessage);
+ object.addJSONField(NodeRequest.ERRORS, errorList);
+ }
+
+ }
+
+ return object;
+
+ }
+