+++ /dev/null
-package org.simantics.district.imports.ui;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.csv.CSVFormat;
-import org.apache.commons.csv.CSVRecord;
-import org.simantics.db.Resource;
-import org.simantics.district.imports.DistrictImportUtils;
-import org.simantics.district.imports.DistrictImportUtils.CSVHeader;
-
-public class CSVImportModel {
-
- // First page fills these
- private Resource targetDiagram;
- private Path source;
-
- // Second page fills these
- private char delimiter;
- private boolean readFirstAsHeader = true;
- private Map<String, Character> delimiters;
-// private Path wktFile;
-
- // Vertex import
- private int xCoordIndex = -1;
- private int yCoordIndex = -1;
- private int zCoordIndex = -1;
-
- // Edge import
- private int startXCoordIndex = -1;
- private int startYCoordIndex = -1;
- private int startZCoordIndex = -1;
- private int endXCoordIndex = -1;
- private int endYCoordIndex = -1;
- private int endZCoordIndex = -1;
-
- // common
- private int componentMappingIndex = -1;
- private Map<String, Resource> componentMappings = new HashMap<>();
- private boolean isVertexImport;
- private String sourceCRS;
- private int supplytempIndex = -1;
- private int supplypressureIndex= -1;
- private int diameterIndex = -1;
- private int outerDiamterIndex = -1;
- private int nominalMassFlowIndex = -1;
- private int returnTempIndex = -1;
- private int returnPressureIndex = -1;
- private int deltaPressureIndex = -1;
- private int deltaTemperatureIndex = -1;
- private int heatPowerIndex = -1;
- private int nominalHeadMIndex = -1;
- private int nominalHeadBIndex = -1;
- private int nominalFlowIndex = -1;
- private int maximumHeadMIndex = -1;
- private int heatLoadDsIndex = -1;
- private int massFlowIndex = -1;
- private int volFlowIndex = -1;
- private int velocityIndex = -1;
- private int flowAreaIndex = -1;
- private int nominalPressureLossIndex = -1;
- private int edgeFlowAreaIndex = -1;
- private int kReturnIndex = -1;
- private int kSupplyIndex = -1;
- private int tGroundIndex = -1;
- private int idIndex = -1;
- private double edgePadding = 0.0001; // default
- private int valvePositionIndx = -1;
- private int addressIndex;
- private int lengthIndex;
- private int detailedGeometryIndex;
-
- // Third page
-
- public CSVImportModel() {
- delimiters = DistrictImportUtils.getSupportedCSVDelimiterFormats();
- }
-
- public void setSource(Path source) {
- this.source = source;
- }
-
- public void setDelimiter(char delimiter) {
- this.delimiter = delimiter;
- }
-
- public void setReadFirstAsHeader(boolean read) {
- this.readFirstAsHeader = read;
- }
-
- public Path getSource() {
- return source;
- }
-
- public List<CSVRecord> getRows(int amount, boolean readFirstAsHeader) throws IOException {
- if (source != null)
- return DistrictImportUtils.readRows(source, delimiter, readFirstAsHeader, amount);
- else
- return Collections.emptyList();
- }
-
- public Map<CSVHeader, List<String>> getHeaderAndRows(int amount) throws IOException {
- if (source != null)
- return DistrictImportUtils.readCSVHeaderAndRows(source, delimiter, readFirstAsHeader, amount);
- else
- return Collections.emptyMap();
- }
-
- public Map<String, Integer> getHeader() throws IOException {
- Map<String, Integer> header = null;
- if (source != null)
- header = DistrictImportUtils.readCSVHeader(source, delimiter, readFirstAsHeader);
- if (header == null)
- header = Collections.emptyMap();
- return header;
- }
-
- public boolean getReadFirstAsHeader() {
- return readFirstAsHeader;
- }
-
- public String[] getDelimiterFormats() {
- return delimiters.keySet().toArray(new String[delimiters.size()]);
- }
-
- public void setDelimiterByLabel(String item) {
- setDelimiter(delimiters.get(item));
- }
-
- public List<Map<String, String>> readRows(int amount) throws IOException {
- if (source != null)
- return DistrictImportUtils.readRows(source, CSVFormat.newFormat(delimiter), readFirstAsHeader, amount);
- else
- return Collections.emptyList();
- }
-
- public char getDelimiter() {
- return delimiter;
- }
-
-// public Path getWKTFile() {
-// return wktFile;
-// }
-
- public int getXCoordIndex() {
- return xCoordIndex;
- }
-
- public void setXCoordIndex(int xCoordIndex) {
- this.xCoordIndex = xCoordIndex;
- }
-
- public int getYCoordIndex() {
- return yCoordIndex;
- }
-
- public void setYCoordIndex(int yCoordIndex) {
- this.yCoordIndex = yCoordIndex;
- }
-
- public int getZCoordIndex() {
- return zCoordIndex;
- }
-
- public void setZCoordIndex(int zCoordIndex) {
- this.zCoordIndex = zCoordIndex;
- }
-
- public int getComponentMappingIndex() {
- return componentMappingIndex;
- }
-
- public void setComponentMappingIndex(int componentMappingIndex) {
- this.componentMappingIndex = componentMappingIndex;
- }
-
- public void setParentDiagram(Resource diagram) {
- this.targetDiagram = diagram;
- }
-
- public Resource getParentDiagram() {
- return targetDiagram;
- }
-
-// public void setWKTFile(Path wktFile) {
-// this.wktFile = wktFile;
-// }
-
- public void setComponentMappings(String value, Resource resource) {
- componentMappings.put(value, resource);
- }
-
- public Map<String, Resource> getComponentMappings() {
- return componentMappings;
- }
-
- public boolean isVertexImport() {
- return isVertexImport;
- }
-
- public void setVertexImport(boolean isVertexImport) {
- this.isVertexImport = isVertexImport;
- }
-
- public void setStartXCoordIndex(int parseInt) {
- this.startXCoordIndex = parseInt;
- }
-
- public int getStartXCoordIndex() {
- return startXCoordIndex;
- }
-
- public void setStartYCoordIndex(int parseInt) {
- this.startYCoordIndex = parseInt;
- }
-
- public int getStartYCoordIndex() {
- return startYCoordIndex;
- }
-
- public void setStartZCoordIndex(int parseInt) {
- this.startZCoordIndex = parseInt;
- }
-
- public int getStartZCoordIndex() {
- return startZCoordIndex;
- }
-
- public void setEndXCoordIndex(int parseInt) {
- this.endXCoordIndex = parseInt;
- }
-
- public int getEndXCoordIndex() {
- return endXCoordIndex;
- }
-
- public void setEndYCoordIndex(int parseInt) {
- this.endYCoordIndex = parseInt;
- }
-
- public int getEndYCoordIndex() {
- return endYCoordIndex;
- }
-
- public void setEndZCoordIndex(int parseInt) {
- this.endZCoordIndex = parseInt;
- }
-
- public int getEndZCoordIndex() {
- return endZCoordIndex;
- }
-
- public void setSourceCRS(String crs) {
- this.sourceCRS = crs;
- }
-
- public String getSourceCRS() {
- return sourceCRS;
- }
-
- public void setSupplyTempIndex(int supplyTempIndex) {
- this.supplytempIndex = supplyTempIndex;
- }
-
- public int getSupplyTempIndex() {
- return supplytempIndex;
- }
-
- public void setSupplyPressureIndex(int supplyPressureIndex) {
- this.supplypressureIndex = supplyPressureIndex;
- }
-
- public int getSupplyPressureIndex() {
- return supplypressureIndex;
- }
-
- public void setReturnTempIndex(int returnTempIndex) {
- this.returnTempIndex = returnTempIndex;
- }
-
- public int getReturnTempIndex() {
- return returnTempIndex;
- }
-
- public void setReturnPressureIndex(int returnPressureIndex) {
- this.returnPressureIndex = returnPressureIndex;
- }
-
- public int getReturnPressureIndex() {
- return returnPressureIndex;
- }
-
- public void setDiameterIndex(int parseInt) {
- this.diameterIndex = parseInt;
- }
-
- public int getDiameterIndex() {
- return diameterIndex;
- }
-
- public void setOuterDiameterIndex(int parseInt) {
- this.outerDiamterIndex = parseInt;
- }
-
- public int getOuterDiamterIndex() {
- return outerDiamterIndex;
- }
-
- public void setNominalMassFlowIndex(int parseInt) {
- this.nominalMassFlowIndex = parseInt;
- }
-
- public int getNominalMassFlowIndex() {
- return nominalMassFlowIndex;
- }
-
- public void setDeltaPressureIndex(int parseInt) {
- this.deltaPressureIndex = parseInt;
- }
-
- public int getDeltaPressureIndex() {
- return deltaPressureIndex;
- }
-
- public void setDeltaTemperatureIndex(int parseInt) {
- this.deltaTemperatureIndex = parseInt;
- }
-
- public int getDeltaTemperatureIndex() {
- return deltaTemperatureIndex;
- }
-
- public void setHeatPowerIndex(int parseInt) {
- this.heatPowerIndex = parseInt;
- }
-
- public int getHeatPowerIndex() {
- return heatPowerIndex;
- }
-
- public void setNominalHeadMIndex(int parseInt) {
- this.nominalHeadMIndex = parseInt;
- }
-
- public int getNominalHeadMIndex() {
- return nominalHeadMIndex;
- }
-
- public void setNominalHeadBIndex(int parseInt) {
- this.nominalHeadBIndex = parseInt;
- }
-
- public int getNominalHeadBIndex() {
- return nominalHeadBIndex;
- }
-
- public void setNominalFlowIndex(int parseInt) {
- this.nominalFlowIndex = parseInt;
- }
-
- public int getNominalFlowIndex() {
- return nominalFlowIndex;
- }
-
- public void setMaximumHeadMIndex(int parseInt) {
- this.maximumHeadMIndex = parseInt;
- }
-
- public int getMaximumHeadMIndex() {
- return maximumHeadMIndex;
- }
-
- public void setHeatLoadDsIndex(int parseInt) {
- this.heatLoadDsIndex = parseInt;
- }
-
- public int getHeatLoadDsIndex() {
- return heatLoadDsIndex;
- }
-
- public void setMassFlowIndex(int parseInt) {
- this.massFlowIndex = parseInt;
- }
-
- public int getMassFlowIndex() {
- return massFlowIndex;
- }
-
- public void setVolFlowIndex(int parseInt) {
- this.volFlowIndex = parseInt;
- }
-
- public int getVolFlowIndex() {
- return volFlowIndex;
- }
-
- public void setVelocityIndex(int parseInt) {
- this.velocityIndex = parseInt;
- }
-
- public int getVelocityIndex() {
- return velocityIndex;
- }
-
- public void setFlowAreaIndex(int parseInt) {
- this.flowAreaIndex = parseInt;
- }
-
- public int getFlowAreaIndex() {
- return flowAreaIndex;
- }
-
- public void setNominalPressureLossIndex(int parseInt) {
- this.nominalPressureLossIndex = parseInt;
- }
-
- public int getNominalPressureLossIndex() {
- return nominalPressureLossIndex;
- }
-
- public void setEdgeFlowAreaIndex(int parseInt) {
- this.edgeFlowAreaIndex = parseInt;
- }
-
- public int getEdgeFlowAreaIndex() {
- return edgeFlowAreaIndex;
- }
-
- public void setKReturnIndex(int parseInt) {
- this.kReturnIndex = parseInt;
- }
-
- public int getkReturnIndex() {
- return kReturnIndex;
- }
-
- public void setKSupplyIndex(int parseInt) {
- this.kSupplyIndex = parseInt;
- }
-
- public int getkSupplyIndex() {
- return kSupplyIndex;
- }
-
- public void setTGroundIndex(int parseInt) {
- this.tGroundIndex = parseInt;
- }
-
- public int gettGroundIndex() {
- return tGroundIndex;
- }
-
- public int getIdIndex() {
- return idIndex;
- }
-
- public void setIdIndex(int idIndex) {
- this.idIndex = idIndex;
- }
-
- public void setEdgePapping(double edgePadding) {
- this.edgePadding = edgePadding;
- }
-
- public double getEdgePadding() {
- return edgePadding;
- }
-
- public void setValvePositionIndex(int valvePositionIndx) {
- this.valvePositionIndx = valvePositionIndx;
- }
-
- public int getValvePositionIndx() {
- return valvePositionIndx;
- }
-
- public void setAddressIndex(int parseInt) {
- this.addressIndex = parseInt;
- }
-
- public int getAddressIndex() {
- return addressIndex;
- }
-
- public int getLengthIndex() {
- return lengthIndex;
- }
-
- public void setLengthIndex(int lengthIndex) {
- this.lengthIndex = lengthIndex;
- }
-
- public void detailedGeometryIndex(int detailedGeometryIndex) {
- this.detailedGeometryIndex = detailedGeometryIndex;
- }
-
- public int getDetailedGeometryIndex() {
- return detailedGeometryIndex;
- }
-}