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 ListTemplate 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 InstanceOf = store.identities.createPathToId(paths.InstanceOf);
23 int Entry = store.identities.createPathToId(paths.List_Entry);
24 int Next = store.identities.createPathToId(paths.List_Next);
25 int Element = store.identities.createPathToId(paths.List_Element);
27 int oldEntry = parameters[0];
28 for(int i=1;i<parameters.length;++i) {
29 int newEntry = store.identities.newResource();
30 store.statements.add(newEntry, InstanceOf, Entry);
31 store.statements.add(oldEntry, Next, newEntry);
32 store.statements.add(newEntry, Element, parameters[i]);
35 store.statements.add(oldEntry, Next, parameters[0]);