1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.layer0.variable;
\r
14 import org.simantics.databoard.Bindings;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.WriteGraph;
\r
17 import org.simantics.db.exception.DatabaseException;
\r
18 import org.simantics.layer0.Layer0;
\r
20 public class StandardResourceVariableSpaceManipulator implements VariableSpaceManipulator {
\r
22 final Variable target;
\r
24 public StandardResourceVariableSpaceManipulator(Variable target) {
\r
25 this.target = target;
\r
28 public Variable createVariable(WriteGraph graph, String rvi) throws DatabaseException {
\r
32 public Variable createProperty(WriteGraph graph, String name) throws DatabaseException {
\r
33 if("HasDescription".equals(name)) {
\r
34 Layer0 l0 = Layer0.getInstance(graph);
\r
35 Resource targetResource = target.getInterface(graph, Resource.class);
\r
36 graph.claimLiteral(targetResource, l0.HasDescription, "", Bindings.STRING);
\r
37 return target.getProperty(graph, "HasDescription");
\r
42 public Variable createChild(WriteGraph graph, String name, Object content) throws DatabaseException {
\r
47 public void apply(WriteGraph graph, Modification modification)
\r
48 throws DatabaseException {
\r
49 for(PropertyCreationData data : modification.newProperties) {
\r
50 createProperty(graph, data.name);
\r