Improved data converter and data model
This commit is contained in:
parent
8dec1aa19d
commit
41e3dc28d9
|
@ -354,7 +354,7 @@ public class ConvertToDataValueObjectModel {
|
||||||
if (project == null)
|
if (project == null)
|
||||||
return 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())
|
if (LOG.isTraceEnabled())
|
||||||
LOG.trace("Source project is: " + project);
|
LOG.trace("Source project is: " + project);
|
||||||
|
|
||||||
|
@ -363,8 +363,8 @@ public class ConvertToDataValueObjectModel {
|
||||||
ProjectDV theProject = new ProjectDV();
|
ProjectDV theProject = new ProjectDV();
|
||||||
theProject.setId(project.getId());
|
theProject.setId(project.getId());
|
||||||
theProject.setProfileID(project.getProfileID());
|
theProject.setProfileID(project.getProfileID());
|
||||||
theProject.setProfileVersion(
|
theProject.setProfileVersion(project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
|
||||||
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
|
theProject.setVersion(project.getVersion()!=null? project.getVersion().getValue():"");
|
||||||
|
|
||||||
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(),
|
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(),
|
||||||
projectReader.isIncludeFullDocumentMap()));
|
projectReader.isIncludeFullDocumentMap()));
|
||||||
|
@ -396,6 +396,11 @@ public class ConvertToDataValueObjectModel {
|
||||||
theProject.setMapIdentReferenceDV(mapIdentReferenceDV);
|
theProject.setMapIdentReferenceDV(mapIdentReferenceDV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (projectReader.isIncludeLifecycleInformation()) {
|
||||||
|
if (project.getLifecycleInformation() != null)
|
||||||
|
theProject.setLifecycleInformationDV(toLifecycleInformationDV(project.getLifecycleInformation()));
|
||||||
|
}
|
||||||
|
|
||||||
// if (projectReader.isIncludeSpatialReference()) {
|
// if (projectReader.isIncludeSpatialReference()) {
|
||||||
// theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
|
// theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
|
||||||
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
||||||
|
@ -406,11 +411,7 @@ public class ConvertToDataValueObjectModel {
|
||||||
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
// 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());
|
// LOG.info("Returning concessioneDV with id: " + theConcessione.getItemId());
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class ProjectDVBuilder {
|
public class ProjectDVBuilder {
|
||||||
|
|
||||||
private boolean validationReport;
|
private boolean lifecycleInformation;
|
||||||
private boolean spatialReference;
|
private boolean spatialReference;
|
||||||
private boolean temporalReference;
|
private boolean temporalReference;
|
||||||
private boolean relationships;
|
private boolean relationships;
|
||||||
|
@ -26,8 +26,8 @@ public class ProjectDVBuilder {
|
||||||
return new ProjectDVBuilder();
|
return new ProjectDVBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeValidationReport() {
|
public boolean isIncludeLifecycleInformation() {
|
||||||
return validationReport;
|
return lifecycleInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeSpatialReference() {
|
public boolean isIncludeSpatialReference() {
|
||||||
|
@ -50,8 +50,8 @@ public class ProjectDVBuilder {
|
||||||
return fullDocumentMap;
|
return fullDocumentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectDVBuilder validationReport(boolean includeValidationReport) {
|
public ProjectDVBuilder lifecycleInformation(boolean lifecycleInformation) {
|
||||||
this.validationReport = includeValidationReport;
|
this.lifecycleInformation = lifecycleInformation;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ public class ProjectDVBuilder {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("ProjectDVBuilder [validationReport=");
|
builder.append("ProjectDVBuilder [lifecycleInformation=");
|
||||||
builder.append(validationReport);
|
builder.append(lifecycleInformation);
|
||||||
builder.append(", spatialReference=");
|
builder.append(", spatialReference=");
|
||||||
builder.append(spatialReference);
|
builder.append(spatialReference);
|
||||||
builder.append(", temporalReference=");
|
builder.append(", temporalReference=");
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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;
|
return listProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,11 +235,11 @@ public class ProjectsCaller {
|
||||||
orderByFields = new ArrayList<ItemFieldDV>();
|
orderByFields = new ArrayList<ItemFieldDV>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderByFields.isEmpty()) {
|
// if (orderByFields.isEmpty()) {
|
||||||
ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false);
|
// ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false);
|
||||||
LOG.info("Order by is null, adding default: " + orderD);
|
// LOG.info("Order by is null, adding default: " + orderD);
|
||||||
orderByFields.add(orderD);
|
// orderByFields.add(orderD);
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (ItemFieldDV itemField : orderByFields) {
|
for (ItemFieldDV itemField : orderByFields) {
|
||||||
if (itemField.getJsonFields() != null) {
|
if (itemField.getJsonFields() != null) {
|
||||||
|
@ -251,12 +250,22 @@ public class ProjectsCaller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Object> projection = filter.getProjection();
|
||||||
|
Document projectionDocument = null;
|
||||||
|
if(projection!=null) {
|
||||||
|
projectionDocument = new Document(projection);
|
||||||
|
}
|
||||||
|
|
||||||
QueryRequest request = new QueryRequest();
|
QueryRequest request = new QueryRequest();
|
||||||
PagedRequest paging = new PagedRequest();
|
PagedRequest paging = new PagedRequest();
|
||||||
paging.setOffset(offsetIndex);
|
paging.setOffset(offsetIndex);
|
||||||
paging.setLimit(limitIndex);
|
paging.setLimit(limitIndex);
|
||||||
request.setPaging(paging);
|
request.setPaging(paging);
|
||||||
|
|
||||||
|
if(projectionDocument!=null) {
|
||||||
|
request.setProjection(projectionDocument);
|
||||||
|
}
|
||||||
|
|
||||||
OrderedRequest ordering = new OrderedRequest();
|
OrderedRequest ordering = new OrderedRequest();
|
||||||
ordering.setDirection(sDirection);
|
ordering.setDirection(sDirection);
|
||||||
ordering.setFields(orderingFields);
|
ordering.setFields(orderingFields);
|
||||||
|
@ -308,6 +317,7 @@ public class ProjectsCaller {
|
||||||
|
|
||||||
LOG.info("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
|
LOG.info("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
|
||||||
LOG.info("Direction: " + sDirection);
|
LOG.info("Direction: " + sDirection);
|
||||||
|
LOG.info("Projection: "+projectionDocument);
|
||||||
LOG.info("Order by Fields: " + orderingFields);
|
LOG.info("Order by Fields: " + orderingFields);
|
||||||
LOG.info("Search for conditions: " + filter.getConditions());
|
LOG.info("Search for conditions: " + filter.getConditions());
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.application.geoportalcommon.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||||
|
|
||||||
|
@ -87,6 +88,8 @@ public class SearchingFilter implements Serializable {
|
||||||
|
|
||||||
private List<WhereClause> conditions;
|
private List<WhereClause> conditions;
|
||||||
|
|
||||||
|
private Map<String, Object> projection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new sort filter.
|
* Instantiates a new sort filter.
|
||||||
*/
|
*/
|
||||||
|
@ -94,6 +97,15 @@ public class SearchingFilter implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Instantiates a new sort filter.
|
||||||
*
|
*
|
||||||
|
@ -126,6 +138,15 @@ public class SearchingFilter implements Serializable {
|
||||||
this.conditions = conditions;
|
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.
|
* Gets the order by fields.
|
||||||
*
|
*
|
||||||
|
@ -171,6 +192,8 @@ public class SearchingFilter implements Serializable {
|
||||||
builder.append(order);
|
builder.append(order);
|
||||||
builder.append(", conditions=");
|
builder.append(", conditions=");
|
||||||
builder.append(conditions);
|
builder.append(conditions);
|
||||||
|
builder.append(", projection=");
|
||||||
|
builder.append(projection);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class ProjectDV implements Serializable {
|
||||||
|
|
||||||
// the key is the IdentificationReferenceDV.getType()
|
// the key is the IdentificationReferenceDV.getType()
|
||||||
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
|
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
|
||||||
|
private LifecycleInformationDV lifecycleInformationDV;
|
||||||
|
|
||||||
public ProjectDV() {
|
public ProjectDV() {
|
||||||
|
|
||||||
|
@ -73,6 +74,10 @@ public class ProjectDV implements Serializable {
|
||||||
this.theDocument = theDocument;
|
this.theDocument = theDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LifecycleInformationDV getLifecycleInformationDV() {
|
||||||
|
return lifecycleInformationDV;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, IdentificationReferenceDV> getMapIdentReferenceDV() {
|
public Map<String, IdentificationReferenceDV> getMapIdentReferenceDV() {
|
||||||
return mapIdentReferenceDV;
|
return mapIdentReferenceDV;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +86,10 @@ public class ProjectDV implements Serializable {
|
||||||
this.mapIdentReferenceDV = mapIdentReferenceDV;
|
this.mapIdentReferenceDV = mapIdentReferenceDV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLifecycleInformationDV(LifecycleInformationDV lifecycleInformationDV) {
|
||||||
|
this.lifecycleInformationDV = lifecycleInformationDV;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -92,12 +101,12 @@ public class ProjectDV implements Serializable {
|
||||||
builder.append(profileID);
|
builder.append(profileID);
|
||||||
builder.append(", profileVersion=");
|
builder.append(", profileVersion=");
|
||||||
builder.append(profileVersion);
|
builder.append(profileVersion);
|
||||||
builder.append(", relationships=");
|
|
||||||
builder.append(relationships);
|
|
||||||
builder.append(", theDocument=");
|
builder.append(", theDocument=");
|
||||||
builder.append(theDocument);
|
builder.append(theDocument);
|
||||||
builder.append(", mapIdentReferenceDV=");
|
builder.append(", mapIdentReferenceDV=");
|
||||||
builder.append(mapIdentReferenceDV);
|
builder.append(mapIdentReferenceDV);
|
||||||
|
builder.append(", lifecycleInformationDV=");
|
||||||
|
builder.append(lifecycleInformationDV);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue