From: jsimomaa Date: Mon, 29 Apr 2019 14:11:16 +0000 (+0300) Subject: Fix copy/paste of pumping station X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F2869%2F1;p=simantics%2Fdistrict.git Fix copy/paste of pumping station gitlab #43 APROS-15307 Change-Id: I07dfa7852146c471fe177c7322c773320fefedac --- diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index 99c1afce..aa801f08 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -76,7 +76,41 @@ DN.Vertex -- DN.Vertex.HasValvePosition @defProperty "Valve position" L0.Double >-- DN.Vertex.HasNominalPressureLoss - @defProperty "Nominal Pressure Loss" L0.Double + @defProperty "Nominal Pressure Loss" L0.Double + >-- DN.Vertex.HasPumpInReturnLine + @defProperty "Pump in Return Line" L0.Double + >-- DN.Vertex.HasHeadPumpMaximum + @defProperty "Head pump maximum" L0.Double + >-- DN.Vertex.HasHeadPumpNominal + @defProperty "Head pump nominal" L0.Double + >-- DN.Vertex.HasFrequencyConverterControlled + @defProperty "Frequency Converter Controlled" L0.Double + >-- DN.Vertex.HasInternalValveMeasurement + @defProperty "Internal Valve Measurement" L0.Double + >-- DN.Vertex.HasPumpMassFlowNominal + @defProperty "Pump Mass Flow Nominal" L0.Double + >-- DN.Vertex.HasPumpMeMax + @defProperty "Pump Me Max" L0.Double + >-- DN.Vertex.HasPumpMeMin + @defProperty "Pump Me Min" L0.Double + >-- DN.Vertex.HasPumpSpeedMax + @defProperty "Pump Speed Max" L0.Double + >-- DN.Vertex.HasPumpSpeedMin + @defProperty "Pump Speed Min" L0.Double + >-- DN.Vertex.HasValveReturnLine + @defProperty "Valve Return Line" L0.Double + >-- DN.Vertex.HasValveMeMax + @defProperty "Valve Me Max" L0.Double + >-- DN.Vertex.HasValveMeMin + @defProperty "Valve Me Min" L0.Double + >-- DN.Vertex.HasValveMinPosition + @defProperty "Valve Min Position" L0.Double + >-- DN.Vertex.HasValveOutletMode + @defProperty "Valve Outlet Mode" L0.Double + >-- DN.Vertex.HasValvePressLossNominal + @defProperty "Valve Press Loss Nominal" L0.Double + >-- DN.Vertex.HasOpeningTime + @defProperty "Opening Time" L0.Double @L0.assert DN.Vertex.HasElevation 0.0 DN.Edge -- DN.Mapping.VertexMapping.NominalPressureLossAttribute --> L0.String -- DN.Mapping.VertexMapping.NominalMassFlowAttribute --> L0.String -- DN.Mapping.VertexMapping.HeadPumpMaximumAttribute --> L0.String -- DN.Mapping.VertexMapping.HeadPumpNominalAttribute --> L0.String -- DN.Mapping.VertexMapping.FrequencyConverterControlledAttribute --> L0.String -- DN.Mapping.VertexMapping.InternalValveMeasurementAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpInReturnLineAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpMassFlowNominalAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpMeMaxAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpMeMinAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpSpeedMaxAttribute --> L0.String -- DN.Mapping.VertexMapping.PumpSpeedMinAttribute --> L0.String -- DN.Mapping.VertexMapping.ValveReturnLineAttribute --> L0.String -- DN.Mapping.VertexMapping.ValveMeMaxAttribute --> L0.String -- DN.Mapping.VertexMapping.ValveMeMinAttribute --> L0.String -- DN.Mapping.VertexMapping.ValveMinPositionAttribute --> L0.String -- DN.Mapping.VertexMapping.ValveOutletModeAttribute --> L0.String -- DN.Mapping.VertexMapping.ValvePressLossNominalAttribute --> L0.String -- DN.Mapping.VertexMapping.OpeningTimeAttribute --> L0.String -- DN.Mapping.EdgeMapping.LengthAttribute --> L0.String -- DN.Mapping.EdgeMapping.DiameterAttribute --> L0.String copyAttributes(WriteGraph graph, Resource mappedElement) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - - Resource mapping = graph.getSingleObject(sourceElement, DN.HasMapping); - Collection statements = graph.getStatements(mapping, L0.HasProperty); - Collection mappingAttributeStatements = statements.stream().filter(stm -> { - try { - Resource predicate = stm.getPredicate(); - Resource hasDomain = graph.getPossibleObject(predicate, L0.HasDomain); - if (hasDomain != null && hasDomain.equals(DN.Mapping_VertexMapping)) { - // filter out x and y and z - Resource vertexAttribute = attributeMappingToVertexAttribute(graph, DN, predicate); - return vertexAttribute != null; - } - } catch (Exception e) { - e.printStackTrace(); - } - return false; - }).collect(Collectors.toList()); - Resource component = graph.getPossibleObject(mappedElement, ModelingResources.getInstance(graph).ElementToComponent); - Variable variable = Variables.getVariable(graph, component); - Map predValues = new HashMap<>(); - for (Statement stm : mappingAttributeStatements) { - String propertyName = graph.getPossibleValue(stm.getObject()); - if (propertyName != null) { - Object propertyValue = variable.getPossiblePropertyValue(graph, propertyName); - if (propertyValue != null) { - predValues.put(attributeMappingToVertexAttribute(graph, DN, stm.getPredicate()), propertyValue); - } else { - System.err.println("no property value for " + variable.getURI(graph) + " and property " + propertyName); - } - } else { - System.err.println("stm.getObject() is not string " + stm.getObject()); - } - } - return predValues; - } }); ThreadUtils.getNonBlockingWorkExecutor().schedule(() -> { try { @@ -273,6 +234,45 @@ public class PasteDistrictVertexHandler { } + private static Map copyAttributes(WriteGraph graph, Resource sourceElement, Resource mappedElement) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + + Resource mapping = graph.getSingleObject(sourceElement, DN.HasMapping); + Collection statements = graph.getStatements(mapping, L0.HasProperty); + Collection mappingAttributeStatements = statements.stream().filter(stm -> { + try { + Resource predicate = stm.getPredicate(); + Resource hasDomain = graph.getPossibleObject(predicate, L0.HasDomain); + if (hasDomain != null && hasDomain.equals(DN.Mapping_VertexMapping)) { + // filter out x and y and z + Resource vertexAttribute = attributeMappingToVertexAttribute(graph, DN, predicate); + return vertexAttribute != null; + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + }).collect(Collectors.toList()); + Resource component = graph.getPossibleObject(mappedElement, ModelingResources.getInstance(graph).ElementToComponent); + Variable variable = Variables.getVariable(graph, component); + Map predValues = new HashMap<>(); + for (Statement stm : mappingAttributeStatements) { + String propertyName = graph.getPossibleValue(stm.getObject()); + if (propertyName != null) { + Object propertyValue = variable.getPossiblePropertyValue(graph, propertyName); + if (propertyValue != null) { + predValues.put(attributeMappingToVertexAttribute(graph, DN, stm.getPredicate()), propertyValue); + } else { + System.err.println("no property value for " + variable.getURI(graph) + " and property " + propertyName); + } + } else { + System.err.println("stm.getObject() is not string " + stm.getObject()); + } + } + return predValues; + } + private static Resource attributeMappingToVertexAttribute(ReadGraph graph, DistrictNetworkResource DN, Resource attribute) throws DatabaseException { Resource attr = null; if (attribute.equals(DN.Mapping_VertexMapping_ElevationAttribute)) @@ -321,6 +321,40 @@ public class PasteDistrictVertexHandler { attr = DN.Vertex_HasVelocity; else if (attribute.equals(DN.Mapping_VertexMapping_VolFlowAttribute)) attr = DN.Vertex_HasVolFlow; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpInReturnLineAttribute)) + attr = DN.Vertex_HasPumpInReturnLine; + else if (attribute.equals(DN.Mapping_VertexMapping_HeadPumpMaximumAttribute)) + attr = DN.Vertex_HasHeadPumpMaximum; + else if (attribute.equals(DN.Mapping_VertexMapping_HeadPumpNominalAttribute)) + attr = DN.Vertex_HasHeadPumpNominal; + else if (attribute.equals(DN.Mapping_VertexMapping_FrequencyConverterControlledAttribute)) + attr = DN.Vertex_HasFrequencyConverterControlled; + else if (attribute.equals(DN.Mapping_VertexMapping_InternalValveMeasurementAttribute)) + attr = DN.Vertex_HasInternalValveMeasurement; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpMassFlowNominalAttribute)) + attr = DN.Vertex_HasPumpMassFlowNominal; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpMeMaxAttribute)) + attr = DN.Vertex_HasPumpMeMax; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpMeMinAttribute)) + attr = DN.Vertex_HasPumpMeMin; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpSpeedMaxAttribute)) + attr = DN.Vertex_HasPumpSpeedMax; + else if (attribute.equals(DN.Mapping_VertexMapping_PumpSpeedMinAttribute)) + attr = DN.Vertex_HasPumpSpeedMin; + else if (attribute.equals(DN.Mapping_VertexMapping_ValveReturnLineAttribute)) + attr = DN.Vertex_HasValveReturnLine; + else if (attribute.equals(DN.Mapping_VertexMapping_ValveMeMaxAttribute)) + attr = DN.Vertex_HasValveMeMax; + else if (attribute.equals(DN.Mapping_VertexMapping_ValveMeMinAttribute)) + attr = DN.Vertex_HasValveMeMin; + else if (attribute.equals(DN.Mapping_VertexMapping_ValveMinPositionAttribute)) + attr = DN.Vertex_HasValveMinPosition; + else if (attribute.equals(DN.Mapping_VertexMapping_ValveOutletModeAttribute)) + attr = DN.Vertex_HasValveOutletMode; + else if (attribute.equals(DN.Mapping_VertexMapping_ValvePressLossNominalAttribute)) + attr = DN.Vertex_HasValvePressLossNominal; + else if (attribute.equals(DN.Mapping_VertexMapping_OpeningTimeAttribute)) + attr = DN.Vertex_HasOpeningTime; else if (attribute.equals(DN.Mapping_VertexMapping_XAttribute)) attr = null; // ignore this! else if (attribute.equals(DN.Mapping_VertexMapping_YAttribute))