From 28277db942cd91105ef8a47925d9c7b33230c183 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 13 Sep 2022 16:18:40 +0200 Subject: [PATCH] Integrated the Workflow Action Panel --- .../ConstantsGeoPortalDataEntryApp.java | 4 + .../client/GeoPortalClientCaches.java | 95 +++++++++- .../client/GeoPortalDataEntryApp.java | 176 ++++++++++++++---- .../client/GeoportalDataEntryService.java | 13 ++ .../GeoportalDataEntryServiceAsync.java | 5 + .../client/events/GetListOfRecordsEvent.java | 17 +- .../WorkflowActionOnSelectedItemEvent.java | 57 ++++++ ...kflowActionOnSelectedItemEventHandler.java | 23 +++ .../client/ui/GeonaMainTabPanel.java | 55 +++--- .../client/ui/GeonaMainTabPanel.ui.xml | 2 +- .../client/ui/action/ActionListPanel.java | 12 +- .../client/ui/utils/UCD_Util.java | 2 +- .../server/GeoportalDataEntryServiceImpl.java | 100 +++++----- src/main/webapp/GeoPortalDataEntryApp.css | 5 + src/main/webapp/GeoPortalDataEntryApp.html | 1 + .../jsp/GeoPortalDataEntryAppPortlet_view.jsp | 2 +- 16 files changed, 429 insertions(+), 140 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/WorkflowActionOnSelectedItemEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/WorkflowActionOnSelectedItemEventHandler.java 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 209f5e4..495b55f 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 @@ -18,6 +18,10 @@ import com.google.gwt.core.client.GWT; * Aug 6, 2021 */ public class ConstantsGeoPortalDataEntryApp { + + public static final String DIV_PORTLET_ID = "geoportal-data-entry"; + + public static final String DIV_LOADERS_ID = "geoportal-loaders"; public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT; 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 b7b388e..10949a1 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,7 @@ 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.UseCaseDescriptorDV; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import com.google.gwt.core.client.GWT; @@ -25,8 +26,10 @@ public class GeoPortalClientCaches { private TreeMap> mapGcubeProfilePerItemType; private Map>> mapHandlersConfigurationsForProfileId; + + private Map mapUseCaseDescriptor; - private Map mapSearchingFitlerParametersorForProfileId; + private Map mapSearchingFilterParametersForProfileId; /** * Instantiates a new geo portal client caches. @@ -34,7 +37,8 @@ public class GeoPortalClientCaches { public GeoPortalClientCaches() { mapGcubeProfilePerItemType = new TreeMap>(); mapHandlersConfigurationsForProfileId = new HashMap>>(); - mapSearchingFitlerParametersorForProfileId = new HashMap(); + mapSearchingFilterParametersForProfileId = new HashMap(); + mapUseCaseDescriptor = new HashMap(); } /** @@ -47,6 +51,26 @@ public class GeoPortalClientCaches { mapHandlersConfigurationsForProfileId.put(profileId, lsitConfigurations); } + /** + * Put UCD for profile id. + * + * @param profileID the profile ID + * @param ucdDV the ucd DV + */ + public void putUCDForProfileId(String profileID, UseCaseDescriptorDV ucdDV) { + mapUseCaseDescriptor.put(profileID, ucdDV); + } + + /** + * Gets the UCD for profile ID. + * + * @param profileID the profile ID + * @return the UCD for profile ID + */ + public UseCaseDescriptorDV getUCDForProfileID(String profileID){ + return mapUseCaseDescriptor.get(profileID); + } + /** * Gets the handler configurations for profile id. * @@ -77,10 +101,16 @@ public class GeoPortalClientCaches { return mapGcubeProfilePerItemType.get(itemType); } + /** + * Gets the filter parameters for profile id. + * + * @param profileID the profile ID + * @return the filter parameters for profile id + */ public CacheSearchingFilterParametersFromConfig getFilterParametersForProfileId(String profileID) { GWT.log("getFilterParametersForProfileId for: " + profileID); - CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFitlerParametersorForProfileId + CacheSearchingFilterParametersFromConfig searchingFilterParameters = mapSearchingFilterParametersForProfileId .get(profileID); if (searchingFilterParameters == null) { @@ -121,12 +151,15 @@ public class GeoPortalClientCaches { } } - mapSearchingFitlerParametersorForProfileId.put(profileID, searchingFilterParameters); + mapSearchingFilterParametersForProfileId.put(profileID, searchingFilterParameters); } return searchingFilterParameters; } + /** + * Prints the cache handler configurations. + */ // DEBUGGING public void printCacheHandlerConfigurations() { GWT.log("print - mapHandlersConfigurationsForProfileId is:"); @@ -135,6 +168,9 @@ public class GeoPortalClientCaches { } } + /** + * Prints the cache gcube profile per item type. + */ // DEBUGGING public void printCacheGcubeProfilePerItemType() { GWT.log("print - mapGcubeProfilePerItemType is:"); @@ -143,6 +179,13 @@ public class GeoPortalClientCaches { } } + /** + * The Class CacheSearchingFilterParametersFromConfig. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 13, 2022 + */ public class CacheSearchingFilterParametersFromConfig { List displayFields; @@ -152,6 +195,9 @@ public class GeoPortalClientCaches { // The projection LinkedHashMap projection; + /** + * Instantiates a new cache searching filter parameters from config. + */ public CacheSearchingFilterParametersFromConfig() { displayFields = new ArrayList(); searchByFields = new ArrayList(); @@ -159,34 +205,75 @@ public class GeoPortalClientCaches { projection = new LinkedHashMap(); } + /** + * Put mongo projection. + * + * @param keyField the key field + * @param value the value + */ public void putMongoProjection(String keyField, Object value) { projection.put(keyField, value); } + /** + * Adds the display field. + * + * @param itemField the item field + */ public void addDisplayField(ItemFieldDV itemField) { displayFields.add(itemField); } + /** + * Adds the search by field. + * + * @param itemField the item field + */ public void addSearchByField(ItemFieldDV itemField) { searchByFields.add(itemField); } + /** + * Adds the order by field. + * + * @param itemField the item field + */ public void addOrderByField(ItemFieldDV itemField) { orderByFields.add(itemField); } + /** + * Gets the display fields. + * + * @return the display fields + */ public List getDisplayFields() { return displayFields; } + /** + * Gets the search by fields. + * + * @return the search by fields + */ public List getSearchByFields() { return searchByFields; } + /** + * Gets the order by fields. + * + * @return the order by fields + */ public List getOrderByFields() { return orderByFields; } + /** + * Gets the projection. + * + * @return the projection + */ 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 5c32159..7a34374 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 @@ -19,13 +19,12 @@ 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.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig; -import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerformedOnItemEvent; -import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerformedOnItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.ClickItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.ClickItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; @@ -34,10 +33,14 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecords import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.OperationOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.OperationOnItemEventHandler; +import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerformedOnItemEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerformedOnItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEventHandler; +import org.gcube.portlets.user.geoportaldataentry.client.events.WorkflowActionOnSelectedItemEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.WorkflowActionOnSelectedItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView; @@ -100,8 +103,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { private static final String SERVER_ERROR = "An error occurred while " + "attempting to contact the server. Please check your network " + "connection and try again."; - public static final String DIV_PORTLET_ID = "geoportal-data-entry"; - public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT .create(GeoportalDataEntryService.class); @@ -178,13 +179,15 @@ public class GeoPortalDataEntryApp implements EntryPoint { */ geoportalCaches = new GeoPortalClientCaches(); - RootPanel.get(DIV_PORTLET_ID).add(loaderApplication); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).add(loaderApplication); mainTabPanel = new GeonaMainTabPanel(appManagerBus); geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); mainTabPanel.addFormPanel(geoNaMainForm); - RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID).add(mainTabPanel); + + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID).getElement().getStyle().setOpacity(0.4); GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { @@ -194,11 +197,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { - RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).remove(loaderApplication); } catch (Exception e) { } - RootPanel.get(DIV_PORTLET_ID).add(alert); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID).add(alert); Window.alert(errorMsg); } @@ -224,11 +227,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { - RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).remove(loaderApplication); } catch (Exception e) { } - RootPanel.get(DIV_PORTLET_ID).add(alert); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID).add(alert); Window.alert(errorMsg); } @@ -238,7 +241,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { GWT.log(GNADataEntryExtConfigProfile.class.getSimpleName() + " loaded: " + gNADataEntryConfig); try { - RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).remove(loaderApplication); } catch (Exception e) { } @@ -292,7 +295,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope); // orderedCards = new ArrayList(); try { - RootPanel.get(DIV_PORTLET_ID).insert(loaderConfigurations, 0); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).insert(loaderConfigurations, 0); } catch (Exception e) { } @@ -302,7 +305,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { try { - RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).remove(loaderConfigurations); } catch (Exception e) { } @@ -323,7 +326,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { // After loading of UCD I can instance the "List of Project" view mainTabPanel.instanceAndShowListOfProjects(); try { - RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID).getElement().getStyle() + .setOpacity(1); + RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_LOADERS_ID).remove(loaderConfigurations); } catch (Exception e) { } @@ -352,6 +357,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations); + geoportalCaches.putUCDForProfileId(ucdDV.getProfileID(), ucdDV); } geoportalCaches.printCacheHandlerConfigurations(); @@ -364,7 +370,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void updateSize() { try { - RootPanel workspace = RootPanel.get(DIV_PORTLET_ID); + RootPanel workspace = RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID); int topBorder = workspace.getAbsoluteTop(); int footer = 85; // footer is bottombar + sponsor int headerSize = 90; @@ -375,10 +381,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { GWT.log("New workspace dimension Height: " + rootHeight); mainTabPanel.setInternalHeight(rootHeight); } catch (Exception e) { - // TODO: handle exception + } - // appController.getMainPanel().setHeight(rootHeight); - // appController.getMainPanel().setWidth(rootWidth); } @@ -774,28 +778,134 @@ public class GeoPortalDataEntryApp implements EntryPoint { String profileID = getListOfRecordsEvent.getProfileID(); if (profileID == null) { - new DialogInform(null, "Error", "No user case descriptor selected").center(); + new DialogInform(null, "Error", "No Use Case Descriptor selected").center(); return; } grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, searchingFilter); mainTabPanel.showListOfConcessioniView(grpw); + + //The Project Type is changed + if(getListOfRecordsEvent.isReloadFilteringParameters()) { + mainTabPanel.initActionListPanel(geoportalCaches.getUCDForProfileID(profileID)); + } + } + }); + + appManagerBus.addHandler(ClickItemEvent.TYPE, new ClickItemEventHandler() { + + @Override + public void onClick(ClickItemEvent clickItemEvent) { + + if (clickItemEvent.getSelectItems() != null) { + mainTabPanel.showActionsOnSelected(clickItemEvent.getSelectItems()); + } } }); - - appManagerBus.addHandler(ClickItemEvent.TYPE, new ClickItemEventHandler() { - - @Override - public void onClick(ClickItemEvent clickItemEvent) { - - if(clickItemEvent.getSelectItems()!=null) { - mainTabPanel.showActionsOnSelected(clickItemEvent.getSelectItems()); - } - - } - }); + + appManagerBus.addHandler(WorkflowActionOnSelectedItemEvent.TYPE, + new WorkflowActionOnSelectedItemEventHandler() { + + @Override + public void onDoActionFired( + final WorkflowActionOnSelectedItemEvent wActionOnItem) { + GWT.log("WorkflowActionOnSelectedItemEvent onDoActionFired item: " + wActionOnItem); + + if (grpw.getSelectItems() == null || grpw.getSelectItems().size() == 0) { + DialogInform di = new DialogInform(null, "No selection", + "You must select a record in the table"); + di.center(); + return; + } + + DocumentDV item = grpw.getSelectItems().get(0); + + if (item instanceof ResultDocumentDV) { + + final ResultDocumentDV resultDocumentDV = (ResultDocumentDV) item; + + String htmlMsg = "Going to perform the step/s " + + wActionOnItem.getAction().getCallSteps() + " on the project with:"; + htmlMsg += "
    "; + htmlMsg += "
  • id: " + resultDocumentDV.getId() + "
  • "; + htmlMsg += "
  • profile: " + resultDocumentDV.getProfileID() + "
  • "; + htmlMsg += "
"; + htmlMsg += "
"; + htmlMsg += "Would you like to proceed?"; + + final ModalConfirm dialog = new ModalConfirm(null, "Step/s Confirm?", htmlMsg); + dialog.addToCenterPanel( + new ReportTemplateToHTML("Project", resultDocumentDV.getDocumentAsJSON(), false)); + + dialog.getYesButton().addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + dialog.hide(); + + final Modal modal = new Modal(true, true); + modal.setCloseVisible(false); + modal.setTitle("Perfoming Steps..."); + modal.hide(false); + modal.setWidth(800); + modal.setMaxHeigth("650px"); + final VerticalPanel modalContainerPanel = new VerticalPanel(); + final LoaderIcon loader = new LoaderIcon(); + loader.setText("Trying to perfom step/s " + wActionOnItem.getAction().getCallSteps() + + ", please wait..."); + modalContainerPanel.add(loader); + modal.add(modalContainerPanel); + + GeoportalDataEntryServiceAsync.Util.getInstance().performActionSteps( + resultDocumentDV.getProfileID(), resultDocumentDV.getId(), + wActionOnItem.getAction(), new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + modal.setCloseVisible(true); + try { + modalContainerPanel.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert(caught.getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + modal.add(alert); + } + + @Override + public void onSuccess(ProjectDV result) { + modal.setCloseVisible(true); + try { + modalContainerPanel.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert( + "Steps: " + wActionOnItem.getAction().getCallSteps() + + ", performed correclty"); + alert.setType(AlertType.INFO); + alert.setClose(false); + modal.add(alert); + + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, + resultDocumentDV.getProfileID(), mainTabPanel.getCurrentSearchingFilter(), true)); + + } + }); + + modal.show(); + + } + + }); + + dialog.show(); + } + + } + }); appManagerBus.addHandler(OperationPerformedOnItemEvent.TYPE, new OperationPerformedOnItemEventHandler() { @@ -832,7 +942,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // actionPerformedOnItemEvent.getProfileID(), null, // mainTabPanel.getCurrentSortFilter())); - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, null, grpw.getProfileID(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, grpw.getProfileID(), mainTabPanel.getCurrentSearchingFilter(), false)); break; } @@ -1073,7 +1183,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { alert.setClose(false); hp.add(alert); - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, null, + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, resultDocumentDV.getProfileID(), mainTabPanel.getCurrentSearchingFilter(), false)); } else { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index 70733fb..b677b0e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -5,7 +5,9 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; 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.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; @@ -163,4 +165,15 @@ public interface GeoportalDataEntryService extends RemoteService { */ boolean deleteProject(String profileID, String projectID) throws Exception; + /** + * Perform action steps. + * + * @param profileID the profile ID + * @param projectID the project ID + * @param action the action + * @return the project DV + * @throws Exception the exception + */ + ProjectDV performActionSteps(String profileID, String projectID, ActionDefinitionDV action) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index cc53217..91fc022 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -5,7 +5,9 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; 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.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; @@ -78,4 +80,7 @@ public interface GeoportalDataEntryServiceAsync { void getLifecycleInfoForProjectId(String profileID, String projectID, AsyncCallback callback); + void performActionSteps(String profileID, String projectID, ActionDefinitionDV action, + AsyncCallback callback); + } 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 1a8f126..f9c9291 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 @@ -22,20 +22,18 @@ public class GetListOfRecordsEvent extends GwtEvent extends GwtEvent { + public static Type TYPE = new Type(); + private ActionDefinitionDV action; + + public WorkflowActionOnSelectedItemEvent(ActionDefinitionDV doAction) { + this.action = doAction; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) + */ + @Override + protected void dispatch(WorkflowActionOnSelectedItemEventHandler handler) { + handler.onDoActionFired(this); + } + + /** + * Gets the action. + * + * @return the action + */ + public ActionDefinitionDV getAction() { + return action; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/WorkflowActionOnSelectedItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/WorkflowActionOnSelectedItemEventHandler.java new file mode 100644 index 0000000..a3d6b18 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/WorkflowActionOnSelectedItemEventHandler.java @@ -0,0 +1,23 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface WorkflowActionOnSelectedItemEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 13, 2022 + */ +public interface WorkflowActionOnSelectedItemEventHandler extends EventHandler { + + /** + * On do action fired. + * + * @param the generic type + * @param workflowActionOnItemEvent the workflow action on item event + */ + void onDoActionFired(WorkflowActionOnSelectedItemEvent workflowActionOnItemEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 0e4ca58..9468977 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -106,7 +106,7 @@ public class GeonaMainTabPanel extends Composite { // NavLink buttCreateNewProject; @UiField - NavLink buttonReloadConcessioni; + NavLink buttonReloadProjects; @UiField TabPanel tabPanel; @@ -262,7 +262,7 @@ public class GeonaMainTabPanel extends Composite { alertSortBy.setText(labelASC); UseCaseDescriptorDV singleUCD = getSelectProjectType(); if (singleUCD != null) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), false)); } } @@ -281,7 +281,7 @@ public class GeonaMainTabPanel extends Composite { alertSortBy.setText(labelDESC); UseCaseDescriptorDV singleUCD = getSelectProjectType(); if (singleUCD != null) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), false)); } } @@ -321,14 +321,14 @@ public class GeonaMainTabPanel extends Composite { */ private void bindEvents() { - buttonReloadConcessioni.addClickHandler(new ClickHandler() { + buttonReloadProjects.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { UseCaseDescriptorDV singleUCD = getSelectProjectType(); if (singleUCD != null) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), true)); } @@ -421,7 +421,7 @@ public class GeonaMainTabPanel extends Composite { UseCaseDescriptorDV singleUCD = getSelectProjectType(); if (singleUCD != null) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), false)); } @@ -460,7 +460,7 @@ public class GeonaMainTabPanel extends Composite { UseCaseDescriptorDV singleUCD = getSelectProjectType(); if (singleUCD != null) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getName(), singleUCD.getProfileID(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, singleUCD.getProfileID(), getCurrentSearchingFilter(), false)); } } @@ -617,7 +617,7 @@ public class GeonaMainTabPanel extends Composite { alertProjectType.setText(singleUCD.getName()); // setFilteringParameters(displayFields, sortByFields, searchForFields, // currentSearchingFilter); - appManagerBus.fireEvent(new GetListOfRecordsEvent(true, singleUCD.getName(), singleUCD.getProfileID(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(true, singleUCD.getProfileID(), getCurrentSearchingFilter(), true)); } } @@ -678,7 +678,7 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, ucd.getName(), ucd.getProfileID(), + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, ucd.getProfileID(), getCurrentSearchingFilter(), true)); } }); @@ -686,23 +686,9 @@ public class GeonaMainTabPanel extends Composite { ddProjectType.add(link); } + + initActionListPanel(ucd); - // Setting Project type having HANDLER WORKFLOW ACTION - dataListHandler = UCD_Util.getHandlerDeclarationFor(ucd, - GEOPORTAL_DATA_HANDLER.geoportal_workflow_action_list); - - if (dataListHandler != null) { - actionListMainPanel.setVisible(true); - actionListMainPanel.clear(); - ConfigurationDV config = dataListHandler.getConfiguration(); - List listActionDef = toListActionDefinition(config); - actionListPanel = new ActionListPanel(ucd.getName(), ucd.getProfileID(), listActionDef); - actionListMainPanel.add(actionListPanel); - - }else { - actionListMainPanel.clear(); - actionListMainPanel.setVisible(false); - } } // IF one type of document is available, fire @@ -730,8 +716,25 @@ public class GeonaMainTabPanel extends Composite { } } - private void initActionListPanel() { + public void initActionListPanel(UseCaseDescriptorDV ucd) { + GWT.log("Init ActionListPanel for UCD: "+ucd); + // Setting Project type having HANDLER WORKFLOW ACTION + HandlerDeclarationDV dataListHandler = UCD_Util.getHandlerDeclarationFor(ucd, + GEOPORTAL_DATA_HANDLER.geoportal_workflow_action_list); + + if (dataListHandler != null) { + actionListMainPanel.setVisible(true); + actionListMainPanel.clear(); + ConfigurationDV config = dataListHandler.getConfiguration(); + List listActionDef = toListActionDefinition(config); + actionListPanel = new ActionListPanel(appManagerBus, ucd.getName(), ucd.getProfileID(), listActionDef); + actionListMainPanel.add(actionListPanel); + + }else { + actionListMainPanel.clear(); + actionListMainPanel.setVisible(false); + } } public void showActionsOnSelected(List selectItems) { 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 e30726b..31d79fd 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 @@ -148,7 +148,7 @@ addStyleNames="alert_box_nav"> - Reload Projects diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java index a9cb1b1..89b5285 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java @@ -8,6 +8,7 @@ import java.util.Map; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; +import org.gcube.portlets.user.geoportaldataentry.client.events.WorkflowActionOnSelectedItemEvent; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ButtonGroup; @@ -15,9 +16,9 @@ import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; @@ -32,14 +33,16 @@ public class ActionListPanel extends Composite { private String projectName; private String profileID; private List listActionDefinition; + private HandlerManager appManagerBus; - public ActionListPanel(String projectName, String profileID, List listActionDef) { + public ActionListPanel(HandlerManager appManagerBus,String projectName, String profileID, List listActionDef) { initWidget(uiBinder.createAndBindUi(this)); GWT.log("Adding list of actions: " + listActionDef); + this.appManagerBus = appManagerBus; this.projectName = projectName; this.profileID = profileID; this.listActionDefinition = listActionDef; - initActions(listActionDef); + initActions(listActionDefinition); actionListBasePanel.setVisible(false); } @@ -70,7 +73,8 @@ public class ActionListPanel extends Composite { @Override public void onClick(ClickEvent event) { - Window.alert("ACTION fired: " + actionDefinitionDV.getTitle()); + + appManagerBus.fireEvent(new WorkflowActionOnSelectedItemEvent(actionDefinitionDV)); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java index 5ee645a..5658a90 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/UCD_Util.java @@ -37,7 +37,7 @@ public class UCD_Util { for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) { GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType(); - + if (dataHandlerType != null && dataHandlerType.equals(dataHandler)) { return handler; } 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 753aeeb..ed98d1c 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 @@ -18,6 +18,7 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.ProjectDVBuilder; import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller; import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller; import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller; @@ -33,9 +34,11 @@ import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_ import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; +import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; 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.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.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -816,61 +819,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } -// @Override -// public List getListDocumentConfigurationForId(String id) throws Exception { -//// MockDocumentConfigurationReader mock = new MockDocumentConfigurationReader(); -//// return mock.getListDocumentConfig(); -// -// UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors(); -// -// //TODO ID MUST BE THE HANDLER ID -// List useCaseDescriptor; -// try { -// List handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_entry.getId(), GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId()); -// useCaseDescriptor = client.getListForHandlerIds(handlersIds); -// } catch (Exception e1) { -// throw new Exception("Error when contacting the Geoportal service. Refresh and try again or contact the support"); -// } -// -// List listUCD = new ArrayList(useCaseDescriptor.size()); -// for (UseCaseDescriptor ucd : useCaseDescriptor) { -// listUCD.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null)); -// } -// -// List listDocumentConfig = new ArrayList(); -// -// for (UseCaseDescriptorDV useCaseDescriptorDV : listUCD) { -// DocumentConfigDV documentConfigDV = new DocumentConfigDV(); -// documentConfigDV.setId(useCaseDescriptorDV.getId()); -// documentConfigDV.setType(useCaseDescriptorDV.getName()); -// documentConfigDV.setItemType(useCaseDescriptorDV.getName()); -// ConfigHandlerDV config = new ConfigHandlerDV(); -// List handlers = useCaseDescriptorDV.getHandlers(); -// List gcubeProfiles = new ArrayList(); -// for (HandlerDeclarationDV handler : handlers) { -// ConfigurationDV docConfig = handler.getConfiguration(); -// try { -// List theConfig = (List) docConfig.getConfiguration(); -// if(theConfig!=null) { -// gcubeProfiles.addAll(gcubeProfiles); -// } -// }catch (Exception e) { -// LOG.warn("The configuration read for "+documentConfigDV.getId()+ " is not a List of "+GcubeProfileDV.class.getSimpleName()+", skipping it"); -// } -// } -// -// if(gcubeProfiles.size()>0) { -// config.setGcubeProfiles(gcubeProfiles); -// documentConfigDV.setConfiguration(config); -// listDocumentConfig.add(documentConfigDV); -// } -// } -// -// return listDocumentConfig; -// -// -// } - /** * Gets the list use case descriptors. * @@ -956,7 +904,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen */ @Override public LifecycleInformationDV getLifecycleInfoForProjectId(String profileID, String projectID) throws Exception { - LOG.info("getLifecycleInfoForProjectId called for profileID {}, projectID {} " + profileID, projectID); + LOG.info("getLifecycleInfoForProjectId called for profileID {}, projectID {} ", profileID, projectID); ProjectsCaller client = GeoportalClientCaller.projects(); SessionUtil.getCurrentContext(getThreadLocalRequest(), true); @@ -973,4 +921,44 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } + + /** + * Perform action steps. + * + * @param profileID the profile ID + * @param projectID the project ID + * @param action the action + * @return the project DV + * @throws Exception the exception + */ + @Override + public ProjectDV performActionSteps(String profileID, String projectID, ActionDefinitionDV action) + throws Exception { + LOG.info("performActionSteps called for profileID {}, projectID {}, action: " + action, profileID, projectID); + + ProjectsCaller client = GeoportalClientCaller.projects(); + SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + + if (action == null || action.getCallSteps() == null || action.getCallSteps().length == 0) { + throw new Exception("Action called is invalid, no step defined"); + } + + try { + Project project = null; + for (String stepID : action.getCallSteps()) { + LOG.info("calling stepID {} on projectID {}", stepID, projectID); + project = client.performStep(profileID, projectID, stepID, null); + } + + ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); + ProjectDV theProject = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); + LOG.info("performActionSteps returning theProject with ID {}", projectID); + return theProject; + } catch (Exception e) { + String error = "Error occurred on performing the workflow step/s on the project id " + projectID; + LOG.error(error, e); + throw new Exception(error + ". Error: "+e.getMessage()+". Refresh and try again or contact the support"); + } + + } } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index fdbc31e..ecd03a7 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -204,3 +204,8 @@ important position: sticky; top: 0; } + +.move-sticky-no-back .gwt-Label { + top: 0; + margin: auto 0; +} diff --git a/src/main/webapp/GeoPortalDataEntryApp.html b/src/main/webapp/GeoPortalDataEntryApp.html index 26b1cc3..3fcf1e6 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.html +++ b/src/main/webapp/GeoPortalDataEntryApp.html @@ -64,6 +64,7 @@ Your web browser must have JavaScript enabled in order for this application to display correctly. +
diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp index 04ca825..1db5f73 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp @@ -45,5 +45,5 @@ - +
\ No newline at end of file