-/*******************************************************************************\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.request;\r
-\r
-import java.util.Collection;\r
-import java.util.Map;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.CommonDBUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-\r
-/**\r
- * Instantiates given type using templates attached to the type.\r
- * @author Hannu Niemistö\r
- */\r
-public class InstantiateRequest extends ApplyTemplatesRequest {\r
- Resource type;\r
- \r
- public InstantiateRequest(Resource type, Map<String, Object> parameters,\r
- Collection<Resource> contexts) {\r
- super(parameters, contexts);\r
- this.type = type;\r
- }\r
- \r
- public InstantiateRequest(Resource type, Map<String, Object> parameters) {\r
- super(parameters);\r
- this.type = type;\r
- }\r
- \r
- public InstantiateRequest(Resource type) {\r
- super();\r
- this.type = type;\r
- }\r
-\r
- public Resource perform(WriteGraph g) throws DatabaseException {\r
- Layer0 b = Layer0.getInstance(g);\r
- \r
- Resource parent = (Resource)parameters.get("parent");\r
- if(parent != null) CommonDBUtils.selectClusterSet(g, parent);\r
- \r
- // Default instantiation logic\r
- Resource instance = g.newResource();\r
- g.newClusterSet(instance);\r
- g.claim(instance, b.InstanceOf, null, type);\r
- \r
- perform(g, instance);\r
- \r
- return instance;\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.request;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.utils.CommonDBUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+
+/**
+ * Instantiates given type using templates attached to the type.
+ * @author Hannu Niemistö
+ */
+public class InstantiateRequest extends ApplyTemplatesRequest {
+ Resource type;
+
+ public InstantiateRequest(Resource type, Map<String, Object> parameters,
+ Collection<Resource> contexts) {
+ super(parameters, contexts);
+ this.type = type;
+ }
+
+ public InstantiateRequest(Resource type, Map<String, Object> parameters) {
+ super(parameters);
+ this.type = type;
+ }
+
+ public InstantiateRequest(Resource type) {
+ super();
+ this.type = type;
+ }
+
+ public Resource perform(WriteGraph g) throws DatabaseException {
+ Layer0 b = Layer0.getInstance(g);
+
+ Resource parent = (Resource)parameters.get("parent");
+ if(parent != null) CommonDBUtils.selectClusterSet(g, parent);
+
+ // Default instantiation logic
+ Resource instance = g.newResource();
+ g.newClusterSet(instance);
+ g.claim(instance, b.InstanceOf, null, type);
+
+ perform(g, instance);
+
+ return instance;
+ }
+}