1 package org.simantics.db.layer0.adapter;
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.db.layer0.adapter.impl.EntityRemover;
7 import org.simantics.db.layer0.exception.CannotRemoveException;
8 import org.simantics.db.layer0.internal.SimanticsInternal;
9 import org.simantics.db.layer0.request.ProjectModels;
10 import org.simantics.db.layer0.util.Layer0Utils;
11 import org.simantics.layer0.Layer0;
14 * @author Tuukka Lehtonen
16 public class SharedOntologyRemover extends EntityRemover {
18 public SharedOntologyRemover(Resource resource) {
23 public void remove(WriteGraph graph) throws DatabaseException {
25 Layer0 L0 = Layer0.getInstance(graph);
27 for(Resource ontology : Layer0Utils.listOntologies(graph)) {
28 if(graph.hasStatement(ontology, L0.IsLinkedTo, resource))
29 throw new CannotRemoveException("The shared library is being referenced by " + graph.getURI(ontology));
32 for(Resource model : graph.syncRequest(new ProjectModels(SimanticsInternal.getProject()))) {
33 if(graph.hasStatement(model, L0.IsLinkedTo, resource))
34 throw new CannotRemoveException("The shared library is being referenced by " + graph.getURI(model));