mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-19 10:39:59 +00:00
fix for gps&sensordata importer
This commit is contained in:
1 parent
d8369aab93
commit
5ccfac2716
3 files changed
+18
-4
No files matched your search
+3
-2
@@ -48,13 +48,14 @@ public class JsonHolder {
|
||||
return jsonExceptionObj;
|
||||
}
|
||||
|
||||
public void add(TrackFileImportDeviceIdentifier mapping) {
|
||||
public void addDevice(TrackFileImportDeviceIdentifier mapping) {
|
||||
String stringRep = mapping.getId().toString();
|
||||
jsonUuidObj.add(stringRep);
|
||||
}
|
||||
|
||||
|
||||
public void writeJSONString(HttpServletResponse resp) throws IOException {
|
||||
resp.setContentType("text/html");
|
||||
jsonResponseObj.writeJSONString(resp.getWriter());
|
||||
}
|
||||
|
||||
}
|
||||
+8
-1
@@ -4,8 +4,11 @@ import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -75,10 +78,14 @@ public class SensorDataImportServlet extends AbstractFileUploadServlet {
|
||||
final String filename = fi.getName();
|
||||
try {
|
||||
importerToUse.importFixes(in, new DoubleVectorFixImporter.Callback() {
|
||||
Set<UUID> knownDevices = new HashSet<>();
|
||||
@Override
|
||||
public void addFixes(Iterable<DoubleVectorFix> fixes, TrackFileImportDeviceIdentifier device) {
|
||||
storeFixes(fixes, device);
|
||||
jsonResult.add(device);
|
||||
if(!knownDevices.contains(device.getId())){
|
||||
knownDevices.add(device.getId());
|
||||
jsonResult.addDevice(device);
|
||||
}
|
||||
}
|
||||
}, filename, requestedImporterName, enableDownsampler);
|
||||
logger.log(Level.INFO, "Successfully imported file " + requestedImporterName);
|
||||
|
||||
+7
-1
@@ -4,9 +4,11 @@ import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -109,10 +111,14 @@ public class TrackFilesImportServlet extends AbstractFileUploadServlet {
|
||||
try (BufferedInputStream in = new BufferedInputStream(fileItem.getInputStream())) {
|
||||
try {
|
||||
importer.importFixes(in, new Callback() {
|
||||
Set<UUID> knownDevices = new HashSet<>();
|
||||
@Override
|
||||
public void addFix(GPSFix fix, TrackFileImportDeviceIdentifier device) {
|
||||
storeFix(fix, device);
|
||||
jsonResult.add(device);
|
||||
if(!knownDevices.contains(device.getId())){
|
||||
knownDevices.add(device.getId());
|
||||
jsonResult.addDevice(device);
|
||||
}
|
||||
}
|
||||
}, true, fileName);
|
||||
succeeded = true;
|
||||
|
||||
Reference in new issue
Block a user