+
+ public static Resource possibleObjectForType(ReadGraph graph, Resource type, Resource relation) throws DatabaseException {
+ PropertyInfo pi = graph.syncRequest(new PropertyInfoRequest(relation));
+ return possibleObjectForType(graph, type, relation, pi.isFunctional);
+ }
+
+ public static Resource possibleObjectForType(ReadGraph graph, Resource type, Resource relation, boolean functional) throws DatabaseException {
+ if(functional) {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Resource result = graph.getPossibleObject(type, relation);
+ if(result != null) return result;
+ for(Resource su : graph.getObjects(L0.Inherits, type)) {
+ Resource r = possibleObjectForType(graph, su, relation);
+ if(r != null) {
+ if(result != null) return null;
+ result = r;
+ }
+ }
+ return result;
+ } else {
+ throw new UnsupportedOperationException("asd");
+ }
+ }