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.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class BulkUpload {
|
||||
|
@ -65,15 +69,37 @@ public class BulkUpload {
|
|||
}
|
||||
else {
|
||||
ace.setResourceType("dataset");
|
||||
Spatial esSpatial = new Spatial();
|
||||
ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).forEach(s -> {
|
||||
esSpatial.setPlaceName(s.getPlaceName());
|
||||
});
|
||||
ace.getSpatial().stream().filter(s -> s.getLocation()!=null).forEach(s -> {
|
||||
esSpatial.setLocation(s.getLocation());
|
||||
});
|
||||
ace.getSpatial().clear();
|
||||
ace.setSpatial(Arrays.asList(esSpatial));
|
||||
if (ace.getSpatial()!=null) {
|
||||
if (ace.getSpatial().size()==2) {
|
||||
Spatial uniqueSpatial = new Spatial();
|
||||
boolean uniquePlaceNameFound = ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).count()==1;
|
||||
boolean uniqueLocationFound = ace.getSpatial().stream().filter(s -> s.getLocation()!=null).count()==1;
|
||||
if (uniquePlaceNameFound&&uniqueLocationFound) {
|
||||
ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).forEach(s -> {
|
||||
uniqueSpatial.setPlaceName(s.getPlaceName());
|
||||
});
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue