+/*******************************************************************************\r
+ * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
+ * 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.graph.schema;\r
\r
import java.lang.annotation.Annotation;\r
import org.simantics.objmap.graph.annotations.HasCollectionRemover;\r
import org.simantics.objmap.graph.annotations.HasSetter;\r
import org.simantics.objmap.graph.annotations.OptionalRelatedElements;\r
+import org.simantics.objmap.graph.annotations.OrderedElementsGet;\r
+import org.simantics.objmap.graph.annotations.OrderedSetType;\r
import org.simantics.objmap.graph.annotations.RelatedElements;\r
import org.simantics.objmap.graph.annotations.RelatedElementsGet;\r
import org.simantics.objmap.graph.annotations.RelatedGetObj;\r
import org.simantics.objmap.graph.annotations.UpdateMethod;\r
import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory;\r
import org.simantics.objmap.graph.annotations.factories.OptionalRelatedElementsRuleFactory;\r
+import org.simantics.objmap.graph.annotations.factories.OrderedElementsRuleFactory;\r
import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory;\r
import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory2;\r
import org.simantics.objmap.graph.annotations.factories.RelatedGetSetObjRuleFactory;\r
\r
return new DynamicSimpleLinkType<Object>(g.getResource(dynamicType.value()), clazz, rules);\r
}\r
+ OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class);\r
+ if (orderedSetType != null) {\r
+ ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();\r
+ collectRulesFromAnnotations(g, clazz, rules);\r
+ \r
+ return new OrderedSetSimpleLinkType<Object>(g.getResource(orderedSetType.value()), clazz, rules);\r
+ }\r
throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations.");\r
}\r
\r
public static ICollectionRuleFactory<Resource,Object> createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) {\r
if (annotation.annotationType().equals(RelatedElementsGet.class))\r
return new RelatedElementsRuleFactory2<Object>();\r
+ if (annotation.annotationType().equals(OrderedElementsGet.class))\r
+ return new OrderedElementsRuleFactory<Object>();\r
return null;\r
}\r
\r