]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.objmap2 / src / org / simantics / objmap / structural / annotations / factories / RelatedOrderedSetElementsRuleFactory.java
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/RelatedOrderedSetElementsRuleFactory.java
new file mode 100644 (file)
index 0000000..b2e6564
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2013 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.structural.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.bidirectional.IBidirectionalMappingRule;\r
+import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements;\r
+import org.simantics.objmap.graph.rules.MappedElementsRule;\r
+import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.graph.rules.range.FieldAccessor;\r
+import org.simantics.objmap.structural.StructuralResource;\r
+import org.simantics.objmap.structural.rules.domain.RelatedOrderedSetElementsAccessor;\r
+\r
+\r
+public class RelatedOrderedSetElementsRuleFactory<Range> implements IFieldRuleFactory<StructuralResource, Range> {\r
+\r
+    @Override\r
+    public IBidirectionalMappingRule<StructuralResource, Range> create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+        RelatedOrderedSetElements annotation = (RelatedOrderedSetElements)_annotation;\r
+        return new MappedElementsRule<StructuralResource,Range>(\r
+                new RelatedOrderedSetElementsAccessor(annotation.composition(),false),\r
+                new FieldAccessor<Range,Collection<Range>>(field)\r
+                );\r
+    }\r
+\r
+}\r