]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Support for new edge properties in district import wizard 99/4499/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 21 Sep 2020 13:49:32 +0000 (16:49 +0300)
committerReino Ruusu <reino.ruusu@semantum.fi>
Tue, 22 Sep 2020 08:35:30 +0000 (11:35 +0300)
gitlab #99

Change-Id: Ief14e7e33c24680c0b2aac7fb3a9c02d67138684

org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java
org.simantics.district.imports/scl/Simantics/District/Import.scl
org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java
org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java

index beb56be19a2ab31f25246ad16d8438fdda8cbc36..5db4581584e6110147a87173b0fa3bb0e6aca5bf 100644 (file)
@@ -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<Integer> setter, Group parent) {
+        DynamicComboFieldEditor selector = new DynamicComboFieldEditor(name, label, parent);
+        createSelectionListener(selector, setter);
+        return selector;
+    }
+    
+    private void createSelectionListener(DynamicComboFieldEditor editor, Consumer<Integer> 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) {
index 483887a355b1d18527a91dbc5a4ca189d4753187..d182e2614159e91b65c2d48d511c85ec198b141e 100644 (file)
@@ -36,6 +36,14 @@ importJava "org.simantics.district.imports.CSVImportModel" where
     setEdgePadding :: CSVImportModel -> Double -> <Proc> ()
     setPipeTypeIndex :: CSVImportModel -> Integer -> <Proc> ()
     
+    setPipeCodeIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setInstallationYearIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setWallThicknessIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setInsulationConductivityIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setPipeSizeDNIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setRoughnessIndex :: CSVImportModel -> Integer -> <Proc> ()
+    setStructureIndex :: CSVImportModel -> Integer -> <Proc> ()
+    
     // Common
     setSourceCRS :: CSVImportModel -> String -> <Proc> ()
     setIdIndex :: CSVImportModel -> Integer -> <Proc> ()
index ffcf5ae9263b18f32a0e979e0064b51275d63ccf..ac422300f8b65a4c9586302b355cf3332e3a7ce0 100644 (file)
@@ -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;
+    }
 }
index d9dac92c5586c5924fbf6fe7e1fc2796aa85d3ef..67e07b0cbd792ec3cfdc9a978ee8f14950382745 100644 (file)
@@ -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);