in progress

This commit is contained in:
Francesco Mangiacrapa 2022-05-20 12:31:39 +02:00
parent eb99899fa4
commit 5e876f32df
10 changed files with 529 additions and 184 deletions

View File

@ -1,7 +1,9 @@
package org.gcube.application.geoportalcommon;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -9,8 +11,9 @@ import java.util.Set;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.Relationship;
import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference;
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.relationships.Relationship;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.geoportal.config.FilePath;
@ -21,14 +24,14 @@ import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.IdentificationReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.TemporalReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV;
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.ItemFieldDV;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,94 +46,6 @@ public class ConvertToDataValueObjectModel {
private static Logger LOG = LoggerFactory.getLogger(ConvertToDataValueObjectModel.class);
/**
* The Enum GEOPORTAL_CONFIGURATION_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 16, 2022
*/
// /**
// * To document config DV.
// *
// * @param dc the dc
// * @return the document config DV
// */
// public static DocumentConfigDV toDocumentConfigDV(DocumentConfig dc) {
// LOG.trace("toDocumentConfigDV called");
//
// if (dc == null) {
// LOG.warn(DocumentConfig.class.getSimpleName() + " is null");
// return null;
// }
//
// DocumentConfigDV dcDV = new DocumentConfigDV();
// dcDV.setId(dc.getId());
// dcDV.setType(dc.getType());
// dcDV.setItemType(dc.getItem_type());
//
// Configuration config = dc.getConfiguration();
// if (config == null) {
// LOG.warn(Configuration.class.getSimpleName() + " is null");
// return null;
// }
//
// List<GcubeProfile> gCubeProfiles = config.getGcubeProfiles();
// if (gCubeProfiles == null) {
// LOG.warn("List of " + GcubeProfile.class.getSimpleName() + " is null");
// return null;
// }
//
// ConfigGcubeProfileDV configGcubeProfile = new ConfigGcubeProfileDV();
// List<GcubeProfileDV> gCubeProfilesVO = new ArrayList<GcubeProfileDV>(gCubeProfiles.size());
// for (GcubeProfile gCubeProfile : gCubeProfiles) {
// gCubeProfilesVO.add(toGcubeProfileDV(gCubeProfile));
// }
// configGcubeProfile.setGcubeProfiles(gCubeProfilesVO);
// dcDV.setConfiguration(configGcubeProfile);
//
// LOG.debug("returning: " + dcDV);
// return dcDV;
// }
// /**
// * To document DV.
// *
// * @param <T> the generic type
// * @param config the config
// * @param type the type
// * @return the document DV
// */
// public static <T> DocumentDV<T> toDocumentDV(Configuration<T> config, Class<T> type) {
// LOG.trace("toDocumentConfigDV called");
//
// if (config == null) {
// LOG.warn(Configuration.class.getSimpleName() + " is null");
// return null;
// }
//
// List<T> listConfigs = config.getListConfigs();
// if (listConfigs == null) {
// LOG.warn("List of Configs is null");
// return null;
// }
//
// DocumentDV<T> doc = null;
// if (type == ConfigGcubeProfileDV.class) {
// doc = (DocumentDV<T>) new DocumentDV<ConfigGcubeProfileDV>();
// ConfigGcubeProfileDV configVO = new ConfigGcubeProfileDV();
// List<GcubeProfileDV> listConfigsDV = new ArrayList<GcubeProfileDV>(listConfigs.size());
// for (GcubeProfile gCubeProfile : listConfigsDV) {
// gCubeProfilesVO.add(toGcubeProfileDV(gCubeProfile));
// }
// configVO.setGcubeProfiles(gCubeProfilesVO);
// doc.setConfiguration(configVO);
// }
// LOG.debug("returning: " + doc);
// return doc;
// }
/**
* To use case descriptor DV.
*
@ -215,11 +130,13 @@ public class ConvertToDataValueObjectModel {
* To handler declaration DV.
*
* @param handlerDeclaration the handler declaration
* @param profileName the profile name
* @param readConfigs the read configs
* @return the handler declaration DV
* @throws Exception the exception
*/
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration, String profileName)
throws Exception {
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration, String profileName,
GEOPORTAL_CONFIGURATION_TYPE... readConfigs) throws Exception {
if (handlerDeclaration == null) {
LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null");
@ -239,26 +156,33 @@ public class ConvertToDataValueObjectModel {
}
try {
if (readConfigs == null || readConfigs.length == 0) {
readConfigs = GEOPORTAL_CONFIGURATION_TYPE.values();
}
GEOPORTAL_CONFIGURATION_TYPE geoportalConfigType = null;
ArrayList<JSONObject> configurations = null;
for (GEOPORTAL_CONFIGURATION_TYPE configManaged : GEOPORTAL_CONFIGURATION_TYPE.values()) {
ArrayList<String> jsonConfigurations = null;
for (GEOPORTAL_CONFIGURATION_TYPE configManaged : readConfigs) {
try {
LOG.debug("searching '" + configManaged.getId() + "' in the configuration " + configuration);
LOG.trace("contains " + configManaged.getId() + ": "
+ configuration.containsKey(configManaged.getId()));
ArrayList<LinkedHashMap<String, Object>> hashMapConfig = configuration.get(configManaged.getId(),
ArrayList.class);
LOG.debug("hashMapConfig found is: {}", hashMapConfig);
ArrayList<LinkedHashMap<String, Object>> listHashMapConfig = configuration
.get(configManaged.getId(), ArrayList.class);
LOG.debug("hashMapConfig found is: {}", listHashMapConfig);
if (hashMapConfig != null) {
if (listHashMapConfig != null) {
configurations = new ArrayList<JSONObject>();
jsonConfigurations = new ArrayList<String>();
for (LinkedHashMap<String, Object> config : hashMapConfig) {
LOG.debug("config is: {}", config.toString());
configurations.add(new JSONObject(config.toString()));
for (LinkedHashMap<String, Object> config : listHashMapConfig) {
Document document = new Document(config);
String jsonValue = document.toJson();
LOG.debug("config is: {}", jsonValue);
jsonConfigurations.add(jsonValue);
}
LOG.debug("configurations found are: {}", configurations);
LOG.debug("configurations found are: {}", jsonConfigurations);
geoportalConfigType = configManaged;
break;
}
@ -268,7 +192,7 @@ public class ConvertToDataValueObjectModel {
}
}
if (configurations == null) {
if (jsonConfigurations == null) {
String error = "No managed configurations as '"
+ Arrays.asList(GEOPORTAL_CONFIGURATION_TYPE.values()).toString() + "' found in the handler "
+ handlerDeclaration.getId();
@ -279,11 +203,10 @@ public class ConvertToDataValueObjectModel {
switch (geoportalConfigType) {
case gcube_profiles: {
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(configurations.size());
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(jsonConfigurations.size());
int i = 0;
for (JSONObject gCubeProfile : configurations) {
String asJSONString = gCubeProfile.toString();
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the gCubeProfile is: " + asJSONString);
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
GcubeProfile.class);
@ -300,11 +223,10 @@ public class ConvertToDataValueObjectModel {
}
case item_fields: {
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(configurations.size());
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(jsonConfigurations.size());
int i = 0;
for (JSONObject itemField : configurations) {
String asJSONString = itemField.toString();
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the itemField is: " + asJSONString);
ItemField profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
ItemField.class);
@ -380,7 +302,7 @@ public class ConvertToDataValueObjectModel {
LOG.trace("toItemFieldDV called");
if (itemField == null) {
LOG.warn(GcubeProfile.class.getSimpleName() + " is null");
LOG.warn(ItemField.class.getSimpleName() + " is null");
return null;
}
@ -413,6 +335,7 @@ public class ConvertToDataValueObjectModel {
FilePathDV fpVO = new FilePathDV();
fpVO.setFieldName(filePath.getFieldName());
fpVO.setFieldDefinition(filePath.getFieldDefinition());
fpVO.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName());
LOG.info("returning: " + fpVO);
return fpVO;
@ -444,13 +367,13 @@ public class ConvertToDataValueObjectModel {
theProject.setProfileVersion(
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class,
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(),
projectReader.isIncludeFullDocumentMap()));
Relationship[] relations = project.getRelationships();
List<Relationship> relations = project.getRelationships();
if (relations != null && projectReader.isIncludeRelationships()) {
List<RelationshipDV> listRelations = new ArrayList<RelationshipDV>(relations.length);
List<RelationshipDV> listRelations = new ArrayList<RelationshipDV>(relations.size());
for (Relationship relationship : relations) {
listRelations.add(toRelationshipDV(relationship));
}
@ -458,15 +381,31 @@ public class ConvertToDataValueObjectModel {
theProject.setRelationships(listRelations);
}
if (projectReader.isIncludeSpatialReference()) {
theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
List<IdentificationReference> identificationReferences = project.getIdentificationReferences();
if(identificationReferences!=null) {
Map<String, IdentificationReferenceDV> mapIdentReferenceDV = new HashMap<String, IdentificationReferenceDV>(identificationReferences.size());
for (IdentificationReference identificationReference : identificationReferences) {
IdentificationReferenceDV idv = toIdentificationReferenceDV(identificationReference, projectReader.getListDocumentKeys(),
projectReader.isIncludeFullDocumentMap());
mapIdentReferenceDV.put(idv.getType(), idv);
}
theProject.setMapIdentReferenceDV(mapIdentReferenceDV);
}
if (projectReader.isIncludeTemporalReference()) {
theProject.setTemporalReference(toTemporalReferenceDV(project.getTemporalReference(),
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
}
// if (projectReader.isIncludeSpatialReference()) {
// theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
// }
//
// if (projectReader.isIncludeTemporalReference()) {
// theProject.setTemporalReference(toTemporalReferenceDV(project.getTemporalReference(),
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
// }
// if (projectReader.isIncludeValidationReport()) {
// theProject.setValidationReport(toValidationReport(concessione.getReport()));
@ -489,25 +428,37 @@ public class ConvertToDataValueObjectModel {
}
/**
* To temporal reference DV.
*
* @param temporalReference the temporal reference
* @param listDocumentKeys the list document keys
* @param getFullMap the get full map
* @return the temporal reference DV
*/
public static TemporalReferenceDV toTemporalReferenceDV(TemporalReference temporalReference,
List<String> listDocumentKeys, boolean getFullMap) {
if (temporalReference == null)
private static IdentificationReferenceDV toIdentificationReferenceDV(
IdentificationReference identificationReference, List<String> listDocumentKeys, boolean getFullMap) {
if (identificationReference == null)
return null;
TemporalReferenceDV trDV = (TemporalReferenceDV) toDocumentDV(temporalReference, TemporalReferenceDV.class,
listDocumentKeys, getFullMap);
trDV.setField(temporalReference.getField());
return trDV;
IdentificationReferenceDV idv = (IdentificationReferenceDV) toDocumentDV(identificationReference,
IdentificationReferenceDV.class, listDocumentKeys, getFullMap);
idv.setType(identificationReference.getType());
return idv;
}
// /**
// * To temporal reference DV.
// *
// * @param temporalReference the temporal reference
// * @param listDocumentKeys the list document keys
// * @param getFullMap the get full map
// * @return the temporal reference DV
// */
// public static TemporalReferenceDV toTemporalReferenceDV(TemporalReference temporalReference,
// List<String> listDocumentKeys, boolean getFullMap) {
// if (temporalReference == null)
// return null;
//
// TemporalReferenceDV trDV = (TemporalReferenceDV) toDocumentDV(temporalReference, TemporalReferenceDV.class,
// listDocumentKeys, getFullMap);
// trDV.setField(temporalReference.getField());
// return trDV;
// }
/**
* To document DV.
*
@ -518,16 +469,26 @@ public class ConvertToDataValueObjectModel {
* @param getFullMap the get full map
* @return the t
*/
public static <T extends DocumentDV> DocumentDV toDocumentDV(Document document, Class<T> toType,
public static <T extends DocumentDV> DocumentDV toDocumentDV(Document document, Class<T> targetClass,
List<String> listDocumentKeys, boolean getFullMap) {
if (document == null)
return null;
T documentDV;
if (toType == TemporalReferenceDV.class) {
documentDV = (T) new TemporalReferenceDV();
} else {
if (targetClass == null)
documentDV = (T) new DocumentDV();
else {
try {
documentDV = targetClass.newInstance();
} catch (InstantiationException e) {
LOG.warn("InstantiationException: " + e.getMessage() + ". Instancing default "
+ DocumentDV.class.getSimpleName());
documentDV = (T) new DocumentDV();
} catch (IllegalAccessException e) {
LOG.warn("IllegalAccessException: " + e.getMessage() + ". Instancing default "
+ DocumentDV.class.getSimpleName());
documentDV = (T) new DocumentDV();
}
}
if (listDocumentKeys != null && !getFullMap) {
@ -566,4 +527,63 @@ public class ConvertToDataValueObjectModel {
return new RelationshipDV(relationship.getRelationshipName(), relationship.getTargetID());
}
/**
* To validation report.
*
* @param validationReport the validation report
* @return the validation report DV
* @throws Exception the exception
*/
public static LifecycleInformationDV toLifecycleInformationDV(LifecycleInformation li) throws Exception {
LOG.info("toLifecycleInformationDV called");
if (li == null)
return null;
LOG.debug("toLifecycleInformationDV called for: " + li);
LifecycleInformationDV liDV = new LifecycleInformationDV();
liDV.setErrorMessages(li.getErrorMessages());
liDV.setLastInvokedStep(li.getLastInvokedStep());
liDV.setLastOperationStatus(toLifecycleInformationDVStatus(li.getLastOperationStatus()));
liDV.setWarningMessages(li.getWarningMessages());
liDV.setAsJSONString(toJSON(li));
LOG.debug("Returning: " + liDV);
return liDV;
}
public static LifecycleInformationDV.Status toLifecycleInformationDVStatus(LifecycleInformation.Status status) {
if (status == null)
return null;
try {
return LifecycleInformationDV.Status.valueOf(status.name());
} catch (Exception e) {
LOG.error("Error on converting " + status, e);
return LifecycleInformationDV.Status.NOT_SPECIFIED;
}
}
/**
* To JSON.
*
* @param theObj the the obj
* @return the string
*/
public static String toJSON(Object theObj) {
LOG.debug("toJSON called");
try {
if (theObj instanceof Serializable) {
return org.gcube.application.geoportal.client.utils.Serialization.write(theObj);
}
throw new Exception("The input object is not serializable");
} catch (Exception e) {
LOG.warn("Error on deserializing: ", e);
return null;
}
}
}

View File

@ -0,0 +1,32 @@
package org.gcube.application.geoportalcommon;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
public class SerializerUtil {
private static ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.registerModule(new JavaTimeModule());
SimpleModule s=new SimpleModule();
mapper.registerModule(s);
}
public static <T> T read(String jsonString,Class<T> clazz) throws JsonProcessingException, IOException {
return mapper.readerFor(clazz).readValue(jsonString);
}
}

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map;
import org.bson.Document;
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
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.rest.QueryRequest;
@ -90,9 +91,10 @@ public class ProjectsCaller {
* @throws RemoteException the remote exception
* @throws FileNotFoundException the file not found exception
* @throws JsonProcessingException the json processing exception
* @throws InvalidRequestException
*/
public Project registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName,
String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException {
String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
LOG.info(
"registerFileSet called with [profileID={}, projectID={}, theFile={}, parentPath={}, fieldName={}, fieldDefinition={}",
parentPath, project.getId(), theFile, parentPath, fieldName, fieldDefinition);

View File

@ -12,6 +12,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FilePath {
@JsonProperty
String gcubeProfileFieldName;
@JsonProperty
String fieldDefinition;
@JsonProperty

View File

@ -1,5 +1,7 @@
//package org.gcube.application.geoportalcommon.geoportal.config;
//
//import java.util.List;
//
//import javax.xml.bind.annotation.XmlRootElement;
//
//import com.fasterxml.jackson.annotation.JsonProperty;
@ -13,15 +15,29 @@
//public class HandlerGcubeProfile {
//
// @JsonProperty
// private String _id;
// private String gcubeSecondaryType;
//
// @JsonProperty
// private String _type;
// private String gcubeName;
//
// @JsonProperty
// private String _item_type;
// private String sectionName;
//
// @JsonProperty
// private ConfigurationGCubeProfile _configuration;
// private String sectionTitle;
//
// @JsonProperty
// private Integer minOccurs;
//
// @JsonProperty
// private Integer maxOccurs;
//
// @JsonProperty
// private String parentName;
//
// @JsonProperty(value = "filePaths")
// private List<FilePath> listFilePaths;
//
//
//
//}

View File

@ -0,0 +1,26 @@
package org.gcube.application.geoportalcommon.shared.geoportal;
import java.io.Serializable;
public class IdentificationReferenceDV extends DocumentDV implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1940104535678320214L;
String type;
public IdentificationReferenceDV() {
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}

View File

@ -0,0 +1,212 @@
package org.gcube.application.geoportalcommon.shared.geoportal;
import java.io.Serializable;
import java.util.List;
/**
* The Class LifecycleInformationDV.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 21, 2022
*/
public class LifecycleInformationDV implements Serializable {
/**
*
*/
private static final long serialVersionUID = 453646810523938512L;
/**
* 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 Status lastOperationStatus;
private List<String> errorMessages;
private List<String> warningMessages;
private String asJSONString;
/**
* Instantiates a new lifecycle information DV.
*/
public LifecycleInformationDV() {
}
/**
* Instantiates a new lifecycle information DV.
*
* @param phase the phase
* @param lastInvokedStep the last invoked step
* @param lastOperationStatus the last operation status
* @param errorMessages the error messages
* @param warningMessages the warning messages
*/
public LifecycleInformationDV(String phase, String lastInvokedStep, Status lastOperationStatus,
List<String> errorMessages, List<String> warningMessages) {
super();
this.phase = phase;
this.lastInvokedStep = lastInvokedStep;
this.lastOperationStatus = lastOperationStatus;
this.errorMessages = errorMessages;
this.warningMessages = warningMessages;
}
/**
* Gets the phase.
*
* @return the phase
*/
public String getPhase() {
return phase;
}
/**
* Gets the last invoked step.
*
* @return the last invoked step
*/
public String getLastInvokedStep() {
return lastInvokedStep;
}
/**
* Gets the last operation status.
*
* @return the last operation status
*/
public Status getLastOperationStatus() {
return lastOperationStatus;
}
/**
* Gets the error messages.
*
* @return the error messages
*/
public List<String> getErrorMessages() {
return errorMessages;
}
/**
* Gets the warning messages.
*
* @return the warning messages
*/
public List<String> getWarningMessages() {
return warningMessages;
}
/**
* Sets the phase.
*
* @param phase the new phase
*/
public void setPhase(String phase) {
this.phase = phase;
}
/**
* Sets the last invoked step.
*
* @param lastInvokedStep the new last invoked step
*/
public void setLastInvokedStep(String lastInvokedStep) {
this.lastInvokedStep = lastInvokedStep;
}
/**
* Sets the last operation status.
*
* @param lastOperationStatus the new last operation status
*/
public void setLastOperationStatus(Status lastOperationStatus) {
this.lastOperationStatus = lastOperationStatus;
}
/**
* Sets the error messages.
*
* @param errorMessages the new error messages
*/
public void setErrorMessages(List<String> errorMessages) {
this.errorMessages = errorMessages;
}
/**
* Sets the warning messages.
*
* @param warningMessages the new warning messages
*/
public void setWarningMessages(List<String> warningMessages) {
this.warningMessages = warningMessages;
}
/**
* Sets the as JSON string.
*
* @param json the new as JSON string
*/
public void setAsJSONString(String json) {
this.asJSONString = json;
}
/**
* Gets the as JSON string.
*
* @return the as JSON string
*/
public String getAsJSONString() {
return asJSONString;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("LifecycleInformationDV [phase=");
builder.append(phase);
builder.append(", lastInvokedStep=");
builder.append(lastInvokedStep);
builder.append(", lastOperationStatus=");
builder.append(lastOperationStatus);
builder.append(", errorMessages=");
builder.append(errorMessages);
builder.append(", warningMessages=");
builder.append(warningMessages);
builder.append(", asJSONString=");
builder.append(asJSONString);
builder.append("]");
return builder.toString();
}
}

View File

@ -2,6 +2,7 @@ package org.gcube.application.geoportalcommon.shared.geoportal;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class ProjectDV implements Serializable {
@ -15,10 +16,11 @@ public class ProjectDV implements Serializable {
private String profileID;
private String profileVersion;
private List<RelationshipDV> relationships;
private DocumentDV spatialReference;
private TemporalReferenceDV temporalReference;
private DocumentDV theDocument;
//the key is the IdentificationReferenceDV.getType()
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
public ProjectDV() {
}
@ -43,14 +45,6 @@ public class ProjectDV implements Serializable {
return relationships;
}
public DocumentDV getSpatialReference() {
return spatialReference;
}
public TemporalReferenceDV getTemporalReference() {
return temporalReference;
}
public DocumentDV getTheDocument() {
return theDocument;
}
@ -75,18 +69,18 @@ public class ProjectDV implements Serializable {
this.relationships = relationships;
}
public void setSpatialReference(DocumentDV spatialReference) {
this.spatialReference = spatialReference;
}
public void setTemporalReference(TemporalReferenceDV temporalReference) {
this.temporalReference = temporalReference;
}
public void setTheDocument(DocumentDV theDocument) {
this.theDocument = theDocument;
}
public Map<String, IdentificationReferenceDV> getMapIdentReferenceDV() {
return mapIdentReferenceDV;
}
public void setMapIdentReferenceDV(Map<String, IdentificationReferenceDV> mapIdentReferenceDV) {
this.mapIdentReferenceDV = mapIdentReferenceDV;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -100,12 +94,10 @@ public class ProjectDV implements Serializable {
builder.append(profileVersion);
builder.append(", relationships=");
builder.append(relationships);
builder.append(", spatialReference=");
builder.append(spatialReference);
builder.append(", temporalReference=");
builder.append(temporalReference);
builder.append(", theDocument=");
builder.append(theDocument);
builder.append(", mapIdentReferenceDV=");
builder.append(mapIdentReferenceDV);
builder.append("]");
return builder.toString();
}

View File

@ -9,12 +9,21 @@ public class FilePathDV implements Serializable {
*/
private static final long serialVersionUID = -9186437393759442989L;
private String gcubeProfileFieldName;
private String fieldName;
private String fieldDefinition;
public FilePathDV() {
}
public String getGcubeProfileFieldName() {
return gcubeProfileFieldName;
}
public void setGcubeProfileFieldName(String gcubeProfileFieldName) {
this.gcubeProfileFieldName = gcubeProfileFieldName;
}
public String getFieldName() {
return fieldName;
}
@ -34,7 +43,9 @@ public class FilePathDV implements Serializable {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FilePathDV [fieldName=");
builder.append("FilePathDV [gcubeProfileFieldName=");
builder.append(gcubeProfileFieldName);
builder.append(", fieldName=");
builder.append(fieldName);
builder.append(", fieldDefinition=");
builder.append(fieldDefinition);

View File

@ -1,5 +1,6 @@
package org.gcube.application;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -22,7 +23,7 @@ public class UCD_Tests {
// private static String TOKEN = ""; //preVRE
private static String CONTEXT = "/gcube/devsec/devVRE";
private static String TOKEN = ""; // devVRE
private static String TOKEN = "3aa85bbf-d5f3-4df4-ad03-4f8f788eba3d-98187548"; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
@ -34,7 +35,7 @@ public class UCD_Tests {
client = GeoportalClientCaller.useCaseDescriptors();
}
//@Test
// @Test
public void getList() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
@ -46,7 +47,7 @@ public class UCD_Tests {
}
}
//@Test
// @Test
public void getItemByID() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
@ -54,9 +55,8 @@ public class UCD_Tests {
UseCaseDescriptor ucd = client.getUCDForId(PROFILE_ID);
System.out.println(ucd);
}
//@Test
// @Test
public void convertToDVObject() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
@ -68,18 +68,50 @@ public class UCD_Tests {
ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null);
}
}
@Test
public void getUCDForHandlerIds() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
List<UseCaseDescriptor> listOfUCD = client.getListForHandlerIds(Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId()));
int i = 0;
for (UseCaseDescriptor useCaseDescriptor : listOfUCD) {
System.out.println(++i + ") " + useCaseDescriptor);
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null);
System.out.println("returned "+ucdDV);
// List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
// List<UseCaseDescriptor> listOfUCD = client
// .getListForHandlerIds(handlersIds);
// int i = 0;
// for (UseCaseDescriptor useCaseDescriptor : listOfUCD) {
// System.out.println(++i + ") " + useCaseDescriptor);
// UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null);
// System.out.println("returned " + ucdDV);
// }
List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
List<UseCaseDescriptor> listUseCaseDescriptor;
try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
if (handlersIds == null) {
handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId());
System.out.println("handlersIds is null, so using default: " + handlersIds);
}
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
} catch (Exception e) {
String error = "Error on contacting the Geoportal service";
System.out.println(error + " for handlers: " + handlersIds);
throw new Exception(
"Error when contacting the Geoportal service. Refresh and try again or contact the support", e);
}
if (listUseCaseDescriptor == null) {
listUseCaseDescriptor = new ArrayList<UseCaseDescriptor>();
}
List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>(listUseCaseDescriptor.size());
for (UseCaseDescriptor ucd : listUseCaseDescriptor) {
listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null));
}
System.out.println(listUCDDV);
}
}