From 0ad71a873ea377c6c97ddcb33d2020e947864af9 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 21 Sep 2020 16:49:32 +0300 Subject: [PATCH] Support for new edge properties in district import wizard gitlab #99 Change-Id: Ief14e7e33c24680c0b2aac7fb3a9c02d67138684 --- .../imports/ui/CSVImportWizardPage.java | 662 +++--------------- .../scl/Simantics/District/Import.scl | 8 + .../district/imports/CSVImportModel.java | 63 ++ .../district/imports/DistrictImportUtils.java | 31 + 4 files changed, 182 insertions(+), 582 deletions(-) diff --git a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java index beb56be1..5db45815 100644 --- a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java +++ b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Consumer; import org.apache.commons.csv.CSVRecord; import org.eclipse.jface.dialogs.IPageChangeProvider; @@ -91,6 +92,13 @@ public class CSVImportWizardPage extends WizardPage { private DynamicComboFieldEditor endYCoordSelector; private DynamicComboFieldEditor endZValueSelector; private DynamicComboFieldEditor detailedGeometrySelector; + private DynamicComboFieldEditor pipeCodeSelector; + private DynamicComboFieldEditor installationYearSelector; + private DynamicComboFieldEditor wallThicknessSelector; + private DynamicComboFieldEditor insulationConductivitySelector; + private DynamicComboFieldEditor pipeSizeDNSelector; + private DynamicComboFieldEditor roughnessSelector; + private DynamicComboFieldEditor structureSelector; private Text edgeConnectionPadding; @@ -315,615 +323,98 @@ public class CSVImportWizardPage extends WizardPage { private void createCommonIndexMappingField(Group parent) { - componentMappingSelector = new DynamicComboFieldEditor("componentMapping", "Apros component mapping", parent); - componentMappingSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setComponentMappingIndex(Integer.parseInt(componentMappingSelector.getValue())); - validatePageComplete(); - } - }); + componentMappingSelector = createComboField("componentMapping", "Apros component mapping", model::setComponentMappingIndex, parent); - idSelector = new DynamicComboFieldEditor("id", "ID", parent); - idSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setIdIndex(Integer.parseInt(idSelector.getValue())); - validatePageComplete(); - } - }); - regionSelector = new DynamicComboFieldEditor("regionValue", "Region", parent); - regionSelector.addComboListener(new SelectionListener() { + idSelector = createComboField("id", "ID", model::setIdIndex, parent); + regionSelector = createComboField("regionValue", "Region", model::setRegionIndex, parent); + } + private DynamicComboFieldEditor createComboField(String name, String label, Consumer setter, Group parent) { + DynamicComboFieldEditor selector = new DynamicComboFieldEditor(name, label, parent); + createSelectionListener(selector, setter); + return selector; + } + + private void createSelectionListener(DynamicComboFieldEditor editor, Consumer setter) { + editor.addComboListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { widgetDefaultSelected(e); } - + @Override public void widgetDefaultSelected(SelectionEvent e) { - model.setRegionIndex(Integer.parseInt(regionSelector.getValue())); + setter.accept(Integer.parseInt(editor.getValue())); validatePageComplete(); } }); } private void createVertexIndexMappingField(Group parent) { - xCoordSelector = new DynamicComboFieldEditor("xCoord", "X Coordinate", parent); - xCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setXCoordIndex(Integer.parseInt(xCoordSelector.getValue())); - validatePageComplete(); - } - }); - - yCoordSelector = new DynamicComboFieldEditor("yCoord", "Y Coordinate", parent); - yCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setYCoordIndex(Integer.parseInt(yCoordSelector.getValue())); - validatePageComplete(); - } - }); - zValueSelector = new DynamicComboFieldEditor("zValue", "Z Value", parent); - zValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setZCoordIndex(Integer.parseInt(zValueSelector.getValue())); - validatePageComplete(); - } - }); + xCoordSelector = createComboField("xCoord", "X Coordinate", model::setXCoordIndex, parent); - altElevationValueSelector = new DynamicComboFieldEditor("altElevation", "Alternative Elevation", parent); - altElevationValueSelector.addComboListener(new SelectionListener() { + yCoordSelector = createComboField("yCoord", "Y Coordinate", model::setYCoordIndex, parent); + zValueSelector = createComboField("zValue", "Z Value", model::setZCoordIndex, parent); - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setAltElevationIndex(Integer.parseInt(altElevationValueSelector.getValue())); - validatePageComplete(); - } - }); + altElevationValueSelector = createComboField("altElevation", "Alternative Elevation", model::setAltElevationIndex, parent); - supplyTempValueSelector = new DynamicComboFieldEditor("tempValue", "Supply Temperature value", parent); - supplyTempValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setSupplyTempIndex(Integer.parseInt(supplyTempValueSelector.getValue())); - validatePageComplete(); - } - }); - returnTempValueSelector = new DynamicComboFieldEditor("returnTempValue", "Return Temperature value", parent); - returnTempValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setReturnTempIndex(Integer.parseInt(returnTempValueSelector.getValue())); - validatePageComplete(); - } - }); - supplyPressureValueSelector = new DynamicComboFieldEditor("pressureValue", "Supply Pressure value", parent); - supplyPressureValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setSupplyPressureIndex(Integer.parseInt(supplyPressureValueSelector.getValue())); - validatePageComplete(); - } - }); - returnPressureValueSelector = new DynamicComboFieldEditor("returnPressureValue", "Return Pressure value", parent); - returnPressureValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setReturnPressureIndex(Integer.parseInt(returnPressureValueSelector.getValue())); - validatePageComplete(); - } - }); - dpSelector = new DynamicComboFieldEditor("dpValue", "Delta pressure ", parent); - dpSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setDeltaPressureIndex(Integer.parseInt(dpSelector.getValue())); - validatePageComplete(); - } - }); - dtSelector = new DynamicComboFieldEditor("dtValue", "Delta temperature ", parent); - dtSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setDeltaTemperatureIndex(Integer.parseInt(dtSelector.getValue())); - validatePageComplete(); - } - }); - heatPowerSelector = new DynamicComboFieldEditor("heatPowerValue", "Heat Power", parent); - heatPowerSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setHeatPowerIndex(Integer.parseInt(heatPowerSelector.getValue())); - validatePageComplete(); - } - }); - peakPowerSelector = new DynamicComboFieldEditor("peakPowerValue", "Peak Power", parent); - peakPowerSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setPeakPowerIndex(Integer.parseInt(peakPowerSelector.getValue())); - validatePageComplete(); - } - }); + supplyTempValueSelector = createComboField("tempValue", "Supply Temperature value", model::setSupplyTempIndex, parent); + returnTempValueSelector = createComboField("returnTempValue", "Return Temperature value", model::setReturnTempIndex, parent); + supplyPressureValueSelector = createComboField("pressureValue", "Supply Pressure value", model::setSupplyPressureIndex, parent); + returnPressureValueSelector = createComboField("returnPressureValue", "Return Pressure value", model::setReturnPressureIndex, parent); + dpSelector = createComboField("dpValue", "Delta pressure ", model::setDeltaPressureIndex, parent); + dtSelector = createComboField("dtValue", "Delta temperature ", model::setDeltaTemperatureIndex, parent); + heatPowerSelector = createComboField("heatPowerValue", "Heat Power", model::setHeatPowerIndex, parent); + peakPowerSelector = createComboField("peakPowerValue", "Peak Power", model::setPeakPowerIndex, parent); - nominalHeadMSelector = new DynamicComboFieldEditor("nominalHeadMValue", "nominalHeadM", parent); - nominalHeadMSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setNominalHeadMIndex(Integer.parseInt(nominalHeadMSelector.getValue())); - validatePageComplete(); - } - }); - nominalHeadBSelector = new DynamicComboFieldEditor("nominalHeadBValue", "nominalHeadB", parent); - nominalHeadBSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setNominalHeadBIndex(Integer.parseInt(nominalHeadBSelector.getValue())); - validatePageComplete(); - } - }); - nominalFlowSelector = new DynamicComboFieldEditor("nominalFlowValue", "nominalFlow", parent); - nominalFlowSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setNominalFlowIndex(Integer.parseInt(nominalFlowSelector.getValue())); - validatePageComplete(); - } - }); - - maximumHeadMSelector = new DynamicComboFieldEditor("maximumHeadMValue", "maximumHeadM", parent); - maximumHeadMSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setMaximumHeadMIndex(Integer.parseInt(maximumHeadMSelector.getValue())); - validatePageComplete(); - } - }); - heatLoadDsSelector = new DynamicComboFieldEditor("heatLoadDsValue", "heatLoadDs", parent); - heatLoadDsSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setHeatLoadDsIndex(Integer.parseInt(heatLoadDsSelector.getValue())); - validatePageComplete(); - } - }); - massFlowSelector = new DynamicComboFieldEditor("massFlowValue", "massFlow", parent); - massFlowSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setMassFlowIndex(Integer.parseInt(massFlowSelector.getValue())); - validatePageComplete(); - } - }); - volFlowSelector = new DynamicComboFieldEditor("volFlowValue", "volFlow", parent); - volFlowSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setVolFlowIndex(Integer.parseInt(volFlowSelector.getValue())); - validatePageComplete(); - } - }); - velocitySelector = new DynamicComboFieldEditor("velocityValue", "velocity", parent); - velocitySelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setVelocityIndex(Integer.parseInt(velocitySelector.getValue())); - validatePageComplete(); - } - }); - flowAreaSelector = new DynamicComboFieldEditor("flowAreaValue", "flowArea", parent); - flowAreaSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setFlowAreaIndex(Integer.parseInt(flowAreaSelector.getValue())); - validatePageComplete(); - } - }); - nominalPressureLossSelector = new DynamicComboFieldEditor("nominalPressureLossValue", "nominalPressureLoss", parent); - nominalPressureLossSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setNominalPressureLossIndex(Integer.parseInt(nominalPressureLossSelector.getValue())); - validatePageComplete(); - } - }); - valvePositionSelector = new DynamicComboFieldEditor("valvePositionSelectorValue", "valvePositionSelector", parent); - valvePositionSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setValvePositionIndex(Integer.parseInt(valvePositionSelector.getValue())); - validatePageComplete(); - } - }); - addressSelector = new DynamicComboFieldEditor("addressValue", "addressSelector", parent); - addressSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setAddressIndex(Integer.parseInt(addressSelector.getValue())); - validatePageComplete(); - } - }); + nominalHeadMSelector = createComboField("nominalHeadMValue", "nominalHeadM", model::setNominalHeadMIndex, parent); + nominalHeadBSelector = createComboField("nominalHeadBValue", "nominalHeadB", model::setNominalHeadBIndex, parent); + nominalFlowSelector = createComboField("nominalFlowValue", "nominalFlow", model::setNominalFlowIndex, parent); + + maximumHeadMSelector = createComboField("maximumHeadMValue", "maximumHeadM", model::setMaximumHeadMIndex, parent); + heatLoadDsSelector = createComboField("heatLoadDsValue", "heatLoadDs", model::setHeatLoadDsIndex, parent); + massFlowSelector = createComboField("massFlowValue", "massFlow", model::setMassFlowIndex, parent); + volFlowSelector = createComboField("volFlowValue", "volFlow", model::setVolFlowIndex, parent); + velocitySelector = createComboField("velocityValue", "velocity", model::setVelocityIndex, parent); + flowAreaSelector = createComboField("flowAreaValue", "flowArea", model::setFlowAreaIndex, parent); + nominalPressureLossSelector = createComboField("nominalPressureLossValue", "nominalPressureLoss", model::setNominalPressureLossIndex, parent); + valvePositionSelector = createComboField("valvePositionSelectorValue", "valvePositionSelector", model::setValvePositionIndex, parent); + addressSelector = createComboField("addressValue", "addressSelector", model::setAddressIndex, parent); } - + private void createEdgeIndexMappingField(Group parent) { // Composite paddingComposite = new Composite(parent, SWT.NONE); // GridLayoutFactory.fillDefaults().numColumns(2).applyTo(paddingComposite); + startXCoordSelector = createComboField("startxCoord", "Start X Coordinate", model::setStartXCoordIndex, parent); + startYCoordSelector = createComboField("startyCoord", "Start Y Coordinate", model::setStartYCoordIndex, parent); + startZValueSelector = createComboField("startzValue", "Start Z Value", model::setStartZCoordIndex, parent); - startXCoordSelector = new DynamicComboFieldEditor("startxCoord", "Start X Coordinate", parent); - startXCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setStartXCoordIndex(Integer.parseInt(startXCoordSelector.getValue())); - validatePageComplete(); - } - }); - - startYCoordSelector = new DynamicComboFieldEditor("startyCoord", "Start Y Coordinate", parent); - startYCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setStartYCoordIndex(Integer.parseInt(startYCoordSelector.getValue())); - validatePageComplete(); - } - }); - startZValueSelector = new DynamicComboFieldEditor("startzValue", "Start Z Value", parent); - startZValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setStartZCoordIndex(Integer.parseInt(startZValueSelector.getValue())); - validatePageComplete(); - } - }); + endXCoordSelector = createComboField("endxCoord", "End X Coordinate", model::setEndXCoordIndex, parent); + endYCoordSelector = createComboField("endyCoord", "End Y Coordinate", model::setEndYCoordIndex, parent); + endZValueSelector = createComboField("endzValue", "End Z Value", model::setEndZCoordIndex, parent); - endXCoordSelector = new DynamicComboFieldEditor("endxCoord", "End X Coordinate", parent); - endXCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setEndXCoordIndex(Integer.parseInt(endXCoordSelector.getValue())); - validatePageComplete(); - } - }); - - endYCoordSelector = new DynamicComboFieldEditor("endyCoord", "End Y Coordinate", parent); - endYCoordSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setEndYCoordIndex(Integer.parseInt(endYCoordSelector.getValue())); - validatePageComplete(); - } - }); - endZValueSelector = new DynamicComboFieldEditor("endzValue", "End Z Value", parent); - endZValueSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setEndZCoordIndex(Integer.parseInt(endZValueSelector.getValue())); - validatePageComplete(); - } - }); - detailedGeometrySelector = new DynamicComboFieldEditor("detailedGeometryValue", "Geometry", parent); - detailedGeometrySelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.detailedGeometryIndex(Integer.parseInt(detailedGeometrySelector.getValue())); - validatePageComplete(); - } - }); - diameterSelector = new DynamicComboFieldEditor("diameterValue", "Diameter value", parent); - diameterSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setDiameterIndex(Integer.parseInt(diameterSelector.getValue())); - validatePageComplete(); - } - }); - outerDiameterSelector = new DynamicComboFieldEditor("outerDiameterValue", "Outer Diameter value", parent); - outerDiameterSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setOuterDiameterIndex(Integer.parseInt(outerDiameterSelector.getValue())); - validatePageComplete(); - } - }); - nominalMassFlowSelector = new DynamicComboFieldEditor("nominalMassFlowValue", "Nominal Mass Flow", parent); - nominalMassFlowSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setNominalMassFlowIndex(Integer.parseInt(nominalMassFlowSelector.getValue())); - validatePageComplete(); - } - }); - edgeFlowAreaSelector = new DynamicComboFieldEditor("edgeFlowAreaValue", "Flow Area", parent); - edgeFlowAreaSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setEdgeFlowAreaIndex(Integer.parseInt(edgeFlowAreaSelector.getValue())); - validatePageComplete(); - } - }); - kReturnSelector = new DynamicComboFieldEditor("kReturnValue", "K Return", parent); - kReturnSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setKReturnIndex(Integer.parseInt(kReturnSelector.getValue())); - validatePageComplete(); - } - }); - kSupplySelector = new DynamicComboFieldEditor("kSupplyValue", "K Supply", parent); - kSupplySelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setKSupplyIndex(Integer.parseInt(kSupplySelector.getValue())); - validatePageComplete(); - } - }); - tGroundSelector = new DynamicComboFieldEditor("tGroundValue", "Temperature Ground", parent); - tGroundSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setTGroundIndex(Integer.parseInt(tGroundSelector.getValue())); - validatePageComplete(); - } - }); - lengthSelector = new DynamicComboFieldEditor("lengthValue", "lengthSelector", parent); - lengthSelector.addComboListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - widgetDefaultSelected(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - model.setLengthIndex(Integer.parseInt(lengthSelector.getValue())); - validatePageComplete(); - } - }); + pipeCodeSelector = createComboField("pipeCodeValue", "Pipe Code", model::setPipeCodeIndex, parent); + + detailedGeometrySelector = createComboField("detailedGeometryValue", "Geometry", model::detailedGeometryIndex, parent); + diameterSelector = createComboField("diameterValue", "Diameter value", model::setDiameterIndex, parent); + outerDiameterSelector = createComboField("outerDiameterValue", "Outer Diameter value", model::setOuterDiameterIndex, parent); + nominalMassFlowSelector = createComboField("nominalMassFlowValue", "Nominal Mass Flow", model::setNominalMassFlowIndex, parent); + edgeFlowAreaSelector = createComboField("edgeFlowAreaValue", "Flow Area", model::setEdgeFlowAreaIndex, parent); + kReturnSelector = createComboField("kReturnValue", "K Return", model::setKReturnIndex, parent); + kSupplySelector = createComboField("kSupplyValue", "K Supply", model::setKSupplyIndex, parent); + tGroundSelector = createComboField("tGroundValue", "Temperature Ground", model::setTGroundIndex, parent); + lengthSelector = createComboField("lengthValue", "lengthSelector", model::setLengthIndex, parent); + + pipeSizeDNSelector = createComboField("pipeSizeDNValue", "Pipe Size DN", model::setPipeSizeDNIndex, parent); + structureSelector = createComboField("structureValue", "Structure", model::setStructureIndex, parent); + installationYearSelector = createComboField("installationYearValue", "Installation Year", model::setInstallationYearIndex, parent); + wallThicknessSelector = createComboField("wallThicknessValue", "Wall Thickness", model::setWallThicknessIndex, parent); + insulationConductivitySelector = createComboField("insulationConductivityValue", "Insulation Conductivity", model::setInsulationConductivityIndex, parent); + roughnessSelector = createComboField("roughnessValue", "Roughness", model::setRoughnessIndex, parent); } private void updateCombos() { @@ -957,6 +448,7 @@ public class CSVImportWizardPage extends WizardPage { endYCoordSelector.updateCombo(namesAndValues); startZValueSelector.updateCombo(namesAndValues); endZValueSelector.updateCombo(namesAndValues); + pipeCodeSelector.updateCombo(namesAndValues); detailedGeometrySelector.updateCombo(namesAndValues); diameterSelector.updateCombo(namesAndValues); outerDiameterSelector.updateCombo(namesAndValues); @@ -966,6 +458,12 @@ public class CSVImportWizardPage extends WizardPage { kSupplySelector.updateCombo(namesAndValues); tGroundSelector.updateCombo(namesAndValues); lengthSelector.updateCombo(namesAndValues); + pipeSizeDNSelector.updateCombo(namesAndValues); + structureSelector.updateCombo(namesAndValues); + installationYearSelector.updateCombo(namesAndValues); + wallThicknessSelector.updateCombo(namesAndValues); + insulationConductivitySelector.updateCombo(namesAndValues); + roughnessSelector.updateCombo(namesAndValues); } private void updateVertexCombos(String[][] namesAndValues) { diff --git a/org.simantics.district.imports/scl/Simantics/District/Import.scl b/org.simantics.district.imports/scl/Simantics/District/Import.scl index 483887a3..d182e261 100644 --- a/org.simantics.district.imports/scl/Simantics/District/Import.scl +++ b/org.simantics.district.imports/scl/Simantics/District/Import.scl @@ -36,6 +36,14 @@ importJava "org.simantics.district.imports.CSVImportModel" where setEdgePadding :: CSVImportModel -> Double -> () setPipeTypeIndex :: CSVImportModel -> Integer -> () + setPipeCodeIndex :: CSVImportModel -> Integer -> () + setInstallationYearIndex :: CSVImportModel -> Integer -> () + setWallThicknessIndex :: CSVImportModel -> Integer -> () + setInsulationConductivityIndex :: CSVImportModel -> Integer -> () + setPipeSizeDNIndex :: CSVImportModel -> Integer -> () + setRoughnessIndex :: CSVImportModel -> Integer -> () + setStructureIndex :: CSVImportModel -> Integer -> () + // Common setSourceCRS :: CSVImportModel -> String -> () setIdIndex :: CSVImportModel -> Integer -> () diff --git a/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java b/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java index ffcf5ae9..ac422300 100644 --- a/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java +++ b/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java @@ -76,6 +76,13 @@ public class CSVImportModel { private int peakPowerIndex = -1; private int regionIndex = -1; private int pipeTypeIndex = -1; + private int pipeCodeIndex = -1; + private int installationYearIndex = -1; + private int wallThicknessIndex = -1; + private int insulationConductivityIndex = -1; + private int pipeSizeDNIndex = -1; + private int roughnessIndex = -1; + private int structureIndex = -1; // Third page @@ -536,4 +543,60 @@ public class CSVImportModel { public void setPipeTypeIndex(int pipeTypeIndex) { this.pipeTypeIndex = pipeTypeIndex; } + + public int getPipeCodeIndex() { + return pipeCodeIndex; + } + + public void setPipeCodeIndex(int pipeCodeIndex) { + this.pipeCodeIndex = pipeCodeIndex; + } + + public int getInstallationYearIndex() { + return installationYearIndex; + } + + public void setInstallationYearIndex(int installationYearIndex) { + this.installationYearIndex = installationYearIndex; + } + + public int getWallThicknessIndex() { + return wallThicknessIndex; + } + + public void setWallThicknessIndex(int wallThicknessIndex) { + this.wallThicknessIndex = wallThicknessIndex; + } + + public int getInsulationConductivityIndex() { + return insulationConductivityIndex; + } + + public void setInsulationConductivityIndex(int insulationConductivityIndex) { + this.insulationConductivityIndex = insulationConductivityIndex; + } + + public int getPipeSizeDNIndex() { + return pipeSizeDNIndex; + } + + public void setPipeSizeDNIndex(int pipeSizeDNIndex) { + this.pipeSizeDNIndex = pipeSizeDNIndex; + } + + public int getRoughnessIndex() { + return roughnessIndex; + } + + public void setRoughnessIndex(int roughnessIndex) { + this.roughnessIndex = roughnessIndex; + } + + public int getStructureIndex() { + return structureIndex; + } + + public void setStructureIndex(int structureIndex) { + this.structureIndex = structureIndex; + } } diff --git a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java index d9dac92c..67e07b0c 100644 --- a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java +++ b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java @@ -387,6 +387,13 @@ public class DistrictImportUtils { int detailedGeometryIndex = model.getDetailedGeometryIndex(); int regionIndex = model.getRegionIndex(); int pipeTypeIndex = model.getPipeTypeIndex(); + int pipeCodeIndex = model.getPipeCodeIndex(); + int installationYearIndex = model.getInstallationYearIndex(); + int wallThicknessIndex = model.getWallThicknessIndex(); + int insulationConductivityIndex = model.getInsulationConductivityIndex(); + int pipeSizeDNIndex = model.getPipeSizeDNIndex(); + int roughnessIndex = model.getRoughnessIndex(); + int structureIndex = model.getStructureIndex(); int mappingColumn = model.getComponentMappingIndex(); int idColumn = model.getIdIndex(); @@ -482,6 +489,13 @@ public class DistrictImportUtils { writeStringValue(graph, row, regionIndex, edge, DN.HasRegion); writeStringValue(graph, row, pipeTypeIndex, edge, DN.Edge_HasType); writeDoubleArrayFromString(graph, row, detailedGeometryIndex, edge, DN.Edge_HasGeometry, actualTransform); + writeStringValue(graph, row, pipeCodeIndex, edge, DN.Edge_HasPipeCode); + writeIntegerValue(graph, row, installationYearIndex, edge, DN.Edge_HasInstallationYear); + writeValue(graph, row, wallThicknessIndex, edge, DN.Edge_HasWallThickness); + writeValue(graph, row, insulationConductivityIndex, edge, DN.Edge_HasInsulationConductivity); + writeIntegerValue(graph, row, pipeSizeDNIndex, edge, DN.Edge_HasPipeSizeDN); + writeValue(graph, row, roughnessIndex, edge, DN.Edge_HasRoughness); + writeStringValue(graph, row, structureIndex, edge, DN.Edge_HasStructure); } } return true; @@ -521,6 +535,23 @@ public class DistrictImportUtils { } } + private static void writeIntegerValue(WriteGraph graph, CSVRecord row, int index, Resource subject, Resource relation) throws DatabaseException { + if (index != -1) { + String stringValue = row.get(index); + if (!stringValue.isEmpty()) { + try { + if (stringValue.startsWith("\"") && stringValue.endsWith("\"")) { + stringValue = stringValue.substring(1, stringValue.length() - 1); + } + graph.claimLiteral(subject, relation, Integer.parseInt(stringValue), Bindings.INTEGER); + } catch (NumberFormatException e) { + LOGGER.error("Could not parse {} {} {} {}", row, index, subject, relation, e); + //throw new DatabaseException(e); + } + } + } + } + private static void writeStringValue(WriteGraph graph, CSVRecord row, int index, Resource subject, Resource relation) throws DatabaseException { if (index != -1) { String stringValue = row.get(index); -- 2.47.1