1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g3d.csg.scenegraph2;
14 import org.simantics.Simantics;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.request.Read;
19 import org.simantics.objmap.graph.schema.IMappingSchema;
20 import org.simantics.objmap.graph.schema.MappingSchemas;
21 import org.simantics.objmap.graph.schema.SimpleSchema;
23 public class SchemaBuilder {
25 public static IMappingSchema<Resource,Object> getSchema() throws DatabaseException{
26 return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,Object>>() {
28 public IMappingSchema<Resource,Object> perform(ReadGraph g)
29 throws DatabaseException {
35 public static IMappingSchema<Resource,Object> getSchema(ReadGraph g) throws DatabaseException{
37 SimpleSchema schema = new SimpleSchema();
38 schema.addLinkType(MappingSchemas.fromAnnotations(g, BarrelNode.class));
39 schema.addLinkType(MappingSchemas.fromAnnotations(g, BoxNode.class));
40 schema.addLinkType(MappingSchemas.fromAnnotations(g, ConeNode.class));
41 schema.addLinkType(MappingSchemas.fromAnnotations(g, CylinderNode.class));
42 schema.addLinkType(MappingSchemas.fromAnnotations(g, DifferenceNode.class));
43 schema.addLinkType(MappingSchemas.fromAnnotations(g, EllipticCylinderNode.class));
44 schema.addLinkType(MappingSchemas.fromAnnotations(g, IntersectionNode.class));
45 schema.addLinkType(MappingSchemas.fromAnnotations(g, RectangularSolidNode.class));
46 schema.addLinkType(MappingSchemas.fromAnnotations(g, RegularPrismNode.class));
47 schema.addLinkType(MappingSchemas.fromAnnotations(g, SphereNode.class));
48 schema.addLinkType(MappingSchemas.fromAnnotations(g, TorusNode.class));
49 schema.addLinkType(MappingSchemas.fromAnnotations(g, UnionNode.class));
50 schema.addLinkType(MappingSchemas.fromAnnotations(g, CSGrootNode.class));
52 } catch (IllegalAccessException e) {
53 throw new DatabaseException(e);
54 } catch (InstantiationException e) {
55 throw new DatabaseException(e);