diff --git a/CHANGELOG.md b/CHANGELOG.md index 6824b2d..26479b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23785] Migrated the GNA functionalities - [#23834] Integrated with the create/view/delete Relationship facility - [#23913] Integrated with GUI presentation configurations read from IS +- [#23926] Integrate a Post Creation Action in the UCD and manage it - Moved to maven-portal-bom v3.7.0[-SNAPSHOT] ## [v2.2.1] - 2022-06-29 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 cdb02f0..3598e10 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 @@ -43,6 +43,8 @@ public class ConstantsGeoPortalDataEntryApp { public static final RootPanel ROOT_PANEL_DIV_PORTLET = RootPanel.get(ConstantsGeoPortalDataEntryApp.DIV_PORTLET_ID); public static final String CSS_CLASS_GEOPORTAL_LOADERS_CENTER = "geoportal-loaders-center"; + + public static final String WORKFLOW_ACTION_POST_CREATION_ACTION_ID = "post_creation_action"; // /** // * The Enum RECORD_TYPE. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 7c079d2..9abde4b 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 @@ -74,13 +74,16 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -88,9 +91,12 @@ import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TreeItem; import com.google.gwt.user.client.ui.VerticalPanel; @@ -547,9 +553,21 @@ public class GeoPortalDataEntryApp implements EntryPoint { modalContainerPanel.add(loader); modal.add(modalContainerPanel); + String[] listPostActionOnSave = mainTabPanel + .getPostCreationActionOnSave(saveGeonaDataFormsEvent.getProfileID()); + + List stepsOnPostCreation = new ArrayList(); + if (listPostActionOnSave != null) { + for (String step : listPostActionOnSave) { + stepsOnPostCreation.add(step); + } + } + + GWT.log("Calling saveGeonaDataForms, stepsOnPostCreation are " + stepsOnPostCreation); + GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms( saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getTreeNode(), - new AsyncCallback() { + stepsOnPostCreation, new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -900,7 +918,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.add(modalContainerPanel); GeoportalDataEntryServiceAsync.Util.getInstance().deleteRelationship(fromProfileID, - fromProjectID, relationName, toProfileID, toProjectID, new AsyncCallback() { + fromProjectID, relationName, toProfileID, toProjectID, + new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -937,11 +956,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { htmlMsg += "
    "; htmlMsg += "
  • id: " + fromProjectID + "
  • "; htmlMsg += "
  • profile: " + fromProfileID + "
  • "; - htmlMsg += "
  • " - + result.getFirstEntryOfMap().getKey() - + ": " - + result.getFirstEntryOfMap().getValue() - + "
  • "; + htmlMsg += "
  • " + result.getFirstEntryOfMap().getKey() + ": " + + result.getFirstEntryOfMap().getValue() + "
  • "; htmlMsg += "
"; htmlMsg += "has been deleted the relationship " + relationName + " to the project wiht id: " + toProjectID; @@ -951,14 +967,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { // rtth.showAsJSON(false); // modal.add(rtth); - List listDocuments = Arrays - .asList(result); - + List listDocuments = Arrays.asList(result); + appManagerBus.fireEvent(new OperationOnItemEvent(listDocuments, OPERATION_ON_ITEM.VIEW_RELATIONSHIPS)); - - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, - fromProfileID, + + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, fromProfileID, mainTabPanel.getCurrentProjectsSearchingFilter(), true)); } @@ -1080,9 +1094,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // modal.add(rtth); appManagerBus.fireEvent(new CloseCreateRelationGUIEvent()); - - appManagerBus.fireEvent(new GetListOfRecordsEvent(false, - fromProfileID, + + appManagerBus.fireEvent(new GetListOfRecordsEvent(false, fromProfileID, mainTabPanel.getCurrentProjectsSearchingFilter(), true)); } }); @@ -1142,7 +1155,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { htmlMsg += "Would you like to proceed?"; final ModalConfirm dialog = new ModalConfirm(null, - "Step/s " + wActionOnItem.getAction().getTitle() + " Confirm?", htmlMsg); + "Step/s " + wActionOnItem.getAction().getTitle() + ", Confirm?", htmlMsg); dialog.addToCenterPanel( new ReportTemplateToHTML("Project", resultDocumentDV.getDocumentAsJSON(), false)); @@ -1183,19 +1196,63 @@ public class GeoPortalDataEntryApp implements EntryPoint { } @Override - public void onSuccess(ProjectDV result) { + public void onSuccess(final ProjectDV result) { modal.setTitle("Step/s performed"); modal.setCloseVisible(true); try { modalContainerPanel.remove(loader); } catch (Exception e) { } + + String stepString = wActionOnItem.getAction().getCallSteps().length==1?"Step":"Steps"; + + String stepsToString = ""; + for (String step : wActionOnItem.getAction().getCallSteps()) { + stepsToString+=step+", "; + } + Alert alert = new Alert( - "Steps: " + wActionOnItem.getAction().getCallSteps() - + ", performed correclty"); + stepString +" "+ stepsToString + + "performed correclty!"); alert.setType(AlertType.INFO); alert.setClose(false); modal.add(alert); + + GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(result.getProfileID(), result.getId(), new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub + + } + + @Override + public void onSuccess(ResultDocumentDV theResultDocument) { + VerticalPanel vp = new VerticalPanel(); + vp.getElement().getStyle().setMarginTop(20, Unit.PX); + vp.add(new Label("Check outcome in the Publication Report")); + Button buttonShowPublicationReport = new Button( + "Show Publication Report"); + buttonShowPublicationReport.setType(ButtonType.INFO); + buttonShowPublicationReport.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + modal.hide(); + appManagerBus.fireEvent(new OperationOnItemEvent( + Arrays.asList(theResultDocument), + OPERATION_ON_ITEM.VIEW_REPORT)); + + } + }); + buttonShowPublicationReport.getElement().getStyle().setMarginTop(10, Unit.PX); + buttonShowPublicationReport.getElement().getStyle().setMarginBottom(20, Unit.PX); + vp.add(buttonShowPublicationReport); + + modal.add(vp); + + } + }); appManagerBus.fireEvent(new GetListOfRecordsEvent(false, resultDocumentDV.getProfileID(), 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 5435c83..42bbe28 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 @@ -34,15 +34,8 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("geoportaldataentryservice") public interface GeoportalDataEntryService extends RemoteService { - /** - * Save geona data forms. - * - * @param profileID the profile ID - * @param tree_Node the tree node - * @return the commit report - * @throws Exception the exception - */ - CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node) throws Exception; + CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node, + List stepsOnPostCreation) throws Exception; /** * Gets the geona init config. 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 342505c..734d713 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 @@ -52,7 +52,7 @@ public interface GeoportalDataEntryServiceAsync { } void saveGeonaDataForms(String profileID, Tree_Node tree_Node, - AsyncCallback callback); + List stepsOnPostCreation, AsyncCallback callback); void getGeonaInitConfig(AsyncCallback callback); 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 586e0cb..190dfcd 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 @@ -1,7 +1,9 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; @@ -9,6 +11,7 @@ import org.gcube.application.geoportalcommon.shared.config.OPERATION_ON_ITEM; 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.ActionDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; @@ -16,6 +19,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescrip import org.gcube.application.geoportalcommon.shared.guipresentation.BodyWelcome; import org.gcube.application.geoportalcommon.shared.guipresentation.DataEntryGUIPresentationConfig; import org.gcube.application.geoportalcommon.shared.guipresentation.Header; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; @@ -159,6 +163,8 @@ public class GeonaMainTabPanel extends Composite { private DataEntryGUIPresentationConfig dataGUIPresentation; + private Map mapProfileIdForPostCreationActionSteps = new HashMap(); + /** * Instantiates a new geona main tab panel. * @@ -497,9 +503,14 @@ public class GeonaMainTabPanel extends Composite { } } + /** + * Sets the GUI presentation. + * + * @param dataEntryGUIPresentation the new GUI presentation + */ public void setGUIPresentation(DataEntryGUIPresentationConfig dataEntryGUIPresentation) { this.dataGUIPresentation = dataEntryGUIPresentation; - GWT.log("Setting: "+dataEntryGUIPresentation); + GWT.log("Setting: " + dataEntryGUIPresentation); Header header = dataGUIPresentation.getHeader(); if (header != null) { @@ -531,6 +542,34 @@ public class GeonaMainTabPanel extends Composite { public void initActionListPanel(UseCaseDescriptorDV ucd) { GWT.log("Init ActionListPanel for UCD: " + ucd); listOfProjectWorkflowActionsPanel.initActionListPanel(ucd); + + // Setting Project type having HANDLER WORKFLOW ACTION + HandlerDeclarationDV dataListHandler = UCD_Util.getHandlerDeclarationFor(ucd, + GEOPORTAL_DATA_HANDLER.geoportal_workflow_action_list); + + String[] callSteps = null; + if (dataListHandler != null) { + ConfigurationDV config = dataListHandler.getConfiguration(); + List listActionDef = (List) config.getConfiguration(); + for (ActionDefinitionDV actionDefinitionDV : listActionDef) { + // skipping the special workflow action + if (actionDefinitionDV.getId() + .equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) { + callSteps = actionDefinitionDV.getCallSteps(); + mapProfileIdForPostCreationActionSteps.put(ucd.getProfileID(), callSteps); + } + } + } + } + + /** + * Gets the post creation action on save. + * + * @param profileID the profile ID + * @return the post creation action on save + */ + public String[] getPostCreationActionOnSave(String profileID) { + return mapProfileIdForPostCreationActionSteps.get(profileID); } /** @@ -607,7 +646,7 @@ public class GeonaMainTabPanel extends Composite { * Show view project relations panel. * * @param bool the bool - * @param resultDocumentDV the result document DV + * @param selectedDocument the selected document */ public void showViewProjectRelationsPanel(boolean bool, ResultDocumentDV selectedDocument) { detailsPanel.clear(); @@ -621,6 +660,11 @@ public class GeonaMainTabPanel extends Composite { detailsPanel.add(viewRelationshipPanel); } + /** + * Enable relatioship facilities. + * + * @param bool the bool + */ public void enableRelatioshipFacilities(boolean bool) { navCreateRelation.setVisible(bool); if (!bool) { 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 3b29feb..0c2be89 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 @@ -10,6 +10,7 @@ import java.util.Set; import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.events.WorkflowActionOnSelectedItemEvent; import com.github.gwtbootstrap.client.ui.Button; @@ -67,6 +68,12 @@ public class ActionListPanel extends Composite { mapPhaseListButtons = new LinkedHashMap>(); for (ActionDefinitionDV actionDefinitionDV : listActionDef) { + + //skipping the special workflow action + if(actionDefinitionDV.getId().equals(ConstantsGeoPortalDataEntryApp.WORKFLOW_ACTION_POST_CREATION_ACTION_ID)) { + continue; + } + Button butt = new Button(); butt.setText(actionDefinitionDV.getTitle()); butt.setTitle(actionDefinitionDV.getDescription()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java index e6dbfb4..e4d489f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java @@ -151,14 +151,15 @@ public class ViewRelationshipPanel extends Composite { + " (id: " + result.getId() + ")"; flexTable.setWidget(1, 0, new HTML(htmlMsg)); + + ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", result.getDocumentAsJSON(), false, false); + rtth2.showAsJSON(false); + flexTable.setWidget(2, 0, rtth2); } }); - ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false); - rtth2.showAsJSON(false); - flexTable.setWidget(2, 0, rtth2); secondProjectPanelContainer.add(flexTable); } 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 3a83491..72f7c37 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 @@ -112,8 +112,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node) - throws Exception { + public CommitReport saveGeonaDataForms(String profileID, Tree_Node tree_Node, + List stepsOnPostCreation) throws Exception { LOG.info("saveGeonaDataForms called for profileID {}", profileID); MongoServiceUtil mongoService = new MongoServiceUtil(); @@ -157,9 +157,25 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } try { + + ProjectsCaller client = GeoportalClientCaller.projects(); + SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + LOG.info("stepsOnPostCreation are {}", stepsOnPostCreation); + for (String stepID : stepsOnPostCreation) { + LOG.info("calling step OnPostCreation are {}", stepID); + theProject = client.performStep(theProject.getProfileID(), theProject.getId(), stepID, null); + } + + } catch (Exception e) { + throw new Exception("Error occurred on performing steps " + stepsOnPostCreation + " on the project: " + + theProject.getId() + ". Error: " + e.getMessage()); + } + + try { + LifecycleInformation lifecycleInfo = theProject.getLifecycleInformation(); LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lifecycleInfo); - + return new CommitReport(theProject.getId(), theProject.getProfileID(), theProject.getTheDocument().toJson(), liDV); } catch (Exception e) { @@ -984,11 +1000,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } - @Override - public ResultDocumentDV deleteRelationship(String fromProfileID, String fromProjectID, String relationshipId, String toProfileID, - String toProjectID) throws Exception { + public ResultDocumentDV deleteRelationship(String fromProfileID, String fromProjectID, String relationshipId, + String toProfileID, String toProjectID) throws Exception { LOG.info("deleteRelationship called"); try { ProjectsCaller projects = GeoportalClientCaller.projects(); @@ -996,7 +1011,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen projects.deleteRelationship(fromProfileID, fromProjectID, relationshipId, toProfileID, toProjectID); SessionUtil.getCurrentContext(getThreadLocalRequest(), true); return getResultDocumentFoProjectByID(fromProfileID, fromProjectID); - + } catch (Exception e) { String error = "Error occurred on deleting the relationship"; LOG.error(error, e);