X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Frequest%2FInstantiateRequest.java;h=7d14b836a209cdd77a318d42044c2d8fe3565a5c;hb=e3446802a81064942a7cbfea0c577e21ae5ae658;hp=9878dea20da54e7ee8fe8e1698170de16d408826;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/InstantiateRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/InstantiateRequest.java index 9878dea20..7d14b836a 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/InstantiateRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/InstantiateRequest.java @@ -1,61 +1,61 @@ -/******************************************************************************* - * 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 parameters, - Collection contexts) { - super(parameters, contexts); - this.type = type; - } - - public InstantiateRequest(Resource type, Map 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; - } -} +/******************************************************************************* + * 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 parameters, + Collection contexts) { + super(parameters, contexts); + this.type = type; + } + + public InstantiateRequest(Resource type, Map 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; + } +}