]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/request/ReferencedProfileEntries.java
Use synchronized hash map instead of ConcurrentHashMap in LazyModule
[simantics/platform.git] / bundles / org.simantics.diagram.profile / src / org / simantics / diagram / profile / request / ReferencedProfileEntries.java
1 package org.simantics.diagram.profile.request;
2
3 import java.util.Collection;
4 import java.util.HashSet;
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.common.utils.ListUtils;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.diagram.stubs.DiagramResource;
12 import org.simantics.scenegraph.profile.ProfileUtils;
13
14 public class ReferencedProfileEntries extends ResourceRead<Collection<Resource>> {
15
16         public ReferencedProfileEntries(Resource part) {
17                 super(part);
18         }
19
20         public HashSet<Resource> process(ReadGraph graph, Resource resource, HashSet<Resource> result) throws DatabaseException {
21
22                 DiagramResource DIA = DiagramResource.getInstance(graph);
23                 
24         if(graph.isInstanceOf(resource, DIA.Profile)) {
25
26                 for(Resource child : ProfileUtils.getProfileChildren(graph, resource)) {
27                         process(graph, child, result);
28                 }
29                 
30         } else if(graph.isInstanceOf(resource, DIA.ProfileEntry)) {
31                 
32                 result.add(resource);
33
34                 }
35         
36         return result;
37         
38         }
39         
40         @Override
41         public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
42                 return process(graph, resource, new HashSet<Resource>());
43         }
44         
45 }