From 660b2606cca6b9c02c624ede88251e947f71009b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 30 Nov 2020 13:01:50 +0100 Subject: [PATCH] task 20210 done. Moved to 'geoportal-client' --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 3 - CHANGELOG.md | 7 ++ pom.xml | 25 +++++- .../server/ConvertToServiceModel.java | 18 ++--- .../server/GeoportalDataEntryServiceImpl.java | 76 +++++++++---------- .../shared/CommitReport.java | 60 ++++++++++----- 8 files changed, 118 insertions(+), 79 deletions(-) diff --git a/.classpath b/.classpath index d34fd2d..57d6904 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index c875387..19fd48b 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.1-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.2-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index a54565a..a6e9c94 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a6da95..98d7701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.0.3-SNAPSHOT] - 2020-11-30 + +#### Enhancements + +[#20210] Updating required for data entry facility after the first feedback by domain experts + + ## [v1.0.2-SNAPSHOT] - 2020-11-09 #### Bug fixes diff --git a/pom.xml b/pom.xml index f342e6a..8130526 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 1.0.2-SNAPSHOT + 1.0.3-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project @@ -115,15 +115,32 @@ compile + + + + + + + + + + + + + org.gcube.application - geoportal-logic + geoportal-client [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) compile - javax.servlet - servlet-api + org.gcube.resources.discovery + ic-client + + + org.gcube.resources.discovery + discovery-client diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java index e3784e7..dd2e4ab 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ConvertToServiceModel.java @@ -8,11 +8,11 @@ import java.util.Date; import java.util.List; import java.util.Map; -import org.gcube.application.geoportal.model.AccessPolicy; -import org.gcube.application.geoportal.model.concessioni.Concessione; -import org.gcube.application.geoportal.model.concessioni.LayerConcessione; -import org.gcube.application.geoportal.model.concessioni.RelazioneScavo; -import org.gcube.application.geoportal.model.content.UploadedImage; +import org.gcube.application.geoportal.common.model.legacy.AccessPolicy; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; +import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; +import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.vomanagement.usermanagement.model.GCubeUser; @@ -140,13 +140,13 @@ public class ConvertToServiceModel { } List titolareCopyrightLst = mapFields.get("Titolare Copyright"); - if(titolareCopyrightLst!=null && titolareCopyrightLst.size()>0){ - concessione.setTitolareCopyright(titolareCopyrightLst.get(0)); + if(titolareCopyrightLst!=null){ + concessione.setTitolareCopyright(titolareCopyrightLst); } List titolareLicenzaLst = mapFields.get("Titolare Licenza"); - if(titolareLicenzaLst!=null && titolareLicenzaLst.size()>0){ - concessione.setTitolareLicenza(titolareLicenzaLst.get(0)); + if(titolareLicenzaLst!=null){ + concessione.setTitolareLicenza(titolareLicenzaLst); } List titolareDatiLst = mapFields.get("Titolare dei dati"); 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 2fe26b8..2a1e4b1 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 @@ -6,17 +6,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.gcube.application.geoportal.managers.ConcessioneManager; -import org.gcube.application.geoportal.managers.ManagerFactory; -import org.gcube.application.geoportal.model.InputStreamDescriptor; -import org.gcube.application.geoportal.model.concessioni.Concessione; -import org.gcube.application.geoportal.model.concessioni.LayerConcessione; -import org.gcube.application.geoportal.model.concessioni.RelazioneScavo; -import org.gcube.application.geoportal.model.content.UploadedImage; -import org.gcube.application.geoportal.model.content.WorkspaceContent; -import org.gcube.application.geoportal.model.fault.PublishException; -import org.gcube.application.geoportal.model.fault.ValidationException; -import org.gcube.application.geoportal.utils.Serialization; +import javax.validation.ValidationException; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManager; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.model.legacy.InputStreamDescriptor; +import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; +import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; +import org.gcube.application.geoportal.common.model.legacy.UploadedImage; +import org.gcube.application.geoportal.common.model.legacy.report.PublicationReport; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; @@ -66,7 +64,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); - ConcessioneManager manager; + ConcessioniManager manager = new ConcessioniManager(); + Concessione concessione = null; + boolean registered = false; try { //Saving Data @@ -79,11 +79,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GenericDatasetBean idp = listGDB.get(0); LOG.debug("\n\n"); LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" building with client obj: "+idp); - Concessione concessione = ConvertToServiceModel.toConcessione(idp, user); + concessione = ConvertToServiceModel.toConcessione(idp, user); LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione); //saving into back-end - manager = ManagerFactory.registerNew(concessione); + concessione = manager.registerNew(concessione); + registered = true; //RELAZIONE_DI_SCAVO list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); @@ -160,7 +161,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); //saving into back-end - manager.addPiantaFineScavo(layerPfs, isd); + manager.addPiantaScavo(layerPfs, isd); } }catch (Exception e) { LOG.error("Error on converting form data: ",e); @@ -169,36 +170,31 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen try { - //If true -> data are published into the SDI - Boolean publish=true; - Concessione registered=manager.commit(publish); - LOG.info("Registered: "+registered); - String link = null; - try { - link = ((WorkspaceContent)registered.getRelazioneScavo().getActualContent().get(0)).getLink(); - }catch (Exception e) { - LOG.warn("Not able to check public link ",e); - } - //String link = "toTest"; - CommitReport cRep = new CommitReport(); - cRep.setRecordId(registered.getId()); - if(link!=null) { - cRep.setState(STATE.OK); - cRep.setMsg("Project saved successfully"); - } - else { - cRep.setState(STATE.WARN); - cRep.setMsg("Project saved with errors"); - } + CommitReport cRep = null; + + if(registered) { + PublicationReport report = manager.commitRegistered(); + LOG.info("Registered: "+report); + + cRep = new CommitReport(); + cRep.setRecordId(report.getTheRecord().getId()); + cRep.setReport(report.toString()); + if(report.getTheRecord()!=null ) { + cRep.setState(STATE.OK); + cRep.setMsg("Project saved successfully"); + } + else { + cRep.setState(STATE.ERROR); + cRep.setMsg("Project not saved correctly"); + } + }else + throw new Exception("Sorry, the record has not been registred correclty. Try again"); return cRep; }catch (ValidationException e1){ LOG.error("Error on validating data: ",e1); - throw new Exception("Error on validating data: "+Serialization.prettyPrint(e1.getReport())); - }catch (PublishException e2) { - LOG.error("Error on publishing data: ",e2); - throw new Exception("Error on publishing data: "+e2.getMessage()); + throw new Exception("Error on validating data: ", e1); }catch (Exception e) { LOG.error("Error on commiting data: ",e); throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 63afb7f..38ecc7d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -8,53 +8,54 @@ import java.io.Serializable; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 21, 2020 + * Nov 30, 2020 */ -public class CommitReport implements Serializable{ - - +public class CommitReport implements Serializable { + /** * */ private static final long serialVersionUID = -9519707669761939L; - /** * The Enum STATE. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 21, 2020 + * Oct 21, 2020 */ - public enum STATE{ERROR, WARN, OK, UNKNOWN} - + public enum STATE { + ERROR, WARN, OK, UNKNOWN + } + public STATE state = STATE.UNKNOWN; public long recordId; public String msg; + public String report; /** * Instantiates a new commit report. */ public CommitReport() { - + } - + /** * Instantiates a new commit report. * - * @param state the state + * @param state the state * @param recordId the record id - * @param msg the msg + * @param msg the msg + * @param report the report */ - public CommitReport(STATE state, long recordId, String msg) { + public CommitReport(STATE state, long recordId, String msg, String report) { super(); this.state = state; this.recordId = recordId; this.msg = msg; + this.report = report; } - - /** * Gets the state. * @@ -82,6 +83,24 @@ public class CommitReport implements Serializable{ return recordId; } + /** + * Gets the report. + * + * @return the report + */ + public String getReport() { + return report; + } + + /** + * Sets the report. + * + * @param report the new report + */ + public void setReport(String report) { + this.report = report; + } + /** * Sets the record id. * @@ -109,10 +128,10 @@ public class CommitReport implements Serializable{ this.msg = msg; } - - - /* (non-Javadoc) - * @see java.lang.Object#toString() + /** + * To string. + * + * @return the string */ @Override public String toString() { @@ -123,8 +142,11 @@ public class CommitReport implements Serializable{ builder.append(recordId); builder.append(", msg="); builder.append(msg); + builder.append(", report="); + builder.append(report); builder.append("]"); return builder.toString(); } + }