#23926 Integrated a Post Creation Action in the UCD and manage it.

Improved Step Performed Feedback
This commit is contained in:
Francesco Mangiacrapa 2022-10-06 11:25:31 +02:00
parent f14a395b0c
commit 63642568eb
9 changed files with 162 additions and 42 deletions

View File

@ -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

View File

@ -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.

View File

@ -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<String> stepsOnPostCreation = new ArrayList<String>();
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<CommitReport>() {
stepsOnPostCreation, new AsyncCallback<CommitReport>() {
@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<ResultDocumentDV>() {
fromProjectID, relationName, toProfileID, toProjectID,
new AsyncCallback<ResultDocumentDV>() {
@Override
public void onFailure(Throwable caught) {
@ -937,11 +956,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
htmlMsg += "<ul>";
htmlMsg += "<li>id: " + fromProjectID + "</li>";
htmlMsg += "<li>profile: " + fromProfileID + "</li>";
htmlMsg += "<li>"
+ result.getFirstEntryOfMap().getKey()
+ ": "
+ result.getFirstEntryOfMap().getValue()
+ "</li>";
htmlMsg += "<li>" + result.getFirstEntryOfMap().getKey() + ": "
+ result.getFirstEntryOfMap().getValue() + "</li>";
htmlMsg += "</ul>";
htmlMsg += "has been deleted the relationship <b>" + relationName
+ "</b> to the project wiht id: " + toProjectID;
@ -951,14 +967,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
// rtth.showAsJSON(false);
// modal.add(rtth);
List<DocumentDV> listDocuments = Arrays
.asList(result);
List<DocumentDV> listDocuments = Arrays.asList(result);
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(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<ResultDocumentDV>() {
@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<DocumentDV>(
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(),

View File

@ -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<GeoNaFormDataObject> tree_Node) throws Exception;
CommitReport saveGeonaDataForms(String profileID, Tree_Node<GeoNaFormDataObject> tree_Node,
List<String> stepsOnPostCreation) throws Exception;
/**
* Gets the geona init config.

View File

@ -52,7 +52,7 @@ public interface GeoportalDataEntryServiceAsync {
}
void saveGeonaDataForms(String profileID, Tree_Node<GeoNaFormDataObject> tree_Node,
AsyncCallback<CommitReport> callback);
List<String> stepsOnPostCreation, AsyncCallback<CommitReport> callback);
void getGeonaInitConfig(AsyncCallback<GeoportalISConfig> callback);

View File

@ -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<String, String[]> mapProfileIdForPostCreationActionSteps = new HashMap<String, String[]>();
/**
* 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<ActionDefinitionDV> listActionDef = (List<ActionDefinitionDV>) 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) {

View File

@ -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<String, List<ActionDefButton>>();
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());

View File

@ -151,14 +151,15 @@ public class ViewRelationshipPanel extends Composite {
+ "</b> (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);
}

View File

@ -112,8 +112,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
* @throws Exception the exception
*/
@Override
public CommitReport saveGeonaDataForms(String profileID, Tree_Node<GeoNaFormDataObject> tree_Node)
throws Exception {
public CommitReport saveGeonaDataForms(String profileID, Tree_Node<GeoNaFormDataObject> tree_Node,
List<String> 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);