]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/AllowedConnectionTypes.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / modelingRules / AllowedConnectionTypes.java
1 package org.simantics.structural2.modelingRules;
2
3 import java.util.Collection;
4 import java.util.HashSet;
5 import java.util.Set;
6
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.Resource;
9 import org.simantics.db.common.request.ResourceRead;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.structural.stubs.StructuralResource2;
12
13 public class AllowedConnectionTypes extends ResourceRead<Collection<Resource>> {
14
15         public AllowedConnectionTypes(Resource connectionPoint) {
16                 super(connectionPoint);
17         }
18
19         @Override
20         public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
21                 StructuralResource2 STR = StructuralResource2.getInstance(graph);
22                 Collection<Resource> types = graph.getObjects(resource, STR.AllowsConnectionType);
23                 Set<Resource> result = new HashSet<Resource>(types);
24                 for(Resource type : types)
25                         for(Resource override : graph.getObjects(type, STR.OverridesConnectionType))
26                                 result.remove(override);
27                 return result;
28         }
29
30 }