#23785 "Publication Report" facility migrated to new client/service

model based on LifecycleInfo
This commit is contained in:
Francesco Mangiacrapa 2022-09-01 12:44:00 +02:00
parent 68b5548718
commit 5b9b776c56
12 changed files with 432 additions and 277 deletions

View File

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

View File

@ -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: <b>" + lcDV.getPhase() + "</b>");
HTML htmlStep = new HTML();
htmlStep.setHTML("Invoked Step: <b>" + lcDV.getLastInvokedStep() + "</b>");
// HTML htmlPhase = new HTML();
// htmlPhase.setHTML("Current phase: <b>" + lcDV.getPhase() + "</b>");
//
// HTML htmlStep = new HTML();
// htmlStep.setHTML("Invoked Step: <b>" + lcDV.getLastInvokedStep() + "</b>");
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<GeoNaItemRef>() {
@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 = "<div>Go to project: <a href=" + theURL
+ " target=\"_blank\">" + theURL + "</a></div>";
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<GeoNaItemRef>() {
*
* @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 =
* "<div>Go to project: <a href=" + theURL + " target=\"_blank\">" + theURL +
* "</a></div>"; 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<ItemFieldDV> 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<GeoNaItemRef>() {
@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(
"<span style='font-size:20px;'>Report for Project: <span style='color:#555; font-size:20px;'>"
+ resultDocumentDV.getId() + "</span></span>");
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<LifecycleInformationDV>() {
@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<GeoNaItemRef>() {
// @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(
// "<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
// + concessione.getNome() + "</span></span>");
// 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;
}
}

View File

@ -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<UseCaseDescriptorDV> getListUseCaseDescriptors(List<String> 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;
}

View File

@ -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<String> handlersIds, AsyncCallback<List<UseCaseDescriptorDV>> callback);
void getLifecycleInfoForProjectId(String profileID, String projectID,
AsyncCallback<LifecycleInformationDV> callback);
}

View File

@ -19,7 +19,6 @@ public class ActionOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionOnIt
public static Type<ActionOnItemEventHandler> TYPE = new Type<ActionOnItemEventHandler>();
private List<T> selectItems;
private ACTION_ON_ITEM action;
private String profileID;
/**
* Instantiates a new action on item event.
@ -28,10 +27,9 @@ public class ActionOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionOnIt
* @param doAction the do action
* @param profileID the profile ID
*/
public ActionOnItemEvent(List<T> selectItems, ACTION_ON_ITEM doAction, String profileID) {
public ActionOnItemEvent(List<T> selectItems, ACTION_ON_ITEM doAction) {
this.selectItems = selectItems;
this.action = doAction;
this.profileID = profileID;
}
/**
@ -84,10 +82,6 @@ public class ActionOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionOnIt
return action;
}
public String getProfileID() {
return profileID;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -95,8 +89,6 @@ public class ActionOnItemEvent<T extends DocumentDV> extends GwtEvent<ActionOnIt
builder.append(selectItems);
builder.append(", action=");
builder.append(action);
builder.append(", profileID=");
builder.append(profileID);
builder.append("]");
return builder.toString();
}

View File

@ -10,6 +10,7 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.config.ACTION_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.config.GcubeProfileDV;
@ -18,6 +19,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA
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.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig;
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
@ -353,17 +355,14 @@ public class GeonaMainTabPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
List<DocumentDV> listConcessioni = null;
List<DocumentDV> 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<ConcessioneDV>(listConcessioni,
* ACTION_ON_ITEM.VIEW_REPORT));
*/
appManagerBus
.fireEvent(new ActionOnItemEvent<DocumentDV>(listDocuments, ACTION_ON_ITEM.VIEW_REPORT));
}
});

View File

@ -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);
}
}

View File

@ -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: <b>" + lcDV.getPhase() + "</b>");
HTML htmlStep = new HTML();
htmlStep.setHTML("Last invoked step: <b>" + lcDV.getLastInvokedStep() + "</b>");
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: <b>" + lcDV.getLastEvent() + "</b>");
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<GeoNaItemRef>() {
@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 = "<div>Go to project on Map: <a href=" + theURL + " target=\"_blank\">"
+ theURL + "</a></div>";
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));
}
}

View File

@ -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("<pre>" + ExternalLib.toPrettyPrintJSON(reportAsJSON) + "</pre>"));
reportJSON.add(new HTML("<pre>" + ExternalLib.toPrettyPrintJSON(theJSONDocument) + "</pre>"));
}
}

View File

@ -14,10 +14,10 @@
<g:HTMLPanel>
<g:VerticalPanel ui:field="vpContainer"
addStyleNames="{style.margin-top-10}">
<b:Label>Publication Report: </b:Label>
<b:Label ui:field="labelToReport">Report: </b:Label>
<g:VerticalPanel ui:field="htmlContainer"
addStyleNames="{style.margin-top-10}"></g:VerticalPanel>
<b:AccordionGroup heading="Show Report as JSON" ui:field="showReportAsJSON">
<b:AccordionGroup heading="Show as JSON" ui:field="showReportAsJSON">
<b:Paragraph ui:field="reportJSON"></b:Paragraph>
</b:AccordionGroup>

View File

@ -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<ResultDocumentDV> 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");
}
}
}

View File

@ -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();
}