]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/GetConstraints.java
Multiple reader thread support for db client
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / validation / GetConstraints.java
1 package org.simantics.db.layer0.validation;
2
3 import java.util.HashSet;
4 import java.util.Set;
5
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.Resource;
8 import org.simantics.db.common.request.ResourceRead;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.layer0.Layer0;
11
12 public class GetConstraints extends ResourceRead<Set<Resource>> {
13
14         public GetConstraints(Resource resource) {
15                 super(resource);
16         }
17
18         @Override
19         public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
20                 
21                 Layer0 L0 = Layer0.getInstance(graph);
22                 HashSet<Resource> result = new HashSet<Resource>(); 
23                 for(Resource type : graph.getTypes(resource)) {
24                         result.addAll(graph.getObjects(type, L0.HasConstraint));
25                 }
26                 return result;
27                 
28         }
29         
30 }