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.ui.SimanticsUI; public class SchemaBuilder { public static IMappingSchema getSchema() throws DatabaseException{ return SimanticsUI.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); } } }