]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/DefaultValuations.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / adapter / impl / DefaultValuations.java
index 8cb7bcf80934803c23e881b6a8efa87e6fba3375..3c1da867a13a5fbe7b9d7fb4e793b9cf88fa7b17 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 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.db.layer0.adapter.impl;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.uri.ResourceToURI;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.Valuations;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-public class DefaultValuations implements Valuations {\r
-\r
-       final private Resource resource;\r
-       \r
-       public DefaultValuations(Resource module) {\r
-               this.resource = module;\r
-       }\r
-\r
-       public static Pair<String, String> splitModelAndStructure(ReadGraph graph, String path, int startPosition) throws DatabaseException {\r
-               int position = path.indexOf("/", startPosition);\r
-               String prefix = path.substring(0, position);\r
-//             System.out.println("prefix=" + prefix);\r
-               Resource r = graph.getResource(prefix);\r
-               if(graph.isInstanceOf(r, SimulationResource.getInstance(graph).Model)) {\r
-                       return new Pair<String, String>(path.substring(0, position), path.substring(position+1, path.length())); \r
-               } else {\r
-                       return splitModelAndStructure(graph, path, position + 1);\r
-               }\r
-       }\r
-\r
-       public static Pair<String, String> splitModelAndStructure(ReadGraph graph, String path) throws DatabaseException {\r
-               Resource r = graph.getResource(path);\r
-               if(graph.isInstanceOf(r, SimulationResource.getInstance(graph).Model)) {\r
-                       return new Pair<String, String>(path, "");\r
-               } else {\r
-                       return splitModelAndStructure(graph, path, 8);\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public Resource getValue(ReadGraph graph, String variableIdentityPrefix, String experiment) throws DatabaseException {\r
-//             System.out.println("getValue " + module);\r
-               String path = graph.syncRequest(new ResourceToURI(resource));\r
-//             System.out.println("path=" + path);\r
-               Pair<String, String> modelAndStructure = splitModelAndStructure(graph, path);\r
-//             System.out.println("mas=" + modelAndStructure);\r
-               // TODO: fixme please\r
-               try {\r
-                       return graph.getResource(modelAndStructure.first + "/" + experiment + "/" + modelAndStructure.second);\r
-               } catch (DatabaseException e) {\r
-                       try {\r
-                               return graph.getResource(modelAndStructure.first + "/BaseRealization/" + modelAndStructure.second);\r
-                       } catch (DatabaseException e2) {\r
-                               return null;\r
-                       }\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public Resource getValue(ReadGraph graph, String variableIdentityPrefix, String experiment, String suffix) throws DatabaseException {\r
-//             System.out.println("getValue " + resource);\r
-               String path = graph.syncRequest(new ResourceToURI(resource));\r
-//             System.out.println("path=" + path);\r
-               Pair<String, String> modelAndStructure = splitModelAndStructure(graph, path);\r
-//             System.out.println("mas=" + modelAndStructure);\r
-               String prefix = modelAndStructure.second.isEmpty() ? "" : "/" + modelAndStructure.second;\r
-               String uri = modelAndStructure.first + "/" + experiment + prefix + (suffix.isEmpty() ? "" : "/" + suffix);\r
-//             System.out.println("defaultValuations uri=" + uri);\r
-               return graph.getResource(uri);\r
-       }\r
-\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.db.layer0.adapter.impl;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.uri.ResourceToURI;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.Valuations;
+import org.simantics.simulation.ontology.SimulationResource;
+import org.simantics.utils.datastructures.Pair;
+
+public class DefaultValuations implements Valuations {
+
+       final private Resource resource;
+       
+       public DefaultValuations(Resource module) {
+               this.resource = module;
+       }
+
+       public static Pair<String, String> splitModelAndStructure(ReadGraph graph, String path, int startPosition) throws DatabaseException {
+               int position = path.indexOf("/", startPosition);
+               String prefix = path.substring(0, position);
+//             System.out.println("prefix=" + prefix);
+               Resource r = graph.getResource(prefix);
+               if(graph.isInstanceOf(r, SimulationResource.getInstance(graph).Model)) {
+                       return new Pair<String, String>(path.substring(0, position), path.substring(position+1, path.length())); 
+               } else {
+                       return splitModelAndStructure(graph, path, position + 1);
+               }
+       }
+
+       public static Pair<String, String> splitModelAndStructure(ReadGraph graph, String path) throws DatabaseException {
+               Resource r = graph.getResource(path);
+               if(graph.isInstanceOf(r, SimulationResource.getInstance(graph).Model)) {
+                       return new Pair<String, String>(path, "");
+               } else {
+                       return splitModelAndStructure(graph, path, 8);
+               }
+       }
+       
+       @Override
+       public Resource getValue(ReadGraph graph, String variableIdentityPrefix, String experiment) throws DatabaseException {
+//             System.out.println("getValue " + module);
+               String path = graph.syncRequest(new ResourceToURI(resource));
+//             System.out.println("path=" + path);
+               Pair<String, String> modelAndStructure = splitModelAndStructure(graph, path);
+//             System.out.println("mas=" + modelAndStructure);
+               // TODO: fixme please
+               try {
+                       return graph.getResource(modelAndStructure.first + "/" + experiment + "/" + modelAndStructure.second);
+               } catch (DatabaseException e) {
+                       try {
+                               return graph.getResource(modelAndStructure.first + "/BaseRealization/" + modelAndStructure.second);
+                       } catch (DatabaseException e2) {
+                               return null;
+                       }
+               }
+       }
+
+       @Override
+       public Resource getValue(ReadGraph graph, String variableIdentityPrefix, String experiment, String suffix) throws DatabaseException {
+//             System.out.println("getValue " + resource);
+               String path = graph.syncRequest(new ResourceToURI(resource));
+//             System.out.println("path=" + path);
+               Pair<String, String> modelAndStructure = splitModelAndStructure(graph, path);
+//             System.out.println("mas=" + modelAndStructure);
+               String prefix = modelAndStructure.second.isEmpty() ? "" : "/" + modelAndStructure.second;
+               String uri = modelAndStructure.first + "/" + experiment + prefix + (suffix.isEmpty() ? "" : "/" + suffix);
+//             System.out.println("defaultValuations uri=" + uri);
+               return graph.getResource(uri);
+       }
+
+       
+}