diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index 2159c64..ce01fe6 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -3,24 +3,30 @@ package org.gcube.application.geoportalcommon; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; 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.geoportalcommon.geoportal.config.Configuration; -import org.gcube.application.geoportalcommon.geoportal.config.DocumentConfig; +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; import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile; +import org.gcube.application.geoportalcommon.geoportal.config.ItemField; +import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; 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.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.RelationshipDV; import org.gcube.application.geoportalcommon.shared.geoportal.TemporalReferenceDV; -import org.gcube.application.geoportalcommon.shared.geoportal.config.ConfigurationDV; -import org.gcube.application.geoportalcommon.shared.geoportal.config.DocumentConfigDV; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,46 +42,258 @@ public class ConvertToDataValueObjectModel { private static Logger LOG = LoggerFactory.getLogger(ConvertToDataValueObjectModel.class); /** - * To document config DV. + * The Enum GEOPORTAL_CONFIGURATION_TYPE. * - * @param dc the dc - * @return the document config DV + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 16, 2022 */ - public static DocumentConfigDV toDocumentConfigDV(DocumentConfig dc) { - LOG.trace("toDocumentConfigDV called"); - if (dc == null) { - LOG.warn(DocumentConfig.class.getSimpleName() + " is null"); +// /** +// * 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 gCubeProfiles = config.getGcubeProfiles(); +// if (gCubeProfiles == null) { +// LOG.warn("List of " + GcubeProfile.class.getSimpleName() + " is null"); +// return null; +// } +// +// ConfigGcubeProfileDV configGcubeProfile = new ConfigGcubeProfileDV(); +// List gCubeProfilesVO = new ArrayList(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 the generic type +// * @param config the config +// * @param type the type +// * @return the document DV +// */ +// public static DocumentDV toDocumentDV(Configuration config, Class type) { +// LOG.trace("toDocumentConfigDV called"); +// +// if (config == null) { +// LOG.warn(Configuration.class.getSimpleName() + " is null"); +// return null; +// } +// +// List listConfigs = config.getListConfigs(); +// if (listConfigs == null) { +// LOG.warn("List of Configs is null"); +// return null; +// } +// +// DocumentDV doc = null; +// if (type == ConfigGcubeProfileDV.class) { +// doc = (DocumentDV) new DocumentDV(); +// ConfigGcubeProfileDV configVO = new ConfigGcubeProfileDV(); +// List listConfigsDV = new ArrayList(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. + * + * @param ucd the ucd + * @param handlersIds the handlers ids. If not null only returns (so filtering + * for) handler ids. Otherwise returns all handlers + * @return the document config DV + * @throws Exception the exception + */ + public static UseCaseDescriptorDV toUseCaseDescriptorDV(UseCaseDescriptor ucd, String... handlersIds) + throws Exception { + LOG.trace("toUseCaseDescriptorDV called"); + + if (ucd == null) { + LOG.warn(UseCaseDescriptor.class.getSimpleName() + " is null"); return null; } - DocumentConfigDV dcVO = new DocumentConfigDV(); - dcVO.setId(dc.getId()); - dcVO.setType(dc.getType()); - dcVO.setItemType(dc.getItem_type()); + UseCaseDescriptorDV ucdVO = new UseCaseDescriptorDV(); + ucdVO.setId(ucd.getId()); + ucdVO.setName(ucd.getName()); + ucdVO.setDescription(ucd.getDescription()); + ucdVO.setVersion(ucd.getVersion() != null ? ucd.getVersion().toString() : ""); - Configuration config = dc.getConfiguration(); - if (config == null) { - LOG.warn(Configuration.class.getSimpleName() + " is null"); + List listHandlersDV = new ArrayList(); + if (handlersIds != null) { + Map> handlersMapByID = ucd.getHandlersMapByID(); + + if (handlersMapByID != null) { + for (String handlersId : handlersIds) { + List listHandlerDeclaration = handlersMapByID.get(handlersId); + for (HandlerDeclaration handlerDeclaration : listHandlerDeclaration) { + LOG.debug("converting handler {}", handlerDeclaration); + HandlerDeclarationDV hdDV = toHandlerDeclarationDV(handlerDeclaration); + LOG.debug("handler converted to {}", hdDV); + listHandlersDV.add(hdDV); + } + } + } + } else { + List listHandlerDeclaration = ucd.getHandlers(); + for (HandlerDeclaration handlerDeclaration : listHandlerDeclaration) { + LOG.debug("converting handler {}", handlerDeclaration); + HandlerDeclarationDV hdDV = toHandlerDeclarationDV(handlerDeclaration); + LOG.debug("handler converted to {}", hdDV); + listHandlersDV.add(hdDV); + } + } + + ucdVO.setHandlers(listHandlersDV); + LOG.info("returning {}", ucdVO); + return ucdVO; + + } + + public static GEOPORTAL_DATA_HANDLER to_GEOPORTAL_DATA_HANDLER(String id) { + + if (id == null) + return null; + + for (GEOPORTAL_DATA_HANDLER gdh : GEOPORTAL_DATA_HANDLER.values()) { + if (gdh.getId().equals(id)) { + return gdh; + } + } + + return null; + } + + /** + * To handler declaration DV. + * + * @param handlerDeclaration the handler declaration + * @return the handler declaration DV + * @throws Exception the exception + */ + public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration) throws Exception { + + if (handlerDeclaration == null) { + LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null"); return null; } - List gCubeProfiles = config.getGcubeProfiles(); - if (gCubeProfiles == null) { - LOG.warn("List of " + GcubeProfile.class.getSimpleName() + " is null"); + Document configuration = handlerDeclaration.getConfiguration(); + + HandlerDeclarationDV hdDV = new HandlerDeclarationDV(); + hdDV.setId(handlerDeclaration.getId()); + hdDV.setType(handlerDeclaration.getType()); + hdDV.setHandlerType(to_GEOPORTAL_DATA_HANDLER(handlerDeclaration.getId())); + if (configuration == null) { + LOG.warn("Configuration is null"); return null; } - ConfigurationDV configVO = new ConfigurationDV(); - List gCubeProfilesVO = new ArrayList(gCubeProfiles.size()); - for (GcubeProfile gCubeProfile : gCubeProfiles) { - gCubeProfilesVO.add(toGcubeProfileDV(gCubeProfile)); - } - configVO.setGcubeProfiles(gCubeProfilesVO); - dcVO.setConfiguration(configVO); + try { + GEOPORTAL_CONFIGURATION_TYPE foundConfig = null; + ArrayList configurations = null; + for (GEOPORTAL_CONFIGURATION_TYPE configManaged : GEOPORTAL_CONFIGURATION_TYPE.values()) { + try { + configurations = configuration.get(configManaged.getId(), ArrayList.class); + foundConfig = configManaged; + break; + } catch (Exception e) { + LOG.info(configManaged.getId() + "not found in the handler"); + } + } + if (configurations == null) { + String error = "No managed configurations as '" + GEOPORTAL_CONFIGURATION_TYPE.values() + + "' found in the handler"; + LOG.warn(error); + throw new Exception(error); + } + + switch (foundConfig) { + case gcube_profiles: { + + List listGcubeProfiles = new ArrayList(configurations.size()); + + int i = 0; + for (String gCubeProfile : configurations) { + LOG.debug(i++ + ") the gCubeProfile is: " + gCubeProfile); + GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(gCubeProfile, + GcubeProfile.class); + listGcubeProfiles.add(toGcubeProfileDV(profile)); + } + + ConfigurationDV> dDV = new ConfigurationDV>( + listGcubeProfiles); + dDV.setConfiguration(listGcubeProfiles); + dDV.setConfigurationType(GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles); + hdDV.setConfiguration(dDV); + LOG.info("returning {}", hdDV); + return hdDV; + } + case item_fields: { + + List listItemFields = new ArrayList(configurations.size()); + + int i = 0; + for (String itemField : configurations) { + LOG.debug(i++ + ") the itemField is: " + itemField); + ItemField profile = org.gcube.application.geoportal.client.utils.Serialization.read(itemField, + ItemField.class); + listItemFields.add(toItemFieldDV(profile)); + } + + ConfigurationDV> dDV = new ConfigurationDV>(listItemFields); + dDV.setConfiguration(listItemFields); + dDV.setConfigurationType(GEOPORTAL_CONFIGURATION_TYPE.item_fields); + hdDV.setConfiguration(dDV); + LOG.info("returning {}", hdDV); + return hdDV; + } + + default: + break; + } + + } catch (Exception e) { + LOG.error("Error on getting " + HandlerDeclaration.class.getSimpleName(), e); + throw e; + } + + return null; - LOG.debug("returning: " + dcVO); - return dcVO; } /** @@ -116,6 +334,32 @@ public class ConvertToDataValueObjectModel { return gpVO; } + /** + * To item field DV. + * + * @param itemField the item field + * @return the item field DV + */ + public static ItemFieldDV toItemFieldDV(ItemField itemField) { + LOG.trace("toItemFieldDV called"); + + if (itemField == null) { + LOG.warn(GcubeProfile.class.getSimpleName() + " is null"); + return null; + } + + ItemFieldDV ifDV = new ItemFieldDV(); + ifDV.setDisplayAsResult(itemField.isAsResult()); + ifDV.setDisplayName(itemField.getLabel()); + ifDV.setJsonFields(itemField.getPaths()); + ifDV.setOperator(itemField.getOperator()); + ifDV.setSearchable(itemField.isSearchable()); + ifDV.setSortable(itemField.isSortable()); + + LOG.info("returning: " + ifDV); + return ifDV; + } + /** * To file path DV. * @@ -138,6 +382,14 @@ public class ConvertToDataValueObjectModel { return fpVO; } + /** + * To project DV. + * + * @param project the project + * @param projectReader the project reader + * @return the project DV + * @throws Exception the exception + */ public static ProjectDV toProjectDV(Project project, ProjectDVBuilder projectReader) throws Exception { LOG.info("toProjectDV called"); @@ -196,18 +448,36 @@ 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 listDocumentKeys, boolean getFullMap) { if (temporalReference == null) return null; - TemporalReferenceDV trDV = toDocumentDV(temporalReference, TemporalReferenceDV.class, listDocumentKeys, - getFullMap); + TemporalReferenceDV trDV = (TemporalReferenceDV) toDocumentDV(temporalReference, TemporalReferenceDV.class, + listDocumentKeys, getFullMap); trDV.setField(temporalReference.getField()); return trDV; } - public static T toDocumentDV(Document document, Class toType, + /** + * To document DV. + * + * @param the generic type + * @param document the document + * @param toType the to type + * @param listDocumentKeys the list document keys + * @param getFullMap the get full map + * @return the t + */ + public static DocumentDV toDocumentDV(Document document, Class toType, List listDocumentKeys, boolean getFullMap) { if (document == null) return null; @@ -241,6 +511,12 @@ public class ConvertToDataValueObjectModel { return documentDV; } + /** + * To relationship DV. + * + * @param relationship the relationship + * @return the relationship DV + */ public static RelationshipDV toRelationshipDV(Relationship relationship) { if (relationship == null) diff --git a/src/main/java/org/gcube/application/geoportalcommon/GNAConfigsConverter.java b/src/main/java/org/gcube/application/geoportalcommon/GNAConfigsConverter.java index 7a355f6..ecba93b 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/GNAConfigsConverter.java +++ b/src/main/java/org/gcube/application/geoportalcommon/GNAConfigsConverter.java @@ -9,8 +9,8 @@ import org.gcube.application.geoportalcommon.config.CSVFile; import org.gcube.application.geoportalcommon.config.CSVReader; import org.gcube.application.geoportalcommon.config.CSVRow; import org.gcube.application.geoportalcommon.config.FileUtil; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,11 +35,11 @@ public class GNAConfigsConverter { * @return the list * @throws GNAConfigException the GNA user rights config exception */ - public List readListItemsConfig(String contentValue) throws GNAConfigException { + public List readListItemsConfig(String contentValue) throws GNAConfigException { LOG.debug("readListItemsConfig called"); File configurationFile = null; - List listItemFields = new ArrayList(); + List listItemFields = new ArrayList(); try { configurationFile = FileUtil.inputStreamToTempFile(contentValue, "GNA_ListItems_Configs"+new Random().nextInt()); @@ -57,7 +57,7 @@ public class GNAConfigsConverter { // Starting from index 1 (means the second row in the CSV) for (int i = 0; i < rows.size(); i++) { LOG.trace(i + " row"); - ItemField itemField = new ItemField(); + ItemFieldDV itemField = new ItemFieldDV(); CSVRow row = rows.get(i); // mapping to ItemFiel diff --git a/src/main/java/org/gcube/application/geoportalcommon/GNADataEntryConfigProfileReader.java b/src/main/java/org/gcube/application/geoportalcommon/GNADataEntryConfigProfileReader.java index a3faaa4..be0121b 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/GNADataEntryConfigProfileReader.java +++ b/src/main/java/org/gcube/application/geoportalcommon/GNADataEntryConfigProfileReader.java @@ -18,13 +18,13 @@ import org.gcube.application.geoportalcommon.config.CSVReader; import org.gcube.application.geoportalcommon.config.CSVRow; import org.gcube.application.geoportalcommon.config.FileUtil; import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM; import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException; import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.resources.discovery.client.api.DiscoveryClient; @@ -129,7 +129,7 @@ public class GNADataEntryConfigProfileReader { LOG.debug(PATH_TO_ITEM_FIELDS_CONFIG + " with new lines: " + value_with_new_lines); GNAConfigsConverter gnc = new GNAConfigsConverter(); - List listItemFieldsConfig = gnc.readListItemsConfig(value_with_new_lines); + List listItemFieldsConfig = gnc.readListItemsConfig(value_with_new_lines); gnDEC.setListItemFields(listItemFieldsConfig); LOG.info("returning: " + gnDEC); diff --git a/src/main/java/org/gcube/application/geoportalcommon/GNADataViewerConfigProfileReader.java b/src/main/java/org/gcube/application/geoportalcommon/GNADataViewerConfigProfileReader.java index f4b986d..f2606c1 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/GNADataViewerConfigProfileReader.java +++ b/src/main/java/org/gcube/application/geoportalcommon/GNADataViewerConfigProfileReader.java @@ -15,9 +15,9 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.resources.discovery.client.api.DiscoveryClient; @@ -150,7 +150,7 @@ public class GNADataViewerConfigProfileReader { LOG.debug(PATH_TO_ITEM_FIELDS_CONFIG + " with new lines: " + value_with_new_lines); GNAConfigsConverter gnc = new GNAConfigsConverter(); - List listItemFieldsConfig = gnc.readListItemsConfig(value_with_new_lines); + List listItemFieldsConfig = gnc.readListItemsConfig(value_with_new_lines); profile.setListItemFields(listItemFieldsConfig); LOG.info("returning: " + profile); diff --git a/src/main/java/org/gcube/application/geoportalcommon/GeoportalCommonConstants.java b/src/main/java/org/gcube/application/geoportalcommon/GeoportalCommonConstants.java index cb31d03..ea8d42a 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/GeoportalCommonConstants.java +++ b/src/main/java/org/gcube/application/geoportalcommon/GeoportalCommonConstants.java @@ -14,5 +14,4 @@ public class GeoportalCommonConstants { public static final String GEOPORTAL_DATA_VIEWER_APP = "geoportal-data-viewer-app"; - } diff --git a/src/main/java/org/gcube/application/geoportalcommon/MockDocumentConfigurationReader.java b/src/main/java/org/gcube/application/geoportalcommon/MockDocumentConfigurationReader.java index 857cc9c..9cd5c1e 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/MockDocumentConfigurationReader.java +++ b/src/main/java/org/gcube/application/geoportalcommon/MockDocumentConfigurationReader.java @@ -1,73 +1,70 @@ -package org.gcube.application.geoportalcommon; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -import org.gcube.application.geoportalcommon.geoportal.config.DocumentConfig; -import org.gcube.application.geoportalcommon.shared.geoportal.config.DocumentConfigDV; - -import com.fasterxml.jackson.core.JsonProcessingException; - -public class MockDocumentConfigurationReader { - - private List listDocumentConfigsDV = new ArrayList(); - - public MockDocumentConfigurationReader() { - try { - loadDocumentConfiguration(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - //THIS IS A MOCK - private void loadDocumentConfiguration() throws Exception { - System.out.println("loadDocumentConfiguration called"); - String filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config.json"; - - DocumentConfigDV dc = getDocumentConfigVO(filePath); - listDocumentConfigsDV.add(dc); - - filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config2.json"; - dc = getDocumentConfigVO(filePath); - listDocumentConfigsDV.add(dc); - - filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config3.json"; - dc = getDocumentConfigVO(filePath); - listDocumentConfigsDV.add(dc); - - filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config4.json"; - dc = getDocumentConfigVO(filePath); - listDocumentConfigsDV.add(dc); - } - - private DocumentConfigDV getDocumentConfigVO(String filePath) throws JsonProcessingException, IOException { - String theFile = readFile(filePath); - System.out.println("the file is: " + theFile); - DocumentConfig dc = org.gcube.application.geoportal.client.utils.Serialization.read(theFile, - DocumentConfig.class); - System.out.println(dc); - - return ConvertToDataValueObjectModel.toDocumentConfigDV(dc); - } - - private static String readFile(String filePath) { - String content = ""; - - try { - content = new String(Files.readAllBytes(Paths.get(filePath))); - } catch (IOException e) { - e.printStackTrace(); - } - - return content; - } - - public List getListDocumentConfig() { - return listDocumentConfigsDV; - } -} +//package org.gcube.application.geoportalcommon; +// +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.util.ArrayList; +//import java.util.List; +// +//import org.gcube.application.geoportalcommon.shared.geoportal.config.DocumentConfigDV; +// +//public class MockDocumentConfigurationReader { +// +// private List listDocumentConfigsDV = new ArrayList(); +// +// public MockDocumentConfigurationReader() { +// try { +// //loadDocumentConfiguration(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +//// //THIS IS A MOCK +//// private void loadDocumentConfiguration() throws Exception { +//// System.out.println("loadDocumentConfiguration called"); +//// String filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config.json"; +//// +//// DocumentConfigDV dc = getDocumentConfigVO(filePath); +//// listDocumentConfigsDV.add(dc); +//// +//// filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config2.json"; +//// dc = getDocumentConfigVO(filePath); +//// listDocumentConfigsDV.add(dc); +//// +//// filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config3.json"; +//// dc = getDocumentConfigVO(filePath); +//// listDocumentConfigsDV.add(dc); +//// +//// filePath = "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config4.json"; +//// dc = getDocumentConfigVO(filePath); +//// listDocumentConfigsDV.add(dc); +//// } +//// +//// private DocumentConfigDV getDocumentConfigVO(String filePath) throws JsonProcessingException, IOException { +//// String theFile = readFile(filePath); +//// System.out.println("the file is: " + theFile); +//// DocumentConfig dc = org.gcube.application.geoportal.client.utils.Serialization.read(theFile, +//// DocumentConfig.class); +//// System.out.println(dc); +//// +//// return ConvertToDataValueObjectModel.toDocumentConfigDV(dc); +//// } +// +// public static String readFile(String filePath) { +// String content = ""; +// +// try { +// content = new String(Files.readAllBytes(Paths.get(filePath))); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// +// return content; +// } +// +// public List getListDocumentConfig() { +// return listDocumentConfigsDV; +// } +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/MongoServiceCommon.java b/src/main/java/org/gcube/application/geoportalcommon/MongoServiceCommon.java index 1fe1108..c4fee2d 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/MongoServiceCommon.java +++ b/src/main/java/org/gcube/application/geoportalcommon/MongoServiceCommon.java @@ -15,7 +15,7 @@ //import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction; //import org.gcube.application.geoportal.common.model.rest.QueryRequest.PagedRequest; //import org.gcube.application.geoportal.common.rest.MongoConcessioni; -//import org.gcube.application.geoportalcommon.shared.ItemField; +//import org.gcube.application.geoportalcommon.shared.ItemFieldDV; //import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; //import org.gcube.application.geoportalcommon.shared.SearchingFilter; //import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP; 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 683914e..f97ea44 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java @@ -24,13 +24,13 @@ import org.gcube.application.geoportal.common.utils.FileSets; 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.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.WhereClause; import org.gcube.application.geoportalcommon.shared.geoportal.ProjectDV; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +44,7 @@ public class ProjectsCaller { private static Logger LOG = LoggerFactory.getLogger(GeoportalClientCaller.class); public Projects getClient(String profileID) { - LOG.info("getProjectsClient called for profileID={}", profileID); + LOG.info("getClient called for profileID={}", profileID); return projects(profileID).build(); } @@ -74,7 +74,7 @@ public class ProjectsCaller { } public List getListForProfileID(String profileID) throws Exception { - LOG.info("getlistOfProjectsForProfileID called for profileID: {}", profileID); + LOG.info("getListForProfileID called for profileID: {}", profileID); Projects client = (Projects) getClient(profileID); List listProjects = new ArrayList(); @@ -108,6 +108,7 @@ public class ProjectsCaller { */ public ResultSetPaginatedData queryOnMongo(String profileID, Integer totalItems, Integer offset, Integer limit, SearchingFilter filter, String recordType, ProjectDVBuilder projectDVBuilder) throws Exception { + LOG.info("queryOnMongo called"); try { @@ -158,19 +159,19 @@ public class ProjectsCaller { break; } - List orderByFields = filter.getOrderByFields(); + List orderByFields = filter.getOrderByFields(); if (orderByFields == null) { - orderByFields = new ArrayList(); + orderByFields = new ArrayList(); } if (orderByFields.isEmpty()) { - ItemField orderD = new ItemField("", Arrays.asList("name"), false, false, false); + ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false); LOG.info("Order by is null, adding default: " + orderD); orderByFields.add(orderD); } - for (ItemField itemField : orderByFields) { + for (ItemFieldDV itemField : orderByFields) { if (itemField.getJsonFields() != null) { for (String field : itemField.getJsonFields()) { orderingFields.add(field); diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/UseCaseDescriptorCaller.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/UseCaseDescriptorCaller.java index a062c8f..d9ce028 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/UseCaseDescriptorCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/UseCaseDescriptorCaller.java @@ -13,6 +13,7 @@ import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.mongodb.BasicDBList; import com.mongodb.BasicDBObject; public class UseCaseDescriptorCaller { @@ -25,7 +26,7 @@ public class UseCaseDescriptorCaller { } public List getList() throws Exception { - LOG.info("getlistOfUseCaseDescriptors called"); + LOG.info("getList called"); UseCaseDescriptorsI client = useCaseDescriptorsClient(); List listUCD = new ArrayList(); Iterator useCaseDescrs = client.query(new QueryRequest()); @@ -38,17 +39,68 @@ public class UseCaseDescriptorCaller { return listUCD; } - public UseCaseDescriptor geUCDForId(String profileID) throws Exception { - LOG.info("getUseCaseDescriptorForId called for profileID: {}", profileID); + public List getListForHandlerIds(List listHandlersIds) throws Exception { + LOG.info("getListForHandlerId called"); + return getListForJSONPath("_handlers._id", listHandlersIds); + } + + public List getListForJSONPath(String jsonPath, List listValues) throws Exception { + LOG.info("getListForJSONPath called for jsonPath: {}, with listValues: {}", jsonPath, listValues); UseCaseDescriptorsI client = useCaseDescriptorsClient(); + List listUCD = new ArrayList(); + +// BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); +// for (String key : listHandlersIds) { +// // using regex and case-insensitive +// BasicDBObject bs = new BasicDBObject(); +// bs.append(jsonPath, key); +// builder.append(key, bs); +// +// } + // Building list of Document in OR clause + BasicDBList list = new BasicDBList(); + for (String value : listValues) { + + Document doc = new Document(jsonPath, value); + list.add(doc); + } + + QueryRequest queryRequest = new QueryRequest(); + Document queryDoc = new Document(); + queryDoc.put("$eq", list); + LOG.debug("Performing query: {}", queryDoc.toJson()); + queryRequest.setFilter(queryDoc); + +// QueryRequest queryRequest = new QueryRequest(); +// Document queryDoc = new Document(); +// BasicDBObject bs = new BasicDBObject(); +// bs.append("$eq", hasValue); +// queryDoc.put(jsonPath, bs); +// LOG.debug("Performing query: {}", queryDoc.toJson()); +// queryRequest.setFilter(queryDoc); + + Iterator useCaseDescrs = client.query(queryRequest); + for (Iterator iterator = useCaseDescrs; useCaseDescrs.hasNext();) { + UseCaseDescriptor prg = (UseCaseDescriptor) iterator.next(); + listUCD.add(prg); + + } + LOG.info("returning %d {}", listUCD.size(), UseCaseDescriptor.class.getName()); + return listUCD; + } + + public UseCaseDescriptor getUCDForId(String profileID) throws Exception { + LOG.info("getUCDForId called for profileID: {}", profileID); + UseCaseDescriptorsI client = useCaseDescriptorsClient(); + QueryRequest queryRequest = new QueryRequest(); Document queryDoc = new Document(); BasicDBObject bs = new BasicDBObject(); bs.append("$eq", profileID); queryDoc.put("_id", bs); - LOG.debug("Performing query: {}", queryDoc.toJson()); queryRequest.setFilter(queryDoc); + Iterator useCaseDescrs = client.query(queryRequest); UseCaseDescriptor ucd = null; diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/Configuration.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/Configuration.java index 3e43ff5..51deef2 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/Configuration.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/Configuration.java @@ -1,17 +1,17 @@ -package org.gcube.application.geoportalcommon.geoportal.config; - -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; - -@Data -@XmlRootElement(name = "configuration") -@Slf4j -public class Configuration{ - - private List gcubeProfiles; - -} +//package org.gcube.application.geoportalcommon.geoportal.config; +// +//import java.util.List; +// +//import javax.xml.bind.annotation.XmlRootElement; +// +//import lombok.Data; +//import lombok.extern.slf4j.Slf4j; +// +//@Data +//@XmlRootElement(name = "_configuration") +//@Slf4j +//public class Configuration{ +// +// private List listConfigs; +// +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ConfigurationGCubeProfile.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ConfigurationGCubeProfile.java new file mode 100644 index 0000000..aa6232f --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ConfigurationGCubeProfile.java @@ -0,0 +1,19 @@ +//package org.gcube.application.geoportalcommon.geoportal.config; +// +//import java.util.List; +// +//import javax.xml.bind.annotation.XmlRootElement; +// +//import com.fasterxml.jackson.annotation.JsonProperty; +// +//import lombok.Data; +//import lombok.extern.slf4j.Slf4j; +// +//@Data +//@XmlRootElement(name = "_configuration") +//@Slf4j +//public class ConfigurationGCubeProfile { +// +// @JsonProperty(value = "gcubeProfiles") +// private List listConfigs; +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/DocumentConfig.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/DocumentConfig.java index f32b918..14168aa 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/DocumentConfig.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/DocumentConfig.java @@ -1,27 +1,27 @@ -package org.gcube.application.geoportalcommon.geoportal.config; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; - -@Data -@XmlRootElement -@Slf4j -public class DocumentConfig { - - @JsonProperty - private String id; - - @JsonProperty - private String type; - - @JsonProperty - private String item_type; - - @JsonProperty - private Configuration configuration; - -} +//package org.gcube.application.geoportalcommon.geoportal.config; +// +//import javax.xml.bind.annotation.XmlRootElement; +// +//import com.fasterxml.jackson.annotation.JsonProperty; +// +//import lombok.Data; +//import lombok.extern.slf4j.Slf4j; +// +//@Data +//@XmlRootElement +//@Slf4j +//public class DocumentConfig { +// +// @JsonProperty +// private String _id; +// +// @JsonProperty +// private String _type; +// +// @JsonProperty +// private String _item_type; +// +// @JsonProperty +// private Configuration _configuration; +// +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/GcubeProfile.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/GcubeProfile.java index d41f95f..2049022 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/GcubeProfile.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/GcubeProfile.java @@ -18,8 +18,6 @@ public class GcubeProfile { public static final int MIN_MAX_NOT_SPECIFIED = -1; - public GcubeProfile() {} - @JsonProperty private String gcubeSecondaryType; @@ -53,6 +51,8 @@ public class GcubeProfile { @JsonProperty(FILE_PATHS) private List filePaths; + public GcubeProfile() {} + } diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/HandlerGcubeProfile.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/HandlerGcubeProfile.java new file mode 100644 index 0000000..a57004c --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/HandlerGcubeProfile.java @@ -0,0 +1,27 @@ +//package org.gcube.application.geoportalcommon.geoportal.config; +// +//import javax.xml.bind.annotation.XmlRootElement; +// +//import com.fasterxml.jackson.annotation.JsonProperty; +// +//import lombok.Data; +//import lombok.extern.slf4j.Slf4j; +// +//@Data +//@XmlRootElement +//@Slf4j +//public class HandlerGcubeProfile { +// +// @JsonProperty +// private String _id; +// +// @JsonProperty +// private String _type; +// +// @JsonProperty +// private String _item_type; +// +// @JsonProperty +// private ConfigurationGCubeProfile _configuration; +// +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ItemField.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ItemField.java new file mode 100644 index 0000000..246af26 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/config/ItemField.java @@ -0,0 +1,33 @@ +package org.gcube.application.geoportalcommon.geoportal.config; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +@Data +@XmlRootElement(name = "itemFields") +@Slf4j +public class ItemField { + + @JsonProperty + private String label; + @JsonProperty + private List paths; + @JsonProperty + private String operator; + @JsonProperty + private boolean searchable; + @JsonProperty + private boolean sortable; + @JsonProperty + private boolean asResult; + + public ItemField() { + } + +} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataEntryConfigProfile.java b/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataEntryConfigProfile.java index 931fea1..922a2f3 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataEntryConfigProfile.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataEntryConfigProfile.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.List; import org.gcube.application.geoportalcommon.shared.config.RoleRights; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; /** * The Class GNADataEntryConfigProfile. @@ -18,7 +19,7 @@ public class GNADataEntryConfigProfile implements Serializable { * */ private static final long serialVersionUID = 5152380669677928785L; - private List listItemFields; + private List listItemFields; private List permissionsForRole; /** @@ -34,7 +35,7 @@ public class GNADataEntryConfigProfile implements Serializable { * @param listItemFields the list item fields * @param permissionsForRole the permissions for role */ - public GNADataEntryConfigProfile(List listItemFields, List permissionsForRole) { + public GNADataEntryConfigProfile(List listItemFields, List permissionsForRole) { super(); this.listItemFields = listItemFields; this.permissionsForRole = permissionsForRole; @@ -45,7 +46,7 @@ public class GNADataEntryConfigProfile implements Serializable { * * @return the list item fields */ - public List getListItemFields() { + public List getListItemFields() { return listItemFields; } @@ -54,7 +55,7 @@ public class GNADataEntryConfigProfile implements Serializable { * * @param listItemFields the new list item fields */ - public void setListItemFields(List listItemFields) { + public void setListItemFields(List listItemFields) { this.listItemFields = listItemFields; } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataViewerConfigProfile.java b/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataViewerConfigProfile.java index de2d1d7..9656514 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataViewerConfigProfile.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/GNADataViewerConfigProfile.java @@ -4,6 +4,8 @@ import java.io.Serializable; import java.util.List; import java.util.Map; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; + /** * The Class GNADataViewerConfigProfile. * @@ -21,7 +23,7 @@ public class GNADataViewerConfigProfile implements Serializable { private String openPortletURL; // the key is the layer type private Map mapLayers; - private List listItemFields; + private List listItemFields; /** * Instantiates a new geo na data viewer profile. @@ -89,7 +91,7 @@ public class GNADataViewerConfigProfile implements Serializable { * * @return the list item fields */ - public List getListItemFields() { + public List getListItemFields() { return listItemFields; } @@ -98,7 +100,7 @@ public class GNADataViewerConfigProfile implements Serializable { * * @param listItemFields the new list item fields */ - public void setListItemFields(List listItemFields) { + public void setListItemFields(List listItemFields) { this.listItemFields = listItemFields; } 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 b724491..77b717e 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/SearchingFilter.java @@ -3,6 +3,8 @@ package org.gcube.application.geoportalcommon.shared; import java.io.Serializable; import java.util.List; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; + /** * The Class SearchingFilter. * @@ -79,7 +81,7 @@ public class SearchingFilter implements Serializable { */ private static final long serialVersionUID = -4004094263090373626L; - private List orderByFields; + private List orderByFields; private ORDER order = ORDER.ASC; @@ -98,7 +100,7 @@ public class SearchingFilter implements Serializable { * @param orderByFields the order by fields * @param order the order */ - public SearchingFilter(List orderByFields, ORDER order) { + public SearchingFilter(List orderByFields, ORDER order) { this.orderByFields = orderByFields; this.order = order; } @@ -110,7 +112,7 @@ public class SearchingFilter implements Serializable { * @param order the order * @param searchInto the search into */ - public SearchingFilter(List orderByFields, ORDER order, List conditions) { + public SearchingFilter(List orderByFields, ORDER order, List conditions) { this.orderByFields = orderByFields; this.order = order; this.conditions = conditions; @@ -129,7 +131,7 @@ public class SearchingFilter implements Serializable { * * @return the order by fields */ - public List getOrderByFields() { + public List getOrderByFields() { return orderByFields; } @@ -147,7 +149,7 @@ public class SearchingFilter implements Serializable { * * @param orderByFields the new order by fields */ - public void setOrderByFields(List orderByFields) { + public void setOrderByFields(List orderByFields) { this.orderByFields = orderByFields; } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ConfigurationDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ConfigurationDV.java new file mode 100644 index 0000000..80a3f6f --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ConfigurationDV.java @@ -0,0 +1,54 @@ +package org.gcube.application.geoportalcommon.shared.geoportal; + +import java.io.Serializable; +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID; + +public class ConfigurationDV> implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4836713840177636940L; + + private T configuration; + private GEOPORTAL_CONFIGURATION_TYPE configurationType; + + public ConfigurationDV() { + } + + public ConfigurationDV(T configuration) { + this.configuration = configuration; + } + + public GEOPORTAL_CONFIGURATION_TYPE getConfigurationType() { + return configurationType; + } + + public void setConfigurationType(GEOPORTAL_CONFIGURATION_TYPE configurationType) { + this.configurationType = configurationType; + } + + public T getConfiguration() { + return configuration; + } + + public void setConfiguration(T config) { + this.configuration = config; + + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("ConfigurationDV [configuration="); + builder.append(configuration); + builder.append(", configurationType="); + builder.append(configurationType); + builder.append("]"); + return builder.toString(); + } + + +} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java index 4b095d8..c0c418a 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java @@ -11,16 +11,11 @@ public class DocumentDV implements Serializable { private static final long serialVersionUID = 4978517506036855883L; private LinkedHashMap documentAsMap; private String documentAsJSON; + private ConfigurationDV configuration; public DocumentDV() { } - public DocumentDV(LinkedHashMap documentAsMap, String documentAsJSON) { - super(); - this.documentAsMap = documentAsMap; - this.documentAsJSON = documentAsJSON; - } - public LinkedHashMap getDocumentAsMap() { return documentAsMap; } @@ -37,6 +32,14 @@ public class DocumentDV implements Serializable { this.documentAsJSON = documentAsJSON; } + public ConfigurationDV getConfiguration() { + return configuration; + } + + public void setConfiguration(ConfigurationDV configuration) { + this.configuration = configuration; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -44,6 +47,8 @@ public class DocumentDV implements Serializable { builder.append(documentAsMap); builder.append(", documentAsJSON="); builder.append(documentAsJSON); + builder.append(", configuration="); + builder.append(configuration); builder.append("]"); return builder.toString(); } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_CONFIGURATION_TYPE.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_CONFIGURATION_TYPE.java new file mode 100644 index 0000000..3f0df1c --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_CONFIGURATION_TYPE.java @@ -0,0 +1,36 @@ +package org.gcube.application.geoportalcommon.shared.geoportal; + +public enum GEOPORTAL_CONFIGURATION_TYPE { + item_fields("itemFields"), gcube_profiles("gcubeProfiles"); + + String id; + + /** + * Instantiates a new gna config managed. + * + * @param id the id + */ + GEOPORTAL_CONFIGURATION_TYPE(String id) { + this.id = id; + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + return id; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_DATA_HANDLER.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_DATA_HANDLER.java new file mode 100644 index 0000000..caa1b3b --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/GEOPORTAL_DATA_HANDLER.java @@ -0,0 +1,23 @@ +package org.gcube.application.geoportalcommon.shared.geoportal; + +public enum GEOPORTAL_DATA_HANDLER { + + geoportal_data_list("org.gcube.portlets.user.geoportal-data-list", "DATA_LIST_GUI"), + geoportal_data_entry("org.gcube.portlets.user.geoportal-data-entry-app", "DATA_ENTRY_GUI"); + + String id; + String type; + + GEOPORTAL_DATA_HANDLER(String id, String type) { + this.id = id; + this.type = type; + } + + public String getId() { + return id; + } + + public String getType() { + return type; + } +} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/HandlerDeclarationDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/HandlerDeclarationDV.java index 95054db..32eb8ba 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/HandlerDeclarationDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/HandlerDeclarationDV.java @@ -10,16 +10,18 @@ public class HandlerDeclarationDV implements Serializable { private static final long serialVersionUID = 9095207023666383038L; private String id; private String type; - private DocumentDV configuration; + private ConfigurationDV configuration; + private GEOPORTAL_DATA_HANDLER dataHandlerType; - HandlerDeclarationDV() { + public HandlerDeclarationDV() { } - public HandlerDeclarationDV(String id, String type, DocumentDV configuration) { - super(); + public HandlerDeclarationDV(String id, String type, ConfigurationDV configuration, + GEOPORTAL_DATA_HANDLER dataHandlerType) { this.id = id; this.type = type; this.configuration = configuration; + this.dataHandlerType = dataHandlerType; } public String getId() { @@ -30,7 +32,7 @@ public class HandlerDeclarationDV implements Serializable { return type; } - public DocumentDV getConfiguration() { + public ConfigurationDV getConfiguration() { return configuration; } @@ -42,10 +44,19 @@ public class HandlerDeclarationDV implements Serializable { this.type = type; } - public void setConfiguration(DocumentDV configuration) { + public void setConfiguration(ConfigurationDV configuration) { this.configuration = configuration; } + public void setHandlerType(GEOPORTAL_DATA_HANDLER dataHandlerType) { + this.dataHandlerType = dataHandlerType; + + } + + public GEOPORTAL_DATA_HANDLER getDataHandlerType() { + return dataHandlerType; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -55,6 +66,8 @@ public class HandlerDeclarationDV implements Serializable { builder.append(type); builder.append(", configuration="); builder.append(configuration); + builder.append(", dataHandlerType="); + builder.append(dataHandlerType); builder.append("]"); return builder.toString(); } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/TemporalReferenceDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/TemporalReferenceDV.java index 8b404ac..0f9e222 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/TemporalReferenceDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/TemporalReferenceDV.java @@ -6,6 +6,7 @@ package org.gcube.application.geoportalcommon.shared.geoportal; * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Mar 10, 2022 + * @param */ public class TemporalReferenceDV extends DocumentDV { diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/UseCaseDescriptorDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/UseCaseDescriptorDV.java index c1cfeab..b62421d 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/UseCaseDescriptorDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/UseCaseDescriptorDV.java @@ -14,24 +14,17 @@ public class UseCaseDescriptorDV implements Serializable { private String name; private String description; - private String fieldType; - private String fieldLabel; - private List handlers; - UseCaseDescriptorDV() { + public UseCaseDescriptorDV() { } - public UseCaseDescriptorDV(String id, String version, String name, String description, String fieldType, - String fieldLabel, List handlers) { + public UseCaseDescriptorDV(String id, String version, String name, String description) { super(); this.id = id; this.version = version; this.name = name; this.description = description; - this.fieldType = fieldType; - this.fieldLabel = fieldLabel; - this.handlers = handlers; } public String getId() { @@ -50,14 +43,6 @@ public class UseCaseDescriptorDV implements Serializable { return description; } - public String getFieldType() { - return fieldType; - } - - public String getFieldLabel() { - return fieldLabel; - } - public List getHandlers() { return handlers; } @@ -78,14 +63,6 @@ public class UseCaseDescriptorDV implements Serializable { this.description = description; } - public void setFieldType(String fieldType) { - this.fieldType = fieldType; - } - - public void setFieldLabel(String fieldLabel) { - this.fieldLabel = fieldLabel; - } - public void setHandlers(List handlers) { this.handlers = handlers; } @@ -101,10 +78,6 @@ public class UseCaseDescriptorDV implements Serializable { builder.append(name); builder.append(", description="); builder.append(description); - builder.append(", fieldType="); - builder.append(fieldType); - builder.append(", fieldLabel="); - builder.append(fieldLabel); builder.append(", handlers="); builder.append(handlers); builder.append("]"); diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigGcubeProfileDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigGcubeProfileDV.java new file mode 100644 index 0000000..a105c5b --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigGcubeProfileDV.java @@ -0,0 +1,35 @@ +//package org.gcube.application.geoportalcommon.shared.geoportal.config; +// +//import java.io.Serializable; +//import java.util.List; +// +//public class ConfigGcubeProfileDV implements Serializable { +// +// /** +// * +// */ +// private static final long serialVersionUID = 372838411789432170L; +// +// private List gcubeProfiles; +// +// public ConfigGcubeProfileDV() { +// } +// +// public List getGcubeProfiles() { +// return gcubeProfiles; +// } +// +// public void setGcubeProfiles(List gcubeProfiles) { +// this.gcubeProfiles = gcubeProfiles; +// } +// +// @Override +// public String toString() { +// StringBuilder builder = new StringBuilder(); +// builder.append("ConfigGcubeProfileDV [gcubeProfiles="); +// builder.append(gcubeProfiles); +// builder.append("]"); +// return builder.toString(); +// } +// +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigurationDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigurationDV.java deleted file mode 100644 index 7b57069..0000000 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ConfigurationDV.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.gcube.application.geoportalcommon.shared.geoportal.config; - -import java.io.Serializable; -import java.util.List; - -public class ConfigurationDV implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 372838411789432170L; - - private List gcubeProfiles; - - public ConfigurationDV() { - } - - public List getGcubeProfiles() { - return gcubeProfiles; - } - - public void setGcubeProfiles(List gcubeProfiles) { - this.gcubeProfiles = gcubeProfiles; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("ConfigurationDV [gcubeProfiles="); - builder.append(gcubeProfiles); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/DocumentConfigDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/DocumentConfigDV.java index c610cb2..c853061 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/DocumentConfigDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/DocumentConfigDV.java @@ -1,66 +1,66 @@ -package org.gcube.application.geoportalcommon.shared.geoportal.config; - -import java.io.Serializable; - -public class DocumentConfigDV implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 7538079431272352662L; - private String id; - private String type; - private String itemType; - private ConfigurationDV configuration; - - public DocumentConfigDV() { - } - - public String getId() { - return id; - } - - public String getType() { - return type; - } - - public ConfigurationDV getConfiguration() { - return configuration; - } - - public void setId(String id) { - this.id = id; - } - - public String getItemType() { - return itemType; - } - - public void setItemType(String itemType) { - this.itemType = itemType; - } - - public void setType(String type) { - this.type = type; - } - - public void setConfiguration(ConfigurationDV configuration) { - this.configuration = configuration; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("DocumentConfigDV [id="); - builder.append(id); - builder.append(", type="); - builder.append(type); - builder.append(", itemType="); - builder.append(itemType); - builder.append(", configuration="); - builder.append(configuration); - builder.append("]"); - return builder.toString(); - } - -} +//package org.gcube.application.geoportalcommon.shared.geoportal.config; +// +//import java.io.Serializable; +// +//public class DocumentConfigDV implements Serializable { +// +// /** +// * +// */ +// private static final long serialVersionUID = 7538079431272352662L; +// private String id; +// private String type; +// private String itemType; +// private ConfigGcubeProfileDV configuration; +// +// public DocumentConfigDV() { +// } +// +// public String getId() { +// return id; +// } +// +// public String getType() { +// return type; +// } +// +// public ConfigGcubeProfileDV getConfiguration() { +// return configuration; +// } +// +// public void setId(String id) { +// this.id = id; +// } +// +// public String getItemType() { +// return itemType; +// } +// +// public void setItemType(String itemType) { +// this.itemType = itemType; +// } +// +// public void setType(String type) { +// this.type = type; +// } +// +// public void setConfiguration(ConfigGcubeProfileDV configuration) { +// this.configuration = configuration; +// } +// +// @Override +// public String toString() { +// StringBuilder builder = new StringBuilder(); +// builder.append("DocumentConfigDV [id="); +// builder.append(id); +// builder.append(", type="); +// builder.append(type); +// builder.append(", itemType="); +// builder.append(itemType); +// builder.append(", configuration="); +// builder.append(configuration); +// builder.append("]"); +// return builder.toString(); +// } +// +//} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GcubeProfileDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GcubeProfileDV.java index 578d284..0ba56b6 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GcubeProfileDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GcubeProfileDV.java @@ -10,7 +10,7 @@ import java.util.List; * * Mar 7, 2022 */ -public class GcubeProfileDV implements Serializable { +public class GcubeProfileDV implements GeoportalConfigurationID, Serializable { /** * @@ -19,6 +19,8 @@ public class GcubeProfileDV implements Serializable { public static final int MIN_MAX_NOT_SPECIFIED = -1; + private String configID; + private String gcubeSecondaryType; private String gcubeName; private String sectionName; @@ -40,12 +42,25 @@ public class GcubeProfileDV implements Serializable { private List filePaths; + + /** * Instantiates a new gcube profile DV. */ public GcubeProfileDV() { } + @Override + public String getID() { + return configID; + } + + @Override + public void setID(String configID) { + this.configID = configID; + + } + /** * Gets the gcube secondary type. * diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GeoportalConfigurationID.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GeoportalConfigurationID.java new file mode 100644 index 0000000..73d3851 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/GeoportalConfigurationID.java @@ -0,0 +1,8 @@ +package org.gcube.application.geoportalcommon.shared.geoportal.config; + +public interface GeoportalConfigurationID { + + String getID(); + + void setID(String configID); +} diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/ItemField.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ItemFieldDV.java similarity index 71% rename from src/main/java/org/gcube/application/geoportalcommon/shared/ItemField.java rename to src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ItemFieldDV.java index 7817b68..d36ccb4 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/ItemField.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/config/ItemFieldDV.java @@ -1,54 +1,69 @@ -package org.gcube.application.geoportalcommon.shared; +package org.gcube.application.geoportalcommon.shared.geoportal.config; import java.io.Serializable; import java.util.List; /** - * The Class ItemField. + * The Class ItemFieldDV. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Dec 21, 2021 + * Mar 16, 2022 */ -public class ItemField implements Serializable { +public class ItemFieldDV implements GeoportalConfigurationID, Serializable { /** * */ - private static final long serialVersionUID = 1856714668390438433L; - + private static final long serialVersionUID = -1489912649531434470L; private String displayName; private List jsonFields; + private String operator; + private boolean displayAsResult; private boolean sortable; private boolean searchable; - private boolean displayAsResult; + + private String configID; /** * Instantiates a new item field. */ - public ItemField() { + public ItemFieldDV() { } /** - * Instantiates a new item field. + * Instantiates a new item field DV. * * @param displayName the display name * @param jsonFields the json fields + * @param operator the operator * @param displayAsResult the display as result * @param sortable the sortable * @param searchable the searchable */ - public ItemField(String displayName, List jsonFields, boolean displayAsResult, boolean sortable, - boolean searchable) { + public ItemFieldDV(String displayName, List jsonFields, String operator, boolean displayAsResult, + boolean sortable, boolean searchable) { super(); this.displayName = displayName; this.jsonFields = jsonFields; + this.operator = operator; this.displayAsResult = displayAsResult; this.sortable = sortable; this.searchable = searchable; } + @Override + public String getID() { + return configID; + } + + @Override + public void setID(String configID) { + this.configID = configID; + + } + /** * Gets the display name. * @@ -67,6 +82,42 @@ public class ItemField implements Serializable { return jsonFields; } + /** + * Gets the operator. + * + * @return the operator + */ + public String getOperator() { + return operator; + } + + /** + * Checks if is display as result. + * + * @return true, if is display as result + */ + public boolean isDisplayAsResult() { + return displayAsResult; + } + + /** + * Checks if is sortable. + * + * @return true, if is sortable + */ + public boolean isSortable() { + return sortable; + } + + /** + * Checks if is searchable. + * + * @return true, if is searchable + */ + public boolean isSearchable() { + return searchable; + } + /** * Sets the display name. * @@ -86,48 +137,12 @@ public class ItemField implements Serializable { } /** - * Checks if is sortable. + * Sets the operator. * - * @return true, if is sortable + * @param operator the new operator */ - public boolean isSortable() { - return sortable; - } - - /** - * Sets the sortable. - * - * @param sortable the new sortable - */ - public void setSortable(boolean sortable) { - this.sortable = sortable; - } - - /** - * Checks if is searchable. - * - * @return true, if is searchable - */ - public boolean isSearchable() { - return searchable; - } - - /** - * Sets the searchable. - * - * @param searchable the new searchable - */ - public void setSearchable(boolean searchable) { - this.searchable = searchable; - } - - /** - * Checks if is display as result. - * - * @return true, if is display as result - */ - public boolean isDisplayAsResult() { - return displayAsResult; + public void setOperator(String operator) { + this.operator = operator; } /** @@ -139,6 +154,24 @@ public class ItemField implements Serializable { this.displayAsResult = displayAsResult; } + /** + * Sets the sortable. + * + * @param sortable the new sortable + */ + public void setSortable(boolean sortable) { + this.sortable = sortable; + } + + /** + * Sets the searchable. + * + * @param searchable the new searchable + */ + public void setSearchable(boolean searchable) { + this.searchable = searchable; + } + /** * To string. * @@ -147,16 +180,18 @@ public class ItemField implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("ItemField [displayName="); + builder.append("ItemFieldDV [displayName="); builder.append(displayName); builder.append(", jsonFields="); builder.append(jsonFields); + builder.append(", operator="); + builder.append(operator); + builder.append(", displayAsResult="); + builder.append(displayAsResult); builder.append(", sortable="); builder.append(sortable); builder.append(", searchable="); builder.append(searchable); - builder.append(", displayAsResult="); - builder.append(displayAsResult); builder.append("]"); return builder.toString(); } diff --git a/src/test/java/org/gcube/application/LoadDocumentConfiguration.java b/src/test/java/org/gcube/application/LoadDocumentConfiguration.java index e2e8935..e94bfea 100644 --- a/src/test/java/org/gcube/application/LoadDocumentConfiguration.java +++ b/src/test/java/org/gcube/application/LoadDocumentConfiguration.java @@ -1,42 +1,129 @@ -package org.gcube.application; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.gcube.application.geoportalcommon.MockDocumentConfigurationReader; -import org.gcube.application.geoportalcommon.geoportal.config.DocumentConfig; -import org.gcube.common.scope.api.ScopeProvider; -import org.junit.Test; - -public class LoadDocumentConfiguration { - - private static String TOKEN = ""; - private static String CONTEXT = "/gcube/devsec/devVRE"; - private static String USERNAME = "francesco.mangiacrapa"; - - // @Before - public void init() { - ScopeProvider.instance.set(CONTEXT); - } - - @Test - public void loadDocumentConfiguration() throws Exception { - - MockDocumentConfigurationReader mock = new MockDocumentConfigurationReader(); - System.out.println(mock.getListDocumentConfig()); - } - - private static String readFile(String filePath) { - String content = ""; - - try { - content = new String(Files.readAllBytes(Paths.get(filePath))); - } catch (IOException e) { - e.printStackTrace(); - } - - return content; - } - -} +//package org.gcube.application; +// +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.util.ArrayList; +//import java.util.LinkedHashMap; +//import java.util.List; +// +//import org.bson.Document; +//import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration; +//import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; +//import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile; +//import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; +//import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV; +//import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; +//import org.gcube.common.scope.api.ScopeProvider; +//import org.junit.Test; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +//public class LoadDocumentConfiguration { +// +// private static String TOKEN = ""; +// private static String CONTEXT = "/gcube/devsec/devVRE"; +// private static String USERNAME = "francesco.mangiacrapa"; +// private static Logger LOG = LoggerFactory.getLogger(LoadDocumentConfiguration.class); +// +// // @Before +// public void init() { +// ScopeProvider.instance.set(CONTEXT); +// } +// +// @Test +// public void loadDocumentConfiguration() throws Exception { +// +//// MockDocumentConfigurationReader mock = new MockDocumentConfigurationReader(); +//// System.out.println(mock.getListDocumentConfig()); +// +// toHandlerDeclarationDV(null); +// } +// +// private static String readFile(String filePath) { +// String content = ""; +// +// try { +// content = new String(Files.readAllBytes(Paths.get(filePath))); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// +// return content; +// } +// +// /** +// * To handler declaration DV. +// * +// * @param the generic type +// * @param handlerDeclaration the handler declaration +// * @return the handler declaration DV +// * @throws Exception +// */ +// public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration) throws Exception { +// +//// if (handlerDeclaration == null) { +//// LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null"); +//// return null; +//// } +// +//// Document configuration = handlerDeclaration.getConfiguration(); +//// +//// if (configuration == null) { +//// LOG.warn("Configuration is null"); +//// return null; +//// } +// +// String jsonConfig = readFile( +// "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config5.json"); +// +// LOG.debug("File as JSON: " + jsonConfig); +// +// Document document = org.gcube.application.geoportal.client.utils.Serialization.read(jsonConfig, Document.class); +// +// LinkedHashMap configuration = (LinkedHashMap) document.get("_configuration"); +// +// try { +// List gcubeProfiles = null; +// try { +// gcubeProfiles = configuration.get("gcubeProfiles", ArrayList.class); +// } catch (Exception e) { +// LOG.info("gcubeProfiles not found in the handler"); +// return null; +// } +// +// // HANDLER OF "gcubeProfiles" configuration +// if (gcubeProfiles != null) { +// +// List listGcubeProfiles = new ArrayList(gcubeProfiles.size()); +// +// int i = 0; +// for (String gCubeProfile : gcubeProfiles) { +// LOG.debug(i++ + ") the gCubeProfile is: " + gCubeProfile); +// GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(gCubeProfile, +// GcubeProfile.class); +// listGcubeProfiles.add(ConvertToDataValueObjectModel.toGcubeProfileDV(profile)); +// } +// +// HandlerDeclarationDV hdDV = new HandlerDeclarationDV(); +// hdDV.setId(handlerDeclaration.getId()); +// hdDV.setType(handlerDeclaration.getType()); +// +// ConfigurationDV> dDV = new ConfigurationDV>( +// listGcubeProfiles); +// dDV.setConfiguration(listGcubeProfiles); +// hdDV.setConfiguration(dDV); +// +// LOG.info("returning {}", hdDV); +// return hdDV; +// } +// } catch (Exception e) { +// LOG.error("Error on getting " + HandlerDeclaration.class.getSimpleName(), e); +// throw e; +// } +// +// return null; +// +// } +// +//} diff --git a/src/test/java/org/gcube/application/TestGNACommon.java b/src/test/java/org/gcube/application/TestGNACommon.java index dbc2262..1ffd157 100644 --- a/src/test/java/org/gcube/application/TestGNACommon.java +++ b/src/test/java/org/gcube/application/TestGNACommon.java @@ -4,8 +4,8 @@ import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; -import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.config.RoleRights; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.scope.api.ScopeProvider; @@ -112,7 +112,7 @@ public class TestGNACommon { System.out.println("Item Fields are:"); i = 0; - for (ItemField item : configurations.getListItemFields()) { + for (ItemFieldDV item : configurations.getListItemFields()) { System.out.println(++i + " " + item); } } catch (Exception e) { @@ -132,7 +132,7 @@ public class TestGNACommon { System.out.println(configurations.getMapLayers()); System.out.println("Item Fields are:"); int i = 0; - for (ItemField item : configurations.getListItemFields()) { + for (ItemFieldDV item : configurations.getListItemFields()) { System.out.println(++i + " " + item); } } catch (Exception e) { diff --git a/src/test/java/org/gcube/application/UCD_Tests.java b/src/test/java/org/gcube/application/UCD_Tests.java index 4f99c1e..faf1c81 100644 --- a/src/test/java/org/gcube/application/UCD_Tests.java +++ b/src/test/java/org/gcube/application/UCD_Tests.java @@ -3,6 +3,7 @@ package org.gcube.application; import java.util.List; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; +import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller; import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; @@ -18,7 +19,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 = "8e74a17c-92f1-405a-b591-3a6090066248-98187548"; // devVRE private static String PROFILE_ID = "profiledConcessioni"; @@ -30,7 +31,7 @@ public class UCD_Tests { client = GeoportalClientCaller.useCaseDescriptors(); } - // @Test + //@Test public void getList() throws Exception { ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN); @@ -42,12 +43,27 @@ public class UCD_Tests { } } - @Test + //@Test public void getItemByID() throws Exception { ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN); - UseCaseDescriptor ucd = client.geUCDForId(PROFILE_ID); + UseCaseDescriptor ucd = client.getUCDForId(PROFILE_ID); System.out.println(ucd); } + + + @Test + public void convertToDVObject() throws Exception { + ScopeProvider.instance.set(CONTEXT); + SecurityTokenProvider.instance.set(TOKEN); + List listOfUCD = client.getList(); + + int i = 0; + for (UseCaseDescriptor useCaseDescriptor : listOfUCD) { + System.out.println(++i + ") " + useCaseDescriptor); + ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null); + } + } + } diff --git a/src/test/resources/geoportal-config.json b/src/test/resources/geoportal-config.json index 0369e48..aba3a8e 100644 --- a/src/test/resources/geoportal-config.json +++ b/src/test/resources/geoportal-config.json @@ -1,89 +1,38 @@ { - "id": "geoportal-data-entry-app", - "type": "DATA_ENTRY_GUI", - "item_type": "Concessione", - "configuration": { + "_id": "org.gcube.geoportal-data-entry-portlet", + "_type": "DATA_ENTRY_GUI", + "_configuration": { "gcubeProfiles": [ { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Informazioni_di_progetto", - "sectionName": "$.", - "sectionTitle": "Informazioni di Progetto" - }, - { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Abstract_Relazione_di_Scavo", - "sectionName": "abstractRelazione", - "sectionTitle": "Abstract Relazione Scavo", - "parentName": "$.", + "gcubeCategory": "1", + "gcubeName": "1", + "order": "", + "sectionName": "", + "sectionTitle": "", + "cardinality": "", + "parentName": "", "filePaths": [ { - "fieldDefinition": "Carica Abstract Ita (in PDF)", - "fieldName": "filesetIta" - }, - { - "fieldDefinition": "Carica Abstract Ita (in PDF)", - "fieldName": "filesetEng" + "field": "field id from XML gcube Profile", + "path": "$.abstract.associatedFiles" } ] }, { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Relazione_di_Scavo", - "sectionName": "relazioneScavo", - "sectionTitle": "Relazione di Scavo", - "parentName": "$.", + "gcubeCategory": "2", + "gcubeName": "2", + "order": "", + "sectionName": "", + "sectionTitle": "", + "cardinality": "", + "parentName": "", "filePaths": [ { - "fieldDefinition": "Relazione di fine scavo (in PDF)", - "fieldName": "fileset" - } - ] - }, - { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Immagine_Rappresentativa_di_Scavo", - "sectionName": "immagini", - "sectionTitle": "Immagini Rappresentative", - "minOccurs": 3, - "maxOccurs": 8, - "parentName": "$.", - "filePaths": [ - { - "fieldDefinition": "Immagine", - "fieldName": "fileset" - } - ] - }, - { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Posizionamento_dell_area_di_indagine", - "sectionName": "posizionamentoScavo", - "sectionTitle": "Posizionamento dell'Area di Indagine", - "parentName": "$.", - "filePaths": [ - { - "fieldDefinition": "File", - "fieldName": "fileset" - } - ] - }, - { - "gcubeSecondaryType": "GeoNaMetadata", - "gcubeName": "Pianta_di_fine_Scavo", - "sectionName": "pianteFineScavo", - "sectionTitle": "Piante di fine Scavo", - "parentName": "$.", - "minOccurs": 0, - "maxOccurs": 0, - "filePaths": [ - { - "fieldDefinition": "File", - "fieldName": "fileset" + "field": "field id from XML gcube Profile", + "path": "$.abstract.associatedFiles" } ] } - ], - "saveStep": "SUBMIT-FOR-REVIEW" + ] } } \ No newline at end of file diff --git a/src/test/resources/geoportal-config2.json b/src/test/resources/geoportal-config2.json index f3dd4c3..0722071 100644 --- a/src/test/resources/geoportal-config2.json +++ b/src/test/resources/geoportal-config2.json @@ -1,5 +1,5 @@ { - "id": "geoportal-data-entry-app", + "id": "org.gcube.portlets.user.geoportal-data-entry-app", "type": "DATA_ENTRY_GUI", "item_type": "Archeologia Preventiva", "configuration": { diff --git a/src/test/resources/geoportal-config3.json b/src/test/resources/geoportal-config3.json index 96e479b..f21f507 100644 --- a/src/test/resources/geoportal-config3.json +++ b/src/test/resources/geoportal-config3.json @@ -1,5 +1,5 @@ { - "id": "geoportal-data-entry-app", + "id": "org.gcube.portlets.user.geoportal-data-entry-app", "type": "DATA_ENTRY_GUI", "item_type": "Deliverable", "configuration": { diff --git a/src/test/resources/geoportal-config4.json b/src/test/resources/geoportal-config4.json index d3a669a..b855f72 100644 --- a/src/test/resources/geoportal-config4.json +++ b/src/test/resources/geoportal-config4.json @@ -1,5 +1,5 @@ { - "id": "geoportal-data-entry-app", + "id": "org.gcube.portlets.user.geoportal-data-entry-app", "type": "DATA_ENTRY_GUI", "item_type": "Dataset", "configuration": { diff --git a/src/test/resources/geoportal-config5.json b/src/test/resources/geoportal-config5.json new file mode 100644 index 0000000..5ffc044 --- /dev/null +++ b/src/test/resources/geoportal-config5.json @@ -0,0 +1,89 @@ +{ + "_id": "org.gcube.portlets.user.geoportal-data-entry-app", + "_type": "DATA_ENTRY_GUI", + "_item_type": "Concessione", + "_configuration": { + "gcubeProfiles": [ + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Informazioni_di_progetto", + "sectionName": "$.", + "sectionTitle": "Informazioni di Progetto" + }, + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Abstract_Relazione_di_Scavo", + "sectionName": "abstractRelazione", + "sectionTitle": "Abstract Relazione Scavo", + "parentName": "$.", + "filePaths": [ + { + "fieldDefinition": "Carica Abstract Ita (in PDF)", + "fieldName": "filesetIta" + }, + { + "fieldDefinition": "Carica Abstract Ita (in PDF)", + "fieldName": "filesetEng" + } + ] + }, + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Relazione_di_Scavo", + "sectionName": "relazioneScavo", + "sectionTitle": "Relazione di Scavo", + "parentName": "$.", + "filePaths": [ + { + "fieldDefinition": "Relazione di fine scavo (in PDF)", + "fieldName": "fileset" + } + ] + }, + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Immagine_Rappresentativa_di_Scavo", + "sectionName": "immagini", + "sectionTitle": "Immagini Rappresentative", + "minOccurs": 1, + "maxOccurs": 8, + "parentName": "$.", + "filePaths": [ + { + "fieldDefinition": "Immagine", + "fieldName": "fileset" + } + ] + }, + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Posizionamento_dell_area_di_indagine", + "sectionName": "posizionamentoScavo", + "sectionTitle": "Posizionamento dell'Area di Indagine", + "parentName": "$.", + "filePaths": [ + { + "fieldDefinition": "File", + "fieldName": "fileset" + } + ] + }, + { + "gcubeSecondaryType": "GeoNaMetadata", + "gcubeName": "Pianta_di_fine_Scavo", + "sectionName": "pianteFineScavo", + "sectionTitle": "Piante di fine Scavo", + "parentName": "$.", + "minOccurs": 0, + "maxOccurs": 0, + "filePaths": [ + { + "fieldDefinition": "File", + "fieldName": "fileset" + } + ] + } + ], + "saveStep": "SUBMIT-FOR-REVIEW" + } +} \ No newline at end of file diff --git a/src/test/resources/org.gcube.geoportal-data-list.json b/src/test/resources/org.gcube.geoportal-data-list.json new file mode 100644 index 0000000..a57f155 --- /dev/null +++ b/src/test/resources/org.gcube.geoportal-data-list.json @@ -0,0 +1,75 @@ +{ + "_id": "org.gcube.geoportal-data-list", + "_type": "DATA_LIST_GUI", + "case": "FullList", + "_configuration": { + "projection": "{\"nome\" : 1, \"lifecycleInformation.phase\" : 1}", + "itemFields": [ + { + "label": "Name", + "paths": [ + "Nome del progetto" + ], + "operator": "$and", + "searchable": true, + "sortable": true, + "asResult": true + }, + { + "label": "Introduction", + "paths": [ + "Introduzione" + ], + "operator": "$and", + "searchable": true, + "sortable": false, + "asResult": true + }, + { + "label": "Author/s", + "paths": [ + "Nome Autore, Email, Ruolo" + ], + "operator": "$and", + "searchable": false, + "sortable": true, + "asResult": true + }, + { + "label": "Project Start", + "paths": [ + "Data inizio Progetto" + ], + "operator": "$and", + "searchable": false, + "sortable": true, + "asResult": true + }, + { + "label": "Director/Staff", + "paths": [ + "Nome Autore, Email, Ruolo", + "Contributore", + "Titolare dei dati", + "Editore", + "Responsabile" + ], + "operator": "$or", + "searchable": true, + "sortable": false, + "asResult": true + }, + { + "label": "Keywords", + "paths": [ + "Parola chiave a scelta libera", + "Parola chiave relativa alla cronologia" + ], + "operator": "$or", + "searchable": true, + "sortable": false, + "asResult": true + } + ] + } +}