diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 961c545..65accbf 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,9 @@ - + + + + + @@ -52,7 +56,11 @@ - + + + + + @@ -105,7 +113,11 @@ - + + + + + @@ -158,7 +170,11 @@ - + + + + + @@ -211,7 +227,11 @@ - + + + + + @@ -219,7 +239,11 @@ uses - + + + + + @@ -272,7 +296,11 @@ - + + + + + @@ -325,7 +353,11 @@ - + + + + + @@ -378,7 +410,11 @@ - + + + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java index 194df51..d706354 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java @@ -9,6 +9,8 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; +import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; @@ -26,7 +28,7 @@ public class GeoPortalClientCaches { private TreeMap> mapGcubeProfilePerItemType; - private Map>> mapHandlersConfigurationsForProfileId; + //private Map> mapHandlersConfigurationsForProfileId; private Map mapUseCaseDescriptor; @@ -39,22 +41,11 @@ public class GeoPortalClientCaches { */ public GeoPortalClientCaches() { mapGcubeProfilePerItemType = new TreeMap>(); - mapHandlersConfigurationsForProfileId = new HashMap>>(); mapSearchingFilterParametersForProfileId = new HashMap(); mapUseCaseDescriptor = new HashMap(); mapRelationsNamesForProfileId = new HashMap>(); } - /** - * Put handler configurations for profile id. - * - * @param profileId the profile id - * @param lsitConfigurations the lsit configurations - */ - public void putHandlerConfigurationsForProfileId(String profileId, List> lsitConfigurations) { - mapHandlersConfigurationsForProfileId.put(profileId, lsitConfigurations); - } - /** * Put list relationships definition for profile ID. * @@ -96,16 +87,6 @@ public class GeoPortalClientCaches { return mapUseCaseDescriptor.get(profileID); } - /** - * Gets the handler configurations for profile id. - * - * @param profileId the profile id - * @return the handler configurations for profile id - */ - public List> getHandlerConfigurationsForProfileId(String profileId) { - return mapHandlersConfigurationsForProfileId.get(profileId); - } - /** * Put gcube profile per item type. * @@ -132,7 +113,8 @@ public class GeoPortalClientCaches { * @param profileID the profile ID * @return the filter parameters for profile id */ - public CacheSearchingFilterParametersFromConfig getFilterParametersForProfileId(String profileID) { + public CacheSearchingFilterParametersFromConfig getFilterParametersForProfileId(String profileID, + GEOPORTAL_DATA_HANDLER handlerType) { GWT.log("getFilterParametersForProfileId for: " + profileID); CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFilterParametersForProfileId @@ -141,57 +123,63 @@ public class GeoPortalClientCaches { if (searchingFilterParameters == null) { searchingFilterParameters = new CacheSearchingFilterParametersFromConfig(); + UseCaseDescriptorDV ucd = mapUseCaseDescriptor.get(profileID); + + for (HandlerDeclarationDV handler : ucd.getHandlers()) { - List> config = mapHandlersConfigurationsForProfileId.get(profileID); + if (handler.getDataHandlerType().equals(handlerType)) { + ConfigurationDV configurationDV = handler.getConfiguration(); + GWT.log("For profileID " + profileID + " and handler type " + handlerType + ", read config for : " + + configurationDV); - GWT.log("For profileID " + profileID + ", read config for : " + config); + switch (configurationDV.getConfigurationType()) { + case item_fields: { + List listItemFields = (List) configurationDV.getConfiguration(); + for (ItemFieldDV itemField : listItemFields) { + if (itemField.isDisplayAsResult()) { + searchingFilterParameters.addDisplayField(itemField); + // adding to projection for filtering + for (String jsonFieldPath : itemField.getJsonFields()) { + // String mongoProjection = itemField.getProjection() + "." + jsonField; + searchingFilterParameters.putMongoProjection(jsonFieldPath, 1); + } + } - for (ConfigurationDV configurationDV : config) { - switch (configurationDV.getConfigurationType()) { - case item_fields: { - List listItemFields = (List) configurationDV.getConfiguration(); - for (ItemFieldDV itemField : listItemFields) { - if (itemField.isDisplayAsResult()) { - searchingFilterParameters.addDisplayField(itemField); - // adding to projection for filtering - for (String jsonFieldPath : itemField.getJsonFields()) { - // String mongoProjection = itemField.getProjection() + "." + jsonField; - searchingFilterParameters.putMongoProjection(jsonFieldPath, 1); + if (itemField.isSearchable()) { + searchingFilterParameters.addSearchByField(itemField); + } + + if (itemField.isSortable()) { + searchingFilterParameters.addOrderByField(itemField); } } - if (itemField.isSearchable()) { - searchingFilterParameters.addSearchByField(itemField); - } - - if (itemField.isSortable()) { - searchingFilterParameters.addOrderByField(itemField); - } + break; + } + default: { + break; + } } - break; - } - case gcube_profiles: - break; + mapSearchingFilterParametersForProfileId.put(profileID, searchingFilterParameters); } } - mapSearchingFilterParametersForProfileId.put(profileID, searchingFilterParameters); } return searchingFilterParameters; } - /** - * Prints the cache handler configurations. - */ - // DEBUGGING - public void printCacheHandlerConfigurations() { - GWT.log("print - mapHandlersConfigurationsForProfileId is:"); - for (String key : mapHandlersConfigurationsForProfileId.keySet()) { - GWT.log("print - key: " + key + ", value: " + mapHandlersConfigurationsForProfileId.get(key)); - } - } +// /** +// * Prints the cache handler configurations. +// */ +// // DEBUGGING +// public void printCacheHandlerConfigurations() { +// GWT.log("print - mapHandlersConfigurationsForProfileId is:"); +// for (String key : mapHandlersConfigurationsForProfileId.keySet()) { +// GWT.log("print - key: " + key + ", value: " + mapHandlersConfigurationsForProfileId.get(key)); +// } +// } /** * Prints the cache gcube profile per item type. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 166d2f9..d19a923 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -13,13 +13,13 @@ import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; import org.gcube.application.geoportalcommon.shared.config.OPERATION_ON_ITEM; import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; -import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; @@ -317,6 +317,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.add(alert); Window.alert(errorMsg); + GWT.log(caught.getMessage()); } @Override @@ -352,23 +353,23 @@ public class GeoPortalDataEntryApp implements EntryPoint { for (final UseCaseDescriptorDV ucdDV : listUCDescriptors) { - List> listConfigurations = geoportalCaches - .getHandlerConfigurationsForProfileId(ucdDV.getProfileID()); - - if (listConfigurations == null) { - listConfigurations = new ArrayList>(); - } - - for (HandlerDeclarationDV handler : ucdDV.getHandlers()) { - ConfigurationDV config = handler.getConfiguration(); - listConfigurations.add(config); - } - - geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations); +// List> listConfigurations = geoportalCaches +// .getHandlerConfigurationsForProfileId(ucdDV.getProfileID()); +// +// if (listConfigurations == null) { +// listConfigurations = new ArrayList>(); +// } +// +// for (HandlerDeclarationDV handler : ucdDV.getHandlers()) { +// ConfigurationDV config = handler.getConfiguration(); +// listConfigurations.add(config); +// } +// +// geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations); geoportalCaches.putUCDForProfileId(ucdDV.getProfileID(), ucdDV); } - geoportalCaches.printCacheHandlerConfigurations(); + //geoportalCaches.printCacheHandlerConfigurations(); } @@ -784,9 +785,13 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { GWT.log("Fired: " + getListOfRecordsEvent); SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter(); + + + CacheSearchingFilterParametersFromConfig seachingFilterParameters = + geoportalCaches.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID(), GEOPORTAL_DATA_HANDLER.geoportal_data_list); - CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches - .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); +// CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches +// .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); String profileID = getListOfRecordsEvent.getProfileID(); if (profileID == null) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 50f5d7d..720bc0a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -925,31 +925,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null)); } - // MOCK - /* - * List listUCDDV = new ArrayList(); - * UseCaseDescriptorDV usecaseDescriptorDV = new UseCaseDescriptorDV("theId", - * "version", "listConcessioni", null); List handlers = - * new ArrayList(); - * - * List gcubeProfiles = new ArrayList(); - * GcubeProfileDV profile = new GcubeProfileDV(); - * profile.setGcubeName("GcubeName"); - * profile.setGcubeSecondaryType("GcubeSecondaryType"); - * gcubeProfiles.add(profile); - * - * ConfigurationDV> configuration = new - * ConfigurationDV>(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); - */ - - LOG.info("for handlersIds {} returning {} " + UseCaseDescriptor.class.getSimpleName(), handlersIds, + LOG.info("for handlersIds {} returning {} " + UseCaseDescriptorDV.class.getSimpleName(), handlersIds, listUCDDV.size()); return listUCDDV; } catch (Exception e) { diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataentry/Complex_Tests.java b/src/test/java/org/gcube/portlets/user/geoportaldataentry/Complex_Tests.java index 0443b29..f259060 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataentry/Complex_Tests.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataentry/Complex_Tests.java @@ -94,7 +94,7 @@ public class Complex_Tests { } - @Before + //@Before public void init() { ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN); @@ -102,7 +102,7 @@ public class Complex_Tests { clientUCD = GeoportalClientCaller.useCaseDescriptors(); } - @Before + //@Before public void preloadgCubeProfilesForUCDs() { LOG.debug("preloadgCubeProfilesForUCDs called"); try { @@ -163,7 +163,7 @@ public class Complex_Tests { } } - @Test + //@Test public void testReadProjectForUCDDataEntry() { ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN);