]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.objmap2 / src / org / simantics / objmap / graph / rules / domain / RelatedObjectAccessor.java
index 91a164781e6c1bd0141c7cd0fc4478c13a315414..99253790cf0e0f0611eadcf06c9f297189882892 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************\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.graph.rules.domain;\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.exception.DatabaseException;\r
-import org.simantics.objmap.exceptions.MappingException;\r
-\r
-/**\r
- * Accesses a resource attached to the element by given functional relation.\r
- * @author Hannu Niemistö\r
- */\r
-public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource> {\r
-\r
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
-    \r
-       Resource relation;\r
-       \r
-       public RelatedObjectAccessor(Resource relation) {\r
-               this.relation = relation;\r
-       }\r
-\r
-       @Override\r
-       public Resource get(ReadGraph g, Resource element) throws MappingException {\r
-               try {\r
-                   LOGGER.info("        RelatedObjectAccessor.get");\r
-                       return g.getPossibleObject(element, relation);\r
-               } catch (DatabaseException e) {\r
-                       throw new MappingException(e);\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public boolean set(WriteGraph g, Resource element, Resource value)\r
-                       throws MappingException {\r
-               try {\r
-                   LOGGER.info("        RelatedObjectAccessor.set");\r
-                   Resource resource = g.getPossibleObject(element, relation);\r
-                       if(resource == null) {\r
-                           if(value == null)\r
-                               return false;\r
-                           g.claim(element, relation, value);\r
-                           return true;\r
-                       }\r
-                       else if(resource.equals(value))\r
-                           return false;\r
-                       else {\r
-                           g.deny(element, relation);\r
-                           if(value != null)\r
-                               g.claim(element, relation, value);\r
-                           return true;\r
-                       }\r
-               } catch (DatabaseException e) {\r
-                       throw new MappingException(e);\r
-               }\r
-               \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.graph.rules.domain;
+
+import org.apache.log4j.Logger;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.objmap.exceptions.MappingException;
+
+/**
+ * Accesses a resource attached to the element by given functional relation.
+ * @author Hannu Niemistö
+ */
+public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource> {
+
+    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    
+       Resource relation;
+       
+       public RelatedObjectAccessor(Resource relation) {
+               this.relation = relation;
+       }
+
+       @Override
+       public Resource get(ReadGraph g, Resource element) throws MappingException {
+               try {
+                   LOGGER.info("        RelatedObjectAccessor.get");
+                       return g.getPossibleObject(element, relation);
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+       }
+       
+       @Override
+       public boolean set(WriteGraph g, Resource element, Resource value)
+                       throws MappingException {
+               try {
+                   LOGGER.info("        RelatedObjectAccessor.set");
+                   Resource resource = g.getPossibleObject(element, relation);
+                       if(resource == null) {
+                           if(value == null)
+                               return false;
+                           g.claim(element, relation, value);
+                           return true;
+                       }
+                       else if(resource.equals(value))
+                           return false;
+                       else {
+                           g.deny(element, relation);
+                           if(value != null)
+                               g.claim(element, relation, value);
+                           return true;
+                       }
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+               
+       }
+
+}