]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/templates/TemplateDefinition.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / templates / TemplateDefinition.java
index 3c79608a90b561260c485f96d0242fb8c9aee436..1fedb881810f6fee32a9a82acb10600d658f7f64 100644 (file)
@@ -1,72 +1,72 @@
-package org.simantics.graph.compiler.internal.templates;\r
-\r
-import gnu.trove.map.hash.TIntIntHashMap;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.graph.compiler.internal.procedures.Compactify;\r
-import org.simantics.graph.compiler.internal.procedures.ConvertPreValues;\r
-import org.simantics.graph.compiler.internal.procedures.DefaultValueTyping;\r
-import org.simantics.graph.compiler.internal.procedures.MergeEqualResources;\r
-import org.simantics.graph.compiler.internal.store.LocationStore;\r
-import org.simantics.graph.query.CompositeGraph;\r
-import org.simantics.graph.query.Path;\r
-import org.simantics.graph.query.TransferableGraphConversion;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.graph.store.GraphStore;\r
-import org.simantics.ltk.Problem;\r
-\r
-public class TemplateDefinition {\r
-       String[] parameters;\r
-       int[] correspondence;\r
-       GraphStore template;\r
-       \r
-       public TemplateDefinition(String[] parameters, int[] correspondence,\r
-                       GraphStore template) {\r
-               this.parameters = parameters;\r
-               this.correspondence = correspondence;\r
-               this.template = template;\r
-       }\r
-\r
-       public String[] getParameters() {\r
-               return parameters;\r
-       }\r
-       \r
-       public GraphStore getTemplate() {\r
-               return template;\r
-       }\r
-\r
-       public void map(TIntIntHashMap map) {\r
-               for(int i=0;i<correspondence.length;i+=2)\r
-                       if(map.containsKey(correspondence[i]))\r
-                               correspondence[i] = map.get(correspondence[i]);\r
-       }\r
-       \r
-       public TransferableGraph1 convert(CompositeGraph graph, GraphStore parent, Collection<Problem> problems) {\r
-               LocationStore locations = template.getStore(LocationStore.class);\r
-               for(int i=0;i<correspondence.length;i+=2) {\r
-                       int parentId = correspondence[i];\r
-                       int childId = correspondence[i+1];\r
-                       Path path = parent.identities.idToPath(parentId);\r
-                       if(path == null) {\r
-                               problems.add(\r
-                                               new Problem(locations.getLocation(childId), \r
-                                               "Template can refer only to resources that have URIs."));\r
-                       }\r
-                       else\r
-                               template.identities.definePath(path, childId);\r
-               }\r
-               new MergeEqualResources(graph.getPaths(), template).run();\r
-               new Compactify(template).run();\r
-               new DefaultValueTyping(graph.getPaths(), template).run();       \r
-               \r
-               graph.addFragment(template);\r
-               new ConvertPreValues(graph, template, problems).run();\r
-               TransferableGraph1 transferableGraph = TransferableGraphConversion.convert(template);\r
-               graph.undoAddFragment();\r
-               \r
-               //transferableGraph.print();\r
-               \r
-               return transferableGraph;\r
-       }\r
-}\r
+package org.simantics.graph.compiler.internal.templates;
+
+import gnu.trove.map.hash.TIntIntHashMap;
+
+import java.util.Collection;
+
+import org.simantics.graph.compiler.internal.procedures.Compactify;
+import org.simantics.graph.compiler.internal.procedures.ConvertPreValues;
+import org.simantics.graph.compiler.internal.procedures.DefaultValueTyping;
+import org.simantics.graph.compiler.internal.procedures.MergeEqualResources;
+import org.simantics.graph.compiler.internal.store.LocationStore;
+import org.simantics.graph.query.CompositeGraph;
+import org.simantics.graph.query.Path;
+import org.simantics.graph.query.TransferableGraphConversion;
+import org.simantics.graph.representation.TransferableGraph1;
+import org.simantics.graph.store.GraphStore;
+import org.simantics.ltk.Problem;
+
+public class TemplateDefinition {
+       String[] parameters;
+       int[] correspondence;
+       GraphStore template;
+       
+       public TemplateDefinition(String[] parameters, int[] correspondence,
+                       GraphStore template) {
+               this.parameters = parameters;
+               this.correspondence = correspondence;
+               this.template = template;
+       }
+
+       public String[] getParameters() {
+               return parameters;
+       }
+       
+       public GraphStore getTemplate() {
+               return template;
+       }
+
+       public void map(TIntIntHashMap map) {
+               for(int i=0;i<correspondence.length;i+=2)
+                       if(map.containsKey(correspondence[i]))
+                               correspondence[i] = map.get(correspondence[i]);
+       }
+       
+       public TransferableGraph1 convert(CompositeGraph graph, GraphStore parent, Collection<Problem> problems) {
+               LocationStore locations = template.getStore(LocationStore.class);
+               for(int i=0;i<correspondence.length;i+=2) {
+                       int parentId = correspondence[i];
+                       int childId = correspondence[i+1];
+                       Path path = parent.identities.idToPath(parentId);
+                       if(path == null) {
+                               problems.add(
+                                               new Problem(locations.getLocation(childId), 
+                                               "Template can refer only to resources that have URIs."));
+                       }
+                       else
+                               template.identities.definePath(path, childId);
+               }
+               new MergeEqualResources(graph.getPaths(), template).run();
+               new Compactify(template).run();
+               new DefaultValueTyping(graph.getPaths(), template).run();       
+               
+               graph.addFragment(template);
+               new ConvertPreValues(graph, template, problems).run();
+               TransferableGraph1 transferableGraph = TransferableGraphConversion.convert(template);
+               graph.undoAddFragment();
+               
+               //transferableGraph.print();
+               
+               return transferableGraph;
+       }
+}