]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/AddConsistsOf.java
0c3d186dbf93e3d7b122a9388bd1861dfdb1e93f
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / procedures / AddConsistsOf.java
1 package org.simantics.graph.compiler.internal.procedures;
2
3 import gnu.trove.procedure.TObjectProcedure;
4
5 import org.simantics.graph.query.Paths;
6 import org.simantics.graph.store.GraphStore;
7 import org.simantics.graph.store.IdentityStore;
8 import org.simantics.graph.store.IdentityStore.ConsistsOf;
9 import org.simantics.graph.store.StatementStore;
10
11 public class AddConsistsOf implements Runnable {
12
13         GraphStore store;
14         Paths paths;
15                 
16         public AddConsistsOf(Paths paths, GraphStore store) {
17             this.paths = paths;
18                 this.store = store;
19         }
20
21         @Override
22         public void run() {
23                 final IdentityStore identities = store.identities;
24                 final int consistsOf = identities.createPathToId(paths.ConsistsOf);
25                 final StatementStore statements = store.statements;
26                 identities.forEachChild(new TObjectProcedure<IdentityStore.ConsistsOf>() {
27             
28             @Override
29             public boolean execute(ConsistsOf co) {
30                 if(identities.isNewResource(co.child))
31                     statements.add(co.parent, consistsOf, co.child);
32                 return true;
33             }
34         });
35         }       
36
37 }