1 package org.simantics.graph.compiler.internal.templates;
3 import java.util.Collection;
5 import org.simantics.graph.compiler.ExternalFileLoader;
6 import org.simantics.graph.query.IGraph;
7 import org.simantics.graph.query.Paths;
8 import org.simantics.graph.store.GraphStore;
9 import org.simantics.ltk.Problem;
11 public enum OrderedSetTemplate implements ITemplate {
16 public void apply(IGraph graph, GraphStore store,
17 int[] parameters, ExternalFileLoader fileLoader, Collection<Problem> problems) {
18 createList(graph.getPaths(), store, parameters);
21 public static void createList(Paths paths, GraphStore store, int[] parameters) {
22 int InverseOf = store.identities.createPathToId(paths.InverseOf);
23 int SubrelationOf = store.identities.createPathToId(paths.SubrelationOf);
24 int HasNext = store.identities.createPathToId(paths.HasNext);
25 int HasPrevious = store.identities.createPathToId(paths.HasPrevious);
27 int relation = parameters[0];
28 store.statements.add(relation, SubrelationOf, HasNext);
29 int inverse = store.identities.newResource();
30 store.statements.add(inverse, SubrelationOf, HasPrevious);
31 store.statements.add(relation, InverseOf, inverse);
33 for(int i=1;i<parameters.length;++i)
34 store.statements.add(parameters[i-1], relation, parameters[i]);
35 store.statements.add(parameters[parameters.length-1], relation, relation);