fix multiple has_spatial_coverage issue
This commit is contained in:
parent
3df2befb52
commit
e5b833169b
|
@ -19,6 +19,10 @@ import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BulkUpload {
|
public class BulkUpload {
|
||||||
|
@ -65,15 +69,37 @@ public class BulkUpload {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ace.setResourceType("dataset");
|
ace.setResourceType("dataset");
|
||||||
Spatial esSpatial = new Spatial();
|
if (ace.getSpatial()!=null) {
|
||||||
ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).forEach(s -> {
|
if (ace.getSpatial().size()==2) {
|
||||||
esSpatial.setPlaceName(s.getPlaceName());
|
Spatial uniqueSpatial = new Spatial();
|
||||||
});
|
boolean uniquePlaceNameFound = ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).count()==1;
|
||||||
ace.getSpatial().stream().filter(s -> s.getLocation()!=null).forEach(s -> {
|
boolean uniqueLocationFound = ace.getSpatial().stream().filter(s -> s.getLocation()!=null).count()==1;
|
||||||
esSpatial.setLocation(s.getLocation());
|
if (uniquePlaceNameFound&&uniqueLocationFound) {
|
||||||
});
|
ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).forEach(s -> {
|
||||||
ace.getSpatial().clear();
|
uniqueSpatial.setPlaceName(s.getPlaceName());
|
||||||
ace.setSpatial(Arrays.asList(esSpatial));
|
});
|
||||||
|
ace.getSpatial().stream().filter(s -> s.getLocation()!=null).forEach(s -> {
|
||||||
|
uniqueSpatial.setLocation(s.getLocation());
|
||||||
|
});
|
||||||
|
ace.getSpatial().clear();
|
||||||
|
ace.setSpatial(Arrays.asList(uniqueSpatial));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ace.getSpatial()!=null) {
|
||||||
|
Set<String> items = new HashSet<>();
|
||||||
|
List<Spatial> spatialsNoDup = ace.getSpatial().stream()
|
||||||
|
.filter(s -> !items.add(s.getPlaceName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
ace.getSpatial().clear();
|
||||||
|
ace.setSpatial(spatialsNoDup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ace.setSpatial(Arrays.asList(new Spatial()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCollection) {
|
if (!isCollection) {
|
||||||
|
|
Loading…
Reference in New Issue