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.g3d.scenegraph.base.INode;
10 import org.simantics.objmap.graph.schema.IMappingSchema;
11 import org.simantics.objmap.graph.schema.MappingSchemas;
12 import org.simantics.objmap.graph.schema.SimpleSchema;
13 import org.simantics.plant3d.ontology.Plant3D;
15 public class SchemaBuilder {
16 public static IMappingSchema<Resource,INode> getSchema() throws DatabaseException{
17 return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,INode>>() {
19 public IMappingSchema<Resource,INode> perform(ReadGraph g)
20 throws DatabaseException {
26 @SuppressWarnings("unchecked")
27 public static IMappingSchema<Resource,INode> getSchema(ReadGraph g) throws DatabaseException{
29 SimpleSchema schema = new SimpleSchema();
30 schema.addLinkType(MappingSchemas.fromAnnotations(g, Equipment.class));
31 schema.addLinkType(MappingSchemas.fromAnnotations(g, InlineComponent.class));
32 schema.addLinkType(MappingSchemas.fromAnnotations(g, TurnComponent.class));
33 schema.addLinkType(MappingSchemas.fromAnnotations(g, EndComponent.class));
34 schema.addLinkType(MappingSchemas.fromAnnotations(g, Nozzle.class));
35 schema.addLinkType(MappingSchemas.fromAnnotations(g, P3DRootNode.class));
36 schema.addLinkType(MappingSchemas.fromAnnotations(g, PipeRun.class));
38 schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.GeometryProvider, GeometryProvider.class));
39 return (IMappingSchema<Resource, INode>)(IMappingSchema<Resource, ?>)schema;
40 } catch (IllegalAccessException e) {
41 throw new DatabaseException(e);
42 } catch (InstantiationException e) {
43 throw new DatabaseException(e);