task_24166 #11
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,6 +192,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,6 +264,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,11 +306,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="geoportal-data-common-2.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
<dependent-module archiveName="geoportal-data-common-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
|
|
||||||
|
@ -358,6 +363,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -429,6 +435,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,6 +507,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,6 +579,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,12 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
@ -505,6 +509,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
ProjectsCaller client = GeoportalClientCaller.projects();
|
ProjectsCaller client = GeoportalClientCaller.projects();
|
||||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||||
|
|
||||||
|
ResultSetPaginatedData searchedData = new ResultSetPaginatedData();
|
||||||
|
|
||||||
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
|
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
|
||||||
theProfileID);
|
theProfileID);
|
||||||
|
|
||||||
|
@ -513,25 +519,51 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
|
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchedData.setTotalItems(totalProjectForProfile);
|
||||||
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
||||||
|
|
||||||
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalProjectForProfile, start, limit,
|
// Saving client PROJECTION
|
||||||
|
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
|
||||||
|
int totalItems = totalProjectForProfile;
|
||||||
|
//PERFORMING FIRST QUERY FOR IDS IF AND ONLY IF WHERE CONDITIONS IN THE QUERY.
|
||||||
|
//SEARCHING FACILITY IS ENACTING.
|
||||||
|
if(filter.getConditions()!=null) {
|
||||||
|
|
||||||
|
// Setting PROJECTION ONLY FOR PROEJCT ID
|
||||||
|
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
|
||||||
|
projectionForIDs.put(Project.ID, 1);
|
||||||
|
filter.setProjection(projectionForIDs);
|
||||||
|
|
||||||
|
// FIRST QUERY TO RETRIEVE IDs
|
||||||
|
// LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
|
||||||
|
//Calculating always the size starting from 0
|
||||||
|
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, false);
|
//Getting the Project IDs from the Iterable
|
||||||
searchedData.setTotalItems(totalProjectForProfile);
|
Iterable<Project> itP = () -> projectsIDs;
|
||||||
|
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
||||||
|
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
||||||
|
totalItems = listProjectIDs.size();
|
||||||
|
searchedData.setTotalItems(totalItems);
|
||||||
|
LOG.info("Total Docs read from query per ID: " + totalItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
//NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
|
||||||
|
// SETTING ORIGINAL PROJECTION FROM CLIENT
|
||||||
|
filter.setProjection(originalProjection);
|
||||||
|
// LIMIT IS FROM CLIENT
|
||||||
|
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
|
||||||
|
filter);
|
||||||
|
|
||||||
|
searchedData.setClientStartIndex(start);
|
||||||
|
searchedData.setLimit(limit);
|
||||||
|
searchedData.setServerSearchFinished(false);
|
||||||
|
|
||||||
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||||
|
|
||||||
searchedData.setData(toReturnList);
|
searchedData.setData(toReturnList);
|
||||||
|
|
||||||
// TODO BUGGY WORKAROUND. BLOCKED BY #22487 IT MUST BE REMOVE AFTER THE QUERY
|
LOG.info("Total Docs page size returned:" + toReturnList.size() + ", start: " + start + ", limit: " + limit);
|
||||||
// COUNT
|
|
||||||
// AND LIST.SIZE BY QUERY WILL BE AVAILABLE IN THE SERVICE
|
|
||||||
if (filter.getConditions() != null) {
|
|
||||||
int totalItems = toReturnList.size();
|
|
||||||
searchedData.setTotalItems(totalItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
|
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
|
||||||
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
|
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
|
||||||
|
|
Loading…
Reference in New Issue