]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/FindSubscription.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / subscription / FindSubscription.java
index 06905d2eb9e1222e76d4ac5c40a27acbe09e3234..916adca9f37aa751b7b0f05d1a7fe0496c11bb98 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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.modeling.subscription;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UniqueRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.utils.ObjectUtils;\r
-\r
-/**\r
- * This query finds subscription using label as keyword.\r
- * If multiple subscriptions have the \r
- * \r
- * @author toni.kalajainen\r
- */\r
-public class FindSubscription extends UniqueRead<Resource> {\r
-\r
-       Resource model;\r
-       String id, label;\r
-       \r
-       public FindSubscription( Resource model, String id, String label )\r
-       {\r
-               this.model = model;\r
-               this.id = id;\r
-               this.label = label;\r
-       }\r
-       \r
-       @Override\r
-       public Resource perform(ReadGraph graph) throws DatabaseException {\r
-        Layer0 L0 = Layer0.getInstance(graph);\r
-        ModelingResources MOD = ModelingResources.getInstance(graph);\r
-\r
-        for (Resource r : graph.getObjects(model, L0.ConsistsOf))\r
-        {\r
-               if ( !graph.isInstanceOf(r, MOD.Subscription) ) continue;\r
-               \r
-               if ( this.id!=null ) {\r
-               String name = graph.getPossibleRelatedValue(r, L0.HasName);\r
-               if ( !name.equals(this.id)) continue;\r
-               }\r
-               \r
-               if ( this.label!=null ) {\r
-               String label = graph.getPossibleRelatedValue(r, L0.HasLabel);\r
-               if ( !label.equals(this.label)) continue;\r
-               }\r
-               \r
-               return r;\r
-        }\r
-        \r
-               return null;\r
-       }\r
-       \r
-    @Override\r
-    public int hashCode() {\r
-        return model.hashCode() + (id!=null?id.hashCode():0) + (label!=null?label.hashCode():0);\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object object) {\r
-        if (this == object) return true;\r
-        if (object == null) return false;\r
-        if (getClass() != object.getClass()) return false;\r
-        FindSubscription r = (FindSubscription) object;\r
-        \r
-        if ( !ObjectUtils.objectEquals(id, r.id) ) return false;\r
-        if ( !ObjectUtils.objectEquals(label, r.label)) return false;\r
-        \r
-        return true;\r
-    }\r
-       \r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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.modeling.subscription;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.utils.ObjectUtils;
+
+/**
+ * This query finds subscription using label as keyword.
+ * If multiple subscriptions have the 
+ * 
+ * @author toni.kalajainen
+ */
+public class FindSubscription extends UniqueRead<Resource> {
+
+       Resource model;
+       String id, label;
+       
+       public FindSubscription( Resource model, String id, String label )
+       {
+               this.model = model;
+               this.id = id;
+               this.label = label;
+       }
+       
+       @Override
+       public Resource perform(ReadGraph graph) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        ModelingResources MOD = ModelingResources.getInstance(graph);
+
+        for (Resource r : graph.getObjects(model, L0.ConsistsOf))
+        {
+               if ( !graph.isInstanceOf(r, MOD.Subscription) ) continue;
+               
+               if ( this.id!=null ) {
+               String name = graph.getPossibleRelatedValue(r, L0.HasName);
+               if ( !name.equals(this.id)) continue;
+               }
+               
+               if ( this.label!=null ) {
+               String label = graph.getPossibleRelatedValue(r, L0.HasLabel);
+               if ( !label.equals(this.label)) continue;
+               }
+               
+               return r;
+        }
+        
+               return null;
+       }
+       
+    @Override
+    public int hashCode() {
+        return model.hashCode() + (id!=null?id.hashCode():0) + (label!=null?label.hashCode():0);
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) return true;
+        if (object == null) return false;
+        if (getClass() != object.getClass()) return false;
+        FindSubscription r = (FindSubscription) object;
+        
+        if ( !ObjectUtils.objectEquals(id, r.id) ) return false;
+        if ( !ObjectUtils.objectEquals(label, r.label)) return false;
+        
+        return true;
+    }
+       
+
+}