/******************************************************************************* * Copyright (c) 2012, 2013 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.g3d.csg.scenegraph2; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.objmap.graph.schema.IMappingSchema; import org.simantics.objmap.graph.schema.MappingSchemas; import org.simantics.objmap.graph.schema.SimpleSchema; public class SchemaBuilder { public static IMappingSchema getSchema() throws DatabaseException{ return Simantics.getSession().syncRequest(new Read>() { @Override public IMappingSchema perform(ReadGraph g) throws DatabaseException { return getSchema(g); } }); } public static IMappingSchema getSchema(ReadGraph g) throws DatabaseException{ try { SimpleSchema schema = new SimpleSchema(); schema.addLinkType(MappingSchemas.fromAnnotations(g, BarrelNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, BoxNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, ConeNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, CylinderNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, DifferenceNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, EllipticCylinderNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, IntersectionNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, RectangularSolidNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, RegularPrismNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, SphereNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, TorusNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, UnionNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, CSGrootNode.class)); return schema; } catch (IllegalAccessException e) { throw new DatabaseException(e); } catch (InstantiationException e) { throw new DatabaseException(e); } } }