]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
Layer0Utils.claimAdaptedValue does not support type adapting
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / Layer0Utils.java
index 103c9bb0129259bd5dd0c2000410a95fc147bc53..936eb58126f0b30563406cd404e1872889d54759 100644 (file)
@@ -569,16 +569,16 @@ public class Layer0Utils {
 
        }
 
-       public static void claimAdaptedValue(WriteGraph graph, Resource objectResource, Object value, Binding binding, Datatype datatype) throws DatabaseException {
+       public static void claimAdaptedValue(WriteGraph graph, Resource objectResource, Object value, Binding binding, Datatype targetDatatype) throws DatabaseException {
 
                try {
 
-                       Datatype source = binding.type();
-                       if(source.equals(datatype)) {
+                       Datatype sourceDatatype = binding.type();
+                       if(sourceDatatype.equals(targetDatatype)) {
                                graph.claimValue(objectResource, value, binding);
                        } else {
-                               Binding target = Bindings.getBinding(datatype);
-                               Adapter adapter = Bindings.getAdapter(binding, target);
+                               Binding target = Bindings.getBinding(targetDatatype);
+                               Adapter adapter = Bindings.getTypeAdapter(binding, target);
                                graph.claimValue(objectResource, adapter.adapt(value), target);
                        }
 
@@ -1379,25 +1379,12 @@ public class Layer0Utils {
        
     }
 
-    public static String prettyPrintResource(ReadGraph graph, Resource resource) throws Exception {
+    public static String prettyPrintResource(ReadGraph graph, Resource resource, boolean ignoreIdentifiers) throws Exception {
         TransferableGraphSource source = makeTGSource(graph, resource);
         TransferableGraph1 tg = TransferableGraphs.create(graph, source);
         GraphRefactoringUtils.fixOntologyExport(tg);
-        return PrettyPrintTG.print(tg);
+        System.out.println("Printing resoure " + graph.getURI(resource));
+        return PrettyPrintTG.print(tg, ignoreIdentifiers);
     }
 
-    public static Resource getPossibleAssertedObject(ReadGraph graph, Resource resource, Resource predicate) throws DatabaseException {
-       Resource result = null;
-       for(Resource type : graph.getPrincipalTypes(resource)) {
-               Collection<Resource> rs = graph.getAssertedObjects(type, predicate);
-               if(rs.size() > 1) return null;
-               if(rs.size() == 1) {
-                       Resource ass = rs.iterator().next();
-                       if (result != null && !result.equals(ass)) return null;
-                       result = ass;
-               }
-       }
-       return result;
-    }
-    
 }