178 lines
7.1 KiB
Java
178 lines
7.1 KiB
Java
//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.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 {
|
|
// //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>();
|
|
//
|
|
//
|
|
//
|
|
// 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);
|
|
////
|
|
//// 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 = "";
|
|
//
|
|
// try {
|
|
// content = new String(Files.readAllBytes(Paths.get(filePath)));
|
|
// } catch (IOException e) {
|
|
// e.printStackTrace();
|
|
// }
|
|
//
|
|
// return content;
|
|
// }
|
|
//
|
|
// public List<DocumentConfigDV> getListDocumentConfig() {
|
|
// return listDocumentConfigsDV;
|
|
// }
|
|
//}
|