]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.objmap2 / src / org / simantics / objmap / structural / rules / domain / RelatedOrderedSetElementsAccessor.java
index c9b63e4c3e976e66a93aa5fd210de531149fbc10..6c1ed3aa2777038fbfa958ee7735c7c3441313ac 100644 (file)
@@ -1,86 +1,86 @@
-/*******************************************************************************\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.rules.domain;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.objmap.exceptions.MappingException;\r
-import org.simantics.objmap.graph.rules.domain.IDomainAccessor;\r
-import org.simantics.objmap.structural.StructuralResource;\r
-\r
-public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<StructuralResource, Collection<StructuralResource>> {\r
-\r
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
-    \r
-       boolean deleteExtraObjects;\r
-       boolean useTypeResource;\r
-\r
-       public RelatedOrderedSetElementsAccessor(boolean deleteExtraObjects, boolean useTypeResource) {\r
-        super();\r
-        this.deleteExtraObjects = deleteExtraObjects;\r
-        this.useTypeResource = useTypeResource;\r
-    }\r
-\r
-    @Override\r
-       public Collection<StructuralResource> get(ReadGraph g, StructuralResource element) throws MappingException {\r
-               try {\r
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.get");\r
-                   Resource res = getServiceResource(g, element);\r
-                   if (res == null)\r
-                       return Collections.emptyList();\r
-                       List<Resource> list =  OrderedSetUtils.toList(g, res);\r
-                       List<StructuralResource> result = new ArrayList<StructuralResource>(list.size());\r
-                       for (Resource r : list) {\r
-                               result.add(new StructuralResource(g,r,element.getContext()));\r
-                       }\r
-                       return result;\r
-               } catch (DatabaseException e) {\r
-                       throw new MappingException(e);\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public boolean set(WriteGraph g, StructuralResource element, Collection<StructuralResource> value)\r
-                       throws MappingException {\r
-               try {\r
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.set");\r
-                   Resource res = getServiceResource(g, element);\r
-                   if (res == null)\r
-                       return false;\r
-                   List<Resource> list = new ArrayList<Resource>(value.size());\r
-                   for (StructuralResource r : value) {\r
-                       list.add(r.getResource());\r
-                   }\r
-                   return OrderedSetUtils.set(g, res, list);\r
-                   // FIXME Implement deleteExtraObjects\r
-               } catch (DatabaseException e) {\r
-                       throw new MappingException(e);\r
-               }\r
-               \r
-       }\r
-       \r
-       private Resource getServiceResource(ReadGraph g, StructuralResource element) {\r
-               if (!useTypeResource)\r
-                       return element.getResource();\r
-               return element.getTypeResource();\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.structural.rules.domain;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.utils.OrderedSetUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.objmap.exceptions.MappingException;
+import org.simantics.objmap.graph.rules.domain.IDomainAccessor;
+import org.simantics.objmap.structural.StructuralResource;
+
+public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<StructuralResource, Collection<StructuralResource>> {
+
+    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    
+       boolean deleteExtraObjects;
+       boolean useTypeResource;
+
+       public RelatedOrderedSetElementsAccessor(boolean deleteExtraObjects, boolean useTypeResource) {
+        super();
+        this.deleteExtraObjects = deleteExtraObjects;
+        this.useTypeResource = useTypeResource;
+    }
+
+    @Override
+       public Collection<StructuralResource> get(ReadGraph g, StructuralResource element) throws MappingException {
+               try {
+                   LOGGER.info("        RelatedOrderedSetElementsAccessor.get");
+                   Resource res = getServiceResource(g, element);
+                   if (res == null)
+                       return Collections.emptyList();
+                       List<Resource> list =  OrderedSetUtils.toList(g, res);
+                       List<StructuralResource> result = new ArrayList<StructuralResource>(list.size());
+                       for (Resource r : list) {
+                               result.add(new StructuralResource(g,r,element.getContext()));
+                       }
+                       return result;
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+       }
+       
+       @Override
+       public boolean set(WriteGraph g, StructuralResource element, Collection<StructuralResource> value)
+                       throws MappingException {
+               try {
+                   LOGGER.info("        RelatedOrderedSetElementsAccessor.set");
+                   Resource res = getServiceResource(g, element);
+                   if (res == null)
+                       return false;
+                   List<Resource> list = new ArrayList<Resource>(value.size());
+                   for (StructuralResource r : value) {
+                       list.add(r.getResource());
+                   }
+                   return OrderedSetUtils.set(g, res, list);
+                   // FIXME Implement deleteExtraObjects
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+               
+       }
+       
+       private Resource getServiceResource(ReadGraph g, StructuralResource element) {
+               if (!useTypeResource)
+                       return element.getResource();
+               return element.getTypeResource();
+       }
+
+}