diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index 51dd2f1..95bd087 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -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()); diff --git a/src/main/java/org/gcube/application/geoportalcommon/ProjectDVBuilder.java b/src/main/java/org/gcube/application/geoportalcommon/ProjectDVBuilder.java index 06d2147..5ee7551 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ProjectDVBuilder.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ProjectDVBuilder.java @@ -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="); diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java index 620d29a..7fd3f95 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java @@ -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(); } - 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 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) { diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java b/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java index 77b717e..ee0529b 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java @@ -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 conditions; + private Map 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 projection) { + this.projection = projection; + addProjectionBaseInfo(); + } + + public Map 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(); } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ProjectDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ProjectDV.java index 6862c81..2700256 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ProjectDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ProjectDV.java @@ -18,8 +18,9 @@ public class ProjectDV implements Serializable { private List relationships; private DocumentDV theDocument; - //the key is the IdentificationReferenceDV.getType() + // the key is the IdentificationReferenceDV.getType() private Map 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 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(); }