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