diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index af6c3e5..c945bdc 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -4,8 +4,12 @@ import java.util.Arrays; import java.util.List; 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.UseCaseDescriptorDV; import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; +import com.google.gwt.core.client.GWT; + /** * The Class ConstantsGeoPortalDataEntryApp. * @@ -21,6 +25,8 @@ public class ConstantsGeoPortalDataEntryApp { public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR; + public static final int MAX_COLUMN_DISPLAYED_IN_THE_TABLE = 5; + /** * The Enum RECORD_TYPE. * @@ -45,4 +51,16 @@ public class ConstantsGeoPortalDataEntryApp { public static final List HANDLERS_IDS = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId(), GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId()); + + public static void printUCDs(List listUCDescriptors) { + GWT.log("print - UCDs"); + for (UseCaseDescriptorDV useCaseDescriptorDV : listUCDescriptors) { + GWT.log("print UCD name: " + useCaseDescriptorDV.getName() + ", profileID: " + + useCaseDescriptorDV.getProfileID()); + for (HandlerDeclarationDV handler : useCaseDescriptorDV.getHandlers()) { + GWT.log("\t print handler getDataHandlerType: " + handler.getDataHandlerType() + ", type: " + + handler.getType()); + } + } + } } 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 new file mode 100644 index 0000000..63e081e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalClientCaches.java @@ -0,0 +1,194 @@ +package org.gcube.portlets.user.geoportaldataentry.client; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; +import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; + +import com.google.gwt.core.client.GWT; + +/** + * The Class GeoPortalClientCaches. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 11, 2022 + */ +public class GeoPortalClientCaches { + + private TreeMap> mapGcubeProfilePerItemType; + + private Map>> mapHandlersConfigurationsForProfileId; + + private Map mapSearchingFitlerParametersorForProfileId; + + /** + * Instantiates a new geo portal client caches. + */ + public GeoPortalClientCaches() { + mapGcubeProfilePerItemType = new TreeMap>(); + mapHandlersConfigurationsForProfileId = new HashMap>>(); + mapSearchingFitlerParametersorForProfileId = 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); + } + + /** + * 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. + * + * @param itemType the item type + * @param listGcubeProfiles the list gcube profiles + */ + public void putGcubeProfilePerItemType(String itemType, List listGcubeProfiles) { + mapGcubeProfilePerItemType.put(itemType, listGcubeProfiles); + } + + /** + * Gets the gcube profile per item type. + * + * @param itemType the item type + * @return the gcube profile per item type + */ + public List getGcubeProfilePerItemType(String itemType) { + return mapGcubeProfilePerItemType.get(itemType); + } + + public CacheSearchingFilterParametersFromConfig getFilterParametersForProfileId(String profileID) { + GWT.log("getFilterParametersForProfileId for: " + profileID); + + CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFitlerParametersorForProfileId + .get(profileID); + + if (searchingFilterParameters == null) { + + searchingFilterParameters = new CacheSearchingFilterParametersFromConfig(); + + List> config = mapHandlersConfigurationsForProfileId.get(profileID); + + GWT.log("For profileID " + profileID + ", read config for : " + config); + + 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 jsonField : itemField.getJsonFields()) { + searchingFilterParameters.putMongoProjection("_theDocument." + jsonField, 1); + } + } + + if (itemField.isSearchable()) { + searchingFilterParameters.addSearchByField(itemField); + } + + if (itemField.isSortable()) { + searchingFilterParameters.addOrderByField(itemField); + } + } + + break; + } + case gcube_profiles: + break; + } + } + + mapSearchingFitlerParametersorForProfileId.put(profileID, searchingFilterParameters); + } + + return searchingFilterParameters; + } + + // DEBUGGING + public void printCacheHandlerConfigurations() { + GWT.log("print - mapHandlersConfigurationsForProfileId is:"); + for (String key : mapHandlersConfigurationsForProfileId.keySet()) { + GWT.log("print - key: " + key + ", value: " + mapHandlersConfigurationsForProfileId.get(key)); + } + } + + // DEBUGGING + public void printCacheGcubeProfilePerItemType() { + GWT.log("print - mapGcubeProfilePerItemType is:"); + for (String key : mapGcubeProfilePerItemType.keySet()) { + GWT.log("print - key: " + key + ", value: " + mapGcubeProfilePerItemType.get(key)); + } + } + + public class CacheSearchingFilterParametersFromConfig { + + List displayFields; + List searchByFields; + List orderByFields; + + // The projection + LinkedHashMap projection; + + public CacheSearchingFilterParametersFromConfig() { + displayFields = new ArrayList(); + searchByFields = new ArrayList(); + orderByFields = new ArrayList(); + projection = new LinkedHashMap(); + } + + public void putMongoProjection(String keyField, Object value) { + projection.put(keyField, value); + } + + public void addDisplayField(ItemFieldDV itemField) { + displayFields.add(itemField); + } + + public void addSearchByField(ItemFieldDV itemField) { + searchByFields.add(itemField); + } + + public void addOrderByField(ItemFieldDV itemField) { + orderByFields.add(itemField); + } + + public List getDisplayFields() { + return displayFields; + } + + public List getSearchByFields() { + return searchByFields; + } + + public List getOrderByFields() { + return orderByFields; + } + + public LinkedHashMap getProjection() { + return projection; + } + + } +} 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 80feee0..84febcf 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 @@ -3,22 +3,18 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.SearchingFilter; -import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; 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.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; @@ -26,6 +22,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclara import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM; +import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent; @@ -120,14 +117,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { private UserRights myRights = null; - private LoaderIcon loader = new LoaderIcon("Loading Application... please wait"); + private LoaderIcon loaderApplication = new LoaderIcon("Loading Application... please wait"); + + private LoaderIcon loaderConfigurations = new LoaderIcon("Loading Configurations... please wait"); private GeonaISConfig geonaISConfig; - private TreeMap> mapGcubeProfilePerItemType = new TreeMap>(); - - private Map>> mapHandlersForProfileId = new HashMap>>(); - private int numberOfCards = 0; private int expectedCards = 0; @@ -140,12 +135,14 @@ public class GeoPortalDataEntryApp implements EntryPoint { return numberOfCards; } - private List listUCDescriptors; + // private List listUCDescriptors; private boolean dataEntryProjectCreated = false; private TreeItemPanel treeItemPanel; + private GeoPortalClientCaches geoportalCaches; + /** * This is the entry point method. */ @@ -172,8 +169,15 @@ public class GeoPortalDataEntryApp implements EntryPoint { * TreeItemPanel tip = new TreeItemPanel("Concessione", gnaCardsModels); * RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree()); */ + geoportalCaches = new GeoPortalClientCaches(); - RootPanel.get(DIV_PORTLET_ID).add(loader); + RootPanel.get(DIV_PORTLET_ID).add(loaderApplication); + + mainTabPanel = new GeonaMainTabPanel(appManagerBus); + geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); + mainTabPanel.addFormPanel(geoNaMainForm); + + RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel); GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { @@ -183,7 +187,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { - RootPanel.get(DIV_PORTLET_ID).remove(loader); + RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); } catch (Exception e) { } @@ -213,7 +217,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { - RootPanel.get(DIV_PORTLET_ID).remove(loader); + RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); } catch (Exception e) { } @@ -224,52 +228,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) { - GWT.log(GNADataEntryExtConfigProfile.class.getSimpleName() + " loaded: "+gNADataEntryConfig); - - try { - RootPanel.get(DIV_PORTLET_ID).remove(loader); - } catch (Exception e) { - - } - -// List itemFields = gNADataEntryConfig.getListItemFields(); -// -// for (ItemFieldDV itemField : itemFields) { -// if (itemField.isDisplayAsResult()) { -// displayFields.add(itemField); -// } -// -// if (itemField.isSearchable()) { -// searchByFields.add(itemField); -// } -// -// if (itemField.isSortable()) { -// sortByFields.add(itemField); -// } -// } -// -// GWT.log("List display fields: " + itemFields); -// SearchingFilter initialSortFilter = new SearchingFilter(); -// initialSortFilter.setOrder(ORDER.ASC); -// initialSortFilter.setOrderByFields( -// Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true))); -// -// displayFields = itemFields; -// mainTabPanel = new GeonaMainTabPanel(appManagerBus); -// -// mainTabPanel.setFilteringParameters(displayFields, sortByFields, searchByFields, initialSortFilter); -// -// // TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE -// setListUseCaseDescriptors(listUCDescriptors); - - SearchingFilter initialSortFilter = new SearchingFilter(); - List defaultItemField = Arrays - .asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true)); - initialSortFilter.setOrder(ORDER.ASC); - initialSortFilter.setOrderByFields(defaultItemField); - mainTabPanel = new GeonaMainTabPanel(appManagerBus, defaultItemField, initialSortFilter); - geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); - mainTabPanel.addFormPanel(geoNaMainForm); + GWT.log(GNADataEntryExtConfigProfile.class.getSimpleName() + " loaded: " + gNADataEntryConfig); // PERMISSIONS myRights = gNADataEntryConfig.getUserRights(); @@ -293,17 +252,22 @@ public class GeoPortalDataEntryApp implements EntryPoint { mainTabPanel.removeTab(0); // activating Tab "List of Project" mainTabPanel.setTabActive(0); - mainTabPanel.instanceAndShowListOfConcessioni(); + mainTabPanel.instanceAndShowListOfProjects(); return; } + try { + RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); + } catch (Exception e) { + + } + } }); } private void initGUI() { bindEvents(); - RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { @@ -322,88 +286,69 @@ public class GeoPortalDataEntryApp implements EntryPoint { private void loadGeoportalConfigs(final String scope) { GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope); // orderedCards = new ArrayList(); + try { + RootPanel.get(DIV_PORTLET_ID).insert(loaderConfigurations, 0); + } catch (Exception e) { + } GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors( ConstantsGeoPortalDataEntryApp.HANDLERS_IDS, new AsyncCallback>() { @Override public void onFailure(Throwable caught) { + try { + RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations); + } catch (Exception e) { + + } GWT.log("caught: " + caught); Window.alert(caught.toString()); } @Override public void onSuccess(List result) { - GWT.log("UseCaseDescriptorDV loaded: "+result); - listUCDescriptors = result; - GWT.log("List: " + listUCDescriptors); - listUCDescriptors = result; - GWT.log("List: " + result); + GWT.log("ListUseCaseDescriptors loaded: " + result); if (result == null || result.size() == 0) { Window.alert("No Configuration found in this scope. Please contact the support"); return; } - setListUseCaseDescriptors(listUCDescriptors); + initDataEntryAppForListUseCaseDescriptors(result); + try { + RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations); + } catch (Exception e) { + } } }); } - private synchronized void setListUseCaseDescriptors(List listUCDescriptors) { - GWT.log("Setting listUCDescriptors: " + listUCDescriptors); - if (listUCDescriptors != null) { + private void initDataEntryAppForListUseCaseDescriptors(List listUCDescriptors) { + GWT.log("initDataEntryAppForListUseCaseDescriptors with size: " + listUCDescriptors.size()); + ConstantsGeoPortalDataEntryApp.printUCDs(listUCDescriptors); - if (mainTabPanel != null) { - // Just to be sure that its set once - if (mainTabPanel.getListUCDescriptors() == null) { - mainTabPanel.setListUseCaseDescriptors(listUCDescriptors); - } + mainTabPanel.initMainAccordingToListUseCaseDescriptors(listUCDescriptors); - for (UseCaseDescriptorDV useCaseDescriptorDV : listUCDescriptors) { + for (UseCaseDescriptorDV ucdDV : listUCDescriptors) { - List> listConfigurations = mapHandlersForProfileId - .get(useCaseDescriptorDV.getProfileID()); - if (listConfigurations == null) { - listConfigurations = new ArrayList>(); - } - - for (HandlerDeclarationDV handler : useCaseDescriptorDV.getHandlers()) { - ConfigurationDV config = handler.getConfiguration(); - listConfigurations.add(config); - } - - mapHandlersForProfileId.put(useCaseDescriptorDV.getProfileID(), listConfigurations); - } - -// for (ItemFieldDV itemField : itemFields) { -// if (itemField.isDisplayAsResult()) { -// displayFields.add(itemField); -// } -// -// if (itemField.isSearchable()) { -// searchByFields.add(itemField); -// } -// -// if (itemField.isSortable()) { -// sortByFields.add(itemField); -// } -// } -// -// GWT.log("List display fields: " + itemFields); -// SearchingFilter initialSortFilter = new SearchingFilter(); -// initialSortFilter.setOrder(ORDER.ASC); -// initialSortFilter.setOrderByFields( -// Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true))); -// -// displayFields = itemFields; -// mainTabPanel = new GeonaMainTabPanel(appManagerBus); -// -// mainTabPanel.setFilteringParameters(displayFields, sortByFields, searchByFields, initialSortFilter); + 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.printCacheHandlerConfigurations(); + } /** @@ -437,7 +382,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // orderedCards.clear(); resetUI(); - List cardsPerIT = mapGcubeProfilePerItemType.get(handlerDeclarationDV.getItemType()); + List cardsPerIT = geoportalCaches + .getGcubeProfilePerItemType(handlerDeclarationDV.getItemType()); mainTabPanel.setPageHeader(handlerDeclarationDV); if (cardsPerIT != null) { @@ -484,7 +430,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // ordered values Collection gnaCardsModels = treemapOrderedGNAProfiles.values(); GWT.log("TreeMap values: " + gnaCardsModels); - mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(), + geoportalCaches.putGcubeProfilePerItemType(handlerDeclarationDV.getItemType(), new ArrayList(gnaCardsModels)); // orderedCards.addAll(new ArrayList(gnaCardsModels)); buildNewCards(profileID, handlerDeclarationDV.getItemType(), @@ -872,66 +818,31 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { - - SearchingFilter sortFilter = getListOfRecordsEvent.getSortFilter(); - List displayFields = mainTabPanel.getDisplayFields(); - - if (sortFilter == null) { - sortFilter = mainTabPanel.getCurrentSortFilter(); + GWT.log("Fired: " + getListOfRecordsEvent); + SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter(); + + CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches + .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); + + if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit()) { + mainTabPanel.setFilteringParameters(seachingFilterParameters); + searchingFilter = mainTabPanel.getCurrentSearchingFilter(); } + + //TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters() + + + searchingFilter.setProjection(seachingFilterParameters.getProjection()); + + List displayFields = seachingFilterParameters.getDisplayFields(); + String profileID = getListOfRecordsEvent.getProfileID(); if (profileID == null) { new DialogInform(null, "Error", "No user case descriptor selected").center(); return; } - // Resetting filtering parameters (e.g. search for, order by, etc.) - if (getListOfRecordsEvent.isReloadFilteringParameters()) { - - displayFields = new ArrayList(); - List searchByFields = new ArrayList(); - List sortByFields = new ArrayList(); - List> config = mapHandlersForProfileId.get(getListOfRecordsEvent.getProfileID()); - - for (ConfigurationDV configurationDV : config) { - switch (configurationDV.getConfigurationType()) { - case item_fields: - List listItemFields = (List) configurationDV.getConfiguration(); - - // The projection - LinkedHashMap projection = new LinkedHashMap(); - - for (ItemFieldDV itemField : listItemFields) { - if (itemField.isDisplayAsResult()) { - displayFields.add(itemField); - // adding to projection for filtering - for (String jsonField : itemField.getJsonFields()) { - projection.put("_theDocument." + jsonField, 1); - } - } - - if (itemField.isSearchable()) { - searchByFields.add(itemField); - } - - if (itemField.isSortable()) { - sortByFields.add(itemField); - } - } - - sortFilter.setProjection(projection); - - mainTabPanel.setFilteringParameters(displayFields, sortByFields, searchByFields, sortFilter); - - break; - - default: - break; - } - } - } - - grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, sortFilter); + grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, searchingFilter); mainTabPanel.showListOfConcessioniView(grpw); @@ -973,8 +884,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // actionPerformedOnItemEvent.getProfileID(), null, // mainTabPanel.getCurrentSortFilter())); - appManagerBus.fireEvent(new GetListOfRecordsEvent(null, grpw.getProfileID(), - mainTabPanel.getCurrentSortFilter(), false)); + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, null, grpw.getProfileID(), + mainTabPanel.getCurrentSearchingFilter(), false)); break; } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java index 1252db5..1a8f126 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java @@ -19,17 +19,20 @@ public class GetListOfRecordsEvent extends GwtEvent sortByFields; - - private List searchForFields; - - private SearchingFilter currentSortFilter; + private SearchingFilter currentSearchingFilter; private GeonaRecordsPaginatedView grpw = null; - private List displayFields; + private List ucdProjectTypesForListingDataView = new ArrayList(); - private List listUCDescriptors; + private CacheSearchingFilterParametersFromConfig cacheSearchingFilterParameters; /** * Instantiates a new geona main tab panel. * - * @param appManagerBus the first name - * @param initialSortFilter - * @param defaultItemField + * @param appManagerBus the app manager bus */ - public GeonaMainTabPanel(HandlerManager appManagerBus, List defaultItemField, - SearchingFilter initialSortFilter) { + public GeonaMainTabPanel(HandlerManager appManagerBus) { initWidget(uiBinder.createAndBindUi(this)); this.appManagerBus = appManagerBus; - setFilteringParameters(defaultItemField, defaultItemField, defaultItemField, initialSortFilter); + // setFilteringParameters(defaultItemField, defaultItemField, defaultItemField, + // initialSortFilter); alertSortBy.setType(AlertType.INFO); alertSortBy.setClose(false); alertSearchFor.setType(AlertType.INFO); alertSearchFor.setClose(false); + alertProjectType.setType(AlertType.INFO); + alertProjectType.setClose(false); + bindEvents(); resetSearch.setIconSize(IconSize.TWO_TIMES); resetSearch.setType(ButtonType.LINK); @@ -196,23 +198,22 @@ public class GeonaMainTabPanel extends Composite { /** * Sets the filtering parameters. * - * @param displayFields the display fields - * @param sortByFields the sort by fields - * @param searchForFields the search for fields - * @param initialSortFilter the initial sort filter + * @param sfp the sfp + * @param searchingFilter the searching filter */ - public void setFilteringParameters(List displayFields, List sortByFields, - List searchForFields, SearchingFilter sortFilter) { - this.displayFields = displayFields; - this.sortByFields = sortByFields; - this.searchForFields = searchForFields; - this.currentSortFilter = sortFilter; + public void setFilteringParameters(CacheSearchingFilterParametersFromConfig sfp) { + GWT.log("setFilteringParameters instancied"); + this.cacheSearchingFilterParameters = sfp; + List sortByFields = sfp.getOrderByFields(); + List searchForFields = sfp.getSearchByFields(); + // currentSearchingFilter = new SearchingFilter(sortByFields, null); alertSearchFor.clear(); dropdownSearchFor.clear(); - //alertSearchFor.setText(searchForFields.get(0).getDisplayName()); - alertSortBy.setText(toLabelFilter((sortFilter.getOrderByFields().get(0)), sortFilter.getOrder())); - + + alertSearchFor.setText(searchForFields.get(0).getDisplayName()); + alertSortBy.setText(toLabelFilter((sortByFields.get(0)), SearchingFilter.ORDER.ASC)); + for (ItemFieldDV record_FIELD : searchForFields) { NavLink nav = new NavLink(record_FIELD.getDisplayName()); @@ -231,52 +232,66 @@ public class GeonaMainTabPanel extends Composite { } }); } - + dropdownSortBy.clear(); - + for (ItemFieldDV record_FIELD : sortByFields) { // if (record_FIELD.equals(RECORD_FIELD.RECORD_STATUS)) // continue; // ASC - String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); - NavLink nav = new NavLink(labelASC); + final String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); + final NavLink nav = new NavLink(labelASC); dropdownSortBy.add(nav); nav.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { + GWT.log("Sort by: "+labelASC); alertSortBy.setText(labelASC); - Window.alert("ASC MUST BE REVISITED"); - /* - * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, - * getCurrentSortFilter())); - */ + UseCaseDescriptorDV singleUCD = getSelectProjectType(); + if (singleUCD != null) { + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), singleUCD.getProfileID(), + getCurrentSearchingFilter(), false)); + } } }); // //DESC - String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); - NavLink nav2 = new NavLink(labelDESC); + final String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); + final NavLink nav2 = new NavLink(labelDESC); dropdownSortBy.add(nav2); nav2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { + GWT.log("Sort by: "+labelDESC); alertSortBy.setText(labelDESC); - Window.alert("DESC MUST BE REVISITED"); - /* - * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, - * getCurrentSortFilter())); - */ + UseCaseDescriptorDV singleUCD = getSelectProjectType(); + if (singleUCD != null) { + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), singleUCD.getProfileID(), + getCurrentSearchingFilter(), false)); + } } }); } } + public UseCaseDescriptorDV getSelectProjectType() { + String projectName = alertProjectType.getText(); + for (UseCaseDescriptorDV usdDV : ucdProjectTypesForListingDataView) { + if (usdDV.getName().compareTo(projectName) == 0) { + GWT.log("Selected project type is: "+usdDV); + return usdDV; + } + } + + return null; + } + /** * Sets the internal height. * @@ -292,15 +307,6 @@ public class GeonaMainTabPanel extends Composite { */ private void bindEvents() { -// buttCreateNewProject.addClickHandler(new ClickHandler() { -// -// @Override -// public void onClick(ClickEvent event) { -// appManagerBus.fireEvent(new CreateNewProjectEvent()); -// -// } -// }); - buttonReloadConcessioni.addClickHandler(new ClickHandler() { @Override @@ -319,71 +325,10 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { - instanceAndShowListOfConcessioni(); + instanceAndShowListOfProjects(); } }); -// for (ItemFieldDV record_FIELD : sortByFields) { -// -//// if (record_FIELD.equals(RECORD_FIELD.RECORD_STATUS)) -//// continue; -// -// // ASC -// String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); -// NavLink nav = new NavLink(labelASC); -// dropdownSortBy.add(nav); -// -// nav.addClickHandler(new ClickHandler() { -// -// @Override -// public void onClick(ClickEvent event) { -// alertSortBy.setText(labelASC); -// Window.alert("ASC MUST BE REVISITED"); -// /* -// * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, -// * getCurrentSortFilter())); -// */ -// } -// }); -// -//// //DESC -// String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); -// NavLink nav2 = new NavLink(labelDESC); -// dropdownSortBy.add(nav2); -// -// nav2.addClickHandler(new ClickHandler() { -// -// @Override -// public void onClick(ClickEvent event) { -// alertSortBy.setText(labelDESC); -// Window.alert("DESC MUST BE REVISITED"); -// /* -// * appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, -// * getCurrentSortFilter())); -// */ -// } -// }); -// } - -// for (ItemFieldDV record_FIELD : searchForFields) { -// -// NavLink nav = new NavLink(record_FIELD.getDisplayName()); -// dropdownSearchFor.add(nav); -// -// nav.addClickHandler(new ClickHandler() { -// -// @Override -// public void onClick(ClickEvent event) { -// alertSearchFor.setText(record_FIELD.getDisplayName()); -// -// if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) { -// doSearchEvent(); -// } -// -// } -// }); -// } - navShowOnMap.addClickHandler(new ClickHandler() { @Override @@ -571,21 +516,23 @@ public class GeonaMainTabPanel extends Composite { GWT.log("toSortFilter for label " + labelFilter); String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); + GWT.log("label filter: "+array[0]); SearchingFilter sortFilter = null; try { ItemFieldDV recordField = null; - for (ItemFieldDV value : sortByFields) { - if (array[0].equalsIgnoreCase(value.getDisplayName())) { + GWT.log("cacheSearchingFilterParameters.getOrderByFields() is: "+cacheSearchingFilterParameters.getOrderByFields()); + for (ItemFieldDV value : cacheSearchingFilterParameters.getOrderByFields()) { + if (array[0].trim().compareTo(value.getDisplayName())==0) { recordField = value; break; } } - ORDER orderField = ORDER.valueOf(array[1]); + ORDER orderField = ORDER.valueOf(array[1].trim()); sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField); } catch (Exception e) { } - GWT.log("toSortFilter Got " + sortFilter); + GWT.log("toSortFilter got " + sortFilter); return sortFilter; } @@ -603,7 +550,7 @@ public class GeonaMainTabPanel extends Composite { String searchForField = ""; - for (ItemFieldDV recordField : searchForFields) { + for (ItemFieldDV recordField : cacheSearchingFilterParameters.getSearchByFields()) { if (recordField.getDisplayName().equals(alertSearchFor.getText())) { searchForField = recordField.getJsonFields().get(0); continue; @@ -615,6 +562,7 @@ public class GeonaMainTabPanel extends Composite { where.setOperator(LOGICAL_OP.OR); searchingFilter.setConditions(Arrays.asList(where)); } + return searchingFilter; } @@ -623,10 +571,12 @@ public class GeonaMainTabPanel extends Composite { * * @return the current sort filter */ - public SearchingFilter getCurrentSortFilter() { - currentSortFilter = builtSearchingFilter(); - GWT.log("currentSortFilter: " + currentSortFilter); - return currentSortFilter; + public SearchingFilter getCurrentSearchingFilter() { + currentSearchingFilter = builtSearchingFilter(); + + // currentSearchingFilter.setProjection(cacheSearchingFilterParameters.getProjection()); + GWT.log("getCurrentSearchingFilter: " + currentSearchingFilter); + return currentSearchingFilter; } /** @@ -652,23 +602,30 @@ public class GeonaMainTabPanel extends Composite { * event for Tab element * */ - public void instanceAndShowListOfConcessioni() { - Window.alert("instanceAndShowListOfConcessioni MUST BE REVISITED"); - /* - * grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, - * displayFields, currentSortFilter); showListOfConcessioniView(grpw); - */ + public void instanceAndShowListOfProjects() { + + // If only one UCD is available for DATA_LIST_GUI.. FIRE THE EVENT OF SELECTION + if (ucdProjectTypesForListingDataView.size() == 1) { + UseCaseDescriptorDV singleUCD = ucdProjectTypesForListingDataView.get(0); + alertProjectType.setText(singleUCD.getName()); + // setFilteringParameters(displayFields, sortByFields, searchForFields, + // currentSearchingFilter); + appManagerBus.fireEvent(new GetListOfRecordsEvent(true, singleUCD.getName(), singleUCD.getProfileID(), + getCurrentSearchingFilter(), true)); + } } /** - * Sets the list use case descriptors. + * Inits the main according to list use case descriptors. * - * @param listUCDescriptors the new list use case descriptors + * @param listUCDescriptors the list UC descriptors */ - public void setListUseCaseDescriptors(List listUCDescriptors) { - GWT.log("Setting listUCDescriptors: " + listUCDescriptors); - this.listUCDescriptors = listUCDescriptors; + public void initMainAccordingToListUseCaseDescriptors(List listUCDescriptors) { + GWT.log("initMainAccordingToListUseCaseDescriptors: " + listUCDescriptors); + // this.listUCDescriptors = listUCDescriptors; ddCreateNewProject.clear(); + ddProjectType.clear(); + ucdProjectTypesForListingDataView.clear(); for (final UseCaseDescriptorDV ucd : listUCDescriptors) { @@ -714,11 +671,11 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(ucd.getName(), ucd.getProfileID(), - getCurrentSortFilter(), true)); + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, ucd.getName(), ucd.getProfileID(), + getCurrentSearchingFilter(), true)); } }); - + ucdProjectTypesForListingDataView.add(ucd); ddProjectType.add(link); } @@ -797,17 +754,4 @@ public class GeonaMainTabPanel extends Composite { this.pageHeaderDataEntry.setSubtext("New: " + hDV.getItemType()); } - /** - * Gets the list UC descriptors. - * - * @return the list UC descriptors - */ - public List getListUCDescriptors() { - return listUCDescriptors; - } - - public List getDisplayFields() { - return displayFields; - } - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 1568cfb..14a2c0f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -134,6 +134,10 @@ ui:field="ddProjectType" icon="BUILDING"> + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 19be7be..f3d6916 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -50,21 +50,21 @@ public class GeonaRecordsPaginatedView { private LoaderIcon loadingPanel = new LoaderIcon("Loading data..."); // private int serverStartIndex; private HandlerManager eventBus; - private SearchingFilter currentSortFilter; + private SearchingFilter currentSearchingFilter; private String profileID; /** * Instantiates a new geona records paginated view. * - * @param eventbus the eventbus - * @param recordType the record type - * @param displayFields the display fields - * @param currentSortFilter the sort by field + * @param eventbus the eventbus + * @param profileID the profile ID + * @param displayFields the display fields + * @param currentSearchingFilter the current searching filter */ public GeonaRecordsPaginatedView(HandlerManager eventbus, String profileID, List displayFields, - SearchingFilter currentSortFilter) { + SearchingFilter currentSearchingFilter) { this.profileID = profileID; - this.currentSortFilter = currentSortFilter; + this.currentSearchingFilter = currentSearchingFilter; this.initClassFirstRangeChanged = true; this.eventBus = eventbus; itemsTable = new ItemsTable(eventbus, displayFields); @@ -115,6 +115,7 @@ public class GeonaRecordsPaginatedView { /** * Load new page. * + * @param profileID the profile ID * @param startIdx the start idx * @param limit the limit * @param resetStore the reset store @@ -144,12 +145,12 @@ public class GeonaRecordsPaginatedView { /** * Load items for type. * - * @param recordType the record type + * @param profileID the profile ID */ private void loadItemsForType(String profileID) { this.profileID = profileID; getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false); - loadNewPage(profileID, ITEM_START_INDEX, ITEMS_PER_PAGE, true, currentSortFilter, true); + loadNewPage(profileID, ITEM_START_INDEX, ITEMS_PER_PAGE, true, currentSearchingFilter, true); } /** @@ -173,7 +174,7 @@ public class GeonaRecordsPaginatedView { getTableDataProvider().updateRowCount((int) result.getTotalItems(), true); // TODO MUST USE PROJECT - getTableDataProvider().updateRowData(result.getClientStartIndex(),(List) result.getData()); + getTableDataProvider().updateRowData(result.getClientStartIndex(), (List) result.getData()); if (result.getData().size() == 0) { getCellTable().setLoadingIndicator(new Label("No data")); @@ -193,15 +194,21 @@ public class GeonaRecordsPaginatedView { } + /** + * To list document DV. + * + * @param data the data + * @return the list + */ private List toListDocumentDV(List data) { if (data == null) return null; - + List listDocuments = new ArrayList(data.size()); for (ProjectDV projectDV : data) { listDocuments.add(projectDV.getTheDocument()); } - + return listDocuments; } @@ -259,8 +266,6 @@ public class GeonaRecordsPaginatedView { /** * Gets the select items. - * - * @return * * @return the select items */ @@ -310,7 +315,7 @@ public class GeonaRecordsPaginatedView { return; } GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); - loadNewPage(profileID, start, length, false, currentSortFilter, false); + loadNewPage(profileID, start, length, false, currentSearchingFilter, false); // eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); } @@ -344,6 +349,11 @@ public class GeonaRecordsPaginatedView { return pagerPanel; } + /** + * Gets the profile ID. + * + * @return the profile ID + */ public String getProfileID() { return profileID; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index e0fa80e..bd40d85 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -10,8 +10,11 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; -import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus; +import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV.Status; +import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import com.github.gwtbootstrap.client.ui.ButtonCell; import com.github.gwtbootstrap.client.ui.Pagination; @@ -92,101 +95,89 @@ public class ItemsTable extends AbstractItemsCellTable int i = 0; for (ItemFieldDV itemField : displayFields) { + + if (i > ConstantsGeoPortalDataEntryApp.MAX_COLUMN_DISPLAYED_IN_THE_TABLE) { + break; + } + String displayName = itemField.getDisplayName(); - // NAME + TextColumn col = new TextColumn() { @Override public String getValue(T object) { if (object == null) return ""; - + DocumentDV documentDV = (DocumentDV) object; - + try { return documentDV.getDocumentAsMap().get(itemField.getJsonFields().get(0)).toString(); - }catch (Exception e) { - GWT.log("Error e: "+e); + } catch (Exception e) { + GWT.log("Error e: " + e); } /* - if (displayName.equalsIgnoreCase("Name")) { - return ((ConcessioneDV) object).getNome(); - } else if (displayName.equalsIgnoreCase("Introduction")) { - return ((ConcessioneDV) object).getIntroduzione(); - } else if (displayName.equalsIgnoreCase("Author/s")) { - - String toDisplay = ""; - if (object.getAuthors() != null) { - toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors()); - } - return toDisplay; - } else if (displayName.equalsIgnoreCase("Project Start/End Date")) { - - Date dS = null; - Date dE = null; - if (object.getDataInizioProgetto() != null) { - dS = (((ConcessioneDV) object).getDataInizioProgetto()); - } - - if (object.getDataFineProgetto() != null) { - dE = (((ConcessioneDV) object).getDataFineProgetto()); - } - - String dateFormat = ""; - if (dS != null) { - dateFormat += dtformat.format(dS); - } - - dateFormat += " / "; - - if (dE != null) { - dateFormat += dtformat.format(dE); - } - - return dateFormat; - } else if (displayName.equalsIgnoreCase("Published with")) { - ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); - if (vr != null && vr.getStatus() != null) - return vr.getStatus().getLabel(); - return ""; - } else if (displayName.equalsIgnoreCase("Created")) { - Date cd = ((ConcessioneDV) object).getCreationTime(); - return dtformat.format(cd); - } else if (displayName.equalsIgnoreCase("Created by")) { - return ((ConcessioneDV) object).getCreationUser(); - }else if (displayName.toLowerCase().contains("unpub")) { - ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); - if (vr != null && vr.getObjectName() != null) - return vr.getObjectName(); - }*/ + * if (displayName.equalsIgnoreCase("Name")) { return ((ConcessioneDV) + * object).getNome(); } else if (displayName.equalsIgnoreCase("Introduction")) { + * return ((ConcessioneDV) object).getIntroduzione(); } else if + * (displayName.equalsIgnoreCase("Author/s")) { + * + * String toDisplay = ""; if (object.getAuthors() != null) { toDisplay = + * toDisplayAuthors(((ConcessioneDV) object).getAuthors()); } return toDisplay; + * } else if (displayName.equalsIgnoreCase("Project Start/End Date")) { + * + * Date dS = null; Date dE = null; if (object.getDataInizioProgetto() != null) { + * dS = (((ConcessioneDV) object).getDataInizioProgetto()); } + * + * if (object.getDataFineProgetto() != null) { dE = (((ConcessioneDV) + * object).getDataFineProgetto()); } + * + * String dateFormat = ""; if (dS != null) { dateFormat += dtformat.format(dS); + * } + * + * dateFormat += " / "; + * + * if (dE != null) { dateFormat += dtformat.format(dE); } + * + * return dateFormat; } else if (displayName.equalsIgnoreCase("Published with")) + * { ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); if + * (vr != null && vr.getStatus() != null) return vr.getStatus().getLabel(); + * return ""; } else if (displayName.equalsIgnoreCase("Created")) { Date cd = + * ((ConcessioneDV) object).getCreationTime(); return dtformat.format(cd); } + * else if (displayName.equalsIgnoreCase("Created by")) { return + * ((ConcessioneDV) object).getCreationUser(); }else if + * (displayName.toLowerCase().contains("unpub")) { ValidationReportDV vr = + * ((ConcessioneDV) object).getValidationReport(); if (vr != null && + * vr.getObjectName() != null) return vr.getObjectName(); } + */ return ""; } - // ADDING TOOLTIP - @Override - public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) { - if (object == null) - return; - - if (displayName.equalsIgnoreCase("Published with")) { - String value = getValue(object); - String color = "#000"; - if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) { - color = "#32CD32"; - } else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) { - color = "#FF8000"; - } else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) { - color = "red"; - } - sb.appendHtmlConstant(""); - super.render(context, object, sb); - sb.appendHtmlConstant(""); - } else - super.render(context, object, sb); - - }; +// // ADDING TOOLTIP +// @Override +// public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) { +// if (object == null) +// return; +// +// if (displayName.equalsIgnoreCase("Published with")) { +// String value = getValue(object); +// String color = "#000"; +// if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) { +// color = "#32CD32"; +// } else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) { +// color = "#FF8000"; +// } else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) { +// color = "red"; +// } +// sb.appendHtmlConstant(""); +// super.render(context, object, sb); +// sb.appendHtmlConstant(""); +// } else +// super.render(context, object, sb); +// +// }; }; // if(i==0) { @@ -200,11 +191,118 @@ public class ItemsTable extends AbstractItemsCellTable // }else if(i==displayFields.size()-1) { // sortedCellTable.setColumnWidth(col, 120, Unit.PX); // } - - sortedCellTable.addColumn(col, itemField.getDisplayName(), true); + + sortedCellTable.addColumn(col, displayName, true); i++; } + + // COL CREATED + TextColumn colCreated = new TextColumn() { + @Override + public String getValue(T object) { + + if (object == null) + return ""; + + ResultDocumentDV documentDV = (ResultDocumentDV) object; + + PublicationInfoDV publicationInfoDV = documentDV.getPublicationInfoDV(); + String created = "N.A."; + try { + created = publicationInfoDV.getCreationInfo().getLocalDate(); + } catch (Exception e) { + // TODO: handle exception + } + return created; + + } + + }; + + sortedCellTable.addColumn(colCreated, "Created", true); + + // COL PUBLISHER + TextColumn colPublisher = new TextColumn() { + @Override + public String getValue(T object) { + + if (object == null) + return ""; + + ResultDocumentDV documentDV = (ResultDocumentDV) object; + + PublicationInfoDV publicationInfoDV = documentDV.getPublicationInfoDV(); + String username = "N.A."; + try { + username = publicationInfoDV.getCreationInfo().getUsername(); + } catch (Exception e) { + // TODO: handle exception + } + return username; + + } + + }; + + sortedCellTable.addColumn(colPublisher, "Publisher", true); + + // COL PUBLICATION PHASE/STATUS + TextColumn colPublicationPhaseStatus = new TextColumn() { + @Override + public String getValue(T object) { + + if (object == null) + return ""; + + ResultDocumentDV documentDV = (ResultDocumentDV) object; + String phase = "N.A."; + try { + phase = documentDV.getLifecycleInfo().getPhase(); + } catch (Exception e) { + // TODO: handle exception + } + String status = "N.A."; + try { + status = documentDV.getLifecycleInfo().getLastOperationStatus().toString(); + } catch (Exception e) { + // TODO: handle exception + } + + return phase + " / " + status; + } + + @Override + public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) { + if (object == null) + return; + + ResultDocumentDV documentDV = (ResultDocumentDV) object; + Status status = null; + try { + status = documentDV.getLifecycleInfo().getLastOperationStatus(); + } catch (Exception e) { + + } + + String color = "#000"; + if (status.equals(Status.OK)) { + color = "#32CD32"; + } else if (status.equals(Status.WARNING)) { + color = "#FF8000"; + } else if (status.equals(Status.ERROR)) { + color = "red"; + } + sb.appendHtmlConstant(""); + super.render(context, object, sb); + sb.appendHtmlConstant(""); + + }; + + }; + + sortedCellTable.addColumn(colPublicationPhaseStatus, "Publ. Phase / Status", true); + } public void enableWriteOperations() {