added new data view models
This commit is contained in:
parent
0d2fddce07
commit
5c8c2a342d
|
@ -1,8 +1,11 @@
|
||||||
package org.gcube.application.geoportalcommon;
|
package org.gcube.application.geoportalcommon;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
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.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -10,6 +13,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.geoportal.common.model.document.Project;
|
import org.gcube.application.geoportal.common.model.document.Project;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo;
|
||||||
import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference;
|
import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference;
|
||||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||||
|
@ -20,12 +26,17 @@ import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.config.ItemField;
|
import org.gcube.application.geoportalcommon.geoportal.config.ItemField;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.AccessDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.AccountingInfoDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferenceDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferenceDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||||
|
@ -45,6 +56,13 @@ public class ConvertToDataValueObjectModel {
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(ConvertToDataValueObjectModel.class);
|
private static Logger LOG = LoggerFactory.getLogger(ConvertToDataValueObjectModel.class);
|
||||||
|
|
||||||
|
private static final String NO_TIME = "T00:00";
|
||||||
|
|
||||||
|
public static final String DATE_FORMAT = "dd-MM-yyyy";
|
||||||
|
|
||||||
|
public static final String HOURS_MINUTES_SEPARATOR = ":";
|
||||||
|
|
||||||
|
public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm";
|
||||||
/**
|
/**
|
||||||
* To use case descriptor DV.
|
* To use case descriptor DV.
|
||||||
*
|
*
|
||||||
|
@ -348,7 +366,7 @@ public class ConvertToDataValueObjectModel {
|
||||||
* @return the project DV
|
* @return the project DV
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static ProjectDV toProjectDV(Project project, ProjectDVBuilder projectReader) throws Exception {
|
public static ProjectDV toProjectDV(Project project, ProjectDVBuilder projectReader) {
|
||||||
LOG.info("toProjectDV called");
|
LOG.info("toProjectDV called");
|
||||||
|
|
||||||
if (project == null)
|
if (project == null)
|
||||||
|
@ -363,11 +381,12 @@ 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(project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
|
theProject.setProfileVersion(
|
||||||
theProject.setVersion(project.getVersion()!=null? project.getVersion().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.isIncludeFullDocumentMap()));
|
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
||||||
|
|
||||||
List<Relationship> relations = project.getRelationships();
|
List<Relationship> relations = project.getRelationships();
|
||||||
|
|
||||||
|
@ -382,13 +401,14 @@ public class ConvertToDataValueObjectModel {
|
||||||
|
|
||||||
List<IdentificationReference> identificationReferences = project.getIdentificationReferences();
|
List<IdentificationReference> identificationReferences = project.getIdentificationReferences();
|
||||||
|
|
||||||
if(identificationReferences!=null) {
|
if (identificationReferences != null) {
|
||||||
|
|
||||||
Map<String, IdentificationReferenceDV> mapIdentReferenceDV = new HashMap<String, IdentificationReferenceDV>(identificationReferences.size());
|
Map<String, IdentificationReferenceDV> mapIdentReferenceDV = new HashMap<String, IdentificationReferenceDV>(
|
||||||
|
identificationReferences.size());
|
||||||
|
|
||||||
for (IdentificationReference identificationReference : identificationReferences) {
|
for (IdentificationReference identificationReference : identificationReferences) {
|
||||||
IdentificationReferenceDV idv = toIdentificationReferenceDV(identificationReference, projectReader.getListDocumentKeys(),
|
IdentificationReferenceDV idv = toIdentificationReferenceDV(identificationReference,
|
||||||
projectReader.isIncludeFullDocumentMap());
|
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap());
|
||||||
|
|
||||||
mapIdentReferenceDV.put(idv.getType(), idv);
|
mapIdentReferenceDV.put(idv.getType(), idv);
|
||||||
}
|
}
|
||||||
|
@ -411,8 +431,6 @@ public class ConvertToDataValueObjectModel {
|
||||||
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// LOG.info("Returning concessioneDV with id: " + theConcessione.getItemId());
|
// LOG.info("Returning concessioneDV with id: " + theConcessione.getItemId());
|
||||||
//
|
//
|
||||||
|
@ -428,6 +446,91 @@ public class ConvertToDataValueObjectModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To result document DV.
|
||||||
|
*
|
||||||
|
* @param project the project
|
||||||
|
* @return the result document DV
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static ResultDocumentDV toResultDocumentDV(Project project) {
|
||||||
|
LOG.info("toResultDocumentDV called");
|
||||||
|
|
||||||
|
if (project == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
LOG.info("toResultDocumentDV called for project id: {}", project.getId());
|
||||||
|
if (LOG.isTraceEnabled())
|
||||||
|
LOG.trace("Source project is: " + project);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
ResultDocumentDV rd = (ResultDocumentDV) toDocumentDV(project.getTheDocument(), ResultDocumentDV.class,
|
||||||
|
null, true);
|
||||||
|
rd.setId(project.getId());
|
||||||
|
rd.setProfileID(project.getProfileID());
|
||||||
|
|
||||||
|
rd.setPublicationInfo(toPublicationInfoDV(project.getInfo()));
|
||||||
|
|
||||||
|
if (project.getLifecycleInformation() != null) {
|
||||||
|
BasicLifecycleInformationDV bld = new BasicLifecycleInformationDV();
|
||||||
|
bld.setPhase(project.getLifecycleInformation().getPhase());
|
||||||
|
bld.setLastOperationStatus(
|
||||||
|
toLifecycleInformationDVStatus(project.getLifecycleInformation().getLastOperationStatus()));
|
||||||
|
rd.setLifecycleInfo(bld);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Returning: " + rd);
|
||||||
|
|
||||||
|
LOG.info("Returning " + ResultDocumentDV.class.getSimpleName() + " with id: " + rd.getId());
|
||||||
|
return rd;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error on converting " + ResultDocumentDV.class.getSimpleName() + ": " + project, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PublicationInfoDV toPublicationInfoDV(PublicationInfo info) {
|
||||||
|
if (info == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
PublicationInfoDV pidv = new PublicationInfoDV();
|
||||||
|
pidv.setCreationInfo(toAccountingInfoDV(info.getCreationInfo()));
|
||||||
|
pidv.setLastEditInfo(toAccountingInfoDV(info.getLastEditInfo()));
|
||||||
|
pidv.setAccess(toAccessDV(info.getAccess()));
|
||||||
|
|
||||||
|
return pidv;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AccessDV toAccessDV(Access access) {
|
||||||
|
if (access == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
AccessDV acDV = new AccessDV();
|
||||||
|
acDV.setLicense(access.getLicense());
|
||||||
|
acDV.setPolicy(access.getPolicy() != null ? access.getPolicy().name() : null);
|
||||||
|
|
||||||
|
return acDV;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AccountingInfoDV toAccountingInfoDV(AccountingInfo creationInfo) {
|
||||||
|
if (creationInfo == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
AccountingInfoDV aidv = new AccountingInfoDV();
|
||||||
|
aidv.setContext(creationInfo.getContext() != null ? creationInfo.getContext().getId() : null);
|
||||||
|
aidv.setLocalDate(toDateFormatString(creationInfo.getInstant()));
|
||||||
|
if (creationInfo.getUser() != null) {
|
||||||
|
aidv.setRoles(creationInfo.getUser().getRoles());
|
||||||
|
aidv.setUsername(creationInfo.getUser().getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
return aidv;
|
||||||
|
}
|
||||||
|
|
||||||
private static IdentificationReferenceDV toIdentificationReferenceDV(
|
private static IdentificationReferenceDV toIdentificationReferenceDV(
|
||||||
IdentificationReference identificationReference, List<String> listDocumentKeys, boolean getFullMap) {
|
IdentificationReference identificationReference, List<String> listDocumentKeys, boolean getFullMap) {
|
||||||
if (identificationReference == null)
|
if (identificationReference == null)
|
||||||
|
@ -440,6 +543,40 @@ public class ConvertToDataValueObjectModel {
|
||||||
return idv;
|
return idv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To date format string.
|
||||||
|
*
|
||||||
|
* @param dateTime the date time
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String toDateFormatString(LocalDateTime dateTime) {
|
||||||
|
|
||||||
|
if (dateTime == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
String time = dateTime.toString();
|
||||||
|
DateTimeFormatter formatter = null;
|
||||||
|
try {
|
||||||
|
if (!time.endsWith(NO_TIME)) {
|
||||||
|
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
|
||||||
|
} else {
|
||||||
|
time = time.replace(NO_TIME, "");
|
||||||
|
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Parsing error: ", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (formatter != null)
|
||||||
|
return dateTime.format(formatter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Date format error: ", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateTime.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * To temporal reference DV.
|
// * To temporal reference DV.
|
||||||
// *
|
// *
|
||||||
|
@ -565,6 +702,51 @@ public class ConvertToDataValueObjectModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To list project.
|
||||||
|
*
|
||||||
|
* @param projects the projects
|
||||||
|
* @param projectBuilder the project builder
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public static List<ProjectDV> toListProject(Iterator<Project> projects, ProjectDVBuilder projectBuilder) {
|
||||||
|
List<ProjectDV> toReturnList = new ArrayList<ProjectDV>();
|
||||||
|
int i = 0;
|
||||||
|
while (projects.hasNext()) {
|
||||||
|
Project project = projects.next();
|
||||||
|
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||||
|
toReturnList.add(projectDV);
|
||||||
|
i++;
|
||||||
|
LOG.trace(i + ") converted: " + projectDV);
|
||||||
|
}
|
||||||
|
LOG.debug("read " + toReturnList + " project/s");
|
||||||
|
|
||||||
|
return toReturnList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To list result document.
|
||||||
|
*
|
||||||
|
* @param projects the projects
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public static List<ResultDocumentDV> toListResultDocument(Iterator<Project> projects) {
|
||||||
|
List<ResultDocumentDV> toReturnList = new ArrayList<ResultDocumentDV>();
|
||||||
|
int i = 0;
|
||||||
|
while (projects.hasNext()) {
|
||||||
|
Project project = projects.next();
|
||||||
|
ResultDocumentDV resultDV = ConvertToDataValueObjectModel.toResultDocumentDV(project);
|
||||||
|
toReturnList.add(resultDV);
|
||||||
|
i++;
|
||||||
|
LOG.trace(i + ") converted: " + resultDV);
|
||||||
|
}
|
||||||
|
LOG.debug("read " + toReturnList + " project/s");
|
||||||
|
|
||||||
|
return toReturnList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To JSON.
|
* To JSON.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package org.gcube.application.geoportalcommon;
|
package org.gcube.application.geoportalcommon;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -330,39 +328,7 @@ public class ConvertToDataViewModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To date format string.
|
|
||||||
*
|
|
||||||
* @param dateTime the date time
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
public static String toDateFormatString(LocalDateTime dateTime) {
|
|
||||||
|
|
||||||
if (dateTime == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
String time = dateTime.toString();
|
|
||||||
DateTimeFormatter formatter = null;
|
|
||||||
try {
|
|
||||||
if (!time.endsWith(NO_TIME)) {
|
|
||||||
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
|
|
||||||
} else {
|
|
||||||
time = time.replace(NO_TIME, "");
|
|
||||||
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("Parsing error: ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (formatter != null)
|
|
||||||
return dateTime.format(formatter);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("Date format error: ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dateTime.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To abstract relazione scavo.
|
* To abstract relazione scavo.
|
||||||
|
|
|
@ -26,16 +26,12 @@ import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||||
import org.gcube.application.geoportal.common.rest.Projects;
|
import org.gcube.application.geoportal.common.rest.Projects;
|
||||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
|
||||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -237,6 +233,13 @@ public class ProjectsCaller {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the phases.
|
||||||
|
*
|
||||||
|
* @param profileID the profile ID
|
||||||
|
* @return the phases
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
public PhaseDV[] getPhases(String profileID) throws Exception {
|
public PhaseDV[] getPhases(String profileID) throws Exception {
|
||||||
LOG.info("getPhases called for profileID: {}", profileID);
|
LOG.info("getPhases called for profileID: {}", profileID);
|
||||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||||
|
@ -264,6 +267,7 @@ public class ProjectsCaller {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query on mongo.
|
* Query on mongo.
|
||||||
*
|
*
|
||||||
|
@ -272,12 +276,11 @@ public class ProjectsCaller {
|
||||||
* @param offset the offset
|
* @param offset the offset
|
||||||
* @param limit the limit
|
* @param limit the limit
|
||||||
* @param filter the filter
|
* @param filter the filter
|
||||||
* @param projectDVBuilder the project DV builder
|
* @return the iterator
|
||||||
* @return the result set paginated data
|
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public ResultSetPaginatedData queryOnMongo(String profileID, Integer totalItems, Integer offset, Integer limit,
|
public Iterator<Project> queryOnMongo(String profileID, Integer totalItems, Integer offset, Integer limit,
|
||||||
SearchingFilter filter, ProjectDVBuilder projectDVBuilder) throws Exception {
|
SearchingFilter filter) throws Exception {
|
||||||
LOG.info("queryOnMongo called");
|
LOG.info("queryOnMongo called");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -301,10 +304,6 @@ public class ProjectsCaller {
|
||||||
limitIndex = totalItems;
|
limitIndex = totalItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(offsetIndex, limitIndex, false);
|
|
||||||
searchedData.setTotalItems(totalItems);
|
|
||||||
|
|
||||||
List<ProjectDV> toReturnList = new ArrayList<ProjectDV>();
|
|
||||||
Direction sDirection = null;
|
Direction sDirection = null;
|
||||||
List<String> orderingFields = new ArrayList<String>();
|
List<String> orderingFields = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -430,6 +429,10 @@ public class ProjectsCaller {
|
||||||
bsValid_Document.append("$ne", null);
|
bsValid_Document.append("$ne", null);
|
||||||
query.append("_theDocument", bsValid_Document);
|
query.append("_theDocument", bsValid_Document);
|
||||||
|
|
||||||
|
BasicDBObject bsValidLfc = new BasicDBObject();
|
||||||
|
bsValidLfc.append("$ne", null);
|
||||||
|
query.append("_lifecycleInformation._phase", bsValidLfc);
|
||||||
|
|
||||||
BasicDBObject bsDocumentExists = new BasicDBObject();
|
BasicDBObject bsDocumentExists = new BasicDBObject();
|
||||||
bsDocumentExists.append("$exists", false);
|
bsDocumentExists.append("$exists", false);
|
||||||
query.append("theDocument", bsDocumentExists);
|
query.append("theDocument", bsDocumentExists);
|
||||||
|
@ -449,35 +452,35 @@ public class ProjectsCaller {
|
||||||
LOG.info("Search query to JSON: " + query.toJson());
|
LOG.info("Search query to JSON: " + query.toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Project> projects = geoportalClient.query(request);
|
return geoportalClient.query(request);
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
while (projects.hasNext()) {
|
// while (projects.hasNext()) {
|
||||||
Project project = projects.next();
|
// Project project = projects.next();
|
||||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectDVBuilder);
|
// ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectDVBuilder);
|
||||||
toReturnList.add(projectDV);
|
// toReturnList.add(projectDV);
|
||||||
i++;
|
// i++;
|
||||||
LOG.trace(i + ") converted: " + projectDV);
|
// LOG.trace(i + ") converted: " + projectDV);
|
||||||
}
|
// }
|
||||||
LOG.debug("read " + toReturnList + " project/s");
|
// LOG.debug("read " + toReturnList + " project/s");
|
||||||
|
//
|
||||||
searchedData.setData(toReturnList);
|
// searchedData.setData(toReturnList);
|
||||||
|
//
|
||||||
// TODO WORKAROUND MUST BE REMOVE AFTER THE QUERY COUNT
|
// // TODO WORKAROUND MUST BE REMOVE AFTER THE QUERY COUNT
|
||||||
// AND LIST.SIZE WILL BE AVAILABLE IN THE SERVICE
|
// // AND LIST.SIZE WILL BE AVAILABLE IN THE SERVICE
|
||||||
if (filter.getConditions() != null) {
|
// if (filter.getConditions() != null) {
|
||||||
searchedData.setTotalItems(toReturnList.size());
|
// searchedData.setTotalItems(toReturnList.size());
|
||||||
totalItems = toReturnList.size();
|
// totalItems = toReturnList.size();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (totalItems == limit || totalItems == 0) {
|
// if (totalItems == limit || totalItems == 0) {
|
||||||
LOG.debug("Page completed returning " + totalItems + " items");
|
// LOG.debug("Page completed returning " + totalItems + " items");
|
||||||
int newOffset = offsetIndex + limitIndex;
|
// int newOffset = offsetIndex + limitIndex;
|
||||||
searchedData.setServerSearchFinished(newOffset > totalItems || totalItems == 0);
|
// searchedData.setServerSearchFinished(newOffset > totalItems || totalItems == 0);
|
||||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
// LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return searchedData;
|
// return searchedData;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on loading paginated and filtered list of Project: ", e);
|
LOG.error("Error on loading paginated and filtered list of Project: ", e);
|
||||||
|
|
|
@ -6,7 +6,8 @@ package org.gcube.application.geoportalcommon.shared;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ResultSetPaginatedData.
|
* The Class ResultSetPaginatedData.
|
||||||
|
@ -21,7 +22,7 @@ public class ResultSetPaginatedData implements Serializable {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6800997954077785719L;
|
private static final long serialVersionUID = 6800997954077785719L;
|
||||||
private List<ProjectDV> data;
|
private List<? extends DocumentDV> data;
|
||||||
private int offset = 0;
|
private int offset = 0;
|
||||||
private int limit;
|
private int limit;
|
||||||
private boolean isServerSearchFinished = false;
|
private boolean isServerSearchFinished = false;
|
||||||
|
@ -52,7 +53,7 @@ public class ResultSetPaginatedData implements Serializable {
|
||||||
*
|
*
|
||||||
* @return the data
|
* @return the data
|
||||||
*/
|
*/
|
||||||
public List<ProjectDV> getData() {
|
public List<? extends DocumentDV> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ public class ResultSetPaginatedData implements Serializable {
|
||||||
*
|
*
|
||||||
* @param data the new data
|
* @param data the new data
|
||||||
*/
|
*/
|
||||||
public void setData(List<ProjectDV> data) {
|
public void setData(List<ResultDocumentDV> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.gcube.application.geoportalcommon.shared;
|
package org.gcube.application.geoportalcommon.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +90,7 @@ public class SearchingFilter implements Serializable {
|
||||||
|
|
||||||
private List<WhereClause> conditions;
|
private List<WhereClause> conditions;
|
||||||
|
|
||||||
private Map<String, Object> projection;
|
private LinkedHashMap<String, Object> projection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new sort filter.
|
* Instantiates a new sort filter.
|
||||||
|
@ -97,12 +99,17 @@ public class SearchingFilter implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProjectionBaseInfo(){
|
private void addProjectionBaseInfo(Class<? extends DocumentDV> theClass) {
|
||||||
if(projection!=null) {
|
|
||||||
// projection.put("_id", 1);
|
if (projection != null) {
|
||||||
projection.put("_profileID", 1);
|
projection.put("_profileID", 1);
|
||||||
projection.put("_profileVersion", 1);
|
projection.put("_profileVersion", 1);
|
||||||
projection.put("_version", 1);
|
projection.put("_version", 1);
|
||||||
|
if (theClass.isAssignableFrom(ResultDocumentDV.class)) {
|
||||||
|
projection.put("_lifecycleInformation", 1);
|
||||||
|
projection.put("_info", 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,12 +145,12 @@ public class SearchingFilter implements Serializable {
|
||||||
this.conditions = conditions;
|
this.conditions = conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjection(Map<String, Object> projection) {
|
public void setProjection(LinkedHashMap<String, Object> projection, Class<? extends DocumentDV> theClass) {
|
||||||
this.projection = projection;
|
this.projection = projection;
|
||||||
addProjectionBaseInfo();
|
addProjectionBaseInfo(theClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getProjection() {
|
public LinkedHashMap<String, Object> getProjection() {
|
||||||
return projection;
|
return projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package org.gcube.application.geoportalcommon.shared.geoportal;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
|
|
||||||
public class ExtendedDocumentDV extends DocumentDV {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -7209592503036632772L;
|
|
||||||
|
|
||||||
public ExtendedDocumentDV() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addItemToMap(String property, Object value) {
|
|
||||||
|
|
||||||
if (documentAsMap == null)
|
|
||||||
documentAsMap = new LinkedHashMap<String, Object>();
|
|
||||||
|
|
||||||
documentAsMap.put(property, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("ExtendedDocumentDV [toString()=");
|
|
||||||
builder.append(super.toString());
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
package org.gcube.application.geoportalcommon.shared.geoportal;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
|
||||||
|
|
||||||
|
public class ResultDocumentDV extends DocumentDV implements Serializable{
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String profileID;
|
||||||
|
private BasicLifecycleInformationDV lifecycleInfo;
|
||||||
|
private PublicationInfoDV publicationInfoDV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -7209592503036632772L;
|
||||||
|
|
||||||
|
public ResultDocumentDV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileID() {
|
||||||
|
return profileID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfileID(String profileID) {
|
||||||
|
this.profileID = profileID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItemToMap(String property, Object value) {
|
||||||
|
|
||||||
|
if (documentAsMap == null)
|
||||||
|
documentAsMap = new LinkedHashMap<String, Object>();
|
||||||
|
|
||||||
|
documentAsMap.put(property, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BasicLifecycleInformationDV getLifecycleInfo() {
|
||||||
|
return lifecycleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLifecycleInfo(BasicLifecycleInformationDV lifecycleInfo) {
|
||||||
|
this.lifecycleInfo = lifecycleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationInfo(PublicationInfoDV publicationInfoDV) {
|
||||||
|
this.publicationInfoDV = publicationInfoDV;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationInfoDV getPublicationInfoDV() {
|
||||||
|
return publicationInfoDV;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("ResultDocumentDV [id=");
|
||||||
|
builder.append(id);
|
||||||
|
builder.append(", profileID=");
|
||||||
|
builder.append(profileID);
|
||||||
|
builder.append(", lifecycleInfo=");
|
||||||
|
builder.append(lifecycleInfo);
|
||||||
|
builder.append(", publicationInfoDV=");
|
||||||
|
builder.append(publicationInfoDV);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class AccessDV.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Aug 10, 2022
|
||||||
|
*/
|
||||||
|
public class AccessDV implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -8017931037814730958L;
|
||||||
|
|
||||||
|
private String policy;
|
||||||
|
|
||||||
|
private String license;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new access DV.
|
||||||
|
*/
|
||||||
|
public AccessDV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the policy.
|
||||||
|
*
|
||||||
|
* @return the policy
|
||||||
|
*/
|
||||||
|
public String getPolicy() {
|
||||||
|
return policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the license.
|
||||||
|
*
|
||||||
|
* @return the license
|
||||||
|
*/
|
||||||
|
public String getLicense() {
|
||||||
|
return license;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the policy.
|
||||||
|
*
|
||||||
|
* @param policy the new policy
|
||||||
|
*/
|
||||||
|
public void setPolicy(String policy) {
|
||||||
|
this.policy = policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the license.
|
||||||
|
*
|
||||||
|
* @param license the new license
|
||||||
|
*/
|
||||||
|
public void setLicense(String license) {
|
||||||
|
this.license = license;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("AccessDV [policy=");
|
||||||
|
builder.append(policy);
|
||||||
|
builder.append(", license=");
|
||||||
|
builder.append(license);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class AccountingInfoDV.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Aug 10, 2022
|
||||||
|
*/
|
||||||
|
public class AccountingInfoDV implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -5676731760855130687L;
|
||||||
|
private String username;
|
||||||
|
private Set<String> roles;
|
||||||
|
private String context;
|
||||||
|
private String localDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new accounting info DV.
|
||||||
|
*/
|
||||||
|
public AccountingInfoDV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username.
|
||||||
|
*
|
||||||
|
* @return the username
|
||||||
|
*/
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the roles.
|
||||||
|
*
|
||||||
|
* @return the roles
|
||||||
|
*/
|
||||||
|
public Set<String> getRoles() {
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the context.
|
||||||
|
*
|
||||||
|
* @return the context
|
||||||
|
*/
|
||||||
|
public String getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the username.
|
||||||
|
*
|
||||||
|
* @param username the new username
|
||||||
|
*/
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the roles.
|
||||||
|
*
|
||||||
|
* @param roles the new roles
|
||||||
|
*/
|
||||||
|
public void setRoles(Set<String> roles) {
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the context.
|
||||||
|
*
|
||||||
|
* @param context the new context
|
||||||
|
*/
|
||||||
|
public void setContext(String context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalDate() {
|
||||||
|
return localDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalDate(String localDate) {
|
||||||
|
this.localDate = localDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("AccountingInfoDV [username=");
|
||||||
|
builder.append(username);
|
||||||
|
builder.append(", roles=");
|
||||||
|
builder.append(roles);
|
||||||
|
builder.append(", context=");
|
||||||
|
builder.append(context);
|
||||||
|
builder.append(", localDate=");
|
||||||
|
builder.append(localDate);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class BasicLifecycleInformationDV.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Aug 10, 2022
|
||||||
|
*/
|
||||||
|
public class BasicLifecycleInformationDV implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 2301238401365921132L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum Status.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Mar 21, 2022
|
||||||
|
*/
|
||||||
|
public static enum Status {
|
||||||
|
OK("Success"), ERROR("Error"), WARNING("Warning"), NOT_SPECIFIED("Not specified");
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new status.
|
||||||
|
*
|
||||||
|
* @param label the label
|
||||||
|
*/
|
||||||
|
private Status(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the label.
|
||||||
|
*
|
||||||
|
* @return the label
|
||||||
|
*/
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String phase;
|
||||||
|
protected Status lastOperationStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new basic lifecycle information DV.
|
||||||
|
*/
|
||||||
|
public BasicLifecycleInformationDV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the phase.
|
||||||
|
*
|
||||||
|
* @return the phase
|
||||||
|
*/
|
||||||
|
public String getPhase() {
|
||||||
|
return phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the last operation status.
|
||||||
|
*
|
||||||
|
* @return the last operation status
|
||||||
|
*/
|
||||||
|
public Status getLastOperationStatus() {
|
||||||
|
return lastOperationStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the phase.
|
||||||
|
*
|
||||||
|
* @param phase the new phase
|
||||||
|
*/
|
||||||
|
public void setPhase(String phase) {
|
||||||
|
this.phase = phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the last operation status.
|
||||||
|
*
|
||||||
|
* @param lastOperationStatus the new last operation status
|
||||||
|
*/
|
||||||
|
public void setLastOperationStatus(Status lastOperationStatus) {
|
||||||
|
this.lastOperationStatus = lastOperationStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("BasicLifecycleInformationDV [phase=");
|
||||||
|
builder.append(phase);
|
||||||
|
builder.append(", lastOperationStatus=");
|
||||||
|
builder.append(lastOperationStatus);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ public class IdentificationReferenceDV extends DocumentDV implements Serializabl
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -1940104535678320214L;
|
private static final long serialVersionUID = -1940104535678320214L;
|
||||||
|
|
||||||
String type;
|
private String type;
|
||||||
|
|
||||||
public IdentificationReferenceDV() {
|
public IdentificationReferenceDV() {
|
||||||
|
|
||||||
|
@ -25,4 +25,14 @@ public class IdentificationReferenceDV extends DocumentDV implements Serializabl
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("IdentificationReferenceDV [type=");
|
||||||
|
builder.append(type);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,47 +9,13 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* Mar 21, 2022
|
* Mar 21, 2022
|
||||||
*/
|
*/
|
||||||
public class LifecycleInformationDV implements Serializable {
|
public class LifecycleInformationDV extends BasicLifecycleInformationDV {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 453646810523938512L;
|
private static final long serialVersionUID = 3042285563158430778L;
|
||||||
|
|
||||||
/**
|
|
||||||
* The Enum Status.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
||||||
*
|
|
||||||
* Mar 21, 2022
|
|
||||||
*/
|
|
||||||
public static enum Status {
|
|
||||||
OK("Success"), ERROR("Error"), WARNING("Warning"), NOT_SPECIFIED("Not specified");
|
|
||||||
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new status.
|
|
||||||
*
|
|
||||||
* @param label the label
|
|
||||||
*/
|
|
||||||
private Status(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the label.
|
|
||||||
*
|
|
||||||
* @return the label
|
|
||||||
*/
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String phase;
|
|
||||||
private String lastInvokedStep;
|
private String lastInvokedStep;
|
||||||
private Status lastOperationStatus;
|
|
||||||
private List<String> errorMessages;
|
private List<String> errorMessages;
|
||||||
private List<String> warningMessages;
|
private List<String> warningMessages;
|
||||||
private String asJSONString;
|
private String asJSONString;
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class PublicationInfoDV implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -6381578837148417563L;
|
||||||
|
private AccountingInfoDV creationInfo;
|
||||||
|
private AccountingInfoDV lastEditInfo;
|
||||||
|
private AccessDV access;
|
||||||
|
|
||||||
|
public PublicationInfoDV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountingInfoDV getCreationInfo() {
|
||||||
|
return creationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountingInfoDV getLastEditInfo() {
|
||||||
|
return lastEditInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccessDV getAccess() {
|
||||||
|
return access;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreationInfo(AccountingInfoDV creationInfo) {
|
||||||
|
this.creationInfo = creationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastEditInfo(AccountingInfoDV lastEditInfo) {
|
||||||
|
this.lastEditInfo = lastEditInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccess(AccessDV access) {
|
||||||
|
this.access = access;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("PublicationInfoDV [creationInfo=");
|
||||||
|
builder.append(creationInfo);
|
||||||
|
builder.append(", lastEditInfo=");
|
||||||
|
builder.append(lastEditInfo);
|
||||||
|
builder.append(", access=");
|
||||||
|
builder.append(access);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,38 +2,30 @@ package org.gcube.application;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
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 org.bson.BsonDocument;
|
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Archive;
|
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||||
import org.gcube.application.geoportal.common.model.document.Project;
|
import org.gcube.application.geoportal.common.model.document.Project;
|
||||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||||
import org.gcube.application.geoportal.common.rest.Projects;
|
|
||||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
|
||||||
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
|
|
||||||
|
|
||||||
public class Project_Tests {
|
public class Project_Tests {
|
||||||
|
|
||||||
private ProjectsCaller client = null;
|
private ProjectsCaller client = null;
|
||||||
|
@ -53,7 +45,7 @@ public class Project_Tests {
|
||||||
client = GeoportalClientCaller.projects();
|
client = GeoportalClientCaller.projects();
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getList() throws Exception {
|
public void getList() throws Exception {
|
||||||
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||||
|
|
||||||
|
@ -63,7 +55,7 @@ public class Project_Tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getByID() throws Exception {
|
public void getByID() throws Exception {
|
||||||
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
|
@ -71,7 +63,7 @@ public class Project_Tests {
|
||||||
System.out.println(projectDV);
|
System.out.println(projectDV);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getListProjectsDV() throws Exception {
|
public void getListProjectsDV() throws Exception {
|
||||||
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
|
@ -83,24 +75,25 @@ public class Project_Tests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
@Test
|
||||||
public void getListProjectsDVFiltered() throws Exception {
|
public void getListProjectsDVFiltered() throws Exception {
|
||||||
//List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||||
|
|
||||||
SearchingFilter filter = new SearchingFilter();
|
SearchingFilter filter = new SearchingFilter();
|
||||||
|
|
||||||
|
// Where Clause
|
||||||
//Where Clause
|
|
||||||
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
||||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||||
//searchInto.put("_id", "61f0299baf51592c36795f52");
|
// searchInto.put("_id", "61f0299baf51592c36795f52");
|
||||||
//searchInto.put("_theDocument.nome", "Test progetto con clustering di fileset");
|
// searchInto.put("_theDocument.nome", "Test progetto con clustering di
|
||||||
|
// fileset");
|
||||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.AND, searchInto);
|
WhereClause whereClause = new WhereClause(LOGICAL_OP.AND, searchInto);
|
||||||
conditions.add(whereClause);
|
conditions.add(whereClause);
|
||||||
filter.setConditions(conditions);
|
filter.setConditions(conditions);
|
||||||
|
|
||||||
Map<String, Object> projection = new HashMap<String, Object>();
|
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||||
//default
|
// default
|
||||||
|
projection.put("_theDocument.nome", 1);
|
||||||
projection.put("_profileID", 1);
|
projection.put("_profileID", 1);
|
||||||
projection.put("_profileVersion", 1);
|
projection.put("_profileVersion", 1);
|
||||||
projection.put("_version", 1);
|
projection.put("_version", 1);
|
||||||
|
@ -109,25 +102,35 @@ public class Project_Tests {
|
||||||
projection.put("_theDocument.paroleChiaveLibere", 1);
|
projection.put("_theDocument.paroleChiaveLibere", 1);
|
||||||
projection.put("_theDocument.editore", 1);
|
projection.put("_theDocument.editore", 1);
|
||||||
projection.put("_theDocument.paroleChiaveICCD", 1);
|
projection.put("_theDocument.paroleChiaveICCD", 1);
|
||||||
projection.put("_theDocument.nome", 1);
|
|
||||||
projection.put("_theDocument.responsabile", 1);
|
projection.put("_theDocument.responsabile", 1);
|
||||||
projection.put("_theDocument.authors", 1);
|
|
||||||
|
|
||||||
projection.put("_theDocument.nome", 1);
|
|
||||||
projection.put("_theDocument.introduzione", 1);
|
projection.put("_theDocument.introduzione", 1);
|
||||||
projection.put("_theDocument.authors", 1);
|
projection.put("_theDocument.authors", 1);
|
||||||
filter.setProjection(projection);
|
filter.setProjection(projection, ResultDocumentDV.class);
|
||||||
|
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
Integer totalDocs = client.getTotalDocument(PROFILE_ID);
|
||||||
ResultSetPaginatedData results = client.queryOnMongo(PROFILE_ID, 300, 0, 10, filter, projectBuilder);
|
|
||||||
|
Iterator<Project> projects = client.queryOnMongo(PROFILE_ID, totalDocs, 0, 10, filter);
|
||||||
|
|
||||||
|
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ProjectDV projectDV : results.getData()) {
|
for (ResultDocumentDV projectDV : results) {
|
||||||
System.out.println(++i + ") " + projectDV);
|
System.out.println(++i + ") " + projectDV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TEST TO PROJECT DV
|
||||||
|
/*
|
||||||
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
|
|
||||||
|
List<ProjectDV> listProjects = ConvertToDataValueObjectModel.toListProject(projects, projectBuilder);
|
||||||
|
i = 0;
|
||||||
|
for (ProjectDV projectDV : listProjects) {
|
||||||
|
System.out.println(++i + ") " + projectDV);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getLifecycleForProjectId() throws Exception {
|
public void getLifecycleForProjectId() throws Exception {
|
||||||
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||||
LifecycleInformation lci = project.getLifecycleInformation();
|
LifecycleInformation lci = project.getLifecycleInformation();
|
||||||
|
@ -136,19 +139,19 @@ public class Project_Tests {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getConfiguration() throws Exception {
|
public void getConfiguration() throws Exception {
|
||||||
Configuration config = client.getConfiguration(PROFILE_ID);
|
Configuration config = client.getConfiguration(PROFILE_ID);
|
||||||
System.out.println(config);
|
System.out.println(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getTotalDocument() throws Exception {
|
public void getTotalDocument() throws Exception {
|
||||||
|
|
||||||
System.out.println(client.getTotalDocument(PROFILE_ID));
|
System.out.println(client.getTotalDocument(PROFILE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getListPhases() throws Exception {
|
public void getListPhases() throws Exception {
|
||||||
|
|
||||||
List<String> idsPhases = client.getIDsPhases(PROFILE_ID);
|
List<String> idsPhases = client.getIDsPhases(PROFILE_ID);
|
||||||
|
|
Loading…
Reference in New Issue