diff --git a/52n-sos-importer-bindings/src/main/resources/import-configuration.xsd b/52n-sos-importer-bindings/src/main/resources/import-configuration.xsd
index 59f43783..e614e3fc 100644
--- a/52n-sos-importer-bindings/src/main/resources/import-configuration.xsd
+++ b/52n-sos-importer-bindings/src/main/resources/import-configuration.xsd
@@ -655,7 +655,7 @@
Defines the pattern used to parse the date information
- of the current pattern.
+ of the current sample.
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/controller/Step2Controller.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/controller/Step2Controller.java
index b8a0c2be..d3375a0f 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/controller/Step2Controller.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/controller/Step2Controller.java
@@ -82,6 +82,26 @@ public boolean isFinished() {
return false;
}
+ if(step2Model.isSampleBased() &&
+ (step2Model.getSampleBasedStartRegEx() == null ||
+ step2Model.getSampleBasedStartRegEx().isEmpty() ||
+ step2Model.getSampleBasedDateOffset() < 1 ||
+ step2Model.getSampleBasedDateExtractionRegEx() == null ||
+ step2Model.getSampleBasedDateExtractionRegEx().isEmpty() ||
+ step2Model.getSampleBasedDateExtractionRegEx().indexOf("(") < 0 ||
+ step2Model.getSampleBasedDateExtractionRegEx().indexOf(")") < 1 ||
+ step2Model.getSampleBasedDatePattern() == null ||
+ step2Model.getSampleBasedDatePattern().isEmpty() ||
+ step2Model.getSampleBasedDataOffset() < 1 ||
+ step2Model.getSampleBasedSampleSizeOffset() < 1 ||
+ step2Model.getSampleBasedSampleSizeRegEx() == null ||
+ step2Model.getSampleBasedSampleSizeRegEx().isEmpty() ||
+ step2Model.getSampleBasedSampleSizeRegEx().indexOf("(") < 0 ||
+ step2Model.getSampleBasedSampleSizeRegEx().indexOf(")") < 1
+ )) {
+ return false;
+ }
+
return true;
}
@@ -93,7 +113,7 @@ public StepController getNextStepController() {
step2Model.getFirstLineWithData());
return new Step3Controller(0,
step2Model.getFirstLineWithData(),
- step2Model.getUseHeader());
+ step2Model.isUseHeader());
}
@Override
@@ -118,12 +138,23 @@ public void loadSettings() {
final String csvFileContent = step2Model.getCSVFileContent();
step2Panel.setCSVFileContent(csvFileContent);
- final boolean useHeader = step2Model.getUseHeader();
+ final boolean useHeader = step2Model.isUseHeader();
step2Panel.setUseHeader(useHeader);
step2Panel.setCSVFileHighlight(firstLineWithData);
final char decimalSeparator = step2Model.getDecimalSeparator();
step2Panel.setDecimalSeparator(decimalSeparator+"");
+
+ if (step2Model.isSampleBased()) {
+ step2Panel.setSampleBased(true);
+ step2Panel.setSampleBasedStartRegEx(step2Model.getSampleBasedStartRegEx());
+ step2Panel.setSampleBasedDateOffset(step2Model.getSampleBasedDateOffset());
+ step2Panel.setSampleBasedDateExtractionRegEx(step2Model.getSampleBasedDateExtractionRegEx());
+ step2Panel.setSampleBasedDatePattern(step2Model.getSampleBasedDatePattern());
+ step2Panel.setSampleBasedDataOffset(step2Model.getSampleBasedDataOffset());
+ step2Panel.setSampleBasedSampleSizeOffset(step2Model.getSampleBasedSampleSizeOffset());
+ step2Panel.setSampleBasedSampleSizeRegEx(step2Model.getSampleBasedSampleSizeRegEx());
+ }
}
@Override
@@ -164,6 +195,17 @@ public void saveSettings() {
Constants.THOUSANDS_SEPARATOR = '.';
}
+ if (step2Panel.isSampleBased()) {
+ step2Model.setSampleBased(true);
+ step2Model.setSampleBasedStartRegEx(step2Panel.getSampleBasedStartRegEx());
+ step2Model.setSampleBasedDateOffset(step2Panel.getSampleBasedDateOffset());
+ step2Model.setSampleBasedDateExtractionRegEx(step2Panel.getSampleBasedDateExtractionRegEx());
+ step2Model.setSampleBasedDatePattern(step2Panel.getSampleBasedDatePattern());
+ step2Model.setSampleBasedDataOffset(step2Panel.getSampleBasedDataOffset());
+ step2Model.setSampleBasedSampleSizeOffset(step2Panel.getSampleBasedSampleSizeOffset());
+ step2Model.setSampleBasedSampleSizeRegEx(step2Panel.getSampleBasedSampleSizeRegEx());
+ }
+
step2Panel = null;
}
@@ -241,7 +283,7 @@ private CsvData parseCSVFile() {
final String quoteChar = step2Model.getCommentIndicator();
final String escape = step2Model.getTextQualifier();
final int firstLineWithData = step2Model.getFirstLineWithData();
- final boolean useHeader = step2Model.getUseHeader();
+ final boolean useHeader = step2Model.isUseHeader();
logger.info("Parse CSV file: " +
"column separator: '" + separator + "', " +
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/Step2Model.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/Step2Model.java
index 191a3490..3fd357fa 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/Step2Model.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/Step2Model.java
@@ -43,6 +43,22 @@ public class Step2Model implements StepModel {
private boolean useHeader;
+ private boolean isSampleBased;
+
+ private String sampleBasedStartRegEx = "";
+
+ private int dateOffset = 0;
+
+ private String sampleBasedDateExtractionRegEx = "";
+
+ private String sampleBasedDatePattern = "";
+
+ private int dataOffset = 0;
+
+ private int sampleSizeOffset = 0;
+
+ private String sampleBasedSampleSizeRegEx = "";
+
public Step2Model(final String csvFileContent, final int csvFileRowCount) {
this.csvFileContent = csvFileContent;
@@ -58,63 +74,145 @@ public int getCsvFileRowRount() {
return csvFileRowRount;
}
- public void setCsvFileRowRount(final int csvFileRowRount) {
+ public Step2Model setCsvFileRowRount(final int csvFileRowRount) {
this.csvFileRowRount = csvFileRowRount;
+ return this;
}
public String getColumnSeparator() {
return columnSeparator;
}
- public void setColumnSeparator(final String selectedColumnSeparator) {
+ public Step2Model setColumnSeparator(final String selectedColumnSeparator) {
columnSeparator = selectedColumnSeparator;
+ return this;
}
public String getCommentIndicator() {
return commentIndicator;
}
- public void setCommentIndicator(final String selectedCommentIndicator) {
+ public Step2Model setCommentIndicator(final String selectedCommentIndicator) {
commentIndicator = selectedCommentIndicator;
+ return this;
}
public int getFirstLineWithData() {
return firstLineWithData;
}
- public void setFirstLineWithData(final int firstLineWithData) {
+ public Step2Model setFirstLineWithData(final int firstLineWithData) {
this.firstLineWithData = firstLineWithData;
+ return this;
}
public String getTextQualifier() {
return textQualifier;
}
- public void setTextQualifier(final String selectedTextQualifier) {
+ public Step2Model setTextQualifier(final String selectedTextQualifier) {
textQualifier = selectedTextQualifier;
+ return this;
}
public String getCSVFileContent() {
return csvFileContent;
}
- public void setCSVFileContent(final String cSVFileContent) {
+ public Step2Model setCSVFileContent(final String cSVFileContent) {
csvFileContent = cSVFileContent;
+ return this;
}
- public boolean getUseHeader() {
+ public boolean isUseHeader() {
return useHeader;
}
- public void setUseHeader(final boolean useHeader) {
+ public Step2Model setUseHeader(final boolean useHeader) {
this.useHeader = useHeader;
+ return this;
}
public char getDecimalSeparator() {
return decimalSeparator;
}
- public void setDecimalSeparator(final char decimalSeparator) {
+ public Step2Model setDecimalSeparator(final char decimalSeparator) {
this.decimalSeparator = decimalSeparator;
+ return this;
+ }
+
+ public boolean isSampleBased() {
+ return isSampleBased;
+ }
+
+ public Step2Model setSampleBased(final boolean isSampleBased) {
+ this.isSampleBased = isSampleBased;
+ return this;
+ }
+
+ public Step2Model setSampleBasedStartRegEx(final String sampleBasedStartRegEx) {
+ this.sampleBasedStartRegEx = sampleBasedStartRegEx;
+ return this;
+ }
+
+ public String getSampleBasedStartRegEx() {
+ return sampleBasedStartRegEx;
+ }
+
+ public Step2Model setSampleBasedDateOffset(final int dateOffset) {
+ this.dateOffset = dateOffset;
+ return this;
+ }
+
+ public int getSampleBasedDateOffset() {
+ return dateOffset;
+ }
+
+ public Step2Model setSampleBasedDateExtractionRegEx(final String sampleBasedDateExtractionRegEx) {
+ this.sampleBasedDateExtractionRegEx = sampleBasedDateExtractionRegEx;
+ return this;
+ }
+
+ public String getSampleBasedDateExtractionRegEx() {
+ return sampleBasedDateExtractionRegEx;
+ }
+
+ public Step2Model setSampleBasedDatePattern(final String sampleBasedDateDatePattern) {
+ sampleBasedDatePattern = sampleBasedDateDatePattern;
+ return this;
+ }
+
+ public String getSampleBasedDatePattern() {
+ return sampleBasedDatePattern;
+ }
+
+ public Step2Model setSampleBasedDataOffset(final int dataOffset) {
+ this.dataOffset = dataOffset;
+ return this;
+ }
+
+ public int getSampleBasedDataOffset() {
+ return dataOffset;
}
+
+ public Step2Model setSampleBasedSampleSizeOffset(final int sampleSizeOffset) {
+ this.sampleSizeOffset = sampleSizeOffset;
+ return this;
+ }
+
+ public int getSampleBasedSampleSizeOffset() {
+ return sampleSizeOffset;
+ }
+
+ public Step2Model setSampleBasedSampleSizeRegEx(final String sampleBasedSampleSizeRegEx) {
+ this.sampleBasedSampleSizeRegEx = sampleBasedSampleSizeRegEx;
+ return this;
+ }
+
+ public String getSampleBasedSampleSizeRegEx() {
+ return sampleBasedSampleSizeRegEx;
+ }
+
+
}
\ No newline at end of file
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/xml/Step2ModelHandler.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/xml/Step2ModelHandler.java
index 40287297..6fc68279 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/xml/Step2ModelHandler.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/model/xml/Step2ModelHandler.java
@@ -27,6 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x52North.sensorweb.sos.importer.x02.CsvMetadataDocument.CsvMetadata;
+import org.x52North.sensorweb.sos.importer.x02.DataFileDocument.DataFile;
import org.x52North.sensorweb.sos.importer.x02.ParameterDocument.Parameter;
import org.x52North.sensorweb.sos.importer.x02.SosImportConfigurationDocument.SosImportConfiguration;
@@ -40,7 +41,7 @@
* @author Eike Hinderk Jürrens
*/
public class Step2ModelHandler implements ModelHandler {
-
+
private static final Logger logger = LoggerFactory.getLogger(Step2ModelHandler.class);
@Override
@@ -49,24 +50,38 @@ public void handleModel(final Step2Model stepModel,
if (logger.isTraceEnabled()) {
logger.trace("handleModel()");
}
- CsvMetadata cM = sosImportConf.getCsvMetadata();
- Parameter p = null;
+ CsvMetadata csvMetadata = sosImportConf.getCsvMetadata();
+ Parameter parameter = null;
//
- if (cM == null) {
- cM = sosImportConf.addNewCsvMetadata();
- p = cM.addNewParameter();
+ if (csvMetadata == null) {
+ csvMetadata = sosImportConf.addNewCsvMetadata();
+ parameter = csvMetadata.addNewParameter();
} else {
- p = cM.getParameter();
+ parameter = csvMetadata.getParameter();
+ }
+ if (parameter == null) {
+ parameter = csvMetadata.addNewParameter();
}
- if (p == null) {
- p = cM.addNewParameter();
+ csvMetadata.setFirstLineWithData(stepModel.getFirstLineWithData());
+ csvMetadata.setUseHeader(stepModel.isUseHeader());
+ csvMetadata.setDecimalSeparator(stepModel.getDecimalSeparator()+"");
+ parameter.setCommentIndicator(stepModel.getCommentIndicator());
+ parameter.setColumnSeparator(stepModel.getColumnSeparator());
+ parameter.setTextIndicator(stepModel.getTextQualifier());
+ if (stepModel.isSampleBased()) {
+ // add other sampling parameters
+ if (sosImportConf.getDataFile() == null) {
+ sosImportConf.addNewDataFile();
+ }
+ final DataFile dataFile = sosImportConf.getDataFile();
+ dataFile.setSampleStartRegEx(stepModel.getSampleBasedStartRegEx());
+ dataFile.setSampleDateOffset(stepModel.getSampleBasedDateOffset());
+ dataFile.setSampleDateExtractionRegEx(stepModel.getSampleBasedDateExtractionRegEx());
+ dataFile.setSampleDatePattern(stepModel.getSampleBasedDatePattern());
+ dataFile.setSampleDataOffset(stepModel.getSampleBasedDataOffset());
+ dataFile.setSampleSizeOffset(stepModel.getSampleBasedSampleSizeOffset());
+ dataFile.setSampleSizeRegEx(stepModel.getSampleBasedSampleSizeRegEx());
}
- cM.setFirstLineWithData(stepModel.getFirstLineWithData());
- cM.setUseHeader(stepModel.getUseHeader());
- cM.setDecimalSeparator(stepModel.getDecimalSeparator()+"");
- p.setCommentIndicator(stepModel.getCommentIndicator());
- p.setColumnSeparator(stepModel.getColumnSeparator());
- p.setTextIndicator(stepModel.getTextQualifier());
}
}
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/Step2Panel.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/Step2Panel.java
index 294b9c9a..0ff056c1 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/Step2Panel.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/Step2Panel.java
@@ -23,9 +23,11 @@
*/
package org.n52.sos.importer.view;
import java.awt.BorderLayout;
+import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -39,6 +41,7 @@
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
+import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
@@ -70,99 +73,274 @@ public class Step2Panel extends JPanel {
private static final long serialVersionUID = 1L;
- private final EditableJComboBoxPanel columnSeparatorCombobox;
- private final EditableJComboBoxPanel commentIndicatorCombobox;
- private final EditableJComboBoxPanel textQualifierCombobox;
+ private EditableJComboBoxPanel columnSeparatorCombobox;
+ private EditableJComboBoxPanel commentIndicatorCombobox;
+ private EditableJComboBoxPanel textQualifierCombobox;
- private final JComboBox decimalSeparatorCombobox;
+ private JComboBox decimalSeparatorCombobox;
- private final JTextArea csvFileTextArea;
+ private JTextArea csvFileTextArea;
private int csvFileRowCount = 0;
- private final SpinnerNumberModel lineModel;
- private final JSpinner firstDataJS;
- private final JLabel firstDataJL;
+ private SpinnerNumberModel lineModel;
+ private JSpinner firstDataJS;
+ private JLabel firstDataJL;
- private final JLabel useHeaderJL;
- private final JCheckBox useHeaderJCB;
+ private JLabel useHeaderJL;
+ private JCheckBox useHeaderJCB;
+
+ private int firstLineWithDataTmp = -1;
+ private JCheckBox isSampleBasedCheckBox;
+
+ private JPanel startRegExPanel;
+ private JTextField startRegExTF;
+
+ private JPanel dateOffsetPanel;
+ private JSpinner dateOffset;
+ private SpinnerNumberModel dateOffsetModel;
+
+ private JTextField dateExtractionRegExTF;
+ private JPanel dateExtractionRegExPanel;
+
+ private JTextField datePatternTF;
+ private JPanel datePatternPanel;
+
+ private SpinnerNumberModel dataOffsetModel;
+ private JSpinner dataOffset;
+ private JPanel dataOffsetPanel;
+
+ private SpinnerNumberModel sampleSizeOffsetModel;
+ private JSpinner sampleSizeOffset;
+ private JPanel sampleSizeOffsetPanel;
+
+ private JTextField sampleSizeRegExTF;
+ private JPanel sampleSizeRegExPanel;
public Step2Panel(final int csvFileRowCount) {
super();
- //
this.csvFileRowCount = csvFileRowCount;
- //
+
+ final JPanel csvSettingsPanel = new JPanel();
+ setupStyle(csvSettingsPanel);
final EditableComboBoxItems items = EditableComboBoxItems.getInstance();
- //
- // FirstLineWithData
- //
- lineModel = new SpinnerNumberModel(0, 0, this.csvFileRowCount-1, 1);
- //
- // useHeader Checkbox
- //
- useHeaderJL = new JLabel(Lang.l().step2ParseHeader() + "?");
- useHeaderJCB = new JCheckBox();
- if (logger.isTraceEnabled()) {
- useHeaderJCB.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- logger.trace("useHeader state changed. is selected?" +
- useHeaderJCB.isSelected());
+ int gridY = 0;
+ addColumnSeparator(csvSettingsPanel, items, gridY);
+ addCommentIndicator(csvSettingsPanel, items, gridY++);
+ addTextQualifier(csvSettingsPanel, items, gridY++);
+ addFirstLineWithData(csvFileRowCount, csvSettingsPanel, gridY++);
+ addDecimalSeparator(csvSettingsPanel, gridY++);
+ addUseHeaderCheckbox(csvSettingsPanel, gridY/*++*/);
+ addElementsForSampleBasedFiles(csvSettingsPanel, gridY++);
+ final JPanel csvDataPanel = new JPanel();
+ addCsvDataPanel(csvDataPanel);
+
+ add(csvSettingsPanel);
+ add(csvDataPanel);
+ }
+
+ private void addCsvDataPanel(final JPanel csvDataPanel) {
+ csvFileTextArea = new JTextArea(20, 60);
+ csvFileTextArea.setEditable(false);
+ final JScrollPane scrollPane = new JScrollPane(csvFileTextArea);
+ csvDataPanel.setBorder(new TitledBorder(null, Lang.l().step2DataPreviewLabel(), TitledBorder.LEADING, TitledBorder.TOP, null, null));
+ csvDataPanel.setLayout(new BorderLayout(0, 0));
+ csvDataPanel.add(scrollPane);
+ setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
+ }
+
+ private void addElementsForSampleBasedFiles(final JPanel csvSettingsPanel,
+ int gridY) {
+ addIsSampleBased(csvSettingsPanel, gridY++);
+ addStartRegEx(csvSettingsPanel, gridY++);
+ addDateOffset(csvSettingsPanel, gridY++);
+ addDateExtractionRegEx(csvSettingsPanel, gridY++);
+ addDatePattern(csvSettingsPanel, gridY++);
+ addDataOffset(csvSettingsPanel, gridY++);
+ addSampleSizeOffset(csvSettingsPanel, gridY++);
+ addSampleSizeRegEx(csvSettingsPanel, gridY++);
+ }
+
+ private void setSampleBasedElementsEnabled(final boolean state) {
+ startRegExPanel.setVisible(state);
+ dateOffsetPanel.setVisible(state);
+ dateExtractionRegExPanel.setVisible(state);
+ datePatternPanel.setVisible(state);
+ dataOffsetPanel.setVisible(state);
+ sampleSizeOffsetPanel.setVisible(state);
+ sampleSizeRegExPanel.setVisible(state);
+ firstDataJS.setEnabled(!state);
+ }
+
+ private void addSampleSizeRegEx(final JPanel csvSettingsPanel,
+ final int gridY) {
+ sampleSizeRegExTF = new JTextField(28);
+ sampleSizeRegExPanel = new JPanel();
+ sampleSizeRegExPanel.setToolTipText(Lang.l().step2SampleBasedSampleSizeRegExTooltip());
+ sampleSizeRegExPanel.setLayout(new GridLayout(2, 1));
+ sampleSizeRegExPanel.add(new JLabel(Lang.l().step2SampleBasedSampleSizeRegExLabel() + ":"));
+ sampleSizeRegExPanel.add(sampleSizeRegExTF);
+ sampleSizeRegExPanel.setVisible(false);
+ csvSettingsPanel.add(sampleSizeRegExPanel, simpleConstraints(gridY));
+ }
+
+ private void addSampleSizeOffset(final JPanel csvSettingsPanel,
+ final int gridY) {
+ sampleSizeOffsetModel = new SpinnerNumberModel(1, 1, csvFileRowCount, 1);
+ sampleSizeOffsetModel.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(final ChangeEvent e) {
+ final int number = sampleSizeOffsetModel.getNumber().intValue();
+ if(number < 0) {
+ sampleSizeOffsetModel.setValue(0);
+ } else if (number > (csvFileRowCount-1)){
+ sampleSizeOffsetModel.setValue((csvFileRowCount-1));
}
- });
- }
- useHeaderJCB.setSelected(false);
- // will be enabled if firstLineWithdata is set to > 0
- useHeaderJCB.setEnabled(false);
- final JPanel useHeaderPanel = new JPanel();
- useHeaderPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
- useHeaderPanel.add(useHeaderJL);
- useHeaderPanel.add(useHeaderJCB);
- /*
- * Decimal Separator
- */
- final String[] decimalSeparators = Constants.DECIMAL_SEPARATORS;
- //
- //
- // CSV-setting panel
- //
- final JPanel csvSettingsPanel = new JPanel();
- csvSettingsPanel.setBorder(new TitledBorder(null, Lang.l().metadata(), TitledBorder.LEADING, TitledBorder.TOP, null, null));
- final GridBagLayout gbl_csvSettingsPanel = new GridBagLayout();
- gbl_csvSettingsPanel.columnWidths = new int[]{239, 0};
- gbl_csvSettingsPanel.rowHeights = new int[]{25, 25, 25, 25, 25, 0};
- gbl_csvSettingsPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
- gbl_csvSettingsPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
- csvSettingsPanel.setLayout(gbl_csvSettingsPanel);
- columnSeparatorCombobox = new EditableJComboBoxPanel(
- items.getColumnSeparators(),
- Lang.l().step2ColumnSeparator(),
- ToolTips.get(ToolTips.COLUMN_SEPARATOR));
- final GridBagConstraints gbc_columnSeparatorCombobox = new GridBagConstraints();
- gbc_columnSeparatorCombobox.fill = GridBagConstraints.BOTH;
- gbc_columnSeparatorCombobox.insets = new Insets(0, 0, 5, 0);
- gbc_columnSeparatorCombobox.gridx = 0;
- gbc_columnSeparatorCombobox.gridy = 0;
- csvSettingsPanel.add(columnSeparatorCombobox, gbc_columnSeparatorCombobox);
- commentIndicatorCombobox = new EditableJComboBoxPanel(
- items.getCommentIndicators(),
- Lang.l().step2CommentIndicator(),
- ToolTips.get(ToolTips.COMMENT_INDICATOR));
- final GridBagConstraints gbc_commentIndicatorCombobox = new GridBagConstraints();
- gbc_commentIndicatorCombobox.fill = GridBagConstraints.BOTH;
- gbc_commentIndicatorCombobox.insets = new Insets(0, 0, 5, 0);
- gbc_commentIndicatorCombobox.gridx = 0;
- gbc_commentIndicatorCombobox.gridy = 1;
- csvSettingsPanel.add(commentIndicatorCombobox, gbc_commentIndicatorCombobox);
- textQualifierCombobox = new EditableJComboBoxPanel(
- items.getTextQualifiers(),
- Lang.l().step2TextQualifier(),
- ToolTips.get(ToolTips.TEXT_QUALIFIER));
- final GridBagConstraints gbc_textQualifierCombobox = new GridBagConstraints();
- gbc_textQualifierCombobox.fill = GridBagConstraints.BOTH;
- gbc_textQualifierCombobox.insets = new Insets(0, 0, 5, 0);
- gbc_textQualifierCombobox.gridx = 0;
- gbc_textQualifierCombobox.gridy = 2;
- csvSettingsPanel.add(textQualifierCombobox, gbc_textQualifierCombobox);
+ }
+ });
+ sampleSizeOffset = new JSpinner(sampleSizeOffsetModel);
+ sampleSizeOffsetPanel = new JPanel();
+ sampleSizeOffsetPanel.setToolTipText(Lang.l().step2SampleBasedSampleSizeOffsetToolTip());
+ sampleSizeOffsetPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
+ sampleSizeOffsetPanel.add(new JLabel(Lang.l().step2SampleBasedSampleSizeOffsetLabel() + ":"));
+ sampleSizeOffsetPanel.add(sampleSizeOffset);
+ sampleSizeOffsetPanel.setVisible(false);
+ csvSettingsPanel.add(sampleSizeOffsetPanel, simpleConstraints(gridY));
+ }
+
+ private void addDataOffset(final JPanel csvSettingsPanel,
+ final int gridY) {
+ dataOffsetModel = new SpinnerNumberModel(1, 1, csvFileRowCount, 1);
+ dataOffsetModel.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(final ChangeEvent e) {
+ final int number = dataOffsetModel.getNumber().intValue();
+ if(number < 0) {
+ dataOffsetModel.setValue(0);
+ } else if (number > (csvFileRowCount-1)){
+ dataOffsetModel.setValue((csvFileRowCount-1));
+ }
+ }
+ });
+ dataOffset = new JSpinner(dataOffsetModel);
+ dataOffsetPanel = new JPanel();
+ dataOffsetPanel.setToolTipText(Lang.l().step2SampleBasedDataOffsetToolTip());
+ dataOffsetPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
+ dataOffsetPanel.add(new JLabel(Lang.l().step2SampleBasedDataOffsetLabel() + ":"));
+ dataOffsetPanel.add(dataOffset);
+ dataOffsetPanel.setVisible(false);
+ csvSettingsPanel.add(dataOffsetPanel, simpleConstraints(gridY));
+ }
+
+ private void addDatePattern(final JPanel csvSettingsPanel,
+ final int gridY) {
+ datePatternTF = new JTextField(28);
+ datePatternPanel = new JPanel();
+ datePatternPanel.setToolTipText(Lang.l().step2SampleBasedDatePatternTooltip());
+ datePatternPanel.setLayout(new GridLayout(2, 1));
+ datePatternPanel.add(new JLabel(Lang.l().step2SampleBasedDatePatternLabel() + ":"));
+ datePatternPanel.add(datePatternTF);
+ datePatternPanel.setVisible(false);
+ csvSettingsPanel.add(datePatternPanel, simpleConstraints(gridY));
+ }
+
+ private void addDateExtractionRegEx(final JPanel csvSettingsPanel,
+ final int gridY) {
+ dateExtractionRegExTF = new JTextField(28);
+ dateExtractionRegExPanel = new JPanel();
+ dateExtractionRegExPanel.setToolTipText(Lang.l().step2SampleBasedDateExtractionRegExTooltip());
+ dateExtractionRegExPanel.setLayout(new GridLayout(2, 1));
+ dateExtractionRegExPanel.add(new JLabel(Lang.l().step2SampleBasedDateExtractionRegExLabel() + ":"));
+ dateExtractionRegExPanel.add(dateExtractionRegExTF);
+ dateExtractionRegExPanel.setVisible(false);
+ csvSettingsPanel.add(dateExtractionRegExPanel, simpleConstraints(gridY));
+ }
+
+ private void addIsSampleBased(final JPanel csvSettingsPanel, final int gridY) {
+ // isSampleBasedFile
+ isSampleBasedCheckBox = new JCheckBox();
+ final JPanel isSampleBasedFilePanel = new JPanel();
+ isSampleBasedFilePanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
+ isSampleBasedFilePanel.add(new JLabel(Lang.l().step2IsSampleBased() + "?"));
+ isSampleBasedFilePanel.add(isSampleBasedCheckBox);
+ isSampleBasedCheckBox.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ if (isSampleBasedCheckBox.isSelected()) {
+ // TODO activateSampleBasedGuiElements
+ setSampleBasedElementsEnabled(true);
+ firstLineWithDataTmp = Integer.parseInt(firstDataJS.getValue().toString());
+ firstDataJS.setValue(0);
+ } else {
+ // TODO disable all sample based elements
+ setSampleBasedElementsEnabled(false);
+ firstDataJS.setValue(firstLineWithDataTmp);
+ }
+ }
+
+ });
+ csvSettingsPanel.add(isSampleBasedFilePanel, simpleConstraints(gridY));
+ }
+
+ private void addStartRegEx(final JPanel csvSettingsPanel,
+ final int gridY) {
+ startRegExTF = new JTextField(28);
+ startRegExPanel = new JPanel();
+ startRegExPanel.setToolTipText(Lang.l().step2SampleBasedStartRegExTooltip());
+ startRegExPanel.setLayout(new GridLayout(2, 1));
+ startRegExPanel.add(new JLabel(Lang.l().step2SampleBasedStartRegExLabel() + ":"));
+ startRegExPanel.add(startRegExTF);
+ startRegExPanel.setVisible(false);
+ csvSettingsPanel.add(startRegExPanel, simpleConstraints(gridY));
+ }
+
+ private void addDateOffset(final JPanel csvSettingsPanel,
+ final int gridY) {
+ dateOffsetModel = new SpinnerNumberModel(1, 1, csvFileRowCount, 1);
+ dateOffsetModel.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(final ChangeEvent e) {
+ final int number = dateOffsetModel.getNumber().intValue();
+ if(number < 0) {
+ dateOffsetModel.setValue(0);
+ } else if (number > (csvFileRowCount-1)){
+ dateOffsetModel.setValue((csvFileRowCount-1));
+ }
+ }
+ });
+ dateOffset = new JSpinner(dateOffsetModel);
+ dateOffsetPanel = new JPanel();
+ dateOffsetPanel.setToolTipText(Lang.l().step2SampleBasedDateOffsetToolTip());
+ dateOffsetPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
+ dateOffsetPanel.add(new JLabel(Lang.l().step2SampleBasedDateOffsetLabel() + ":"));
+ dateOffsetPanel.add(dateOffset);
+ dateOffsetPanel.setVisible(false);
+ csvSettingsPanel.add(dateOffsetPanel, simpleConstraints(gridY));
+ }
+
+ private GridBagConstraints simpleConstraints(final int gridY) {
+ final GridBagConstraints simpleConstraints = new GridBagConstraints();
+ simpleConstraints.fill = GridBagConstraints.HORIZONTAL;
+ simpleConstraints.anchor = GridBagConstraints.NORTHWEST;
+ simpleConstraints.gridx = 0;
+ simpleConstraints.gridy = gridY;
+ return simpleConstraints;
+ }
+
+ private void addDecimalSeparator(final JPanel csvSettingsPanel, final int gridY) {
+ final JLabel decimalSeparatorLabel = new JLabel(Lang.l().step2DecimalSeparator() + " : ");
+ decimalSeparatorCombobox = new JComboBox(Constants.DECIMAL_SEPARATORS);
+ decimalSeparatorCombobox.setSelectedIndex(0);
+ final JPanel decimalSeparatorPanel = new JPanel();
+ decimalSeparatorPanel.setLayout(new FlowLayout(FlowLayout.LEADING,0,0));
+ decimalSeparatorPanel.add(decimalSeparatorLabel);
+ decimalSeparatorPanel.add(decimalSeparatorCombobox);
+ csvSettingsPanel.add(decimalSeparatorPanel, simpleConstraints(gridY));
+ }
+
+ private void addFirstLineWithData(final int csvFileRowCount,
+ final JPanel csvSettingsPanel, final int gridY) {
+ lineModel = new SpinnerNumberModel(0, 0, csvFileRowCount-1, 1);
firstDataJS = new JSpinner(lineModel);
// Highlight the current selected line in the file preview
firstDataJS.addChangeListener(new ChangeListener() {
@@ -197,35 +375,89 @@ public void stateChanged(final ChangeEvent e) {
gbc_firstLineWithDataJPanel.fill = GridBagConstraints.BOTH;
gbc_firstLineWithDataJPanel.insets = new Insets(0, 0, 5, 0);
gbc_firstLineWithDataJPanel.gridx = 0;
- gbc_firstLineWithDataJPanel.gridy = 3;
+ gbc_firstLineWithDataJPanel.gridy = gridY;
csvSettingsPanel.add(firstLineWithDataJPanel, gbc_firstLineWithDataJPanel);
- final JLabel decimalSeparatorLabel = new JLabel(Lang.l().step2DecimalSeparator() + " : ");
- decimalSeparatorCombobox = new JComboBox(decimalSeparators);
- decimalSeparatorCombobox.setSelectedIndex(0);
- final JPanel decimalSeparatorPanel = new JPanel();
- decimalSeparatorPanel.setLayout(new FlowLayout(FlowLayout.LEADING,0,0));
- decimalSeparatorPanel.add(decimalSeparatorLabel);
- decimalSeparatorPanel.add(decimalSeparatorCombobox);
- // USE_HEADER uncomment next line to enable again
- // csvSettingsPanel.add(useHeaderPanel);
- final GridBagConstraints gbc_decimalSeparatorPanel = new GridBagConstraints();
- gbc_decimalSeparatorPanel.fill = GridBagConstraints.BOTH;
- gbc_decimalSeparatorPanel.gridx = 0;
- gbc_decimalSeparatorPanel.gridy = 4;
- csvSettingsPanel.add(decimalSeparatorPanel, gbc_decimalSeparatorPanel);
- //
- // CSV text area
- //
- csvFileTextArea = new JTextArea(20, 60);
- csvFileTextArea.setEditable(false);
- final JScrollPane scrollPane = new JScrollPane(csvFileTextArea);
- final JPanel csvDataPanel = new JPanel();
- csvDataPanel.setBorder(new TitledBorder(null, Lang.l().step2DataPreviewLabel(), TitledBorder.LEADING, TitledBorder.TOP, null, null));
- csvDataPanel.setLayout(new BorderLayout(0, 0));
- csvDataPanel.add(scrollPane);
- setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
- add(csvSettingsPanel);
- add(csvDataPanel);
+ }
+
+ private void addTextQualifier(final JPanel csvSettingsPanel,
+ final EditableComboBoxItems items, final int gridY) {
+ textQualifierCombobox = new EditableJComboBoxPanel(
+ items.getTextQualifiers(),
+ Lang.l().step2TextQualifier(),
+ ToolTips.get(ToolTips.TEXT_QUALIFIER));
+ final GridBagConstraints gbc_textQualifierCombobox = new GridBagConstraints();
+ gbc_textQualifierCombobox.fill = GridBagConstraints.BOTH;
+ gbc_textQualifierCombobox.insets = new Insets(0, 0, 5, 0);
+ gbc_textQualifierCombobox.gridx = 0;
+ gbc_textQualifierCombobox.gridy = gridY;
+ csvSettingsPanel.add(textQualifierCombobox, gbc_textQualifierCombobox);
+ }
+
+ private void addCommentIndicator(final JPanel csvSettingsPanel,
+ final EditableComboBoxItems items, final int gridY) {
+ commentIndicatorCombobox = new EditableJComboBoxPanel(
+ items.getCommentIndicators(),
+ Lang.l().step2CommentIndicator(),
+ ToolTips.get(ToolTips.COMMENT_INDICATOR));
+ final GridBagConstraints gbc_commentIndicatorCombobox = new GridBagConstraints();
+ gbc_commentIndicatorCombobox.fill = GridBagConstraints.BOTH;
+ gbc_commentIndicatorCombobox.insets = new Insets(0, 0, 5, 0);
+ gbc_commentIndicatorCombobox.gridx = 0;
+ gbc_commentIndicatorCombobox.gridy = gridY;
+ csvSettingsPanel.add(commentIndicatorCombobox, gbc_commentIndicatorCombobox);
+ }
+
+ private void setupStyle(final JPanel csvSettingsPanel) {
+ csvSettingsPanel.setBorder(new TitledBorder(null, Lang.l().metadata(), TitledBorder.LEADING, TitledBorder.TOP, null, null));
+ final GridBagLayout gbl_csvSettingsPanel = new GridBagLayout();
+ gbl_csvSettingsPanel.columnWidths = new int[]{239, 0};
+ gbl_csvSettingsPanel.rowHeights = new int[]{25, 25, 25, 25, 25, 0};
+ gbl_csvSettingsPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+ gbl_csvSettingsPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
+ csvSettingsPanel.setLayout(gbl_csvSettingsPanel);
+ }
+
+ private void addColumnSeparator(final JPanel csvSettingsPanel,
+ final EditableComboBoxItems items,
+ final int gridY) {
+ columnSeparatorCombobox = new EditableJComboBoxPanel(
+ items.getColumnSeparators(),
+ Lang.l().step2ColumnSeparator(),
+ ToolTips.get(ToolTips.COLUMN_SEPARATOR));
+ final GridBagConstraints gbc_columnSeparatorCombobox = new GridBagConstraints();
+ gbc_columnSeparatorCombobox.fill = GridBagConstraints.BOTH;
+ gbc_columnSeparatorCombobox.insets = new Insets(0, 0, 5, 0);
+ gbc_columnSeparatorCombobox.gridx = 0;
+ gbc_columnSeparatorCombobox.gridy = gridY;
+ csvSettingsPanel.add(columnSeparatorCombobox, gbc_columnSeparatorCombobox);
+ }
+
+ private void addUseHeaderCheckbox(final Container csvSettingsPanel, final int gridY) {
+ useHeaderJL = new JLabel(Lang.l().step2ParseHeader() + "?");
+ useHeaderJCB = new JCheckBox();
+ if (logger.isTraceEnabled()) {
+ useHeaderJCB.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ logger.trace("useHeader state changed. is selected?" +
+ useHeaderJCB.isSelected());
+ }
+ });
+ }
+ useHeaderJCB.setSelected(false);
+ // will be enabled if firstLineWithdata is set to > 0
+ useHeaderJCB.setEnabled(false);
+ final JPanel useHeaderPanel = new JPanel();
+ useHeaderPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ useHeaderPanel.add(useHeaderJL);
+ useHeaderPanel.add(useHeaderJCB);
+ final GridBagConstraints gbc_useHeaderPanel = new GridBagConstraints();
+ gbc_useHeaderPanel.fill = GridBagConstraints.BOTH;
+ gbc_useHeaderPanel.insets = new Insets(0, 0, 5, 0);
+ gbc_useHeaderPanel.gridx = 0;
+ gbc_useHeaderPanel.gridy = gridY;
+ // TODO uncomment to enable useHeader
+ // csvSettingsPanel.add(useHeaderPanel, gbc_useHeaderPanel);
}
public String getCommentIndicator() {
@@ -341,4 +573,79 @@ public boolean getUseHeader() {
public void setUseHeader(final boolean useHeader) {
useHeaderJCB.setSelected(useHeader);
}
+
+ public Step2Panel setSampleBased(final boolean isSampleBased) {
+ isSampleBasedCheckBox.setSelected(isSampleBased);
+ setSampleBasedElementsEnabled(isSampleBased);
+ return this;
+ }
+
+ public boolean isSampleBased() {
+ return isSampleBasedCheckBox.isSelected();
+ }
+
+ public String getSampleBasedStartRegEx() {
+ return startRegExTF.getText();
+ }
+
+ public Step2Panel setSampleBasedStartRegEx(final String sampleBasedStartRegEx) {
+ startRegExTF.setText(sampleBasedStartRegEx);
+ return this;
+ }
+
+ public int getSampleBasedDateOffset() {
+ return dateOffsetModel.getNumber().intValue();
+ }
+
+ public Step2Panel setSampleBasedDateOffset(final int dateOffset) {
+ dateOffsetModel.setValue(dateOffset);
+ return this;
+ }
+
+ public String getSampleBasedDateExtractionRegEx() {
+ return dateExtractionRegExTF.getText();
+ }
+
+ public Step2Panel setSampleBasedDateExtractionRegEx(final String sampleBasedDateExtractionRegEx) {
+ dateExtractionRegExTF.setText(sampleBasedDateExtractionRegEx);
+ return this;
+ }
+
+ public String getSampleBasedDatePattern() {
+ return datePatternTF.getText();
+ }
+
+ public Step2Panel setSampleBasedDatePattern(final String sampleBasedDatePattern) {
+ datePatternTF.setText(sampleBasedDatePattern);
+ return this;
+ }
+
+ public int getSampleBasedDataOffset() {
+ return dataOffsetModel.getNumber().intValue();
+ }
+
+ public Step2Panel setSampleBasedDataOffset(final int dataOffset) {
+ dataOffsetModel.setValue(dataOffset);
+ return this;
+ }
+
+ public int getSampleBasedSampleSizeOffset() {
+ return sampleSizeOffsetModel.getNumber().intValue();
+ }
+
+ public Step2Panel setSampleBasedSampleSizeOffset(final int sampleSizeOffset) {
+ sampleSizeOffsetModel.setValue(sampleSizeOffset);
+ return this;
+ }
+
+ public String getSampleBasedSampleSizeRegEx() {
+ return sampleSizeRegExTF.getText();
+ }
+
+ public Step2Panel setSampleBasedSampleSizeRegEx(final String sampleBasedSampleSizeRegEx) {
+ sampleSizeRegExTF.setText(sampleBasedSampleSizeRegEx);
+ return this;
+ }
+
+
}
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/De.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/De.java
index 0aaa566b..4c86c0bd 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/De.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/De.java
@@ -29,10 +29,11 @@
import org.n52.sos.importer.Constants;
/**
- * @author e.h.juerrens@52north.org
* This class contains all String used by the GUI in German
+ *
+ * @author e.h.juerrens@52north.org
*/
-public class De extends Lang{
+public class De extends Lang {
private final static Locale locale = Locale.GERMAN;
@@ -409,11 +410,96 @@ public String step2FirstLineWithData() {
return "Ignoriere Daten bis Zeile";
}
+ @Override
+ public String step2IsSampleBased() {
+ return "Besteht die Datei aus Messreihen";
+ }
+
@Override
public String step2ParseHeader() {
return "Kopfzeile auswerten";
}
+ @Override
+ public String step2SampleBasedDataOffsetLabel() {
+ return "Zeilenabstand 'Messdaten'";
+ }
+
+ @Override
+ public String step2SampleBasedDataOffsetToolTip() {
+ return "Der Abstand zwischen dem Start einer Messreihe und dem Beginn der Daten in Zeilen.";
+ }
+
+ @Override
+ public String step2SampleBasedDateExtractionRegExLabel() {
+ return "Regulärer Ausdruck \"Datumsinformation\"";
+ }
+
+ @Override
+ public String step2SampleBasedDateExtractionRegExTooltip() {
+ return new StringBuffer("Der Reguläre Ausdruck mit dessen Hilfe die
")
+ .append("Datumsinformatione aus der Zeile extrahiert werden, die
")
+ .append("die entspr. Informationen für die aktuelle Messreihe
")
+ .append("enthält. Das Ergebnis des Asudrucks MUSS genau EINE
")
+ .append("Gruppe enthalten. Diese Gruppe wird mit Hilfe des
")
+ .append("Attributes \"sampleDatePattern\" in einen Zeitstempel
")
+ .append("umgewandelt.")
+ .toString();
+ }
+
+ @Override
+ public String step2SampleBasedDateOffsetLabel() {
+ return "Zeilenabstand 'Datumsinformation'";
+ }
+
+ @Override
+ public String step2SampleBasedDateOffsetToolTip() {
+ return "Der Abstand zwischen dem Start einer Messreihe und der Zeile mit den Datumsinformationen";
+ }
+
+ @Override
+ public String step2SampleBasedDatePatternLabel() {
+ return "Analyse Muster \"Datumsinformationen\"";
+ }
+
+ @Override
+ public String step2SampleBasedDatePatternTooltip() {
+ return "Muster, das zur Interpretation der Datumsinformationen für die aktuelle Messreihe verwendet wird.";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeOffsetLabel() {
+ return "Zeilenabstand 'Messreihengröße'";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeOffsetToolTip() {
+ return "Der Abstand ziwschem dem Start einer Messreihe und der Zeile mit der Anzahl der Zeilen in der aktuellen Reihe.";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeRegExLabel() {
+ return "Regulärer Ausdruck \"Messreihengröße\"";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeRegExTooltip() {
+ return new StringBuffer("Wird benutzt um die Größe der aktuellen Messreihe aus der Zeile")
+ .append(" zu extrahieren.
Das Ergebnis der Zeile muss EINE Gruppe sein,
")
+ .append("die in eine Zahl umgewandelt werden kann.")
+ .toString();
+ }
+
+ @Override
+ public String step2SampleBasedStartRegExLabel() {
+ return "Regulärer Ausdruck \"Beginn der Messreihe\"";
+ }
+
+ @Override
+ public String step2SampleBasedStartRegExTooltip() {
+ return "Wird benutzt um den Start einer Messreihe zu finden.\nMuss für die gesamte Zeile passen";
+ }
+
@Override
public String step2TextQualifier() {
return "Text-Qualifier";
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/En.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/En.java
index ccd1b58e..8173137a 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/En.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/En.java
@@ -30,10 +30,11 @@
import org.n52.sos.importer.Constants;
/**
- * @author e.h.juerrens@52north.org
* This class contains all String used by the GUI in English
+ *
+ * @author e.h.juerrens@52north.org
*/
-public class En extends Lang{
+public class En extends Lang {
private final static Locale locale = Locale.ENGLISH;
@@ -412,11 +413,97 @@ public String step2FirstLineWithData() {
return "Ignore data until line";
}
+ @Override
+ public String step2IsSampleBased() {
+ return "Is data file sample based";
+ }
+
@Override
public String step2ParseHeader() {
return "Interpret Header";
}
+ @Override
+ public String step2SampleBasedDataOffsetLabel() {
+ return "Offset data";
+ }
+
+ @Override
+ public String step2SampleBasedDataOffsetToolTip() {
+ return "The offset in lines from sample beginning till the first lines with data.";
+ }
+
+ @Override
+ public String step2SampleBasedDateExtractionRegExLabel() {
+ return "Regular Expression \"Date Extraction\"";
+ }
+
+ @Override
+ public String step2SampleBasedDateExtractionRegExTooltip() {
+ return new StringBuffer("The regular expression to extract the date
")
+ .append("information from the line containing the date
")
+ .append("information of the current sample. The expression MUST
")
+ .append("result in ONE group. This group will be parsed to a
")
+ .append("java.util.Date using \"sampleDatePattern\" attribute.")
+ .toString();
+ }
+
+ @Override
+ public String step2SampleBasedDateOffsetLabel() {
+ return "Offset date information";
+ }
+
+ @Override
+ public String step2SampleBasedDateOffsetToolTip() {
+ return "The offset of the line containing the date of the sample from the start line.";
+ }
+
+ @Override
+ public String step2SampleBasedDatePatternLabel() {
+ return "Parse Pattern \"Date Information\"";
+ }
+
+ @Override
+ public String step2SampleBasedDatePatternTooltip() {
+ return "The pattern used to parse the date information of the current sample.";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeOffsetLabel() {
+ return "Offset sample size";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeOffsetToolTip() {
+ return new StringBuffer("The offset in lines from sample beginning")
+ .append("till
the line containing the sample size in lines ")
+ .append("with data.")
+ .toString();
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeRegExLabel() {
+ return "Regular Expression \"Sample Size\"";
+ }
+
+ @Override
+ public String step2SampleBasedSampleSizeRegExTooltip() {
+ return new StringBuffer("The regular expression to extract the sample size.
")
+ .append("The regular expression MUST result in ONE group
")
+ .append("which contains an integer value.")
+ .toString();
+ }
+
+ @Override
+ public String step2SampleBasedStartRegExLabel() {
+ return "Regular Expression \"Sample Start\"";
+ }
+
+ @Override
+ public String step2SampleBasedStartRegExTooltip() {
+ return "Used to identify the start of a new sample.
MUST match the whole line.";
+ }
+
@Override
public String step2TextQualifier() {
return "Text qualifier";
diff --git a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/Lang.java b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/Lang.java
index 6db2769b..565553af 100644
--- a/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/Lang.java
+++ b/52n-sos-importer-core/src/main/java/org/n52/sos/importer/view/i18n/Lang.java
@@ -390,120 +390,240 @@ public String sos() {
* @return Ignore data until line
*/
public abstract String step2FirstLineWithData();
+ /**
+ *
+ * @return Is data file sample based
+ */
+ public abstract String step2IsSampleBased();
/**
* @return Interpret Header
*/
public abstract String step2ParseHeader();
+
+ /**
+ *
+ * @return Offset data
+ */
+ public abstract String step2SampleBasedDataOffsetLabel();
+
+ /**
+ *
+ * @return The offset in lines from sample beginning till the first lines
+ * with data.
+ */
+ public abstract String step2SampleBasedDataOffsetToolTip();
+
+ /**
+ * @return Regular Expression "Date Extraction"
+ */
+ public abstract String step2SampleBasedDateExtractionRegExLabel();
+
+ /**
+ * @return The regular expression to extract the date information from the
+ * line containing the date information of the current sample.
+ * The expression MUST result in ONE group. This group will be
+ * parsed to a {@link java.util.Date} using
+ * "sampleDatePattern" attribute.
+ */
+ public abstract String step2SampleBasedDateExtractionRegExTooltip();
+
+ /**
+ * @return Offset date information
+ */
+ public abstract String step2SampleBasedDateOffsetLabel();
+
+ /**
+ *
+ * @return The offset of the line containing the date of the
+ * sample from the start line.
+ */
+ public abstract String step2SampleBasedDateOffsetToolTip();
+
+ /**
+ * @return Parse Pattern "Date Information"
+ */
+ public abstract String step2SampleBasedDatePatternLabel();
+
+ /**
+ * @return The pattern used to parse the date information of the
+ * current sample.
+ */
+ public abstract String step2SampleBasedDatePatternTooltip();
+
+ /**
+ *
+ * @return Offset sample size
+ */
+ public abstract String step2SampleBasedSampleSizeOffsetLabel();
+
+ /**
+ *
+ * @return The offset in lines from sample beginning till the line
+ * containing the sample size in lines with data.
+ */
+ public abstract String step2SampleBasedSampleSizeOffsetToolTip();
+
+ /**
+ * @return Regular Expression "Sample Size"
+ */
+ public abstract String step2SampleBasedSampleSizeRegExLabel();
+
+ /**
+ * @return The regular expression to extract the sample size. The regular
+ * expression MUST result in ONE group which contains an
+ * integer value.
+ */
+ public abstract String step2SampleBasedSampleSizeRegExTooltip();
+
+ /**
+ *
+ * @return Regular Expression "Sample Start"
+ */
+ public abstract String step2SampleBasedStartRegExLabel();
+
+ /**
+ *
+ * @return Used to identify the start of a new sample.\n
+ * MUST match the whole line.
+ */
+ public abstract String step2SampleBasedStartRegExTooltip();
+
/**
* @return Text qualifier
*/
public abstract String step2TextQualifier();
+
/**
* @return Step 3a: Choose Metadata for the selected column
*/
public abstract String step3aDescription();
+
/**
* @return You have to specify at least one measured value column.
*/
public abstract String step3aMeasureValueColMissingDialogMessage();
+
/**
* @return Measured value column missing
*/
public abstract String step3aMeasureValueColMissingDialogTitle();
+
/**
* @return 1 value not parseable.
*/
public abstract String step3aParseTest1Failed();
+
/**
* @return All values parseable.
*/
public abstract String step3aParseTestAllOk();
+
/**
* @param n
* @return n
values not parseable.
*/
public abstract String step3aParseTestNFailed(int n);
+
/**
* @return The type for this column is "undefined" please select one. Chose "Do Not Export" for skipping it.
*/
public abstract String step3aSelectedColTypeUndefinedMsg();
+
/**
* @return Column Type is "undefined"
*/
public abstract String step3aSelectedColTypeUndefinedTitle();
+
/**
* @return Step 3b: Choose metadata for rows
*/
public abstract String step3bDescription();
+
/**
* @return Date & Time
*/
public abstract String step3ColTypeDateTime();
+
/**
* @return Do not export
*/
public abstract String step3ColTypeDoNotExport();
+
/**
* @return Measured Value
*/
public abstract String step3ColTypeMeasuredValue();
+
/**
* @return Undefined
*/
public abstract String step3ColTypeUndefined();
+
/**
* @return Combination
*/
public abstract String step3DateAndTimeCombination();
+
/**
* @return UNIX time
*/
public abstract String step3DateAndTimeUnixTime();
+
/**
* @return Boolean
*/
public abstract String step3MeasuredValBoolean();
+
/**
* @return Count
*/
public abstract String step3MeasuredValCount();
+
/**
* @return Numeric Value
*/
public abstract String step3MeasuredValNumericValue();
+
/**
* @return Text
*/
public abstract String step3MeasuredValText();
+
/**
* @return {@linkplain org.n52.sos.importer.view.i18n.En.step3DateAndTimeCombination()}
*
:= Combination
*/
public abstract String step3PositionCombination();
+
/**
* @return Step 4a: Solve Date & Time ambiguities
*/
public abstract String step4aDescription();
+
/**
* @return Date and Time are already set for this En.measuredValue()
.
* @see {@link org.n52.sos.importer.view.i18n.En.measuredValue()}
*/
public abstract String step4aInfoDateAndTime();
+
/**
* @param element
* @return This is not a En.measuredValue()
.
* @see {@link org.n52.sos.importer.view.i18n.En.measuredValue()}
*/
public abstract String step4aInfoMeasuredValue();
+
/**
* @param stringReplacer
* @return Select all measured value Constants.STRING_REPLACER
s where the marked Date & Time group corresponds to.
*/
public abstract String step4aModelDescription();
+
/**
* @return Step 4b: Solve ambiguities
*/
public abstract String step4bDescription();
+
/**
* @return This is not a En.measuredValue()
.
* @see {@link org.n52.sos.importer.view.i18n.En.measuredValue()}
@@ -588,6 +708,7 @@ public String step4bInfoResoureAlreadySet(final Resource resource) {
* @return Step 6b: Add missing metadata
*/
public abstract String step6bDescription();
+
/**
* Replacements: Resource → Orientation
* @return <html>What is the <u>Constants.STRING_REPLACER
</u> for the marked measured value Constants.STRING_REPLACER
?</html>
@@ -599,52 +720,64 @@ public String step4bInfoResoureAlreadySet(final Resource resource) {
* \nMultiple columns could be selected.
*/
public abstract String step6bSelectColumnsLabel();
+
/**
* @return Step 6b (Special): Add missing sensors
*/
public abstract String step6bSpecialDescription();
+
/**
* @return What is the sensor for
*/
public abstract String step6bSpecialModelDescription();
+
/**
* @return Please provide a URI or a prefix if using the name as part of the URI.
*/
public abstract String step6bURIInstructions();
+
/**
* @return Use Name after prefix?
*/
public abstract String step6bUseNameAfterPrefix();
+
/**
* @return Step 6c: Add missing positions
*/
public abstract String step6cDescription();
+
/**
*
* @return Set Position
*/
public abstract String step6cInfoToolName();
+
/**
*
* @return Set the position by clicking on the map
*/
public abstract String step6cInfoToolTooltip();
+
/**
* @return What is the position of
*/
public abstract String step6cModelDescription();
+
/**
* @return Automatically Generate Identifier
*/
public abstract String step6Generation();
+
/**
* @return Set Identifier Manually
*/
public abstract String step6ManualInput();
+
/**
* @return Some User Input is missing. Please enter the required information.
*/
public abstract String step6MissingUserInput();
+
/**
* @return No user input at all. Please fill in the required information.
*/
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/controller/Step2ControllerTest.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/controller/Step2ControllerTest.java
new file mode 100644
index 00000000..2d48451e
--- /dev/null
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/controller/Step2ControllerTest.java
@@ -0,0 +1,176 @@
+/**
+ * Copyright (C) 2014
+ * by 52 North Initiative for Geospatial Open Source Software GmbH
+ *
+ * Contact: Andreas Wytzisk
+ * 52 North Initiative for Geospatial Open Source Software GmbH
+ * Martin-Luther-King-Weg 24
+ * 48155 Muenster, Germany
+ * info@52north.org
+ *
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; even without the implied
+ * WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (see gnu-gpl v2.txt). If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
+ * visit the Free Software Foundation web page, http://www.fsf.org.
+ */
+package org.n52.sos.importer.controller;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.n52.sos.importer.model.Step2Model;
+
+/*
+ * @author Eike Hinderk Jürrens
+ */
+public class Step2ControllerTest {
+
+ private Step2Controller controller;
+
+ @Before
+ public void init() {
+ controller = new Step2Controller(new Step2Model("", 1));
+ }
+
+ @Test
+ public void shouldReturnFalseIfStartRegExIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true);
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfDateOffsetIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex");
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfDateExtractionRegExIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5);
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ ((Step2Model)controller.getModel()).setSampleBasedDateExtractionRegEx("test-regex");
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfDatePatternIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5)
+ .setSampleBasedDateExtractionRegEx("(test)-regex-2");
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfDataOffsetIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5)
+ .setSampleBasedDateExtractionRegEx("(test)-regex-2")
+ .setSampleBasedDatePattern("test-pattern");
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfSampleSizeOffsetIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5)
+ .setSampleBasedDateExtractionRegEx("(test)-regex-2")
+ .setSampleBasedDatePattern("test-pattern")
+ .setSampleBasedDataOffset(6);
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnFalseIfSampleSizeRegExIsMissing() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5)
+ .setSampleBasedDateExtractionRegEx("(test)-regex-2")
+ .setSampleBasedDatePattern("test-pattern")
+ .setSampleBasedDataOffset(6)
+ .setSampleBasedSampleSizeOffset(7);
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ ((Step2Model)controller.getModel()).setSampleBasedSampleSizeRegEx("test-regex");
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(false));
+ }
+
+ @Test
+ public void shouldReturnTrueIfSampleBasedValuesAreSet() {
+ ((Step2Model)controller.getModel())
+ .setColumnSeparator(",")
+ .setCommentIndicator("#")
+ .setDecimalSeparator('.')
+ .setTextQualifier("\"")
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(5)
+ .setSampleBasedDateExtractionRegEx("(test)-regex2-with-one-group")
+ .setSampleBasedDatePattern("date-pattern")
+ .setSampleBasedDataOffset(6)
+ .setSampleBasedSampleSizeOffset(7)
+ .setSampleBasedSampleSizeRegEx("(test-regex)-with-one-group");
+ // TODO extend with other sample based parameters
+ controller.loadSettings();
+ assertThat(controller.isFinished(), is(true));
+ }
+
+}
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/Step2ModelTest.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/Step2ModelTest.java
new file mode 100644
index 00000000..83608c06
--- /dev/null
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/Step2ModelTest.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright (C) 2014
+ * by 52 North Initiative for Geospatial Open Source Software GmbH
+ *
+ * Contact: Andreas Wytzisk
+ * 52 North Initiative for Geospatial Open Source Software GmbH
+ * Martin-Luther-King-Weg 24
+ * 48155 Muenster, Germany
+ * info@52north.org
+ *
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; even without the implied
+ * WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (see gnu-gpl v2.txt). If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
+ * visit the Free Software Foundation web page, http://www.fsf.org.
+ */
+package org.n52.sos.importer.model;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Eike Hinderk Jürrens
+ */
+public class Step2ModelTest {
+
+ private Step2Model model;
+
+ @Before
+ public void init() {
+ model = new Step2Model("", 0);
+ }
+
+ @Test
+ public void shouldReturnTrueIfIsSampleBasedIsSet() {
+ assertThat(model.setSampleBased(true).isSampleBased(), is(true));
+ }
+
+ @Test
+ public void shouldReturnFalseAsDefaultValueForSampleBased() {
+ assertThat(model.isSampleBased(), is(false));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedStartRegExIsSet() {
+ final String sampleBasedStartRegEx = "test-regex";
+ assertThat(model.setSampleBasedStartRegEx(sampleBasedStartRegEx).getSampleBasedStartRegEx(), is(sampleBasedStartRegEx));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedStartRegEx() {
+ assertThat(model.getSampleBasedStartRegEx(), is(""));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedDateOffsetIsSet() {
+ final int dateOffset = 25;
+ assertThat(model.setSampleBasedDateOffset(dateOffset).getSampleBasedDateOffset(), is(dateOffset));
+ }
+
+ @Test
+ public void shouldReturnZeroAsDefaultValueForSampleBasedDateOffset() {
+ assertThat(model.getSampleBasedDateOffset(), is(0));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedDateExtractionRegExIsSet() {
+ final String sampleBasedDateExtractionRegEx = "test-regex";
+ assertThat(model.setSampleBasedDateExtractionRegEx(sampleBasedDateExtractionRegEx).getSampleBasedDateExtractionRegEx(), is(sampleBasedDateExtractionRegEx));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedDateExtractionRegEx() {
+ assertThat(model.getSampleBasedDateExtractionRegEx(), is(""));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedDatePatternIsSet() {
+ final String datePattern = "test-regex";
+ assertThat(model.setSampleBasedDatePattern(datePattern).getSampleBasedDatePattern(), is(datePattern));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedDatePattern() {
+ assertThat(model.getSampleBasedDatePattern(), is(""));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedDataOffsetIsSet() {
+ final int dataOffset = 25;
+ assertThat(model.setSampleBasedDataOffset(dataOffset).getSampleBasedDataOffset(), is(dataOffset));
+ }
+
+ @Test
+ public void shouldReturnZeroAsDefaultValueForSampleBasedDataOffset() {
+ assertThat(model.getSampleBasedDataOffset(), is(0));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedSampleSizeOffsetIsSet() {
+ final int sampleSizeOffset = 25;
+ assertThat(model.setSampleBasedSampleSizeOffset(sampleSizeOffset).getSampleBasedSampleSizeOffset(), is(sampleSizeOffset));
+ }
+
+ @Test
+ public void shouldReturnZeroAsDefaultValueForSampleBasedSampleSizeOffset() {
+ assertThat(model.getSampleBasedSampleSizeOffset(), is(0));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedSampleSizeRegExIsSet() {
+ final String sampleBasedSampleSizeRegEx = "test-regex";
+ assertThat(model.setSampleBasedSampleSizeRegEx(sampleBasedSampleSizeRegEx).getSampleBasedSampleSizeRegEx(), is(sampleBasedSampleSizeRegEx));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedSampleSizeRegEx() {
+ assertThat(model.getSampleBasedSampleSizeRegEx(), is(""));
+ }
+}
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step2ModelHandlerTest.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step2ModelHandlerTest.java
new file mode 100644
index 00000000..f04adf9f
--- /dev/null
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step2ModelHandlerTest.java
@@ -0,0 +1,150 @@
+/**
+ * Copyright (C) 2014
+ * by 52 North Initiative for Geospatial Open Source Software GmbH
+ *
+ * Contact: Andreas Wytzisk
+ * 52 North Initiative for Geospatial Open Source Software GmbH
+ * Martin-Luther-King-Weg 24
+ * 48155 Muenster, Germany
+ * info@52north.org
+ *
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; even without the implied
+ * WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (see gnu-gpl v2.txt). If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
+ * visit the Free Software Foundation web page, http://www.fsf.org.
+ */
+package org.n52.sos.importer.model.xml;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.n52.sos.importer.model.Step2Model;
+import org.x52North.sensorweb.sos.importer.x02.SosImportConfigurationDocument.SosImportConfiguration;
+
+/**
+ * @author Eike Hinderk Jürrens
+ */
+public class Step2ModelHandlerTest {
+
+ @Test
+ public void shouldSetSampleBasedStartRegEx() {
+ final String sampleBasedStartRegEx = "test-regex";
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx(sampleBasedStartRegEx);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleStartRegEx(), is(true));
+ assertThat(importConf.getDataFile().getSampleStartRegEx(), is(sampleBasedStartRegEx));
+ }
+
+ @Test
+ public void shouldSetSampleBasedDateOffset() {
+ final int dateOffset = 25;
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(dateOffset);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleDateOffset(), is(true));
+ assertThat(importConf.getDataFile().getSampleDateOffset(), is(dateOffset));
+ }
+
+ @Test
+ public void shouldSetSampleBasedDateExtractionRegEx() {
+ final String dateExtractionRegEx = "test-regex-2";
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(25)
+ .setSampleBasedDateExtractionRegEx(dateExtractionRegEx);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleDateExtractionRegEx(), is(true));
+ assertThat(importConf.getDataFile().getSampleDateExtractionRegEx(), is(dateExtractionRegEx));
+ }
+
+ @Test
+ public void shouldSetSampleBasedDatePattern() {
+ final String datePattern = "test-regex-2";
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(25)
+ .setSampleBasedDateExtractionRegEx("test-regex-2")
+ .setSampleBasedDatePattern(datePattern);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleDatePattern(), is(true));
+ assertThat(importConf.getDataFile().getSampleDatePattern(), is(datePattern));
+ }
+
+ @Test
+ public void shouldSetSampleBasedDataOffset() {
+ final int dataOffset = 42;
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(25)
+ .setSampleBasedDateExtractionRegEx("test-regex-2")
+ .setSampleBasedDatePattern("test-pattern")
+ .setSampleBasedDataOffset(dataOffset);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleDataOffset(), is(true));
+ assertThat(importConf.getDataFile().getSampleDataOffset(), is(dataOffset));
+ }
+
+ @Test
+ public void shouldSetSampleBasedSampleSizeOffset() {
+ final int sampleSizeOffset = 42;
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(25)
+ .setSampleBasedDateExtractionRegEx("test-regex-2")
+ .setSampleBasedDatePattern("test-pattern")
+ .setSampleBasedDataOffset(6)
+ .setSampleBasedSampleSizeOffset(sampleSizeOffset);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleSizeOffset(), is(true));
+ assertThat(importConf.getDataFile().getSampleSizeOffset(), is(sampleSizeOffset));
+ }
+
+ @Test
+ public void shouldSetSampleBasedSampleSizeRegEx() {
+ final String sampleSizeRegEx = "test-regex";
+ final Step2Model stepModel = new Step2Model("",2)
+ .setSampleBased(true)
+ .setSampleBasedStartRegEx("test-regex")
+ .setSampleBasedDateOffset(25)
+ .setSampleBasedDateExtractionRegEx("test-regex-2")
+ .setSampleBasedDatePattern("test-pattern")
+ .setSampleBasedDataOffset(6)
+ .setSampleBasedSampleSizeOffset(42)
+ .setSampleBasedSampleSizeRegEx(sampleSizeRegEx);
+ final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
+ new Step2ModelHandler().handleModel(stepModel, importConf);
+
+ assertThat(importConf.getDataFile().isSetSampleSizeRegEx(), is(true));
+ assertThat(importConf.getDataFile().getSampleSizeRegEx(), is(sampleSizeRegEx));
+ }
+
+}
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java
index c96586ef..87b8054f 100644
--- a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java
@@ -31,62 +31,56 @@
import org.n52.sos.importer.model.Step7Model;
import org.x52North.sensorweb.sos.importer.x02.SosImportConfigurationDocument.SosImportConfiguration;
-
/**
* @author Eike Hinderk Jürrens
- *
*/
public class Step7ModelHandlerTest {
-
+
@Test
- public void should_add_binding_if_set_in_model()
- {
+ public void shouldAddBindingIfSetInModel() {
final String binding = "test-binding";
final Step7Model stepModel = new Step7Model(null, null, false, null, null, binding);
final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModel, importConf);
-
+
assertThat(importConf.getSosMetadata().isSetBinding(), is(TRUE));
assertThat(importConf.getSosMetadata().getBinding(), is(binding));
}
-
+
@Test
- public void should_not_add_binding_if_empty_or_null()
- {
+ public void shouldNotAddBindingIfEmptyOrNull() {
final Step7Model stepModelEmpty = new Step7Model(null, null, false, null, null, "");
final SosImportConfiguration importConfEmpty = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModelEmpty, importConfEmpty);
-
+
final Step7Model stepModelNull = new Step7Model(null, null, false, null, null, null);
final SosImportConfiguration importConfNull = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModelNull, importConfNull);
-
+
assertThat(importConfEmpty.getSosMetadata().isSetBinding(), is(FALSE));
assertThat(importConfNull.getSosMetadata().isSetBinding(), is(FALSE));
}
-
+
@Test
- public void should_add_version_if_set_in_model()
- {
+ public void shouldAddVersionIfSetInModel() {
final String version = "test-version";
final Step7Model stepModel = new Step7Model(null, null, false, null, version, null);
final SosImportConfiguration importConf = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModel, importConf);
-
+
assertThat(importConf.getSosMetadata().getVersion(), is(version));
}
-
+
@Test
- public void should_not_add_version_if_empty_or_null()
- {
+ public void shouldNotAddVersionIfEmptyOrNull() {
final Step7Model stepModelEmpty = new Step7Model(null, null, false, null, "",null);
final SosImportConfiguration importConfEmpty = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModelEmpty, importConfEmpty);
-
+
final Step7Model stepModelNull = new Step7Model(null, null, false, null, null, null);
final SosImportConfiguration importConfNull = SosImportConfiguration.Factory.newInstance();
new Step7ModelHandler().handleModel(stepModelNull, importConfNull);
-
+
assertThat(importConfEmpty.getSosMetadata().getVersion(), is(nullValue()));
assertThat(importConfNull.getSosMetadata().getVersion(), is(nullValue()));
}
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/test/Step2Test.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/test/Step2Test.java
new file mode 100644
index 00000000..5ca44bf9
--- /dev/null
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/test/Step2Test.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2012
+ * by 52North Initiative for Geospatial Open Source Software GmbH
+ *
+ * Contact: Andreas Wytzisk
+ * 52 North Initiative for Geospatial Open Source Software GmbH
+ * Martin-Luther-King-Weg 24
+ * 48155 Muenster, Germany
+ * info@52north.org
+ *
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; even without the implied
+ * WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (see gnu-gpl v2.txt). If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
+ * visit the Free Software Foundation web page, http://www.fsf.org.
+ */
+package org.n52.sos.importer.test;
+
+import org.n52.sos.importer.controller.MainController;
+import org.n52.sos.importer.controller.Step2Controller;
+import org.n52.sos.importer.controller.TableController;
+import org.n52.sos.importer.model.Step2Model;
+
+public class Step2Test {
+
+ public static void main(final String[] args) {
+ final MainController f = MainController.getInstance();
+ final TableController tc = TableController.getInstance();
+ tc.setContent(TestData.EXAMPLE_TABLE);
+ final Step2Model s2M = new Step2Model("line 1\nline2\nline3\nlin4\nline5\nline6", 6);
+ final Step2Controller s2C = new Step2Controller(
+ s2M);
+ //
+ f.setStepController(s2C);
+ }
+}
diff --git a/52n-sos-importer-core/src/test/java/org/n52/sos/importer/view/Step2PanelTest.java b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/view/Step2PanelTest.java
new file mode 100644
index 00000000..d0b2de99
--- /dev/null
+++ b/52n-sos-importer-core/src/test/java/org/n52/sos/importer/view/Step2PanelTest.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright (C) 2014
+ * by 52 North Initiative for Geospatial Open Source Software GmbH
+ *
+ * Contact: Andreas Wytzisk
+ * 52 North Initiative for Geospatial Open Source Software GmbH
+ * Martin-Luther-King-Weg 24
+ * 48155 Muenster, Germany
+ * info@52north.org
+ *
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; even without the implied
+ * WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program (see gnu-gpl v2.txt). If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or
+ * visit the Free Software Foundation web page, http://www.fsf.org.
+ */
+package org.n52.sos.importer.view;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Eike Hinderk Jürrens
+ */
+public class Step2PanelTest {
+
+ private static final int MAX_ROWS = 30;
+
+ private Step2Panel panel;
+
+ @Before
+ public void init() {
+ panel = new Step2Panel(MAX_ROWS);
+ }
+
+ @Test
+ public void shouldReturnTrueIfIsSampleBasedIsSet() {
+ assertThat(panel.setSampleBased(true).isSampleBased(), is(true));
+ }
+
+ @Test
+ public void shouldReturnFalseAsDefaultValueForSampleBased() {
+ assertThat(panel.isSampleBased(), is(false));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedStartRegExIsSet() {
+ final String sampleBasedStartRegEx = "test-regex";
+ assertThat(panel.setSampleBasedStartRegEx(sampleBasedStartRegEx).getSampleBasedStartRegEx(), is(sampleBasedStartRegEx));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedStartRegEx() {
+ assertThat(panel.getSampleBasedStartRegEx(), is(""));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedDateOffsetIsSet() {
+ final int dateOffset = MAX_ROWS-5;
+ assertThat(panel.setSampleBasedDateOffset(dateOffset).getSampleBasedDateOffset(), is(dateOffset));
+ }
+
+ @Test
+ public void shouldReturnOneAsDefaultValueForDateOffset() {
+ assertThat(panel.getSampleBasedDateOffset(), is(1));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedDateExtractionRegExIsSet() {
+ final String dateExtractionRegEx = "test-regex";
+ assertThat(panel.setSampleBasedDateExtractionRegEx(dateExtractionRegEx)
+ .getSampleBasedDateExtractionRegEx(),
+ is(dateExtractionRegEx));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedDateExtractionRegEx() {
+ assertThat(panel.getSampleBasedDateExtractionRegEx(), is(""));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedDatePatternIsSet() {
+ final String datePattern = "test-regex";
+ assertThat(panel.setSampleBasedDatePattern(datePattern).getSampleBasedDatePattern(), is(datePattern));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedDatePattern() {
+ assertThat(panel.getSampleBasedDatePattern(), is(""));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedDataOffsetIsSet() {
+ final int dataOffset = MAX_ROWS-5;
+ assertThat(panel.setSampleBasedDataOffset(dataOffset).getSampleBasedDataOffset(), is(dataOffset));
+ }
+
+ @Test
+ public void shouldReturnOneAsDefaultValueForDataOffset() {
+ assertThat(panel.getSampleBasedDataOffset(), is(1));
+ }
+
+ @Test
+ public void shouldReturnValueIfIsSampleBasedSampleSizeOffsetIsSet() {
+ final int sampleSizeOffset = MAX_ROWS-5;
+ assertThat(panel.setSampleBasedSampleSizeOffset(sampleSizeOffset).getSampleBasedSampleSizeOffset(), is(sampleSizeOffset));
+ }
+
+ @Test
+ public void shouldReturnOneAsDefaultValueForSampleSizeOffset() {
+ assertThat(panel.getSampleBasedSampleSizeOffset(), is(1));
+ }
+
+ @Test
+ public void shouldReturnEmptyStringAsDefaultValueForSampleBasedSampleSizeRegEx() {
+ assertThat(panel.getSampleBasedSampleSizeRegEx(), is(""));
+ }
+
+ @Test
+ public void shouldReturnStringIfIsSampleBasedSampleSizeRegExIsSet() {
+ final String sampleSizeRegEx = "test-regex";
+ assertThat(panel.setSampleBasedSampleSizeRegEx(sampleSizeRegEx).getSampleBasedSampleSizeRegEx(), is(sampleSizeRegEx));
+ }
+}
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 4bf0db40..ca17d30b 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -45,7 +45,7 @@ Features:
group will be parsed to a java.util.Date
using "sampleDatePattern" attribute.
* "sampleDatePattern" - the pattern used to parse the date information of
- the current pattern.
+ the current sample.
* "sampleDataOffset" - the offset in lines from sample beginning till the
first lines with data.
* "sampleSizeOffset" - the offset in lines from sample beginning till the