in progress on migration to UCD
This commit is contained in:
parent
f1cec8071a
commit
9f3bd01da0
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -27,6 +28,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorD
|
|||
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;
|
||||
|
||||
|
@ -134,7 +136,7 @@ public class ConvertToDataValueObjectModel {
|
|||
*
|
||||
* @param ucd the ucd
|
||||
* @param handlersIds the handlers ids. If not null only returns (so filtering
|
||||
* for) handler ids. Otherwise returns all handlers
|
||||
* for) the handler ids. Otherwise returns all handlers
|
||||
* @return the document config DV
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -162,9 +164,15 @@ public class ConvertToDataValueObjectModel {
|
|||
List<HandlerDeclaration> 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);
|
||||
HandlerDeclarationDV hdDV = toHandlerDeclarationDV(handlerDeclaration, ucd.getName());
|
||||
if (hdDV != null) {
|
||||
LOG.debug("handler converted to {}", hdDV);
|
||||
listHandlersDV.add(hdDV);
|
||||
} else {
|
||||
LOG.info("Skipping {} as null for {}", HandlerDeclarationDV.class.getSimpleName(),
|
||||
handlerDeclaration);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,9 +180,14 @@ public class ConvertToDataValueObjectModel {
|
|||
List<HandlerDeclaration> 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);
|
||||
HandlerDeclarationDV hdDV = toHandlerDeclarationDV(handlerDeclaration, ucd.getName());
|
||||
if (hdDV != null) {
|
||||
LOG.debug("handler converted to {}", hdDV);
|
||||
listHandlersDV.add(hdDV);
|
||||
} else {
|
||||
LOG.info("Skipping {} as null for {}", HandlerDeclarationDV.class.getSimpleName(),
|
||||
handlerDeclaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +218,8 @@ public class ConvertToDataValueObjectModel {
|
|||
* @return the handler declaration DV
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration) throws Exception {
|
||||
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration, String profileName)
|
||||
throws Exception {
|
||||
|
||||
if (handlerDeclaration == null) {
|
||||
LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null");
|
||||
|
@ -217,40 +231,61 @@ public class ConvertToDataValueObjectModel {
|
|||
HandlerDeclarationDV hdDV = new HandlerDeclarationDV();
|
||||
hdDV.setId(handlerDeclaration.getId());
|
||||
hdDV.setType(handlerDeclaration.getType());
|
||||
hdDV.setHandlerType(to_GEOPORTAL_DATA_HANDLER(handlerDeclaration.getId()));
|
||||
hdDV.setItemType(profileName);
|
||||
hdDV.setDataHandlerType(to_GEOPORTAL_DATA_HANDLER(handlerDeclaration.getId()));
|
||||
if (configuration == null) {
|
||||
LOG.warn("Configuration is null");
|
||||
LOG.warn("Configuration is null in the handler with id: " + handlerDeclaration.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
GEOPORTAL_CONFIGURATION_TYPE foundConfig = null;
|
||||
ArrayList<String> configurations = null;
|
||||
GEOPORTAL_CONFIGURATION_TYPE geoportalConfigType = null;
|
||||
ArrayList<JSONObject> configurations = null;
|
||||
for (GEOPORTAL_CONFIGURATION_TYPE configManaged : GEOPORTAL_CONFIGURATION_TYPE.values()) {
|
||||
try {
|
||||
configurations = configuration.get(configManaged.getId(), ArrayList.class);
|
||||
foundConfig = configManaged;
|
||||
break;
|
||||
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);
|
||||
|
||||
if (hashMapConfig != null) {
|
||||
|
||||
configurations = new ArrayList<JSONObject>();
|
||||
|
||||
for (LinkedHashMap<String, Object> config : hashMapConfig) {
|
||||
LOG.debug("config is: {}", config.toString());
|
||||
configurations.add(new JSONObject(config.toString()));
|
||||
}
|
||||
LOG.debug("configurations found are: {}", configurations);
|
||||
geoportalConfigType = configManaged;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.info(configManaged.getId() + "not found in the handler");
|
||||
LOG.info(configManaged.getId() + " not found in the configuration of the handler "
|
||||
+ handlerDeclaration.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (configurations == null) {
|
||||
String error = "No managed configurations as '" + GEOPORTAL_CONFIGURATION_TYPE.values()
|
||||
+ "' found in the handler";
|
||||
String error = "No managed configurations as '"
|
||||
+ Arrays.asList(GEOPORTAL_CONFIGURATION_TYPE.values()).toString() + "' found in the handler "
|
||||
+ handlerDeclaration.getId();
|
||||
LOG.warn(error);
|
||||
throw new Exception(error);
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (foundConfig) {
|
||||
switch (geoportalConfigType) {
|
||||
case gcube_profiles: {
|
||||
|
||||
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(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,
|
||||
for (JSONObject gCubeProfile : configurations) {
|
||||
String asJSONString = gCubeProfile.toString();
|
||||
LOG.debug(++i + ") the gCubeProfile is: " + asJSONString);
|
||||
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
|
||||
GcubeProfile.class);
|
||||
listGcubeProfiles.add(toGcubeProfileDV(profile));
|
||||
}
|
||||
|
@ -268,9 +303,10 @@ public class ConvertToDataValueObjectModel {
|
|||
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(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,
|
||||
for (JSONObject itemField : configurations) {
|
||||
String asJSONString = itemField.toString();
|
||||
LOG.debug(++i + ") the itemField is: " + asJSONString);
|
||||
ItemField profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
|
||||
ItemField.class);
|
||||
listItemFields.add(toItemFieldDV(profile));
|
||||
}
|
||||
|
@ -408,6 +444,9 @@ public class ConvertToDataValueObjectModel {
|
|||
theProject.setProfileVersion(
|
||||
project.getProfileVersion() != null ? project.getProfileVersion().getValue() : "");
|
||||
|
||||
theProject.setTheDocument(toDocumentDV(project.getTheDocument(), DocumentDV.class,
|
||||
projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
||||
|
||||
Relationship[] relations = project.getRelationships();
|
||||
|
||||
if (relations != null && projectReader.isIncludeRelationships()) {
|
||||
|
@ -434,12 +473,14 @@ public class ConvertToDataValueObjectModel {
|
|||
// if (theProject.getValidationReport() != null)
|
||||
// theProject.setValidationStatus(theConcessione.getValidationReport().getStatus());
|
||||
// }
|
||||
|
||||
//
|
||||
// LOG.info("Returning concessioneDV with id: " + theConcessione.getItemId());
|
||||
//
|
||||
// if (LOG.isTraceEnabled())
|
||||
// LOG.trace("Returning: " + theConcessione);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.trace("Returning: " + theProject);
|
||||
|
||||
LOG.info("Returning project with id: " + theProject.getId());
|
||||
return theProject;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on converting project: " + project, e);
|
||||
|
|
|
@ -4,53 +4,160 @@
|
|||
//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.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.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.UseCaseDescriptorDV;
|
||||
//import org.gcube.application.geoportalcommon.shared.geoportal.config.DocumentConfigDV;
|
||||
//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;
|
||||
//
|
||||
//public class MockDocumentConfigurationReader {
|
||||
//
|
||||
// private static final Logger LOG = LoggerFactory.getLogger(MockDocumentConfigurationReader.class);
|
||||
//
|
||||
// private List<DocumentConfigDV> listDocumentConfigsDV = new ArrayList<DocumentConfigDV>();
|
||||
//
|
||||
// public MockDocumentConfigurationReader() {
|
||||
// try {
|
||||
// //loadDocumentConfiguration();
|
||||
// //loadConfigurations();
|
||||
// } catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void loadConfigurations() {
|
||||
//
|
||||
// List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>();
|
||||
// UseCaseDescriptorDV usecaseDescriptorDV = new UseCaseDescriptorDV("theId","version","listConcessioni", null);
|
||||
// List<HandlerDeclarationDV> handlers = new ArrayList<HandlerDeclarationDV>();
|
||||
//
|
||||
//
|
||||
//
|
||||
//// //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);
|
||||
// HandlerDeclarationDV hdDV = new HandlerDeclarationDV();
|
||||
// hdDV.setId(handlerDeclaration.getId());
|
||||
// hdDV.setType(handlerDeclaration.getType());
|
||||
// hdDV.setItemType("MISSING ITEM TYPE IN THE SERVICE MODEL");
|
||||
// hdDV.setDataHandlerType(to_GEOPORTAL_DATA_HANDLER(handlerDeclaration.getId()));
|
||||
//
|
||||
//// List<GcubeProfileDV> gcubeProfiles = new ArrayList<GcubeProfileDV>();
|
||||
//// GcubeProfileDV profile = new GcubeProfileDV();
|
||||
//// profile.setGcubeName("GcubeName");
|
||||
//// profile.setGcubeSecondaryType("GcubeSecondaryType");
|
||||
//// gcubeProfiles.add(profile);
|
||||
////
|
||||
//// ConfigurationDV<List<GcubeProfileDV>> configuration = new ConfigurationDV<List<GcubeProfileDV>>(gcubeProfiles);
|
||||
//// HandlerDeclarationDV handler = new HandlerDeclarationDV(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId(), GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getType(), "Concessioni", configuration,GEOPORTAL_DATA_HANDLER.geoportal_data_entry);
|
||||
////
|
||||
//// 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);
|
||||
//// }
|
||||
//// handlers.add(handler);
|
||||
//// usecaseDescriptorDV.setHandlers(handlers);
|
||||
//// listUCDDV.add(usecaseDescriptorDV);
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// GEOPORTAL_CONFIGURATION_TYPE geoportalConfigType = null;
|
||||
//
|
||||
// String jsonConfig = readFile(
|
||||
// "/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config5.json");
|
||||
//
|
||||
// Document document = org.gcube.application.geoportal.client.utils.Serialization.read(jsonConfig, Document.class);
|
||||
//
|
||||
// LinkedHashMap<String, String> configuration = (LinkedHashMap<String, String>) document.get("_configuration");
|
||||
//
|
||||
//
|
||||
// List<String> configurations = new ArrayList<String>(configuration.values());
|
||||
//
|
||||
// switch (geoportalConfigType) {
|
||||
// case gcube_profiles: {
|
||||
//
|
||||
// List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(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(ConvertToDataValueObjectModel.toGcubeProfileDV(profile));
|
||||
// }
|
||||
//
|
||||
// ConfigurationDV<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
|
||||
// listGcubeProfiles);
|
||||
// dDV.setConfiguration(listGcubeProfiles);
|
||||
// dDV.setConfigurationType(GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||
// hdDV.setConfiguration(dDV);
|
||||
// LOG.info("returning {}", hdDV);
|
||||
// return hdDV;
|
||||
// }
|
||||
// case item_fields: {
|
||||
//
|
||||
// List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(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(ConvertToDataValueObjectModel.toItemFieldDV(profile));
|
||||
// }
|
||||
//
|
||||
// ConfigurationDV<List<ItemFieldDV>> dDV = new ConfigurationDV<List<ItemFieldDV>>(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;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //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 = "";
|
||||
|
|
|
@ -39,15 +39,36 @@ import com.mongodb.BasicDBList;
|
|||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.BasicDBObjectBuilder;
|
||||
|
||||
/**
|
||||
* The Class ProjectsCaller.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 17, 2022
|
||||
*/
|
||||
public class ProjectsCaller {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(GeoportalClientCaller.class);
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the client
|
||||
*/
|
||||
public Projects<Project> getClient(String profileID) {
|
||||
LOG.info("getClient called for profileID={}", profileID);
|
||||
return projects(profileID).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the new.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param jsonDocument the json document
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public Project createNew(String profileID, String jsonDocument) throws RemoteException {
|
||||
LOG.info("createNew called on profileID={}", profileID);
|
||||
Document myDocument = Document.parse(jsonDocument);
|
||||
|
@ -56,6 +77,20 @@ public class ProjectsCaller {
|
|||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register file set.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param project the project
|
||||
* @param theFile the the file
|
||||
* @param parentPath the parent path
|
||||
* @param fieldName the field name
|
||||
* @param fieldDefinition the field definition
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
*/
|
||||
public Project registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName,
|
||||
String fieldDefinition) throws RemoteException, FileNotFoundException, JsonProcessingException {
|
||||
LOG.info(
|
||||
|
@ -73,6 +108,13 @@ public class ProjectsCaller {
|
|||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list for profile ID.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the list for profile ID
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<Project> getListForProfileID(String profileID) throws Exception {
|
||||
LOG.info("getListForProfileID called for profileID: {}", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
|
@ -88,6 +130,13 @@ public class ProjectsCaller {
|
|||
return listProjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the configuration
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Configuration getConfiguration(String profileID) throws Exception {
|
||||
LOG.info("getConfiguration called for profileID: {} ", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
|
@ -99,15 +148,17 @@ public class ProjectsCaller {
|
|||
/**
|
||||
* Query on mongo.
|
||||
*
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param recordType the record type
|
||||
* @param profileID the profile ID
|
||||
* @param totalItems the total items
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param projectDVBuilder the project DV builder
|
||||
* @return the result set paginated data
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ResultSetPaginatedData queryOnMongo(String profileID, Integer totalItems, Integer offset, Integer limit,
|
||||
SearchingFilter filter, String recordType, ProjectDVBuilder projectDVBuilder) throws Exception {
|
||||
SearchingFilter filter, ProjectDVBuilder projectDVBuilder) throws Exception {
|
||||
LOG.info("queryOnMongo called");
|
||||
|
||||
try {
|
||||
|
|
|
@ -35,12 +35,12 @@ public class UseCaseDescriptorCaller {
|
|||
listUCD.add(prg);
|
||||
|
||||
}
|
||||
LOG.info("returning %d {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
LOG.info("returning {} {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
return listUCD;
|
||||
}
|
||||
|
||||
public List<UseCaseDescriptor> getListForHandlerIds(List<String> listHandlersIds) throws Exception {
|
||||
LOG.info("getListForHandlerId called");
|
||||
LOG.info("getListForHandlerIds called");
|
||||
return getListForJSONPath("_handlers._id", listHandlersIds);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class UseCaseDescriptorCaller {
|
|||
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
Document queryDoc = new Document();
|
||||
queryDoc.put("$eq", list);
|
||||
queryDoc.put("$and", list);
|
||||
LOG.debug("Performing query: {}", queryDoc.toJson());
|
||||
queryRequest.setFilter(queryDoc);
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class UseCaseDescriptorCaller {
|
|||
listUCD.add(prg);
|
||||
|
||||
}
|
||||
LOG.info("returning %d {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
LOG.info("returning {} {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
return listUCD;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
//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<T>{
|
||||
//
|
||||
// private List<T> listConfigs;
|
||||
//
|
||||
//}
|
|
@ -1,19 +0,0 @@
|
|||
//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<GcubeProfile> listConfigs;
|
||||
//}
|
|
@ -1,27 +0,0 @@
|
|||
//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<T> {
|
||||
//
|
||||
// @JsonProperty
|
||||
// private String _id;
|
||||
//
|
||||
// @JsonProperty
|
||||
// private String _type;
|
||||
//
|
||||
// @JsonProperty
|
||||
// private String _item_type;
|
||||
//
|
||||
// @JsonProperty
|
||||
// private Configuration<T> _configuration;
|
||||
//
|
||||
//}
|
|
@ -2,61 +2,147 @@ package org.gcube.application.geoportalcommon.shared.geoportal;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class HandlerDeclarationDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 17, 2022
|
||||
*/
|
||||
public class HandlerDeclarationDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9095207023666383038L;
|
||||
private static final long serialVersionUID = 3664650151266716354L;
|
||||
|
||||
private String id;
|
||||
private String type;
|
||||
private String itemType; // This is the use case (e.g. Concessioni)
|
||||
private ConfigurationDV<?> configuration;
|
||||
private GEOPORTAL_DATA_HANDLER dataHandlerType;
|
||||
|
||||
/**
|
||||
* Instantiates a new handler declaration DV.
|
||||
*/
|
||||
public HandlerDeclarationDV() {
|
||||
}
|
||||
|
||||
public HandlerDeclarationDV(String id, String type, ConfigurationDV<?> configuration,
|
||||
/**
|
||||
* Instantiates a new handler declaration DV.
|
||||
*
|
||||
* @param id the id
|
||||
* @param type the type
|
||||
* @param itemType the item type
|
||||
* @param configuration the configuration
|
||||
* @param dataHandlerType the data handler type
|
||||
*/
|
||||
public HandlerDeclarationDV(String id, String type, String itemType,
|
||||
ConfigurationDV<?> configuration,
|
||||
GEOPORTAL_DATA_HANDLER dataHandlerType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.itemType = itemType;
|
||||
this.configuration = configuration;
|
||||
this.dataHandlerType = dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item type.
|
||||
*
|
||||
* @return the item type
|
||||
*/
|
||||
public String getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
public ConfigurationDV<?> getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setConfiguration(ConfigurationDV<?> configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void setHandlerType(GEOPORTAL_DATA_HANDLER dataHandlerType) {
|
||||
this.dataHandlerType = dataHandlerType;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data handler type.
|
||||
*
|
||||
* @return the data handler type
|
||||
*/
|
||||
public GEOPORTAL_DATA_HANDLER getDataHandlerType() {
|
||||
return dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type.
|
||||
*
|
||||
* @param type the new type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item type.
|
||||
*
|
||||
* @param itemType the new item type
|
||||
*/
|
||||
public void setItemType(String itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration.
|
||||
*
|
||||
* @param configuration the new configuration
|
||||
*/
|
||||
public void setConfiguration(ConfigurationDV<?> configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data handler type.
|
||||
*
|
||||
* @param dataHandlerType the new data handler type
|
||||
*/
|
||||
public void setDataHandlerType(GEOPORTAL_DATA_HANDLER dataHandlerType) {
|
||||
this.dataHandlerType = dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -64,6 +150,8 @@ public class HandlerDeclarationDV implements Serializable {
|
|||
builder.append(id);
|
||||
builder.append(", type=");
|
||||
builder.append(type);
|
||||
builder.append(", itemType=");
|
||||
builder.append(itemType);
|
||||
builder.append(", configuration=");
|
||||
builder.append(configuration);
|
||||
builder.append(", dataHandlerType=");
|
||||
|
@ -72,4 +160,6 @@ public class HandlerDeclarationDV implements Serializable {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
//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<GcubeProfileDV> gcubeProfiles;
|
||||
//
|
||||
// public ConfigGcubeProfileDV() {
|
||||
// }
|
||||
//
|
||||
// public List<GcubeProfileDV> getGcubeProfiles() {
|
||||
// return gcubeProfiles;
|
||||
// }
|
||||
//
|
||||
// public void setGcubeProfiles(List<GcubeProfileDV> gcubeProfiles) {
|
||||
// this.gcubeProfiles = gcubeProfiles;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// StringBuilder builder = new StringBuilder();
|
||||
// builder.append("ConfigGcubeProfileDV [gcubeProfiles=");
|
||||
// builder.append(gcubeProfiles);
|
||||
// builder.append("]");
|
||||
// return builder.toString();
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -1,66 +0,0 @@
|
|||
//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();
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -5,4 +5,5 @@ public interface GeoportalConfigurationID {
|
|||
String getID();
|
||||
|
||||
void setID(String configID);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,129 +1,131 @@
|
|||
//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();
|
||||
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 <T> 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();
|
||||
//
|
||||
// return content;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * To handler declaration DV.
|
||||
// *
|
||||
// * @param <T> 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<String, String> configuration = (LinkedHashMap<String, String>) document.get("_configuration");
|
||||
//
|
||||
// try {
|
||||
// List<String> gcubeProfiles = null;
|
||||
// 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<String, String> configuration = (LinkedHashMap<String, String>) document.get("_configuration");
|
||||
|
||||
//configuration.values();
|
||||
|
||||
try {
|
||||
List<String> gcubeProfiles = new ArrayList<String>(configuration.values());
|
||||
// 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<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(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<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
|
||||
// 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;
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
// HANDLER OF "gcubeProfiles" configuration
|
||||
if (gcubeProfiles != null) {
|
||||
|
||||
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(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<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.util.Arrays;
|
||||
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.application.geoportalcommon.shared.geoportal.GEOPORTAL_DATA_HANDLER;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.Before;
|
||||
|
@ -53,7 +55,7 @@ public class UCD_Tests {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void convertToDVObject() throws Exception {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
@ -65,5 +67,17 @@ 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);
|
||||
ConvertToDataValueObjectModel.toUseCaseDescriptorDV(useCaseDescriptor, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue