1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2012 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
13 package org.simantics.sysdyn.representation.annotations;
\r
15 import org.simantics.db.ReadGraph;
\r
16 import org.simantics.db.Resource;
\r
17 import org.simantics.db.WriteGraph;
\r
18 import org.simantics.db.common.request.PossibleObjectWithType;
\r
19 import org.simantics.db.exception.DatabaseException;
\r
20 import org.simantics.layer0.Layer0;
\r
21 import org.simantics.objmap.MappingException;
\r
22 import org.simantics.objmap.rules.domain.IDomainAccessor;
\r
23 import org.simantics.sysdyn.SysdynResource;
\r
26 * Accesses the built-in functions in Sysdyn ontology
\r
28 * @author Teemu Lempinen
\r
30 public class BuiltinFunctionsAccessor implements IDomainAccessor<Resource> {
\r
33 public BuiltinFunctionsAccessor() {
\r
37 public Resource get(ReadGraph graph, Resource element) throws MappingException {
\r
38 SysdynResource sr = SysdynResource.getInstance(graph);
\r
39 Layer0 l0 = Layer0.getInstance(graph);
\r
40 Resource builtinFunctions = null;
\r
42 Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.1");
\r
43 builtinFunctions = graph.syncRequest(new PossibleObjectWithType(sysdyn, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary));
\r
44 } catch (DatabaseException e) {
\r
45 throw new MappingException(e);
\r
47 return builtinFunctions;
\r
51 public boolean set(WriteGraph g, Resource element, Resource value)
\r
52 throws MappingException {
\r
53 // Built-in functions should not be set programmatically
\r