1 package org.simantics.modeling;
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.common.request.WriteResultRequest;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.diagram.stubs.DiagramResource;
8 import org.simantics.layer0.Layer0;
10 public class NewSymbolGroupRequest extends WriteResultRequest<Resource> {
15 public NewSymbolGroupRequest(String name, Resource model) {
21 public Resource perform(WriteGraph graph) throws DatabaseException {
22 return createNewSymbolGroup(graph, model, name);
25 public static Resource createNewSymbolGroup(WriteGraph graph, Resource model, String name) throws DatabaseException {
26 Layer0 L0 = Layer0.getInstance(graph);
27 DiagramResource DIA = DiagramResource.getInstance(graph);
30 Resource symbolGroup = graph.newResource();
31 graph.claim(symbolGroup, L0.PartOf, model);
32 graph.claim(symbolGroup, L0.InstanceOf, DIA.SymbolReferenceLibrary);
35 graph.claimLiteral(symbolGroup, L0.HasName, name);