package org.simantics.plant3d.scenegraph; 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.g3d.scenegraph.GeometryProvider; import org.simantics.g3d.scenegraph.base.INode; import org.simantics.objmap.graph.schema.IMappingSchema; import org.simantics.objmap.graph.schema.MappingSchemas; import org.simantics.objmap.graph.schema.SimpleSchema; import org.simantics.plant3d.ontology.Plant3D; 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); } }); } @SuppressWarnings("unchecked") public static IMappingSchema getSchema(ReadGraph g) throws DatabaseException{ try { SimpleSchema schema = new SimpleSchema(); schema.addLinkType(MappingSchemas.fromAnnotations(g, Equipment.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, InlineComponent.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, TurnComponent.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, EndComponent.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, Nozzle.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, P3DRootNode.class)); schema.addLinkType(MappingSchemas.fromAnnotations(g, PipeRun.class)); schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.GeometryProvider, GeometryProvider.class)); return (IMappingSchema)(IMappingSchema)schema; } catch (IllegalAccessException e) { throw new DatabaseException(e); } catch (InstantiationException e) { throw new DatabaseException(e); } } }