Merged manually against the `task_24166` to resolve conflicts

This commit is contained in:
Francesco Mangiacrapa 2023-05-12 10:57:02 +02:00
parent 84a8bdf5d2
commit 4407711fe6
1 changed files with 242 additions and 32 deletions

View File

@ -18,12 +18,16 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.WORKFLOW_PHASE;
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.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
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.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
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;
import org.gcube.application.geoportaldatamapper.shared.MetaDataProfileBeanExt;
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.ClickItemEvent;
@ -40,6 +44,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerform
import org.gcube.portlets.user.geoportaldataentry.client.events.OperationPerformedOnItemEventHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.RelationActionHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.RelationActionHandlerEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.RelationActionHandlerEvent.RELACTION_ACTION_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEvent;
@ -52,6 +57,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginate
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.edit.EditModeRecord;
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.UpdateRecord;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.LifecycleInformationPanel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
@ -68,10 +74,17 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig;
import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node;
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
import org.gcube.portlets.widgets.gdvw.client.GeoportalDataViewerWidget;
import org.gcube.portlets.widgets.gdvw.client.project.ProjectViewer;
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FilePath;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
@ -195,7 +208,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
String errorMsg = "Sorry, an error occurrend when loading configurations. Please, contact the support";
String errorMsg = "Sorry, an error occurred when loading configurations. Please, contact the support";
Alert alert = new Alert(errorMsg, AlertType.ERROR);
alert.setClose(false);
try {
@ -226,7 +239,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support";
Alert alert = new Alert(errorMsg, AlertType.ERROR);
alert.setClose(false);
try {
@ -307,7 +320,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
String errorMsg = "Sorry, an error occurrend on loading configurations. Please, contact the support";
String errorMsg = "Sorry, an error occurred on loading configurations. Please, contact the support";
Alert alert = new Alert(errorMsg, AlertType.ERROR);
alert.setClose(false);
try {
@ -382,8 +395,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
private void createNewDataEntyFor(String profileID, HandlerDeclarationDV handlerDeclarationDV,
List<GcubeProfileDV> listGPs) {
private <T extends MetaDataProfileBean> void createNewDataEntyFor(String profileID,
HandlerDeclarationDV handlerDeclarationDV, List<GcubeProfileDV> listGPs) {
dataEntryProjectCreated = true;
mainTabPanel.setLoaderVisible("Loading...", true);
// orderedCards.clear();
@ -412,10 +425,18 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final int order = i;
GWT.log("calling getProfilesInTheScope for secondaryType: " + gcubeProfile.getGcubeSecondaryType()
+ ", name: " + gcubeProfile.getGcubeName());
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScopeForName(
geoportalISConfigs.getScope(), gcubeProfile.getGcubeSecondaryType(), gcubeProfile.getGcubeName(),
new AsyncCallback<List<MetaDataProfileBean>>() {
@Override
public void onFailure(Throwable caught) {
mainTabPanel.setLoaderVisible("Loading...", false);
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(List<MetaDataProfileBean> result) {
@ -429,7 +450,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
GWT.log("Building form card for type: " + theMetaType);
GeoNaFormCardModel geonaForm = buildNewFormCardModelFromProfile(gcubeProfile, order,
metaDataProfileBean, OPERATION.UPDATE);
metaDataProfileBean, OPERATION.UPDATE, appManagerBus);
treemapOrderedGNAProfiles.put(order, geonaForm);
}
@ -446,12 +467,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
// orderedCards.addAll(new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
buildNewCards(profileID, handlerDeclarationDV.getItemType(), listGNAFormCardModel);
}
}
@Override
public void onFailure(Throwable caught) {
mainTabPanel.setLoaderVisible("Loading...", false);
Window.alert(caught.getMessage());
}
});
@ -608,7 +624,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
savedMap.put(result.getProjectID(), saveGeonaDataFormsEvent.getTreeNode());
LifecycleInformationPanel lip = new LifecycleInformationPanel(result.getProjectID(),
result.getProfileID(), result.getProjectAsJSON(), lcDV, true);
result.getProfileID(), result.getProjectAsJSON(), lcDV, false);
modalContainerPanel.add(lip);
@ -865,6 +881,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
switch (createRelationHE.getRelactionActionType()) {
case DELETE: {
GcubeUserRole myRole = myRights.getRoleRights().getUserRole();
// TODO REMOVE THIS IF AFTER ADDING ALL THE OPERATIONS IN THE IS
// OPERATIONS/RIGHTS CONFIGURATION
if (!myRole.equals(GcubeUserRole.DATA_MANAGER) && !myRole.equals(GcubeUserRole.DATA_EDITOR)) {
String action = RELACTION_ACTION_TYPE.DELETE + " Relation";
String msg = "You are not authorized to perform the action: " + action;
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()),
"Forbidden: " + action, msg, AlertType.WARNING);
modalW.show();
return;
}
if (createRelationHE.getFromProject() == null || createRelationHE.getToProject() == null) {
DialogInform di = new DialogInform(null, "No selection", "You must select a Project");
di.center();
@ -1416,14 +1446,28 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final Modal modal = new Modal(true, true);
modal.setTitle("Show on Map the Project...");
modal.setCloseVisible(true);
if (resultDocumentDV.getLifecycleInfo() != null) {
String phase = resultDocumentDV.getLifecycleInfo().getPhase();
// IF the project is not in DRAFT phase, showing an alert and no Update Mode
// will
// be activated
if (phase != null && phase.compareToIgnoreCase(WORKFLOW_PHASE.DRAFT.getLabel()) == 0) {
Alert alert = new Alert(
ConstantsGeoPortalDataEntryApp.SHOW_ON_MAP_NOT_AVAILABLE_IN_DRAFT);
alert.setType(AlertType.WARNING);
alert.setClose(false);
modal.add(alert);
modal.show();
return;
}
}
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<GeoportalItemReferences>() {
@Override
@ -1514,23 +1558,28 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
case EDIT_PROJECT: {
final Modal modal3 = new Modal(true, true);
modal3.setTitle(
"<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
"<span style='font-size:20px;'>Update Project with id: <span style='color:#555; font-size:20px;'>"
+ resultDocumentDV.getId() + "</span></span>");
modal3.setWidth(950);
modal3.setHeight("700px");
// modal3.setWidth(950);
// modal3.setHeight("700px");
modal3.setCloseVisible(true);
((Element) modal3.getElement().getChildNodes().getItem(1))
.addClassName("modal-body-custom");
((Element) modal3.getElement().getChildNodes().getItem(1)).addClassName("modal-body-edit");
int height = Window.getClientHeight() * 70 / 100;
//#24569
int width = Window.getClientWidth() * 70 / 100;
modal3.setWidth(width);
modal3.setHeight(height + "px");
// #24569
boolean isNotInDRAFT = false;
if (resultDocumentDV.getLifecycleInfo() != null) {
String phase = resultDocumentDV.getLifecycleInfo().getPhase();
// IF the project is not in DRAFT phase, showing an alert and no Update Mode will
// IF the project is not in DRAFT phase, showing an alert and no Update Mode
// will
// be activated
if (phase != null && phase.compareToIgnoreCase(WORKFLOW_PHASE.DRAFT.getLabel()) != 0) {
@ -1544,19 +1593,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
}
EditModeRecord emr = new EditModeRecord(appManagerBus, resultDocumentDV);
modal3.add(emr);
modal3.show();
UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(),
resultDocumentDV.getId(), width, height);
if (isNotInDRAFT) {
emr.noUpdateMode();
ur.noUpdateMode();
}
modal3.add(ur);
modal3.show();
break;
}
case CREATE_RELATION: {
//#24571
// #24571
boolean isNotInDRAFT = false;
if (resultDocumentDV.getLifecycleInfo() != null) {
@ -1573,8 +1623,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
isNotInDRAFT = true;
}
}
//Allowing the Create Relation only in DRAFT phase
// Allowing the Create Relation only in DRAFT phase
if (!isNotInDRAFT) {
mainTabPanel.showCreateRelationPanel(true, resultDocumentDV);
}
@ -1589,6 +1639,79 @@ public class GeoPortalDataEntryApp implements EntryPoint {
break;
}
// It is the show document
case VIEW_PROJECT_AS_DOCUMENT: {
GWT.log("VIEW VIEW_PROJECT_AS_DOCUMENT fired");
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final int height = Window.getClientHeight() * 70 / 100;
int width = Window.getClientWidth() * 70 / 100;
modal.setMaxHeigth("none");
modal.setWidth(width);
modal.setHeight(height + "px");
modal.setTitle(
"<span style='font-size:20px;'>View Document for Project ID: <span style='color:#555; font-size:20px;'>"
+ resultDocumentDV.getId() + "</span></span>");
final HorizontalPanel hp = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Loading Project... please wait");
hp.add(lc);
modal.add(hp);
GeoportalDataEntryServiceAsync.Util.getInstance().getProjectView(
resultDocumentDV.getProfileID(), resultDocumentDV.getProjectID(),
new AsyncCallback<ProjectView>() {
@Override
public void onFailure(Throwable caught) {
hp.clear();
modal.setTitle("Error :-(");
Alert alert = new Alert(
"Sorry, I cannot show the Project with id '"
+ resultDocumentDV.getId()
+ "' Refresh an try again. Error: " + caught.getMessage(),
AlertType.ERROR);
alert.setClose(false);
hp.add(alert);
}
@Override
public void onSuccess(ProjectView result) {
hp.clear();
GeoportalDataViewerWidget wid = new GeoportalDataViewerWidget();
ProjectViewer viewer = wid.getProjectViewer(result);
viewer.setTocContentVisible(true);
viewer.setHeight((height - 80) + "px");
modal.add(viewer);
}
});
modal.show();
break;
}
case VIEW_PROJECT_AS_JSON: {
GWT.log("VIEW VIEW_PROJECT_AS_JSON fired");
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final int height = Window.getClientHeight() * 70 / 100;
int width = Window.getClientWidth() * 70 / 100;
modal.setMaxHeigth("none");
modal.setWidth(width);
modal.setHeight(height + "px");
modal.setTitle(
"<span style='font-size:20px;'>View as JSON for Project ID: <span style='color:#555; font-size:20px;'>"
+ resultDocumentDV.getId() + "</span></span>");
EditModeRecord editMode = new EditModeRecord(appManagerBus, resultDocumentDV, height);
modal.add(editMode);
modal.show();
break;
}
case DELETE_PROJECT: {
String htmlMsg = "Going to delete the project with:";
@ -1625,7 +1748,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
hp.clear();
modal.setTitle("Error");
modal.setTitle("Error :-(");
Alert alert = new Alert(
"Sorry, I cannot delete the Project with id '"
+ resultDocumentDV.getId()
@ -1699,7 +1822,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
NodeItem theRootNode = (NodeItem) root.getWidget();
GeoNaFormCardModel nodeCard = theRootNode.getGeoNaFormCardModel();
GeoNaFormCardModel newNodeFormCard = buildNewFormCardModelFromProfile(nodeCard.getGcubeProfile(), -1,
nodeCard.getMetadataProfileBean(), OPERATION.UPDATE);
nodeCard.getMetadataProfileBean(), OPERATION.UPDATE, appManagerBus);
// create a new node with the same data as the root node
boolean canBeDuplicated = newNodeFormCard.getFormCard().isInternalRepeatibleForm();
@ -1793,4 +1916,91 @@ public class GeoPortalDataEntryApp implements EntryPoint {
});
}
/**
* Builds the new form card model from profile.
*
* @param gcubeProfile the gcube profile
* @param order the order
* @param metaDataProfileBean the meta data profile bean
* @param operation the operation
* @param appManagerBus the app manager bus
* @return the geo na form card model
*/
public static <T extends MetaDataProfileBean> GeoNaFormCardModel buildNewFormCardModelFromProfile(
GcubeProfileDV gcubeProfile, int order, T metaDataProfileBean, OPERATION operation,
HandlerManager appManagerBus) {
// Managing Forms Repeatability
int minOccurs = gcubeProfile.getMinOccurs();
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
int maxOccurs = gcubeProfile.getMaxOccurs();
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
// TODO MUST BE MANAGED MIN_OCCURS
ProjectFormCard cct = new ProjectFormCard(gcubeProfile.getSectionName(), gcubeProfile.getSectionTitle(), order,
maxOccurs > 1, minOccurs, maxOccurs);
List<FilesetDV> fileset = null;
if (metaDataProfileBean instanceof MetaDataProfileBeanExt) {
MetaDataProfileBeanExt metaDataProfileBeanExt = (MetaDataProfileBeanExt) metaDataProfileBean;
fileset = metaDataProfileBeanExt.getListFileset();
}
GeoNaFormCardModel geoNaFormCardModel = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfile);
// In case of UPDATE operation, the fields of kind File will be not mandatory.
if (operation != null && operation.equals(OPERATION.UPDATE)) {
List<MetadataFieldWrapper> fields = geoNaFormCardModel.getMetadataProfileBean().getMetadataFields();
for (MetadataFieldWrapper metadataFieldWrapper : fields) {
if (metadataFieldWrapper.getMandatory()
&& metadataFieldWrapper.getType().equals(DataTypeWrapper.File)) {
metadataFieldWrapper.setMandatory(false);
}
}
}
CreateMetadataForm baseForm = null;
if (fileset == null) {
GWT.log("Instancing CreateMetadataForm without files");
baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()), appManagerBus,
operation);
} else {
GWT.log("Instancing CreateMetadataForm with files");
List<? extends FileUploaded> files = toListFileUploadedRemote(fileset);
GWT.log("files are: " + files);
baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()), appManagerBus,
operation, files);
}
geoNaFormCardModel.setMetadataForm(baseForm);
return geoNaFormCardModel;
}
public static List<? extends FileUploaded> toListFileUploadedRemote(List<FilesetDV> fileset) {
if (fileset == null || fileset.size() == 0)
return null;
List<FileUploadedRemote> fileUploaded = new ArrayList<FileUploadedRemote>();
for (FilesetDV filesetDV : fileset) {
GWT.log("filesetDV fieldName: " + filesetDV.getFilesetFieldName() + " profile: "
+ filesetDV.getGcubeProfileFieldName());
for (PayloadDV payload : filesetDV.getListPayload()) {
FileUploadedRemote fu = new FileUploadedRemote();
fu.setFileName(payload.getName());
fu.setUrl(payload.getLink());
fu.setMimeType(payload.getMimetype());
// adding FilePath according to spefic file registred in the UCD
FilePath filePath = new FilePath(filesetDV.getGcubeProfileFieldName(), filesetDV.getFilesetFieldName());
fu.setFilePath(filePath);
fileUploaded.add(fu);
}
}
return fileUploaded;
}
}