diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d996e1..8e9d42c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#22883] Integrated with (the new) geoportal-client (>= 1.1.0-SNAPSHOT) - [#22685] Migrated to geoportal-data-list configuration for UCD - [#23784] Migrated list and reload, searching and ordering functionalities +- [#23785] Migrated the GNA functionalities - 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/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index c7d5fdf..d2e2b00 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 @@ -15,12 +15,12 @@ import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE; import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; @@ -38,9 +38,10 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEventHan 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; +import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; -import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; +import org.gcube.portlets.user.geoportaldataentry.client.ui.report.LifecycleInformationPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.NodeItem; import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.TreeItemPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; @@ -48,6 +49,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -558,11 +560,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { LifecycleInformationDV lcDV = result.getLifecycleInformation(); - HTML htmlPhase = new HTML(); - htmlPhase.setHTML("Current phase: " + lcDV.getPhase() + ""); - - HTML htmlStep = new HTML(); - htmlStep.setHTML("Invoked Step: " + lcDV.getLastInvokedStep() + ""); +// HTML htmlPhase = new HTML(); +// htmlPhase.setHTML("Current phase: " + lcDV.getPhase() + ""); +// +// HTML htmlStep = new HTML(); +// htmlStep.setHTML("Invoked Step: " + lcDV.getLastInvokedStep() + ""); HTML lastOperationStatus = new HTML(); switch (lcDV.getLastOperationStatus()) { @@ -577,18 +579,18 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; } case WARNING: { - String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, - "WARNING"); - String msg = lcDV.getLastInvokedStep() + "terminated with: " + warning; - lastOperationStatus.setHTML(msg); +// String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, +// "WARNING"); +// String msg = lcDV.getLastInvokedStep() + "terminated with: " + warning; +// lastOperationStatus.setHTML(msg); geoNaMainForm.enableButtonSave(true); break; } case ERROR: { - String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", - "ERROR"); - String msg = lcDV.getLastInvokedStep() + "terminated with: " + error; - lastOperationStatus.setHTML(msg); +// String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", +// "ERROR"); +// String msg = lcDV.getLastInvokedStep() + "terminated with: " + error; +// lastOperationStatus.setHTML(msg); geoNaMainForm.enableButtonSave(true); break; } @@ -596,55 +598,46 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; } - modalContainerPanel.add(htmlPhase); - modalContainerPanel.add(htmlStep); - modalContainerPanel.add(lastOperationStatus); + LifecycleInformationPanel lip = new LifecycleInformationPanel(result.getProjectID(), + result.getProfileID(), result.getProjectAsJSON(), lcDV, true); - if (result.getProjectID() != null) { - modalContainerPanel.add(new HTML("Record id: " + (result.getProjectID()))); + modalContainerPanel.add(lip); - try { - savedMap.put(result.getProjectID(), saveGeonaDataFormsEvent.getTreeNode()); - } catch (Exception e) { - // TODO: handle exception - } - - final HorizontalPanel hpGetLink = new HorizontalPanel(); - final LoaderIcon lc = new LoaderIcon("Get link..."); - hpGetLink.add(lc); - modalContainerPanel.add(hpGetLink); - GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor( - result.getProjectID(), saveGeonaDataFormsEvent.getProfileID(), - new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - hpGetLink.clear(); - - } - - @Override - public void onSuccess(GeoNaItemRef result) { - hpGetLink.clear(); - String theURL = result.getRestrictedLink().getShortURL() != null - ? result.getRestrictedLink().getShortURL() - : result.getRestrictedLink().getCompleteURL(); - String htmlLink = "
Go to project: " + theURL + "
"; - HTML html = new HTML(htmlLink); - hpGetLink.add(html); - // modal.add(html); - } - }); - } - - // geoNaMainForm.enableButtonSave(true); - // resetUI(); - - if (lcDV.getAsJSONString() != null) { - modalContainerPanel - .add(new ReportTemplateToHTML(lcDV.getAsJSONString(), false)); - } + /* + * modalContainerPanel.add(htmlPhase); modalContainerPanel.add(htmlStep); + * modalContainerPanel.add(lastOperationStatus); + * + * if (result.getProjectID() != null) { modalContainerPanel.add(new + * HTML("Record id: " + (result.getProjectID()))); + * + * try { savedMap.put(result.getProjectID(), + * saveGeonaDataFormsEvent.getTreeNode()); } catch (Exception e) { // TODO: + * handle exception } + * + * final HorizontalPanel hpGetLink = new HorizontalPanel(); final LoaderIcon lc + * = new LoaderIcon("Get link..."); hpGetLink.add(lc); + * modalContainerPanel.add(hpGetLink); + * GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor( + * result.getProjectID(), saveGeonaDataFormsEvent.getProfileID(), new + * AsyncCallback() { + * + * @Override public void onFailure(Throwable caught) { hpGetLink.clear(); + * + * } + * + * @Override public void onSuccess(GeoNaItemRef result) { hpGetLink.clear(); + * String theURL = result.getRestrictedLink().getShortURL() != null ? + * result.getRestrictedLink().getShortURL() : + * result.getRestrictedLink().getCompleteURL(); String htmlLink = + * "
Go to project: " + theURL + + * "
"; HTML html = new HTML(htmlLink); hpGetLink.add(html); // + * modal.add(html); } }); } + * + * // geoNaMainForm.enableButtonSave(true); // resetUI(); + * + * if (lcDV.getAsJSONString() != null) { modalContainerPanel .add(new + * ReportTemplateToHTML(lcDV.getAsJSONString(), false)); } + */ } }); @@ -820,18 +813,18 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { GWT.log("Fired: " + getListOfRecordsEvent); SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter(); - + CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches .getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID()); - - if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit() || getListOfRecordsEvent.isReloadFilteringParameters()) { + + if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit() + || getListOfRecordsEvent.isReloadFilteringParameters()) { mainTabPanel.setFilteringParameters(seachingFilterParameters); searchingFilter = mainTabPanel.getCurrentSearchingFilter(); } - - //TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters() - - + + // TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters() + searchingFilter.setProjection(seachingFilterParameters.getProjection()); List displayFields = seachingFilterParameters.getDisplayFields(); @@ -924,103 +917,127 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (item == null) return; - if (item instanceof DocumentDV) { + if (item instanceof ResultDocumentDV) { - Window.alert("ACTION MUST BE REVISITED"); + final ResultDocumentDV resultDocumentDV = (ResultDocumentDV) item; + GWT.log("onDoActionFired item: " + resultDocumentDV); + + // Checking if the user is NOT authorized to perform this action in two ways: + // 1. the map of actions allowed for the user does not contain the action; + RoleRights roleRights = myRights.getRoleRights(); + OPERATION_TYPE operationType = roleRights.getListPermessions().get(action); + boolean allowedOperationForUser = operationType != null ? true : false; + if (!allowedOperationForUser) { + + String msg = "You are not authorized to perform the action: " + action.getLabel(); + ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), + "Forbidden: " + action, msg, AlertType.WARNING); + modalW.show(); + return; + } + // 2. the user cannot access to action (e.g. the user cannot write an item of + // another user) + // if so an error is shown + GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); + String creatorUsername = ""; + try { + creatorUsername = resultDocumentDV.getPublicationInfoDV().getCreationInfo().getUsername(); + } catch (Exception e) { + // TODO: handle exception + } + boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, + creatorUsername); + if (!allowedWriteActionOnItem) { + String title = "Forbidden: missing write access"; + String msg = "You do not have write access to item: " + resultDocumentDV.getId(); + if (!userRole.isWriteOwn()) { + msg = "You do not have write access to item: " + resultDocumentDV.getId(); + } else if (!userRole.isWriteAny()) { + title = "Forbidden: missing ownership"; + msg = "You are not the creator of: " + resultDocumentDV.getId() + + ". You cannot access to it"; + } + ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, + AlertType.WARNING); + modalW.show(); + return; + } + + switch (action) { + case VIEW_ON_MAP: { + final Modal modal = new Modal(true, true); + modal.setCloseVisible(true); + final HorizontalPanel hpGetLink = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Just moment getting link..."); + hpGetLink.add(lc); + modal.add(hpGetLink); + + final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); + + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(), + resultDocumentDV.getProfileID(), new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + hpGetLink.clear(); + Alert alert = new Alert(caught.getMessage(), AlertType.ERROR); + alert.setClose(false); + hpGetLink.add(alert); + newBrowserWindow.close(); + } + + @Override + public void onSuccess(GeoNaItemRef result) { + String theURL = result.getRestrictedLink().getShortURL() != null + ? result.getRestrictedLink().getShortURL() + : result.getRestrictedLink().getCompleteURL(); + newBrowserWindow.setUrl(theURL); + modal.hide(); + } + }); + + modal.show(); + + break; + } + + case VIEW_REPORT: + + final Modal modal2 = new Modal(true, true); + modal2.setTitle( + "Report for Project: " + + resultDocumentDV.getId() + ""); + modal2.setWidth(800); + modal2.setCloseVisible(true); + final LoaderIcon lc = new LoaderIcon("Just moment loading lifecycle info..."); + modal2.add(lc); + + GeoportalDataEntryServiceAsync.Util.getInstance().getLifecycleInfoForProjectId( + resultDocumentDV.getProfileID(), resultDocumentDV.getId(), + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + lc.setVisible(false); + modal2.add( + new HTML("No report available for: " + resultDocumentDV.getId())); + modal2.add(new Alert(caught.getMessage(), AlertType.ERROR)); + } + + @Override + public void onSuccess(LifecycleInformationDV result) { + lc.setVisible(false); + LifecycleInformationPanel lip = new LifecycleInformationPanel( + resultDocumentDV.getId(), resultDocumentDV.getProfileID(), + resultDocumentDV.getDocumentAsJSON(), result, false); + modal2.add(lip); + + } + }); + + modal2.show(); + + break; -// final DocumentDV concessione = (DocumentDV) item; -// GWT.log("onDoActionFired item: " + concessione); -// -// // Checking if the user is NOT authorized to perform this action in two ways: -// // 1. the map of actions allowed for the user does not contain the action; -// RoleRights roleRights = myRights.getRoleRights(); -// OPERATION_TYPE operationType = roleRights.getListPermessions().get(action); -// boolean allowedOperationForUser = operationType != null ? true : false; -// if (!allowedOperationForUser) { -// -// String msg = "You are not authorized to perform the action: " + action.getLabel(); -// ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), -// "Forbidden: " + action, msg, AlertType.WARNING); -// modalW.show(); -// return; -// } -// // 2. the user cannot access to action (e.g. the user cannot write an item of -// // another user) -// // if so an error is shown -// GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); -// boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, -// concessione); -// if (!allowedWriteActionOnItem) { -// String title = "Forbidden: missing write access"; -// String msg = "You do not have write access to item: " + concessione.getNome(); -// if (!userRole.isWriteOwn()) { -// msg = "You do not have write access to item: " + concessione.getNome(); -// } else if (!userRole.isWriteAny()) { -// title = "Forbidden: missing ownership"; -// msg = "You are not the creator of: " + concessione.getNome() -// + ". You cannot access to it"; -// } -// ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, -// AlertType.WARNING); -// modalW.show(); -// return; -// } -// -// switch (action) { -// case VIEW_ON_MAP: -// final Modal modal = new Modal(true, true); -// modal.setCloseVisible(true); -// final HorizontalPanel hpGetLink = new HorizontalPanel(); -// final LoaderIcon lc = new LoaderIcon("Just moment getting link..."); -// hpGetLink.add(lc); -// modal.add(hpGetLink); -// -// final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); -// -// GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), -// showItemEvent.getProfileID(), new AsyncCallback() { -// @Override -// public void onFailure(Throwable caught) { -// hpGetLink.clear(); -// Alert alert = new Alert(caught.getMessage(), AlertType.ERROR); -// alert.setClose(false); -// hpGetLink.add(alert); -// newBrowserWindow.close(); -// } -// -// @Override -// public void onSuccess(GeoNaItemRef result) { -// String theURL = result.getRestrictedLink().getShortURL() != null -// ? result.getRestrictedLink().getShortURL() -// : result.getRestrictedLink().getCompleteURL(); -// newBrowserWindow.setUrl(theURL); -// modal.hide(); -// } -// }); -// -// modal.show(); -// -// break; -// -// case VIEW_REPORT: -// -// final Modal modal2 = new Modal(true, true); -// modal2.setTitle( -// "Report: " -// + concessione.getNome() + ""); -// modal2.setWidth(800); -// modal2.setCloseVisible(true); -// if (concessione.getValidationReport() == null) { -// modal2.add(new HTML("No report available for: " + concessione.getNome())); -// } else { -// BuildValidationReport buildValidationReport = new BuildValidationReport( -// concessione.getValidationReport()); -// modal2.add(buildValidationReport); -// } -// modal2.show(); -// -// break; -// // case EDIT_PROJECT: // final Modal modal3 = new Modal(true, true); // modal3.setTitle( @@ -1036,11 +1053,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { // modal3.add(emr); // modal3.show(); // break; -// -//// case UPDATED_PROJECT: -//// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, -//// mainTabPanel.getCurrentSortFilter())); -//// break; + +// case UPDATED_PROJECT: +// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, +// mainTabPanel.getCurrentSortFilter())); +// break; // case DELETE_PROJECT: // // String htmlMsg = "Going to delete the project with:"; @@ -1098,11 +1115,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { // modal.show(); // } // }); -// -// default: -// break; -// } -// + + default: + break; + } } @@ -1153,7 +1169,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, - ConcessioneDV concessione) { + String creatorUsername) { boolean writeAnyAPassed = false; boolean writeOwnPassed = false; @@ -1166,11 +1182,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { // Case EDITOR // Going to check if the user can RW the record is owner of. if (userRole.isWriteOwn()) { - String ownerUser = concessione.getCreationUser(); + String ownerUser = creatorUsername; if (ownerUser == null || ownerUser.isEmpty()) { writeOwnPassed = false; } else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) { - // if my username is equal the owner of the concessione + // if my username is equal the owner of the project writeOwnPassed = true; } } 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 523a414..3ea5c68 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,6 +5,7 @@ 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.project.LifecycleInformationDV; 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; @@ -136,4 +137,14 @@ public interface GeoportalDataEntryService extends RemoteService { */ List getListUseCaseDescriptors(List handlersIds) throws Exception; + /** + * Gets the lifecycle info for project id. + * + * @param profileID the profile ID + * @param projectID the project ID + * @return the lifecycle info for project id + * @throws Exception the exception + */ + LifecycleInformationDV getLifecycleInfoForProjectId(String profileID, String projectID) 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 f207a93..62c4c7f 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,6 +5,7 @@ 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.project.LifecycleInformationDV; 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; @@ -67,4 +68,7 @@ public interface GeoportalDataEntryServiceAsync { void getListUseCaseDescriptors(List handlersIds, AsyncCallback> callback); + void getLifecycleInfoForProjectId(String profileID, String projectID, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index 6ef2160..4d7152a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -19,7 +19,6 @@ public class ActionOnItemEvent extends GwtEvent TYPE = new Type(); private List selectItems; private ACTION_ON_ITEM action; - private String profileID; /** * Instantiates a new action on item event. @@ -28,10 +27,9 @@ public class ActionOnItemEvent extends GwtEvent selectItems, ACTION_ON_ITEM doAction, String profileID) { + public ActionOnItemEvent(List selectItems, ACTION_ON_ITEM doAction) { this.selectItems = selectItems; this.action = doAction; - this.profileID = profileID; } /** @@ -84,10 +82,6 @@ public class ActionOnItemEvent extends GwtEvent extends GwtEvent listConcessioni = null; + List listDocuments = null; if (grpw != null && grpw.getSelectItems() != null) { - listConcessioni = grpw.getSelectItems(); + listDocuments = grpw.getSelectItems(); } - Window.alert("ACTION_ON_ITEM.VIEW_REPORT must be implemented"); - /* - * appManagerBus .fireEvent(new - * ActionOnItemEvent(listConcessioni, - * ACTION_ON_ITEM.VIEW_REPORT)); - */ + appManagerBus + .fireEvent(new ActionOnItemEvent(listDocuments, ACTION_ON_ITEM.VIEW_REPORT)); + } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java deleted file mode 100644 index 1b68850..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.gcube.portlets.user.geoportaldataentry.client.ui.report; - -import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; -import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; - -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HTML; - -/** - * The Class BuildValidationReport. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 14, 2021 - */ -public class BuildValidationReport extends FlowPanel { - private HTML recordPublished = new HTML(); - private ReportTemplateToHTML rTToHTML; - - /** - * Instantiates a new builds the validation report. - * - * @param validationReport the validation report - */ - public BuildValidationReport(ValidationReportDV validationReport) { - - if(validationReport==null) - return; - - ValidationStatus status = validationReport.getStatus(); - switch (status) { - case PASSED: - String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); - recordPublished.setHTML("Record Published with " + success); - break; - case WARNING: - String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); - recordPublished.setHTML("Record Published with " + warning); - - break; - case ERROR: - String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR"); - recordPublished.setHTML(error + " on publishing the Record"); - break; - default: - break; - } - - rTToHTML = new ReportTemplateToHTML(validationReport.getAsJSONString(), true); - - add(recordPublished); - add(rTToHTML); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java new file mode 100644 index 0000000..90baec1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/LifecycleInformationPanel.java @@ -0,0 +1,134 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.report; + +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV; +import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; + +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.HorizontalPanel; + +/** + * The Class LifecycleInformationPanel. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 1, 2022 + */ +public class LifecycleInformationPanel extends FlowPanel { + + /** + * Instantiates a new lifecycle information panel. + * + * @param projectID the project ID + * @param profileID the profile ID + * @param projectAsJSON the project as JSON + * @param lcDV the lc DV + * @param showGoToProject the show go to project + */ + public LifecycleInformationPanel(String projectID, String profileID, String projectAsJSON, + LifecycleInformationDV lcDV, boolean showGoToProject) { + + add(new HTML("Project id: " + (projectID))); + + HTML htmlPhase = new HTML(); + htmlPhase.setHTML("Current phase: " + lcDV.getPhase() + ""); + + HTML htmlStep = new HTML(); + htmlStep.setHTML("Last invoked step: " + lcDV.getLastInvokedStep() + ""); + + HTML lastOperationStatus = new HTML(); + String lastOperationMsg = "Last operation status: "; + switch (lcDV.getLastOperationStatus()) { + case OK: { + lastOperationMsg += HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, + lcDV.getLastOperationStatus().toString()); + break; + } + case WARNING: { + lastOperationMsg += HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, + lcDV.getLastOperationStatus().toString()); + break; + } + case ERROR: { + lastOperationMsg += HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + lcDV.getLastOperationStatus().toString()); + break; + } + default: + lastOperationMsg += HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + lcDV.getLastOperationStatus().toString()); + break; + } + lastOperationStatus.setHTML(lastOperationMsg); + +// switch (lcDV.getLastOperationStatus()) { +// case OK: { +// String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); +// String msg = lcDV.getLastInvokedStep() + " terminated with: " + success; +// lastOperationStatus.setHTML(msg); +// break; +// } +// case WARNING: { +// String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); +// String msg = lcDV.getLastInvokedStep() + " terminated with: " + warning; +// lastOperationStatus.setHTML(msg); +// break; +// } +// case ERROR: { +// String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR"); +// String msg = lcDV.getLastInvokedStep() + " terminated with: " + error; +// lastOperationStatus.setHTML(msg); +// break; +// } +// default: +// break; +// } + + add(htmlPhase); + add(htmlStep); + add(lastOperationStatus); + + HTML htmlEvent = new HTML(); + htmlEvent.setHTML("Last event step: " + lcDV.getLastEvent() + ""); + + if (showGoToProject) { + final HorizontalPanel hpGetLink = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Get link..."); + hpGetLink.add(lc); + add(hpGetLink); + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(projectID, profileID, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + hpGetLink.clear(); + + } + + @Override + public void onSuccess(GeoNaItemRef result) { + hpGetLink.clear(); + String theURL = result.getRestrictedLink().getShortURL() != null + ? result.getRestrictedLink().getShortURL() + : result.getRestrictedLink().getCompleteURL(); + String htmlLink = "
Go to project on Map: " + + theURL + "
"; + HTML html = new HTML(htmlLink); + hpGetLink.add(html); + // modal.add(html); + } + }); + } + + if (projectAsJSON != null) + add(new ReportTemplateToHTML("Project", projectAsJSON, false)); + if (lcDV.getAsJSONString() != null) + add(new ReportTemplateToHTML("Lifecycle Report", lcDV.getAsJSONString(), false)); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java index 329f95c..122be3a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.report; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ExternalLib; import com.github.gwtbootstrap.client.ui.AccordionGroup; +import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.event.HiddenEvent; @@ -47,57 +48,63 @@ public class ReportTemplateToHTML extends Composite { @UiField VerticalPanel htmlContainer; - + @UiField AccordionGroup showReportAsJSON; @UiField Paragraph reportJSON; + @UiField + Label labelToReport; + boolean toJSONERROR = false; /** * Instantiates a new report template to HTML. * - * @param reportAsJSON the report as JSON + * @param documentLabel the document label + * @param theJSONDocument the the JSON document + * @param openJSONReport the open JSON report */ - public ReportTemplateToHTML(String reportAsJSON, boolean openJSONReport) { + public ReportTemplateToHTML(String documentLabel, String theJSONDocument, boolean openJSONReport) { initWidget(uiBinder.createAndBindUi(this)); vpContainer.setVisible(false); showReportAsJSON.setDefaultOpen(openJSONReport); - //showReportAsJSON.setIconPosition(IconPosition.RIGHT); - - if(openJSONReport) { + documentLabel = documentLabel == null ? "Document" : documentLabel; + labelToReport.setText(documentLabel); + // showReportAsJSON.setIconPosition(IconPosition.RIGHT); + + if (openJSONReport) { showReportAsJSON.setIcon(IconType.ARROW_DOWN); - }else { + } else { showReportAsJSON.setIcon(IconType.ARROW_RIGHT); } - + showReportAsJSON.addShowHandler(new ShowHandler() { - + @Override public void onShow(ShowEvent showEvent) { showReportAsJSON.setIcon(IconType.ARROW_DOWN); - + } }); - + showReportAsJSON.addHiddenHandler(new HiddenHandler() { - + @Override public void onHidden(HiddenEvent hiddenEvent) { showReportAsJSON.setIcon(IconType.ARROW_RIGHT); - + } }); - - - if (reportAsJSON != null) { - GWT.log("report is: " + reportAsJSON); + + if (theJSONDocument != null) { + GWT.log("report is: " + theJSONDocument); vpContainer.setVisible(true); try { - JSONValue jsonObj = JSONParser.parse(reportAsJSON); + JSONValue jsonObj = JSONParser.parse(theJSONDocument); JSONObject json = (JSONObject) jsonObj; JSONValue valueChildren = json.get("children"); JSONArray jsonChildren = (JSONArray) valueChildren; @@ -119,7 +126,7 @@ public class ReportTemplateToHTML extends Composite { e.printStackTrace(); GWT.log("error: " + e.getMessage()); } - reportJSON.add(new HTML("
" + ExternalLib.toPrettyPrintJSON(reportAsJSON) + "
")); + reportJSON.add(new HTML("
" + ExternalLib.toPrettyPrintJSON(theJSONDocument) + "
")); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml index 572b030..30e0217 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml @@ -14,10 +14,10 @@ - Publication Report: + Report: - + 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 a7a274c..3ce34c6 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 @@ -157,7 +157,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen try { LifecycleInformation lifecycleInfo = theProject.getLifecycleInformation(); LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lifecycleInfo); - return new CommitReport(theProject.getId(), liDV); + + return new CommitReport(theProject.getId(), theProject.getProfileID(), theProject.getTheDocument().toJson(), + liDV); } catch (Exception e) { throw new Exception("Error occurred on loading LifecycleInformation for the project: " + theProject.getId() + ". Error: " + e.getMessage()); @@ -400,9 +402,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen List toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects); searchedData.setData(toReturnList); - - // TODO BUGGY WORKAROUND. BLOCKED BY #22487 IT MUST BE REMOVE AFTER THE QUERY COUNT + // TODO BUGGY WORKAROUND. BLOCKED BY #22487 IT MUST BE REMOVE AFTER THE QUERY + // COUNT // AND LIST.SIZE BY QUERY WILL BE AVAILABLE IN THE SERVICE if (filter.getConditions() != null) { searchedData.setTotalItems(toReturnList.size()); @@ -745,7 +747,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // DEV MODE if (!SessionUtil.isIntoPortal()) { LOG.warn("OUT OF PORTAL - DEV MODE detected"); - GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR; + GcubeUserRole myRole = GcubeUserRole.DATA_MANAGER; for (RoleRights roleRight : listUserRightsForRole) { if (roleRight.getUserRole().equals(myRole)) { @@ -945,4 +947,24 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen throw new Exception("An error occurred when getting list of Use Case Descriptors", e); } } + + @Override + public LifecycleInformationDV getLifecycleInfoForProjectId(String profileID, String projectID) throws Exception { + LOG.info("getLifecycleInfoForProjectId called for profileID {}, projectID {} " + profileID, projectID); + + ProjectsCaller client = GeoportalClientCaller.projects(); + SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + try { + + Project project = client.getProjectByID(profileID, projectID); + return ConvertToDataValueObjectModel.toLifecycleInformationDV(project.getLifecycleInformation()); + + } catch (Exception e) { + String error = "Error on retrieving the LifecycleInfo for profileID " + profileID + " and projectID " + + projectID; + LOG.error(error, e); + throw new Exception(error + ". Refresh and try again or contact the support"); + } + + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 6022964..236bbdd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -19,6 +19,8 @@ public class CommitReport implements Serializable { private static final long serialVersionUID = -3606902201347318287L; public String projectID; private LifecycleInformationDV lifecycleInformation; + private String profileID; + private String projectAsJSON; /** * Instantiates a new commit report. @@ -27,8 +29,11 @@ public class CommitReport implements Serializable { } - public CommitReport(String projectID, LifecycleInformationDV lifecycleInfo) { + public CommitReport(String projectID, String profileID, String projectAsJSON, + LifecycleInformationDV lifecycleInfo) { this.projectID = projectID; + this.profileID = profileID; + this.projectAsJSON = projectAsJSON; this.lifecycleInformation = lifecycleInfo; } @@ -41,12 +46,29 @@ public class CommitReport implements Serializable { } public void setProjectID(String projectID) { + this.projectID = projectID; } public void setLifecycleInformation(LifecycleInformationDV lifecycleInformation) { this.lifecycleInformation = lifecycleInformation; } + public String getProfileID() { + return profileID; + } + + public void setProfileID(String profileID) { + this.profileID = profileID; + } + + public String getProjectAsJSON() { + return projectAsJSON; + } + + public void setProjectAsJSON(String projectAsJSON) { + this.projectAsJSON = projectAsJSON; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -54,6 +76,10 @@ public class CommitReport implements Serializable { builder.append(projectID); builder.append(", lifecycleInformation="); builder.append(lifecycleInformation); + builder.append(", profileID="); + builder.append(profileID); + builder.append(", projectAsJSON="); + builder.append(projectAsJSON); builder.append("]"); return builder.toString(); }