-package org.simantics.db.layer0.genericrelation;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.datatypes.literal.GUID;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.TypeString;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-\r
-class Entry implements Comparable<Entry> {\r
-\r
- Entry(Resource parent, Resource resource, String name, String types, String id) {\r
- this.parent = parent;\r
- this.resource = resource;\r
- this.name = name;\r
- this.types = types;\r
- this.id = id;\r
- }\r
-\r
- Entry(ReadGraph graph, Layer0 L0, Resource resource) throws DatabaseException {\r
- this.parent = graph.getPossibleObject(resource, L0.PartOf);\r
- this.resource = resource;\r
- this.name = graph.getPossibleRelatedValue(resource, L0.HasName, Bindings.STRING);\r
- this.types = graph.syncRequest(new TypeString(L0, graph.getTypes(resource)));\r
- this.id = idFromGUID(graph.getPossibleRelatedValue(resource, L0.identifier, GUID.BINDING));\r
- }\r
- \r
- private static String idFromGUID(GUID guid) {\r
- if(guid == null) return "";\r
- return guid.indexString();\r
- }\r
-\r
- Entry(ReadGraph graph, Resource resource) throws DatabaseException {\r
- this(graph, Layer0.getInstance(graph), resource);\r
- }\r
-\r
- final Resource parent;\r
- final Resource resource;\r
-\r
- String types;\r
- String name;\r
- String id;\r
- Resource principalType;\r
-\r
- @Override\r
- public int compareTo(Entry o) {\r
- int names = name.compareTo(o.name);\r
- if(names != 0) return names;\r
- int resources = resource.compareTo(o.resource);\r
- if(resources != 0) return resources;\r
- return id.compareTo(o.id);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return resource.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- Entry other = (Entry)obj;\r
- return resource.equals(other.resource);\r
- }\r
-\r
+package org.simantics.db.layer0.genericrelation;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.datatypes.literal.GUID;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.TypeString;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+class Entry implements Comparable<Entry> {
+
+ Entry(Resource parent, Resource resource, String name, String types, String id) {
+ this.parent = parent;
+ this.resource = resource;
+ this.name = name;
+ this.types = types;
+ this.id = id;
+ }
+
+ Entry(ReadGraph graph, Layer0 L0, Resource resource) throws DatabaseException {
+ this.parent = graph.getPossibleObject(resource, L0.PartOf);
+ this.resource = resource;
+ this.name = graph.getPossibleRelatedValue(resource, L0.HasName, Bindings.STRING);
+ this.types = graph.syncRequest(new TypeString(L0, graph.getTypes(resource)));
+ this.id = idFromGUID(graph.getPossibleRelatedValue(resource, L0.identifier, GUID.BINDING));
+ }
+
+ private static String idFromGUID(GUID guid) {
+ if(guid == null) return "";
+ return guid.indexString();
+ }
+
+ Entry(ReadGraph graph, Resource resource) throws DatabaseException {
+ this(graph, Layer0.getInstance(graph), resource);
+ }
+
+ final Resource parent;
+ final Resource resource;
+
+ String types;
+ String name;
+ String id;
+ Resource principalType;
+
+ @Override
+ public int compareTo(Entry o) {
+ int names = name.compareTo(o.name);
+ if(names != 0) return names;
+ int resources = resource.compareTo(o.resource);
+ if(resources != 0) return resources;
+ return id.compareTo(o.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return resource.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ Entry other = (Entry)obj;
+ return resource.equals(other.resource);
+ }
+
}
\ No newline at end of file