Integrated with the geoportal-data-mapper library

This commit is contained in:
Francesco Mangiacrapa 2022-12-07 09:43:48 +01:00
parent 95264c261e
commit 240ac0a74b
11 changed files with 307 additions and 66 deletions

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -72,7 +75,10 @@
<wb-module deploy-name="geoportal-data-entry-app-3.1.0-SNAPSHOT">
@ -145,7 +151,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -218,7 +227,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -291,7 +303,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -316,10 +331,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -392,7 +407,10 @@
<property name="context-root" value="geoportal-data-entry-app"/>
@ -465,7 +483,10 @@
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
@ -538,7 +559,10 @@
</wb-module>

View File

@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v3.1.0-SNAPSHOT] - 2022-11-30
- [#24166] Implemented the Update facility
- [#24244] Integrated with the geoportal-data-mapper library
## [v3.0.0] - 2022-11-09

24
pom.xml
View File

@ -68,22 +68,6 @@
<scope>provided</scope>
</dependency>
<!-- needed to compile with gwt > 2.7 -->
<!-- <dependency> -->
<!-- <groupId>xml-apis</groupId> -->
<!-- <artifactId>xml-apis</artifactId> -->
<!-- <version>1.4.01</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- ASM required for GWT 2.9 -->
<!-- <dependency> -->
<!-- <groupId>org.ow2.asm</groupId> -->
<!-- <artifactId>asm</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- <version>7.1</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
@ -107,6 +91,14 @@
<artifactId>gwt-bootstrap</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-mapper</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>

View File

@ -13,9 +13,13 @@
<inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<inherits name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<inherits
name='org.gcube.application.geoportaldatamapper.GeoportalDataMapper' />
<inherits
name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->

View File

@ -50,7 +50,7 @@ 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.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;
@ -1481,8 +1481,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal3.setCloseVisible(true);
((Element) modal3.getElement().getChildNodes().getItem(1))
.addClassName("modal-body-custom");
EditModeRecord emr = new EditModeRecord(appManagerBus, resultDocumentDV);
modal3.add(emr);
//EditModeRecord emr = new EditModeRecord(appManagerBus, resultDocumentDV);
UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(), resultDocumentDV.getId());
modal3.add(ur);
modal3.show();
break;
}

View File

@ -12,6 +12,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.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@ -31,6 +32,15 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("geoportaldataentryservice")
public interface GeoportalDataEntryService extends RemoteService {
/**
* Save geona data forms.
*
* @param profileID the profile ID
* @param tree_Node the tree node
* @param stepsOnPostCreation the steps on post creation
* @return the commit report
* @throws Exception the exception
*/
CommitReport saveGeonaDataForms(String profileID, Tree_Node<GeoNaFormDataObject> tree_Node,
List<String> stepsOnPostCreation) throws Exception;
@ -184,7 +194,7 @@ public interface GeoportalDataEntryService extends RemoteService {
* @param id the id
* @param toProfileID the to profile ID
* @param toProjectID the to project ID
* @return
* @return the result document DV
* @throws Exception the exception
*/
ResultDocumentDV deleteRelationship(String fromProfileID, String fromProjectID, String id, String toProfileID,
@ -199,4 +209,14 @@ public interface GeoportalDataEntryService extends RemoteService {
*/
TemporalReferenceDV temporalReferenceForProject(String profileID, String projectID);
/**
* Gets the project edit.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project edit
* @throws Exception the exception
*/
ProjectEdit getProjectEdit(String profileID, String projectID) throws Exception;
}

View File

@ -12,6 +12,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.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
@ -88,4 +89,6 @@ public interface GeoportalDataEntryServiceAsync {
void temporalReferenceForProject(String profileID, String projectID, AsyncCallback<TemporalReferenceDV> callback);
void getProjectEdit(String profileID, String projectID, AsyncCallback<ProjectEdit> callback);
}

View File

@ -0,0 +1,112 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
import java.util.List;
import org.gcube.application.geoportaldatamapper.shared.MetaDataProfileBeanExt;
import org.gcube.application.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class UpdateRecord extends Composite {
private static UpdateRecordUiBinder uiBinder = GWT.create(UpdateRecordUiBinder.class);
interface UpdateRecordUiBinder extends UiBinder<Widget, UpdateRecord> {
}
@UiField
ListBox listBoxSections;
@UiField
HTMLPanel htmlSectionContent;
@UiField
HTMLPanel alertHTMLPanel;
@UiField
ControlGroup controlsControlGroup;
private LoaderIcon loaderProjectSections = new LoaderIcon("Loading Project sections..., please wait");
public UpdateRecord(HandlerManager editorManagerBus, String profileID, String projectID) {
initWidget(uiBinder.createAndBindUi(this));
alertHTMLPanel.add(loaderProjectSections);
GeoportalDataEntryServiceAsync.Util.getInstance().getProjectEdit(profileID, projectID,
new AsyncCallback<ProjectEdit>() {
@Override
public void onSuccess(ProjectEdit result) {
try {
alertHTMLPanel.remove(loaderProjectSections);
} catch (Exception e) {
}
for (final MetaDataProfileBeanExt profileBean : result.getTheProfileBeans()) {
listBoxSections.addItem(profileBean.getType(), profileBean.getType());
listBoxSections.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
controlsControlGroup.setVisible(true);
htmlSectionContent.clear();
List<MetadataFieldWrapper> listMeta = profileBean.getMetadataFields();
if (listMeta != null && listMeta.size() > 0) {
MetadataFieldWrapper firstMeta = listMeta.get(0);
FlowPanel fp = new FlowPanel();
fp.add(new HTML(firstMeta.getFieldName()));
fp.add(new HTML(firstMeta.getCurrentValue()));
htmlSectionContent.add(fp);
}
}
});
}
}
@Override
public void onFailure(Throwable caught) {
alertHTMLPanel.remove(loaderProjectSections);
String errorMsg = caught.getMessage();
Alert alert = new Alert(errorMsg, AlertType.ERROR);
alert.setClose(false);
try {
alertHTMLPanel.remove(loaderProjectSections);
} catch (Exception e) {
}
alertHTMLPanel.add(alert);
Window.alert(errorMsg);
}
});
}
}

View File

@ -0,0 +1,50 @@
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.button-save-style {
margin-top: 10px;
float: right;
}
.max-height-500 {
max-height: 450px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="alertHTMLPanel">
</g:HTMLPanel>
<g:ScrollPanel>
<b:Form type="INLINE">
<b:Fieldset addStyleNames="form-fieldset-edit">
<b:ControlGroup>
<b:ControlLabel>Select the section of the document you want to update...</b:ControlLabel>
<b:Controls>
<b:ListBox ui:field="listBoxSections"></b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="controlsControlGroup"
visible="false">
<b:ControlLabel>Manage the content of</b:ControlLabel>
<b:Controls>
<g:HTMLPanel ui:field="htmlSectionContent"></g:HTMLPanel>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<g:ScrollPanel>
<g:HTMLPanel ui:field="uploadFileContainer"
addStyleNames="upload-file-container"></g:HTMLPanel>
</g:ScrollPanel>
</b:ControlGroup>
</b:Fieldset>
</b:Form>
</g:ScrollPanel>
<b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}" ui:field="buttonUpdate"
visible="false">UPDATE</b:Button>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -53,6 +53,8 @@ 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.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.application.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.common.portal.PortalContext;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
@ -521,26 +523,26 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
searchedData.setTotalItems(totalProjectForProfile);
LOG.info("Total Docs read from config: " + totalProjectForProfile);
// Saving client PROJECTION
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
int totalItems = totalProjectForProfile;
//PERFORMING FIRST QUERY FOR IDS IF AND ONLY IF WHERE CONDITIONS IN THE QUERY.
//SEARCHING FACILITY IS ENACTING.
if(filter.getConditions()!=null) {
// PERFORMING FIRST QUERY FOR IDS IF AND ONLY IF WHERE CONDITIONS IN THE QUERY.
// SEARCHING FACILITY IS ENACTING.
if (filter.getConditions() != null) {
// Setting PROJECTION ONLY FOR PROEJCT ID
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
projectionForIDs.put(Project.ID, 1);
filter.setProjection(projectionForIDs);
// FIRST QUERY TO RETRIEVE IDs
// LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
//Calculating always the size starting from 0
// Calculating always the size starting from 0
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
filter);
//Getting the Project IDs from the Iterable
// Getting the Project IDs from the Iterable
Iterable<Project> itP = () -> projectsIDs;
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
@ -548,13 +550,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
searchedData.setTotalItems(totalItems);
LOG.info("Total Docs read from query per ID: " + totalItems);
}
//NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
// NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
// SETTING ORIGINAL PROJECTION FROM CLIENT
filter.setProjection(originalProjection);
// LIMIT IS FROM CLIENT
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
filter);
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
searchedData.setClientStartIndex(start);
searchedData.setLimit(limit);
@ -562,9 +563,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
searchedData.setData(toReturnList);
LOG.info("Total Docs page size returned:" + toReturnList.size() + ", start: " + start + ", limit: " + limit);
LOG.info(
"Total Docs page size returned:" + toReturnList.size() + ", start: " + start + ", limit: " + limit);
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
int newOffset = start + limit;
@ -1129,6 +1131,36 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
return null;
}
@Override
public ProjectEdit getProjectEdit(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);
ProjectEdit projectEdit = Geoportal_JSON_Mapper.loadProjectEdit(theProjectDV, scope, user.getUsername());
if (LOG.isDebugEnabled()) {
Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectEdit);
}
LOG.info("getProjectEdit returing not null: " + (projectEdit != null));
return projectEdit;
} catch (Exception e) {
String erroMsg = "Error occurred on reading ProjectEdit DTO for id: " + projectID;
LOG.warn(erroMsg, e);
throw new Exception(
erroMsg + ". Error: " + e.getMessage() + ". Refresh and try again or contact the support");
}
}
/**
* Pretty print client data entry map.
*

View File

@ -12,28 +12,27 @@
<inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<inherits
name='org.gcube.application.geoportaldatamapper.GeoportalDataMapper' />
<inherits
name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<inherits name='org.gcube.application.geoportalcommon.GeoportalDataCommon' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name='org.gcube.portlets.widgets.mpformbuilder.MetadataProfileFormBuilder' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' />
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>