bug fixing init app for handler ID

This commit is contained in:
Francesco Mangiacrapa 2022-10-26 16:38:42 +02:00
parent d03d1a1477
commit 9dd99c5d73
5 changed files with 117 additions and 112 deletions

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -52,7 +56,11 @@
<wb-module deploy-name="geoportal-data-entry-app-3.0.0-SNAPSHOT"> <wb-module deploy-name="geoportal-data-entry-app-3.0.0-SNAPSHOT">
@ -105,7 +113,11 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -158,7 +170,11 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -211,7 +227,11 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -219,7 +239,11 @@
<dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common"> <dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
@ -272,7 +296,11 @@
<property name="context-root" value="geoportal-data-entry-app"/> <property name="context-root" value="geoportal-data-entry-app"/>
@ -325,7 +353,11 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -378,7 +410,11 @@
</wb-module> </wb-module>

View File

@ -9,6 +9,8 @@ import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; 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.RelationshipDefinitionDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
@ -26,7 +28,7 @@ public class GeoPortalClientCaches {
private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType; private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType;
private Map<String, List<ConfigurationDV<?>>> mapHandlersConfigurationsForProfileId; //private Map<String, List<HandlerDeclarationDV>> mapHandlersConfigurationsForProfileId;
private Map<String, UseCaseDescriptorDV> mapUseCaseDescriptor; private Map<String, UseCaseDescriptorDV> mapUseCaseDescriptor;
@ -39,22 +41,11 @@ public class GeoPortalClientCaches {
*/ */
public GeoPortalClientCaches() { public GeoPortalClientCaches() {
mapGcubeProfilePerItemType = new TreeMap<String, List<GeoNaFormCardModel>>(); mapGcubeProfilePerItemType = new TreeMap<String, List<GeoNaFormCardModel>>();
mapHandlersConfigurationsForProfileId = new HashMap<String, List<ConfigurationDV<?>>>();
mapSearchingFilterParametersForProfileId = new HashMap<String, GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig>(); mapSearchingFilterParametersForProfileId = new HashMap<String, GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig>();
mapUseCaseDescriptor = new HashMap<String, UseCaseDescriptorDV>(); mapUseCaseDescriptor = new HashMap<String, UseCaseDescriptorDV>();
mapRelationsNamesForProfileId = new HashMap<String, List<RelationshipDefinitionDV>>(); mapRelationsNamesForProfileId = new HashMap<String, List<RelationshipDefinitionDV>>();
} }
/**
* Put handler configurations for profile id.
*
* @param profileId the profile id
* @param lsitConfigurations the lsit configurations
*/
public void putHandlerConfigurationsForProfileId(String profileId, List<ConfigurationDV<?>> lsitConfigurations) {
mapHandlersConfigurationsForProfileId.put(profileId, lsitConfigurations);
}
/** /**
* Put list relationships definition for profile ID. * Put list relationships definition for profile ID.
* *
@ -96,16 +87,6 @@ public class GeoPortalClientCaches {
return mapUseCaseDescriptor.get(profileID); 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<ConfigurationDV<?>> getHandlerConfigurationsForProfileId(String profileId) {
return mapHandlersConfigurationsForProfileId.get(profileId);
}
/** /**
* Put gcube profile per item type. * Put gcube profile per item type.
* *
@ -132,7 +113,8 @@ public class GeoPortalClientCaches {
* @param profileID the profile ID * @param profileID the profile ID
* @return the filter parameters for 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); GWT.log("getFilterParametersForProfileId for: " + profileID);
CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFilterParametersForProfileId CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFilterParametersForProfileId
@ -141,57 +123,63 @@ public class GeoPortalClientCaches {
if (searchingFilterParameters == null) { if (searchingFilterParameters == null) {
searchingFilterParameters = new CacheSearchingFilterParametersFromConfig(); searchingFilterParameters = new CacheSearchingFilterParametersFromConfig();
UseCaseDescriptorDV ucd = mapUseCaseDescriptor.get(profileID);
for (HandlerDeclarationDV handler : ucd.getHandlers()) {
List<ConfigurationDV<?>> 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<ItemFieldDV> listItemFields = (List<ItemFieldDV>) 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) { if (itemField.isSearchable()) {
switch (configurationDV.getConfigurationType()) { searchingFilterParameters.addSearchByField(itemField);
case item_fields: { }
List<ItemFieldDV> listItemFields = (List<ItemFieldDV>) configurationDV.getConfiguration();
for (ItemFieldDV itemField : listItemFields) { if (itemField.isSortable()) {
if (itemField.isDisplayAsResult()) { searchingFilterParameters.addOrderByField(itemField);
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()) { break;
searchingFilterParameters.addSearchByField(itemField); }
} default: {
break;
if (itemField.isSortable()) { }
searchingFilterParameters.addOrderByField(itemField);
}
} }
break; mapSearchingFilterParametersForProfileId.put(profileID, searchingFilterParameters);
}
case gcube_profiles:
break;
} }
} }
mapSearchingFilterParametersForProfileId.put(profileID, searchingFilterParameters);
} }
return searchingFilterParameters; return searchingFilterParameters;
} }
/** // /**
* Prints the cache handler configurations. // * Prints the cache handler configurations.
*/ // */
// DEBUGGING // // DEBUGGING
public void printCacheHandlerConfigurations() { // public void printCacheHandlerConfigurations() {
GWT.log("print - mapHandlersConfigurationsForProfileId is:"); // GWT.log("print - mapHandlersConfigurationsForProfileId is:");
for (String key : mapHandlersConfigurationsForProfileId.keySet()) { // for (String key : mapHandlersConfigurationsForProfileId.keySet()) {
GWT.log("print - key: " + key + ", value: " + mapHandlersConfigurationsForProfileId.get(key)); // GWT.log("print - key: " + key + ", value: " + mapHandlersConfigurationsForProfileId.get(key));
} // }
} // }
/** /**
* Prints the cache gcube profile per item type. * Prints the cache gcube profile per item type.

View File

@ -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.OPERATION_ON_ITEM;
import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights;
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; 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.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; 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.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; 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.LifecycleInformationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; 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.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; 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); ConstantsGeoPortalDataEntryApp.ROOT_PANEL_DIV_LOADERS.add(alert);
Window.alert(errorMsg); Window.alert(errorMsg);
GWT.log(caught.getMessage());
} }
@Override @Override
@ -352,23 +353,23 @@ public class GeoPortalDataEntryApp implements EntryPoint {
for (final UseCaseDescriptorDV ucdDV : listUCDescriptors) { for (final UseCaseDescriptorDV ucdDV : listUCDescriptors) {
List<ConfigurationDV<?>> listConfigurations = geoportalCaches // List<ConfigurationDV<?>> listConfigurations = geoportalCaches
.getHandlerConfigurationsForProfileId(ucdDV.getProfileID()); // .getHandlerConfigurationsForProfileId(ucdDV.getProfileID());
//
if (listConfigurations == null) { // if (listConfigurations == null) {
listConfigurations = new ArrayList<ConfigurationDV<?>>(); // listConfigurations = new ArrayList<ConfigurationDV<?>>();
} // }
//
for (HandlerDeclarationDV handler : ucdDV.getHandlers()) { // for (HandlerDeclarationDV handler : ucdDV.getHandlers()) {
ConfigurationDV<?> config = handler.getConfiguration(); // ConfigurationDV<?> config = handler.getConfiguration();
listConfigurations.add(config); // listConfigurations.add(config);
} // }
//
geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations); // geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations);
geoportalCaches.putUCDForProfileId(ucdDV.getProfileID(), ucdDV); geoportalCaches.putUCDForProfileId(ucdDV.getProfileID(), ucdDV);
} }
geoportalCaches.printCacheHandlerConfigurations(); //geoportalCaches.printCacheHandlerConfigurations();
} }
@ -784,9 +785,13 @@ public class GeoPortalDataEntryApp implements EntryPoint {
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
GWT.log("Fired: " + getListOfRecordsEvent); GWT.log("Fired: " + getListOfRecordsEvent);
SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter(); SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter();
CacheSearchingFilterParametersFromConfig seachingFilterParameters =
geoportalCaches.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID(), GEOPORTAL_DATA_HANDLER.geoportal_data_list);
CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches // CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches
.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); // .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID());
String profileID = getListOfRecordsEvent.getProfileID(); String profileID = getListOfRecordsEvent.getProfileID();
if (profileID == null) { if (profileID == null) {

View File

@ -925,31 +925,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null)); listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null));
} }
// MOCK LOG.info("for handlersIds {} returning {} " + UseCaseDescriptorDV.class.getSimpleName(), handlersIds,
/*
* List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>();
* UseCaseDescriptorDV usecaseDescriptorDV = new UseCaseDescriptorDV("theId",
* "version", "listConcessioni", null); List<HandlerDeclarationDV> handlers =
* new ArrayList<HandlerDeclarationDV>();
*
* 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);
*/
LOG.info("for handlersIds {} returning {} " + UseCaseDescriptor.class.getSimpleName(), handlersIds,
listUCDDV.size()); listUCDDV.size());
return listUCDDV; return listUCDDV;
} catch (Exception e) { } catch (Exception e) {

View File

@ -94,7 +94,7 @@ public class Complex_Tests {
} }
@Before //@Before
public void init() { public void init() {
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);
@ -102,7 +102,7 @@ public class Complex_Tests {
clientUCD = GeoportalClientCaller.useCaseDescriptors(); clientUCD = GeoportalClientCaller.useCaseDescriptors();
} }
@Before //@Before
public void preloadgCubeProfilesForUCDs() { public void preloadgCubeProfilesForUCDs() {
LOG.debug("preloadgCubeProfilesForUCDs called"); LOG.debug("preloadgCubeProfilesForUCDs called");
try { try {
@ -163,7 +163,7 @@ public class Complex_Tests {
} }
} }
@Test //@Test
public void testReadProjectForUCDDataEntry() { public void testReadProjectForUCDDataEntry() {
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);