X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FSchemaBuilder.java;fp=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Fscenegraph2%2FSchemaBuilder.java;h=0534a314d913c99b049d92dd8b048bfee447d2e4;hb=824f36cd731304e46deb4765883e47a4eec6132e;hp=b44a7693c97e89f3a4072ea0ec373fc5273c19ca;hpb=a460e609147d064dd3da464bcf1626845e0f93b4;p=simantics%2F3d.git diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SchemaBuilder.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SchemaBuilder.java index b44a7693..0534a314 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SchemaBuilder.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SchemaBuilder.java @@ -1,59 +1,59 @@ -/******************************************************************************* - * 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.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; -import org.simantics.Simantics; - -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); - } - } - -} +/******************************************************************************* + * 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); + } + } + +}