1 package org.simantics.plant3d.scenegraph;
3 import org.simantics.Simantics;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.request.Read;
8 import org.simantics.g3d.scenegraph.GeometryProvider;
9 import org.simantics.objmap.graph.schema.IMappingSchema;
10 import org.simantics.objmap.graph.schema.MappingSchemas;
11 import org.simantics.objmap.graph.schema.SimpleSchema;
12 import org.simantics.plant3d.ontology.Plant3D;
14 public class SchemaBuilder {
15 public static IMappingSchema<Resource,Object> getSchema() throws DatabaseException{
16 return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,Object>>() {
18 public IMappingSchema<Resource,Object> perform(ReadGraph g)
19 throws DatabaseException {
25 public static IMappingSchema<Resource,Object> getSchema(ReadGraph g) throws DatabaseException{
27 SimpleSchema schema = new SimpleSchema();
28 schema.addLinkType(MappingSchemas.fromAnnotations(g, Equipment.class));
29 schema.addLinkType(MappingSchemas.fromAnnotations(g, InlineComponent.class));
30 schema.addLinkType(MappingSchemas.fromAnnotations(g, TurnComponent.class));
31 schema.addLinkType(MappingSchemas.fromAnnotations(g, EndComponent.class));
32 schema.addLinkType(MappingSchemas.fromAnnotations(g, Nozzle.class));
33 schema.addLinkType(MappingSchemas.fromAnnotations(g, P3DRootNode.class));
34 schema.addLinkType(MappingSchemas.fromAnnotations(g, PipeRun.class));
36 schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.Builtin_GeometryProvider, GeometryProvider.class));
38 } catch (IllegalAccessException e) {
39 throw new DatabaseException(e);
40 } catch (InstantiationException e) {
41 throw new DatabaseException(e);