Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #100 from EHJ-52n/fix/99-no-such-method-error
Browse files Browse the repository at this point in the history
Fix #99: no such method error
  • Loading branch information
EHJ-52n authored Feb 25, 2019
2 parents 1b00dde + 0e4a715 commit f87757a
Show file tree
Hide file tree
Showing 13 changed files with 549 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: java
#notifications:
# email: false
jdk:
- openjdk7
- oraclejdk7
- openjdk8
- oraclejdk8
# - oraclejdk8
install: true
script: mvn clean install
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ For a complete Release Notes overview visit

https://wiki.52north.org/bin/view/SensorWeb/SosImporter#Road_map

Release Notes for SOS-Importer 0.4.2
====================================
Bugfixes:
---------
* https://github.com/52North/sos-importer/issues/99

Release Notes for SOS-Importer 0.4.1
====================================
Bugfixes:
Expand Down
4 changes: 2 additions & 2 deletions feeder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>${java.source.version}</source>
<target>${java.target.version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
Expand Down
50 changes: 29 additions & 21 deletions feeder/src/main/java/org/n52/sos/importer/feeder/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public final class Configuration {

public static HashMap<String, Boolean> EPSG_EASTING_FIRST_MAP = null;
static {
EPSG_EASTING_FIRST_MAP = new HashMap<String, Boolean>();
EPSG_EASTING_FIRST_MAP = new HashMap<>();
EPSG_EASTING_FIRST_MAP.put("default", false);
EPSG_EASTING_FIRST_MAP.put("4326",false);
EPSG_EASTING_FIRST_MAP.put("4979",false);
Expand Down Expand Up @@ -159,7 +159,7 @@ public Configuration(final String pathToFile) throws XmlException, IOException {
SosImportConfigurationDocument.Factory.parse(configFile);
// Create an XmlOptions instance and set the error listener.
final XmlOptions validateOptions = new XmlOptions();
final ArrayList<XmlError> errorList = new ArrayList<XmlError>();
final ArrayList<XmlError> errorList = new ArrayList<>();
validateOptions.setErrorListener(errorList);

// Validate the XML.
Expand Down Expand Up @@ -222,7 +222,7 @@ public File getDataFile() {
importConf.getDataFile().isSetLocalFile() &&
!importConf.getDataFile().getLocalFile().getPath().equalsIgnoreCase("") ) {
// Path for LocalFile set to something, so return a new File using is
return new File(importConf.getDataFile().getLocalFile().getPath());
return new File(importConf.getDataFile().getLocalFile().getPath().trim());
}
LOG.error("DataFile.LocalFile.Path not set!");
return null;
Expand Down Expand Up @@ -357,7 +357,7 @@ public char getCsvEscape() {
public int[] getMeasureValueColumnIds() {
LOG.trace("getMeasureValueColumnIds()");
final Column[] cols = importConf.getCsvMetadata().getColumnAssignments().getColumnArray();
final ArrayList<Integer> ids = new ArrayList<Integer>();
final ArrayList<Integer> ids = new ArrayList<>();
for (final Column column : cols) {
if (column.getType().equals(Type.MEASURED_VALUE)){
LOG.debug("Found measured value column: {}", column.getNumber());
Expand All @@ -378,7 +378,7 @@ public int[] getMeasureValueColumnIds() {
public int[] getIgnoredColumnIds() {
LOG.trace("getIgnoredColumnIds()");
final Column[] cols = importConf.getCsvMetadata().getColumnAssignments().getColumnArray();
final ArrayList<Integer> ids = new ArrayList<Integer>();
final ArrayList<Integer> ids = new ArrayList<>();
for (final Column column : cols) {
if (column.getType().equals(Type.DO_NOT_EXPORT)){
LOG.debug("Found ignored column: {}", column.getNumber());
Expand Down Expand Up @@ -441,25 +441,20 @@ public int getColumnIdForSensor(final int mvColumnId) {
return -1;
}

/**
*
* @param mvColumnId
* @return
*/
public Column getColumnById(final int mvColumnId) {
LOG.trace(String.format("getColumnById(%d)",mvColumnId));
public Column getColumnById(final int columnId) {
LOG.trace(String.format("getColumnById(%d)", columnId));
final Column[] cols = importConf.getCsvMetadata().getColumnAssignments().getColumnArray();
for (final Column column : cols) {
if (column.getNumber() == mvColumnId) {
if (column.getNumber() == columnId) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Column found for id %d",
mvColumnId));
columnId));
}
return column;
}
}
LOG.error(String.format("CsvMetadat.ColumnAssignments not set properly. Could not find Column for id %d.",
mvColumnId));
columnId));
return null;
}

Expand Down Expand Up @@ -854,14 +849,14 @@ private char getDecimalSeparator() {
* @return a <code>Column[]</code> having all the group id
* <code>group</code> <b>or</or><br />
*/
public Column[] getAllColumnsForGroup(final String group, final Enum t) {
public Column[] getAllColumnsForGroup(final String group, final Enum type) {
LOG.trace("getAllColumnsForGroup()");
if (group == null) { return null; }
final Column[] allCols = importConf.getCsvMetadata().getColumnAssignments().getColumnArray();
final ArrayList<Column> tmpResultSet = new ArrayList<Column>(allCols.length);
final ArrayList<Column> tmpResultSet = new ArrayList<>(allCols.length);
for (final Column col : allCols) {
if (col.getType() != null &&
col.getType().equals(t) ) {
col.getType().equals(type) ) {
// we have a position or dateTime
// check the Metadata kvps
if (col.getMetadataArray() != null && col.getMetadataArray().length > 0) {
Expand All @@ -882,16 +877,29 @@ public Column[] getAllColumnsForGroup(final String group, final Enum t) {
return result;
}

/**
* Returns the group id of the first position group found in
* <code>CsvMetadata.ColumnAssignments.Column[]</code>
* @return a <code>{@link java.lang.String String}</code>
*/
public String getFirstPositionGroup() {
return getFirstGroup(Type.POSITION);
}

/**
* Returns the group id of the first date time group found in
* <code>CsvMetadata.ColumnAssignments.Column[]</code>
* @return a <code>{@link java.lang.String String}</code>
*/
public String getFirstDateTimeGroup() {
LOG.trace("getFirstDateTimeGroup()");
return getFirstGroup(Type.DATE_TIME);
}

public String getFirstGroup(Enum type) {
LOG.trace("getFirstGroup()");
final Column[] cols = importConf.getCsvMetadata().getColumnAssignments().getColumnArray();
for (final Column col : cols) {
if (col.getType().equals(Type.DATE_TIME)){
if (col.getType().equals(type)){
// it's DATE_TIME -> get group id from metadata[]
if (col.getMetadataArray() != null && col.getMetadataArray().length > 0) {
for (final Metadata m : col.getMetadataArray()) {
Expand Down Expand Up @@ -1028,7 +1036,7 @@ public SensorType getSensorFromAdditionalMetadata() {
}

public boolean isOneMvColumn() {
return (getMeasureValueColumnIds().length == 1);
return getMeasureValueColumnIds().length == 1;
}

public String getSosVersion() {
Expand Down
35 changes: 24 additions & 11 deletions feeder/src/main/java/org/n52/sos/importer/feeder/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ public boolean isAvailable() {
return false;
}

private boolean checkWindowsJavaApiBugJDK6203387(final File file) {
private boolean checkWindowsJavaApiBugJDK6203387(File file) {
if (isWindows()) {
FileReader fr = null;
try {
new FileReader(file);
fr = new FileReader(file);
}
catch (final FileNotFoundException fnfe) {
// TODO add more language specific versions of this error message
Expand All @@ -143,6 +144,14 @@ private boolean checkWindowsJavaApiBugJDK6203387(final File file) {
{
return true;
}
} finally {
if (fr != null) {
try {
fr.close();
} catch (IOException e) {
LOG.error("Exception thrown", e);
}
}
}
}
return false;
Expand Down Expand Up @@ -266,7 +275,7 @@ public FeatureOfInterest getFoiForColumn(final int mvColumnId, final String[] va
mvColumnId,
Arrays.toString(values)));
// check for foi column and return new sensor
FeatureOfInterest foi = getFoiColumn(mvColumnId,values);
FeatureOfInterest foi = getFoiColumn(mvColumnId, values);
if (foi == null) {
LOG.debug(String.format("Could not find foi column for column id %d",
mvColumnId));
Expand Down Expand Up @@ -784,17 +793,21 @@ private Sensor getSensorFromColumn(final int mvColumnId, final String[] values)
}
}

private FeatureOfInterest getFoiColumn(final int mvColumnId, final String[] values) {
private FeatureOfInterest getFoiColumn(int mvColumnId, String[] values) throws ParseException {
LOG.trace(String.format("getFoiColumn(%d,%s)",
mvColumnId,
Arrays.toString(values)));
final int i = configuration.getColumnIdForFoi(mvColumnId);
int i = configuration.getColumnIdForFoi(mvColumnId);
if (i < 0) {
// foi is not in the data file -> return null
return null;
} else {
final Position p = configuration.getFoiPosition(values[i]);
final FeatureOfInterest s = new FeatureOfInterest(values[i],
Position p = configuration.getFoiPosition(values[i]);
if (p == null) {
String group = configuration.getFirstPositionGroup();
p = configuration.getPosition(group, values);
}
FeatureOfInterest s = new FeatureOfInterest(values[i],
values[i],
p);
LOG.debug(String.format("Feature of Interst found in datafile: %s", s));
Expand Down Expand Up @@ -850,7 +863,7 @@ private short parseTimestampComponent(final String timestampPart,
private int[] getGregorianCalendarFields(final String pattern) {
LOG.trace(String.format("getGregorianCalendarFields(%s)",
pattern));
final ArrayList<Integer> fields = new ArrayList<Integer>();
final ArrayList<Integer> fields = new ArrayList<>();
if (pattern.indexOf("y") != -1) {
fields.add(GregorianCalendar.YEAR);
}
Expand All @@ -860,13 +873,13 @@ private int[] getGregorianCalendarFields(final String pattern) {
fields.add(GregorianCalendar.MONTH);
}
if (pattern.indexOf("d") != -1 ||
(pattern.indexOf("W") != -1 && pattern.indexOf("d") != -1)) {
pattern.indexOf("W") != -1 && pattern.indexOf("d") != -1) {
fields.add(GregorianCalendar.DAY_OF_MONTH);
}
if (pattern.indexOf("H") != -1 ||
pattern.indexOf("k") != -1 ||
((pattern.indexOf("K") != -1 ||
(pattern.indexOf("h") != -1) && pattern.indexOf("a") != -1))) {
pattern.indexOf("K") != -1 ||
pattern.indexOf("h") != -1 && pattern.indexOf("a") != -1) {
fields.add(GregorianCalendar.HOUR_OF_DAY);
}
if (pattern.indexOf("m") != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void main(final String[] args) {
// data file
if (args.length == 2) {
// Case: one time feeding with defined configuration
new Thread(new OneTimeFeeder(c),OneTimeFeeder.class.getSimpleName()).start();
new Thread(new OneTimeFeeder(c), OneTimeFeeder.class.getSimpleName()).start();
}
else if (args.length == 4) {
// Case: one time feeding with file override or period with file from configuration
Expand Down
Loading

0 comments on commit f87757a

Please sign in to comment.