--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2007, 2018 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.request;
+
+import org.simantics.datatypes.literal.GUID;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+public class PossibleGUID extends ResourceRead<String> {
+
+ public PossibleGUID(Resource resource) {
+ super(resource);
+ }
+
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ GUID guid = graph.getPossibleRelatedValue(resource, L0.identifier, GUID.BINDING);
+ return guid != null ? guid.indexString() : null;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2007, 2018 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.request;
+
+import org.simantics.datatypes.literal.GUID;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+public class PossibleVariableGUID extends VariableRead<String> {
+
+ public PossibleVariableGUID(Variable variable) {
+ super(variable);
+ }
+
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ GUID guid = variable.getPossiblePropertyValue(graph, "identifier", GUID.BINDING);
+ return guid != null ? guid.indexString() : null;
+ }
+
+}
import org.simantics.db.common.primitiverequest.Supertypes;
import org.simantics.db.common.primitiverequest.Types;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.request.PossibleGUID;
+import org.simantics.db.layer0.request.PossibleVariableGUID;
import org.simantics.db.layer0.request.PossibleURI;
import org.simantics.db.layer0.request.PossibleVariableRepresents;
import org.simantics.db.layer0.request.VariableRead;
String typesStr = getTypeResourceString(processor, res, var);
if(var != null) {
String uri = processor.syncRequest(new VariableURI(var));
+ String guid = processor.syncRequest(new PossibleVariableGUID(var));
return toJSONObjectString(
"type", "\"Variable\"",
"uri", safeQuotedString(uri),
+ "guid", safeQuotedString(guid),
+ "resourceId", res == null ? "" : Long.toString(res.getResourceId()),
"typeResources", typesStr);
}
if(res != null) {
- String uri = processor.syncRequest(new PossibleURI(res));
+ String uri = processor.syncRequest(new PossibleURI(res));
+ String guid = processor.syncRequest(new PossibleGUID(res));
return toJSONObjectString(
"type", "\"Resource\"",
"uri", safeQuotedString(uri),
+ "guid", safeQuotedString(guid),
+ "resourceId", Long.toString(res.getResourceId()),
"typeResources", typesStr);
}
return "{ \"type\": \"Unknown\" }";