diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index fa00f2b..b85b0bb 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -100,7 +102,9 @@ - + + + @@ -201,7 +205,9 @@ - + + + @@ -302,7 +308,9 @@ - + + + @@ -403,7 +411,9 @@ - + + + @@ -459,7 +469,12 @@ uses - + + uses + + + + @@ -560,7 +575,9 @@ - + + + @@ -661,7 +678,9 @@ - + + + @@ -762,7 +781,9 @@ - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index f26c19a..67eb45a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#24166] Implemented the Update facility - [#24244] Integrated with the geoportal-data-mapper library +- [#25015] Integrated the Geoportal Data-Viewer Widget ## [v3.1.0] - 2023-03-06 diff --git a/pom.xml b/pom.xml index ab15f89..0c974e3 100644 --- a/pom.xml +++ b/pom.xml @@ -92,6 +92,13 @@ compile + + org.gcube.portlets.widgets.gdvw + geoportal-data-viewer-widget + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + compile + + org.gcube.application geoportal-data-mapper diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml index bcdccbb..2611f74 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml @@ -17,6 +17,10 @@ + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index c337ce1..06e5537 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 @@ -26,6 +26,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.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; @@ -43,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; @@ -71,6 +73,8 @@ 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; @@ -875,7 +879,21 @@ 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(); @@ -1532,8 +1550,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // modal3.setWidth(950); // modal3.setHeight("700px"); modal3.setCloseVisible(true); - ((Element) modal3.getElement().getChildNodes().getItem(1)) - .addClassName("modal-body-edit"); + ((Element) modal3.getElement().getChildNodes().getItem(1)).addClassName("modal-body-edit"); int height = Window.getClientHeight() * 70 / 100; int width = Window.getClientWidth() * 70 / 100; @@ -1614,6 +1631,56 @@ public class GeoPortalDataEntryApp implements EntryPoint { break; } + case SHOW_METADATA: { + GWT.log("VIEW SHOW_METADATA 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( + "View Document for Project ID: " + + resultDocumentDV.getId() + ""); + 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() { + + @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 DELETE_PROJECT: { String htmlMsg = "Going to delete the project with:"; @@ -1650,7 +1717,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() @@ -1849,13 +1916,13 @@ public class GeoPortalDataEntryApp implements EntryPoint { } 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)) { + + // In case of UPDATE operation, the fields of kind File will be not mandatory. + if (operation != null && operation.equals(OPERATION.UPDATE)) { List fields = geoNaFormCardModel.getMetadataProfileBean().getMetadataFields(); for (MetadataFieldWrapper metadataFieldWrapper : fields) { - if(metadataFieldWrapper.getMandatory() && metadataFieldWrapper.getType().equals(DataTypeWrapper.File)) { + if (metadataFieldWrapper.getMandatory() + && metadataFieldWrapper.getType().equals(DataTypeWrapper.File)) { metadataFieldWrapper.setMandatory(false); } } @@ -1869,7 +1936,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } else { GWT.log("Instancing CreateMetadataForm with files"); List files = toListFileUploadedRemote(fileset); - GWT.log("files are: "+files); + GWT.log("files are: " + files); baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()), appManagerBus, operation, files); } @@ -1885,16 +1952,17 @@ public class GeoPortalDataEntryApp implements EntryPoint { return null; List fileUploaded = new ArrayList(); - + for (FilesetDV filesetDV : fileset) { - GWT.log("filesetDV fieldName: "+filesetDV.getFilesetFieldName() + " profile: "+filesetDV.getGcubeProfileFieldName()); + 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 + // adding FilePath according to spefic file registred in the UCD FilePath filePath = new FilePath(filesetDV.getGcubeProfileFieldName(), filesetDV.getFilesetFieldName()); fu.setFilePath(filePath); fileUploaded.add(fu); 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 0deb7ec..af4ed14 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 @@ -13,6 +13,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; import org.gcube.application.geoportalcommon.shared.geoportal.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.ProjectEdit; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile; @@ -234,4 +235,6 @@ public interface GeoportalDataEntryService extends RemoteService { CommitReport updateGeportalDataForm(String profileID, String projectID, GeoNaFormDataObject section, String sectionPath, List listFilePaths) throws Exception; + ProjectView getProjectView(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 4ca3553..512434d 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 @@ -13,6 +13,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; import org.gcube.application.geoportalcommon.shared.geoportal.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.ProjectEdit; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile; @@ -95,4 +96,6 @@ public interface GeoportalDataEntryServiceAsync { void getProjectEdit(String profileID, String projectID, AsyncCallback callback); + void getProjectView(String profileID, String projectID, AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 7d7c58a..9fe49f7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -97,6 +97,9 @@ public class GeonaMainTabPanel extends Composite { @UiField Tab tabGetListOfProjects; + + @UiField + NavLink navView; @UiField NavLink navShowOnMap; @@ -243,6 +246,21 @@ public class GeonaMainTabPanel extends Composite { } }); + + navView.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + List listDocuments = null; + if (grpw != null && grpw.getSelectItems() != null) { + listDocuments = grpw.getSelectItems(); + } + + appManagerBus + .fireEvent(new OperationOnItemEvent(listDocuments, OPERATION_ON_ITEM.SHOW_METADATA)); + + } + }); navShowReport.addClickHandler(new ClickHandler() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index ea2d301..0b7402c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -99,6 +99,8 @@ + View Document Show on Map @@ -49,7 +54,18 @@ - UPDATE + + + To update the document: + "Select the Section you wish to update, update the metadata and/or + the + file/s and then confirm by clicking on "Create". + Finally select + "Update". + + UPDATE + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java index 7b878ed..13a0c38 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java @@ -173,7 +173,7 @@ public class ViewRelationshipPanel extends Composite { FlowPanel panelContainer = new FlowPanel(); Button deleteRelation = new Button("", IconType.TRASH); - deleteRelation.setTitle("Delete this releation"); + deleteRelation.setTitle("Delete this relation"); deleteRelation.setType(ButtonType.LINK); deleteRelation.addClickHandler(new ClickHandler() { 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 806b3bd..c7c381d 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 @@ -59,6 +59,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalRe import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; +import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper; import org.gcube.application.geoportaldatamapper.shared.ProjectEdit; import org.gcube.common.portal.PortalContext; @@ -1414,10 +1415,40 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectEdit); } - LOG.info("getProjectEdit returing not null: " + (projectEdit != null)); + LOG.info(ProjectEdit.class.getSimpleName()+" returing not null: " + (projectEdit != null)); return projectEdit; } catch (Exception e) { - String erroMsg = "Error occurred on reading ProjectEdit DTO for id: " + projectID; + String erroMsg = "Error occurred on reading "+ProjectEdit.class.getSimpleName()+" DTO for id: " + projectID; + LOG.warn(erroMsg, e); + throw new Exception( + erroMsg + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support"); + } + } + + @Override + public ProjectView getProjectView(String profileID, String projectID) throws Exception { + LOG.info("getProjectEdit called for profileID: {}, and projectID: {}", profileID, projectID); + try { + PortalContext pContext = PortalContext.getConfiguration(); + GCubeUser user = pContext.getCurrentUser(this.getThreadLocalRequest()); + String scope = SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + + ProjectsCaller clientProjects = GeoportalClientCaller.projects(); + Project theProject = clientProjects.getProjectByID(profileID, projectID); + ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); + projectBuilder.relationships(true); + ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder); + + ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, user.getUsername()); + + if (LOG.isDebugEnabled()) { + Geoportal_JSON_Mapper.prettyPrintProjectView(projectView); + } + + LOG.info(ProjectView.class.getSimpleName()+" returing not null: " + (projectView != null)); + return projectView; + } catch (Exception e) { + String erroMsg = "Error occurred on reading "+ProjectView.class.getSimpleName()+" DTO for id: " + projectID; LOG.warn(erroMsg, e); throw new Exception( erroMsg + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support"); diff --git a/src/main/resources/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml b/src/main/resources/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml index bcdccbb..2611f74 100644 --- a/src/main/resources/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/geoportaldataentry/GeoPortalDataEntryApp.gwt.xml @@ -17,6 +17,10 @@ + + +