#25015 Integrated the Geoportal Data-Viewer Widget

This commit is contained in:
Francesco Mangiacrapa 2023-04-27 16:39:21 +02:00
parent 5b615a2bd9
commit 9d8c3dbc0a
14 changed files with 205 additions and 27 deletions

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -100,7 +102,9 @@
<wb-module deploy-name="geoportal-data-entry-app-3.2.0-SNAPSHOT">
@ -201,7 +205,9 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -302,7 +308,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -403,7 +411,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -459,7 +469,12 @@
<dependent-module archiveName="geoportal-data-mapper-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="metadata-profile-form-builder-widget-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -560,7 +575,9 @@
<property name="context-root" value="geoportal-data-entry-app"/>
@ -661,7 +678,9 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -762,7 +781,9 @@
</wb-module>

View File

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

View File

@ -92,6 +92,13 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets.gdvw</groupId>
<artifactId>geoportal-data-viewer-widget</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-mapper</artifactId>

View File

@ -17,6 +17,10 @@
<inherits
name='org.gcube.application.geoportaldatamapper.GeoportalDataMapper' />
<inherits
name='org.gcube.portlets.widgets.gdvw.geoportal_data_viewer_widget' />
<inherits
name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />

View File

@ -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(
"<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 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<MetadataFieldWrapper> 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<? extends FileUploaded> 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<FileUploadedRemote> fileUploaded = new ArrayList<FileUploadedRemote>();
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);

View File

@ -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<FilePathDV> listFilePaths) throws Exception;
ProjectView getProjectView(String profileID, String projectID) throws Exception;
}

View File

@ -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<ProjectEdit> callback);
void getProjectView(String profileID, String projectID, AsyncCallback<ProjectView> callback);
}

View File

@ -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<DocumentDV> listDocuments = null;
if (grpw != null && grpw.getSelectItems() != null) {
listDocuments = grpw.getSelectItems();
}
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.SHOW_METADATA));
}
});
navShowReport.addClickHandler(new ClickHandler() {

View File

@ -99,6 +99,8 @@
<g:FlowPanel>
<g:FlowPanel addStyleNames="move-sticky">
<b:NavPills>
<b:NavLink ui:field="navView" title="View Document"
icon="FILE">View Document</b:NavLink>
<b:NavLink ui:field="navShowOnMap" title="Show on Map"
icon="MAP_MARKER">Show on Map</b:NavLink>
<b:NavLink ui:field="navShowReport"

View File

@ -100,7 +100,7 @@ public class UpdateRecord extends Composite {
alertHTMLPanel.add(loaderProjectSections);
scrollSectionContent.setHeight((modalHeight-340)+"px");
scrollSectionContent.setHeight((modalHeight-350)+"px");
listBoxSections.setWidth((modalWidth-50)+"px");

View File

@ -18,6 +18,11 @@
.margin-top-10 {
margin-top: 10px;
}
.info-operation {
font-size: 12px;
color: gray;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="alertHTMLPanel">
@ -49,7 +54,18 @@
</b:Fieldset>
</b:Form>
</g:HTMLPanel>
<b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}" ui:field="buttonUpdate">UPDATE</b:Button>
<g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.info-operation}">
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".
</g:HTMLPanel>
<b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}" ui:field="buttonUpdate">UPDATE</b:Button>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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() {

View File

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

View File

@ -17,6 +17,10 @@
<inherits
name='org.gcube.application.geoportaldatamapper.GeoportalDataMapper' />
<inherits
name='org.gcube.portlets.widgets.gdvw.geoportal_data_viewer_widget' />
<inherits
name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />