]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableMapImpl.java
Merge "Added resourceId and GUID to diagram DnD content" into release/1.35.1
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / VariableMapImpl.java
1 package org.simantics.db.layer0.variable;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.Set;
6
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.exception.DatabaseException;
9
10 abstract public class VariableMapImpl implements VariableMap {
11
12         @Override
13         public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
14                 return getVariables(graph, context, null).get(name);
15         }
16
17         @Override
18         public Map<String, Variable> getVariables(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
19                 
20         Map<String,Variable> all = getVariables(graph, context, null);
21         if(all.isEmpty()) return all;
22         
23         for(Map.Entry<String, Variable> entry : all.entrySet()) {
24                 Set<String> classifications = entry.getValue().getClassifications(graph);
25                 if(classifications.contains(classification)) {
26                         if(map == null) map = new HashMap<String,Variable>();
27                         map.put(entry.getKey(), entry.getValue());
28                 }
29         }
30         
31         return map;
32                 
33         }
34
35 }