mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-18 02:00:58 +00:00
fixed filename/sourcename misunderstanding in importers
Change-Id: I2e79aff97666f93f55a0cd696b52c2c850e4b6e8
This commit is contained in:
1 parent
8a6b1a7394
commit
308b047cbc
2 files changed
+15
-9
No files matched your search
+3
-3
@@ -21,9 +21,9 @@ import com.sap.sailing.server.trackfiles.impl.BravoExtendedDataImporterImpl;
|
||||
|
||||
public class BravoGPSFixImporter implements GPSFixImporter {
|
||||
@Override
|
||||
public void importFixes(InputStream inputStream, Callback callback, boolean inferSpeedAndBearing, final String sourceName)
|
||||
public void importFixes(InputStream inputStream, Callback callback, boolean inferSpeedAndBearing, final String filename)
|
||||
throws FormatNotSupportedException, IOException {
|
||||
TrackFileImportDeviceIdentifier device = new TrackFileImportDeviceIdentifierImpl(sourceName, getType() + "@" + new Date());
|
||||
TrackFileImportDeviceIdentifier device = new TrackFileImportDeviceIdentifierImpl(filename, getType() + "@" + new Date());
|
||||
new BravoExtendedDataImporterImpl().importFixes(inputStream,
|
||||
(Iterable<DoubleVectorFix> fixes, TrackFileImportDeviceIdentifier deviceIdentifier)->{
|
||||
for (final DoubleVectorFix fix : fixes) {
|
||||
@@ -35,7 +35,7 @@ public class BravoGPSFixImporter implements GPSFixImporter {
|
||||
new DegreeBearingImpl(fix.get(BravoExtendedSensorDataMetadata.COG.getColumnIndex()))));
|
||||
callback.addFix(gpsFix, device);
|
||||
}
|
||||
}, sourceName, sourceName, /* downsample */ false);
|
||||
}, filename, /* sourceName */ getType(), /* downsample */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-6
@@ -31,6 +31,8 @@ import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class BravoWindImportServlet extends AbstractWindImportServlet {
|
||||
private static final String BRAVO_WIND_IMPORT = "Bravo Wind Import";
|
||||
private static final String GZIP_SUFFIX = ".gz";
|
||||
private static final long serialVersionUID = -4547876638456305135L;
|
||||
private static final Logger logger = Logger.getLogger(BravoWindImportServlet.class.getName());
|
||||
|
||||
@@ -42,7 +44,7 @@ public class BravoWindImportServlet extends AbstractWindImportServlet {
|
||||
if (uploadRequest.files != null && !uploadRequest.files.isEmpty()) {
|
||||
sourceName = uploadRequest.files.stream().map(f->f.getName()).collect(Collectors.joining(", "));
|
||||
} else {
|
||||
sourceName = "Bravo Wind Import";
|
||||
sourceName = BRAVO_WIND_IMPORT;
|
||||
}
|
||||
windSource = new WindSourceWithAdditionalID(WindSourceType.EXPEDITION, sourceName + "@" + MillisecondsTimePoint.now());
|
||||
return windSource;
|
||||
@@ -75,7 +77,7 @@ public class BravoWindImportServlet extends AbstractWindImportServlet {
|
||||
for (final Fields field : Fields.values()) {
|
||||
columnsMap.put(field.name(), field.ordinal());
|
||||
}
|
||||
final BaseBravoDataImporterImpl importer = new BaseBravoDataImporterImpl(columnsMap, "BRAVO_WIND");
|
||||
final BaseBravoDataImporterImpl importer = new BaseBravoDataImporterImpl(columnsMap, BRAVO_WIND_IMPORT);
|
||||
final Callback callback = new Callback() {
|
||||
@Override
|
||||
public void addFixes(Iterable<DoubleVectorFix> fixes, TrackFileImportDeviceIdentifier device) {
|
||||
@@ -91,22 +93,26 @@ public class BravoWindImportServlet extends AbstractWindImportServlet {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (filename.toLowerCase().endsWith("zip")) {
|
||||
if (filename.toLowerCase().endsWith(".zip")) {
|
||||
logger.info("Bravo file "+filename+" is a ZIP file");
|
||||
try (final ZipInputStream zipInputStream = new ZipInputStream(inputStream)) {
|
||||
ZipEntry entry;
|
||||
while ((entry=zipInputStream.getNextEntry()) != null) {
|
||||
if (entry.getName().toLowerCase().endsWith(".txt")) {
|
||||
logger.info("Reading Bravo wind data from "+filename+"'s ZIP entry "+entry.getName());
|
||||
importer.importFixes(zipInputStream, callback, filename, filename, /* downsample */ false);
|
||||
importer.importFixes(zipInputStream, callback, entry.getName(), BRAVO_WIND_IMPORT, /* downsample */ false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (filename.toLowerCase().endsWith("gz")) {
|
||||
final String sourceName;
|
||||
if (filename.toLowerCase().endsWith(GZIP_SUFFIX)) {
|
||||
inputStream = new GZIPInputStream(inputStream);
|
||||
sourceName = filename.substring(0, filename.length()-GZIP_SUFFIX.length());
|
||||
} else {
|
||||
sourceName = filename;
|
||||
}
|
||||
importer.importFixes(inputStream, callback, filename, filename, /* downsample */ false);
|
||||
importer.importFixes(inputStream, callback, filename, sourceName, /* downsample */ false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user