]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/techtype/requests/WriteTechTypeTable.java
Add enable/disable feature for tech type tables
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / techtype / requests / WriteTechTypeTable.java
index 1f85c5a43a039ba1fec5da57090eb86ee4c480b0..500c83e391355c48ef7fc593d714363e6cf89253 100644 (file)
@@ -9,6 +9,7 @@ import org.simantics.db.common.procedure.adapter.TransientCacheListener;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.PossibleActiveModel;
+import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.district.network.ontology.DistrictNetworkResource;
 import org.simantics.layer0.Layer0;
 
@@ -32,12 +33,18 @@ public final class WriteTechTypeTable extends WriteRequest {
 
                Resource ttt = graph.syncRequest(new PossibleTechTypeTable(model, componentType), TransientCacheListener.instance());
 
+               graph.getSession().markUndoPoint();
+               
                if (ttt == null) {
                        ttt = graph.newResource();
                        graph.claim(ttt, L0.InstanceOf, DN.TechType_TechTypeTable);
                        graph.claimLiteral(ttt, L0.HasName, UUID.randomUUID().toString());
                        graph.claim(model, L0.ConsistsOf, ttt);
                        graph.claim(ttt, DN.TechType_TechTypeTable_HasComponentType, componentType);
+                       Layer0Utils.addCommentMetadata(graph, "Create tech type table");
+               } else {
+                       graph.deny(ttt, DN.TechType_TechTypeTable_HasEnabledItems);
+                       Layer0Utils.addCommentMetadata(graph, "Update tech type table");
                }
 
                graph.claimLiteral(ttt, DN.TechType_TechTypeTable_HasData, data);