From 63816fe6480de775ef03b8ecffbebdd5885b2f7b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 11 Apr 2024 11:04:54 +0200 Subject: [PATCH] integrated new bean StepPerformedResultDV --- .settings/org.eclipse.wst.common.component | 48 +++++++++---- .../client/GeoPortalDataEntryApp.java | 72 +++++++++++++------ .../client/GeoportalDataEntryService.java | 3 +- .../GeoportalDataEntryServiceAsync.java | 3 +- .../client/ui/action/StepViewPanel.ui.xml | 2 +- .../server/GeoportalDataEntryServiceImpl.java | 16 +++-- 6 files changed, 104 insertions(+), 40 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index e3f5ed7..077df57 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,8 @@ - + + + + @@ -141,7 +144,10 @@ - + + + + @@ -283,7 +289,10 @@ - + + + + @@ -425,7 +434,10 @@ - + + + + @@ -567,7 +579,10 @@ - + + + + @@ -667,10 +682,10 @@ uses - - uses - - + + + + @@ -812,7 +827,10 @@ - + + + + @@ -954,7 +972,10 @@ - + + + + @@ -1096,7 +1117,10 @@ - + + + + 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 3d2eb98..11c4639 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 @@ -21,8 +21,9 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfil import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; +import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV.Status; 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.step.StepPerformedResultDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; @@ -257,7 +258,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support. Error is: "+caught.getMessage(); + String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support. Error is: " + + caught.getMessage(); Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { @@ -328,8 +330,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { - - if(caught instanceof ProjectNotFoundException) { + + if (caught instanceof ProjectNotFoundException) { Modal errorModal = new Modal(true, true); errorModal.setCloseVisible(true); errorModal.setTitle("Oops..."); @@ -343,11 +345,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { errorPanelMsg.add(erroMessage); errorModal.add(errorPanelMsg); errorModal.show(); - } - else { + } else { Window.alert("Error " + caught.getMessage()); } - + initExecutor.execute(); } @@ -1365,8 +1366,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.add(modalContainerPanel); GeoportalDataEntryServiceAsync.Util.getInstance().performActionSteps( - resultDocumentDV.getProfileID(), resultDocumentDV.getId(),stvp.getOptionalMessage(), - wActionOnItem.getAction(), new AsyncCallback() { + resultDocumentDV.getProfileID(), resultDocumentDV.getId(), + stvp.getOptionalMessage(), wActionOnItem.getAction(), + new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -1382,7 +1384,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } @Override - public void onSuccess(final ProjectDV result) { + public void onSuccess(final StepPerformedResultDV result) { modal.setTitle("Step/s performed"); modal.setCloseVisible(true); try { @@ -1396,22 +1398,50 @@ public class GeoPortalDataEntryApp implements EntryPoint { String stepsToString = ""; for (String step : wActionOnItem.getAction().getCallSteps()) { - stepsToString += step + ", "; + stepsToString += step + " "; + } + + Status status = Status.NOT_SPECIFIED; + AlertType alertType = AlertType.INFO; + String statusMsg = "status " + status.getLabel(); + try { + status = result.getLifecycleInfoDV().getLastOperationStatus(); + switch (status) { + case OK: + alertType = AlertType.SUCCESS; + statusMsg = "performed with " + status.getLabel().toUpperCase()+"!"; + break; + case WARNING: + alertType = AlertType.WARNING; + statusMsg = "performed with " + status.getLabel().toUpperCase()+"!"; + break; + case ERROR: + alertType = AlertType.ERROR; + statusMsg = "performed with " + status.getLabel().toUpperCase()+"!"; + break; + default: + alertType = AlertType.INFO; + statusMsg = "performed. Current status " + status.getLabel(); + break; + } + } catch (Exception e) { + // silent } Alert alert = new Alert( - stepString + " " + stepsToString + "performed correclty!"); - alert.setType(AlertType.INFO); + stepString + " " + stepsToString + " " + statusMsg); + alert.setType(alertType); alert.setClose(false); modal.add(alert); GeoportalDataEntryServiceAsync.Util.getInstance() .getResultDocumentFoProjectByID(result.getProfileID(), - result.getId(), new AsyncCallback() { + result.getProjectId(), + new AsyncCallback() { @Override public void onFailure(Throwable caught) { - // TODO Auto-generated method stub + Window.alert("Error: " + caught.getMessage()); } @@ -1631,7 +1661,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.add(hpGetLink); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(), - resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_VIEWER, new AsyncCallback() { + resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_VIEWER, + new AsyncCallback() { @Override public void onFailure(Throwable caught) { try { @@ -1679,7 +1710,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; } - + case GET_SHAREABLE_LINK: { final Modal modal = new Modal(true, true); @@ -1691,7 +1722,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.add(hpGetLink); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(), - resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_ENTRY, new AsyncCallback() { + resultDocumentDV.getProfileID(), GeoportalItemReferences.SHARE_LINK_TO.DATA_ENTRY, + new AsyncCallback() { @Override public void onFailure(Throwable caught) { try { @@ -1722,8 +1754,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { Anchor anchor = new Anchor(theURL); anchor.setHref(theURL); anchor.setTarget("_blank"); - anchor.setTitle( - "Shareable link of the project with id: " + resultDocumentDV.getId()); + anchor.setTitle("Shareable link of the project with id: " + + resultDocumentDV.getId()); com.github.gwtbootstrap.client.ui.Label label = new com.github.gwtbootstrap.client.ui.Label( "Shareable link"); label.setType(LabelType.SUCCESS); 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 0d3e054..c52839b 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 @@ -12,6 +12,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; +import org.gcube.application.geoportalcommon.shared.geoportal.step.StepPerformedResultDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; @@ -146,7 +147,7 @@ public interface GeoportalDataEntryService extends RemoteService { * @param action the action * @return the project DV */ - ProjectDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action) throws Exception; + StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action) throws Exception; /** * Gets the relationships definition. 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 e861ee0..20b337c 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 @@ -12,6 +12,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; +import org.gcube.application.geoportalcommon.shared.geoportal.step.StepPerformedResultDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; @@ -80,7 +81,7 @@ public interface GeoportalDataEntryServiceAsync { AsyncCallback callback); void performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action, - AsyncCallback callback); + AsyncCallback callback); void getRelationshipsDefinition(String profileID, AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/StepViewPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/StepViewPanel.ui.xml index 5fbae1b..01bd0d1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/StepViewPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/StepViewPanel.ui.xml @@ -36,7 +36,7 @@ - You can add an optional message... + You can optionally add a message... 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 d15b04a..4349754 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 @@ -55,6 +55,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfil import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; +import org.gcube.application.geoportalcommon.shared.geoportal.step.StepPerformedResultDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; @@ -1272,7 +1273,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public ProjectDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action) + public StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action) throws Exception { LOG.info("performActionSteps called for profileID {}, projectID {}, action: " + action, profileID, projectID); @@ -1289,11 +1290,16 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("calling stepID {} on projectID {}", stepID, projectID); project = client.performStep(profileID, projectID, stepID, optionalMessage, null); } + + LifecycleInformationDV lifecycleInfo = getLifecycleInfoForProjectId(profileID, projectID); + lifecycleInfo.getLastOperationStatus(); - ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); - ProjectDV theProject = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); - LOG.info("performActionSteps returning theProject with ID {}", projectID); - return theProject; + StepPerformedResultDV sprv = new StepPerformedResultDV(profileID, projectID, lifecycleInfo); + +// ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); +// ProjectDV theProject = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); + LOG.info("performActionSteps returning theProject with ID {}", sprv); + return sprv; } catch (Exception e) { String error = "Error occurred on performing the workflow step/s on the project id " + projectID; LOG.error(error, e);