Improved data converter and data model

This commit is contained in:
Francesco Mangiacrapa 2022-08-08 12:18:38 +02:00
parent 8dec1aa19d
commit 41e3dc28d9
5 changed files with 68 additions and 25 deletions

View File

@ -354,7 +354,7 @@ public class ConvertToDataValueObjectModel {
if (project == null)
return null;
LOG.info("toProjectDV called for project id=%s with ", project.getId(), projectReader);
LOG.info("toProjectDV called for project id: {}, with {}", project.getId(), projectReader);
if (LOG.isTraceEnabled())
LOG.trace("Source project is: " + project);
@ -363,8 +363,8 @@ public class ConvertToDataValueObjectModel {
ProjectDV theProject = new ProjectDV();
theProject.setId(project.getId());
theProject.setProfileID(project.getProfileID());
theProject.setProfileVersion(
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
theProject.setProfileVersion(project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
theProject.setVersion(project.getVersion()!=null? project.getVersion().getValue():"");
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(),
projectReader.isIncludeFullDocumentMap()));
@ -395,6 +395,11 @@ public class ConvertToDataValueObjectModel {
theProject.setMapIdentReferenceDV(mapIdentReferenceDV);
}
if (projectReader.isIncludeLifecycleInformation()) {
if (project.getLifecycleInformation() != null)
theProject.setLifecycleInformationDV(toLifecycleInformationDV(project.getLifecycleInformation()));
}
// if (projectReader.isIncludeSpatialReference()) {
// theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
@ -406,11 +411,7 @@ public class ConvertToDataValueObjectModel {
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
// }
// if (projectReader.isIncludeValidationReport()) {
// theProject.setValidationReport(toValidationReport(concessione.getReport()));
// if (theProject.getValidationReport() != null)
// theProject.setValidationStatus(theConcessione.getValidationReport().getStatus());
// }
//
// LOG.info("Returning concessioneDV with id: " + theConcessione.getItemId());

View File

@ -11,7 +11,7 @@ import java.util.List;
*/
public class ProjectDVBuilder {
private boolean validationReport;
private boolean lifecycleInformation;
private boolean spatialReference;
private boolean temporalReference;
private boolean relationships;
@ -26,8 +26,8 @@ public class ProjectDVBuilder {
return new ProjectDVBuilder();
}
public boolean isIncludeValidationReport() {
return validationReport;
public boolean isIncludeLifecycleInformation() {
return lifecycleInformation;
}
public boolean isIncludeSpatialReference() {
@ -50,8 +50,8 @@ public class ProjectDVBuilder {
return fullDocumentMap;
}
public ProjectDVBuilder validationReport(boolean includeValidationReport) {
this.validationReport = includeValidationReport;
public ProjectDVBuilder lifecycleInformation(boolean lifecycleInformation) {
this.lifecycleInformation = lifecycleInformation;
return this;
}
@ -83,8 +83,8 @@ public class ProjectDVBuilder {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ProjectDVBuilder [validationReport=");
builder.append(validationReport);
builder.append("ProjectDVBuilder [lifecycleInformation=");
builder.append(lifecycleInformation);
builder.append(", spatialReference=");
builder.append(spatialReference);
builder.append(", temporalReference=");

View File

@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -130,7 +129,7 @@ public class ProjectsCaller {
}
LOG.info("returning %d {}", listProjects.size(), Project.class.getName());
LOG.info("returning {} project/s", listProjects.size(), Project.class.getName());
return listProjects;
}
@ -236,11 +235,11 @@ public class ProjectsCaller {
orderByFields = new ArrayList<ItemFieldDV>();
}
if (orderByFields.isEmpty()) {
ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false);
LOG.info("Order by is null, adding default: " + orderD);
orderByFields.add(orderD);
}
// if (orderByFields.isEmpty()) {
// ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false);
// LOG.info("Order by is null, adding default: " + orderD);
// orderByFields.add(orderD);
// }
for (ItemFieldDV itemField : orderByFields) {
if (itemField.getJsonFields() != null) {
@ -250,12 +249,22 @@ public class ProjectsCaller {
}
}
Map<String, Object> projection = filter.getProjection();
Document projectionDocument = null;
if(projection!=null) {
projectionDocument = new Document(projection);
}
QueryRequest request = new QueryRequest();
PagedRequest paging = new PagedRequest();
paging.setOffset(offsetIndex);
paging.setLimit(limitIndex);
request.setPaging(paging);
if(projectionDocument!=null) {
request.setProjection(projectionDocument);
}
OrderedRequest ordering = new OrderedRequest();
ordering.setDirection(sDirection);
@ -308,6 +317,7 @@ public class ProjectsCaller {
LOG.info("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
LOG.info("Direction: " + sDirection);
LOG.info("Projection: "+projectionDocument);
LOG.info("Order by Fields: " + orderingFields);
LOG.info("Search for conditions: " + filter.getConditions());
if (query != null) {

View File

@ -2,6 +2,7 @@ package org.gcube.application.geoportalcommon.shared;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
@ -87,12 +88,23 @@ public class SearchingFilter implements Serializable {
private List<WhereClause> conditions;
private Map<String, Object> projection;
/**
* Instantiates a new sort filter.
*/
public SearchingFilter() {
}
private void addProjectionBaseInfo(){
if(projection!=null) {
// projection.put("_id", 1);
projection.put("_profileID", 1);
projection.put("_profileVersion", 1);
projection.put("_version", 1);
}
}
/**
* Instantiates a new sort filter.
@ -126,6 +138,15 @@ public class SearchingFilter implements Serializable {
this.conditions = conditions;
}
public void setProjection(Map<String, Object> projection) {
this.projection = projection;
addProjectionBaseInfo();
}
public Map<String, Object> getProjection() {
return projection;
}
/**
* Gets the order by fields.
*
@ -171,6 +192,8 @@ public class SearchingFilter implements Serializable {
builder.append(order);
builder.append(", conditions=");
builder.append(conditions);
builder.append(", projection=");
builder.append(projection);
builder.append("]");
return builder.toString();
}

View File

@ -18,8 +18,9 @@ public class ProjectDV implements Serializable {
private List<RelationshipDV> relationships;
private DocumentDV theDocument;
//the key is the IdentificationReferenceDV.getType()
// the key is the IdentificationReferenceDV.getType()
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
private LifecycleInformationDV lifecycleInformationDV;
public ProjectDV() {
@ -73,6 +74,10 @@ public class ProjectDV implements Serializable {
this.theDocument = theDocument;
}
public LifecycleInformationDV getLifecycleInformationDV() {
return lifecycleInformationDV;
}
public Map<String, IdentificationReferenceDV> getMapIdentReferenceDV() {
return mapIdentReferenceDV;
}
@ -81,6 +86,10 @@ public class ProjectDV implements Serializable {
this.mapIdentReferenceDV = mapIdentReferenceDV;
}
public void setLifecycleInformationDV(LifecycleInformationDV lifecycleInformationDV) {
this.lifecycleInformationDV = lifecycleInformationDV;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -92,12 +101,12 @@ public class ProjectDV implements Serializable {
builder.append(profileID);
builder.append(", profileVersion=");
builder.append(profileVersion);
builder.append(", relationships=");
builder.append(relationships);
builder.append(", theDocument=");
builder.append(theDocument);
builder.append(", mapIdentReferenceDV=");
builder.append(mapIdentReferenceDV);
builder.append(", lifecycleInformationDV=");
builder.append(lifecycleInformationDV);
builder.append("]");
return builder.toString();
}