]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/TypicalMasterRemover.java
Added new field TypeId to dependency index for exact type searching
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / adapters / TypicalMasterRemover.java
1 package org.simantics.modeling.adapters;
2
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.common.request.IsParent;
6 import org.simantics.db.exception.DatabaseException;
7
8 /**
9  * @author Tuukka Lehtonen
10  */
11 public class TypicalMasterRemover extends ExistingInstancesRemover {
12
13         public TypicalMasterRemover(Resource resource, String typeDescription) {
14                 super(resource, typeDescription);
15         }
16
17         @Override
18         public void remove(WriteGraph graph) throws DatabaseException {
19                 // In typical masters the actual typical type is defined as a part of
20                 // the master instance itself. Therefore we need to customize this code
21                 // to look for the correct type.
22                 for (Resource type : graph.getPrincipalTypes(resource)) {
23                         if (graph.syncRequest(new IsParent(resource, type))) {
24                                 remove(graph, resource, type, resource);
25                                 return;
26                         }
27                 }
28
29                 // Typical type not found. Just remove, no questions asked.
30                 justRemove(graph);
31         }
32
33 }