]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ClassificationsRequest.java
Merge "Documented difference of RuntimeEnvironmentRequest and Runti...quest2" into...
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / request / ClassificationsRequest.java
1 package org.simantics.db.layer0.request;
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.UnaryRead;
10 import org.simantics.db.exception.DatabaseException;
11
12 public class ClassificationsRequest extends UnaryRead<Collection<Resource>, Set<String>> {
13
14         public ClassificationsRequest(Collection<Resource> principalTypes) {
15                 super(principalTypes);
16         }
17
18         @Override
19         public Set<String> perform(ReadGraph graph) throws DatabaseException {
20         Set<String> result = new HashSet<String>(parameter.size());
21         Set<Resource> allTypes = new HashSet<Resource>(parameter);
22         for(Resource principalType : parameter) allTypes.addAll(graph.getSupertypes(principalType));
23         for(Resource type : allTypes) {
24                 String uri = graph.getPossibleURI(type);
25                 if(uri != null) result.add(uri);
26         }
27         return result;
28         }
29
30 }