- libs: for(Resource library : graph.syncRequest(new ObjectsWithType(resource, L0.IsLinkedTo, L0.SharedOntology))) {
+ for(Resource library : graph.syncRequest(new ObjectsWithType(resource, L0.IsLinkedTo, L0.SharedOntology))) {
+ if (order.contains(library)) continue;
+ if (visited.contains(library)) throw new DatabaseException("Cyclic dependency detected.");
+ visited.add(library);
+ collectDependencies(graph, library, order, visited);
+ order.addFirst(library);
+ }
+ }
+
+ private static List<ModelDependency> collectModelDependencies(ReadGraph graph, Resource resource) throws DatabaseException {
+ List<Resource> order = collectDependencies(graph, resource);
+ Collections.reverse(order);
+
+ List<ModelDependency> modelDependencies = new ArrayList<>(order.size());
+
+ for (Resource library : order) {