+++ /dev/null
-package org.simantics.district.network.ui.techtype.requests;
-
-import java.util.UUID;
-
-import org.simantics.Simantics;
-import org.simantics.db.Resource;
-import org.simantics.db.WriteGraph;
-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.district.network.ontology.DistrictNetworkResource;
-import org.simantics.layer0.Layer0;
-
-public final class WriteTechTypeTableRequest extends WriteRequest {
- private final String data;
- private final Resource componentType;
-
- public WriteTechTypeTableRequest(Resource componentType, String data) {
- this.data = data;
- this.componentType = componentType;
- }
-
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- Layer0 L0 = Layer0.getInstance(graph);
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-
- Resource model = graph.syncRequest(new PossibleActiveModel(Simantics.getProjectResource()));
- if (model == null)
- throw new DatabaseException("No active model for storing tech type data");
-
- Resource ttt = graph.syncRequest(new PossibleTechTypeTable(model, componentType), TransientCacheListener.instance());
-
- 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);
- }
-
- graph.claimLiteral(ttt, DN.TechType_TechTypeTable_HasData, data);
- }
-}
\ No newline at end of file