]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/SchemaBuilder.java
Handle fixed turn components when pipe run is reversed.
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / scenegraph / SchemaBuilder.java
1 package org.simantics.plant3d.scenegraph;
2
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;
13
14 public class SchemaBuilder {
15         public static IMappingSchema<Resource,Object> getSchema() throws DatabaseException{
16                 return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,Object>>() {
17                         @Override
18                         public IMappingSchema<Resource,Object> perform(ReadGraph g)
19                                         throws DatabaseException {
20                                 return getSchema(g);
21                         }
22                 });
23         }
24         
25         public static IMappingSchema<Resource,Object> getSchema(ReadGraph g) throws DatabaseException{
26                 try {
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));
35                         
36                         schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.Builtin_GeometryProvider, GeometryProvider.class));
37                         return schema;
38                 } catch (IllegalAccessException e) {
39                         throw new DatabaseException(e);
40                 } catch (InstantiationException e) {
41                         throw new DatabaseException(e);
42                 }
43         }
44         
45 }