From 733042b8bd03cf02da9fa38fbb8d404a19740763 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 4 Nov 2020 11:20:25 +0100 Subject: [PATCH 01/11] moved at 1.0.1-SNAPSHOT --- CHANGELOG.md | 7 +++++++ pom.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7a2c14..d51a196 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.1-SNAPSHOT] - 2020-11-04 + +#### Bug fixes + +[#20063] Fixes for data-entry components + + ## [v1.0.0] - 2020-10-07 [#19916] First release diff --git a/pom.xml b/pom.xml index 35dd044..447df2e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 1.0.0 + 1.0.1-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 -- 2.17.1 From 25abea947395b66ca9e16af03ef47a0e4912d987 Mon Sep 17 00:00:00 2001 From: francescomangiacrapa Date: Fri, 6 Nov 2020 11:27:57 +0100 Subject: [PATCH 02/11] fixed minor issue on submit --- .../client/GeoPortalDataEntryApp.java | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) 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 3d520e9..93aaee5 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 @@ -30,6 +30,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.RootPanel; /** @@ -64,7 +65,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { private LinkedHashMap> savedMap = new LinkedHashMap>(); - //private List orderedListMetadataProfilesForGeona = null; + private boolean projectSavedWithSuccess; /** * This is the entry point method. @@ -119,6 +120,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } private void buildNewCards(Collection orderedCards) { + projectSavedWithSuccess = false; //resetting state of saving mainPanel.setLoaderVisible("Loading...", true); resetUI(); //ordered values @@ -204,14 +206,20 @@ public class GeoPortalDataEntryApp implements EntryPoint { final Modal modal = new Modal(true); modal.setCloseVisible(false); + modal.setTitle("Saving project..."); + modal.hide(false); + final HorizontalPanel modalContainerPanel = new HorizontalPanel(); final LoaderIcon loader = new LoaderIcon(); loader.setText("Trying to save the data, please wait..."); - modal.add(loader); - + modalContainerPanel.add(loader); + modal.add(modalContainerPanel); + GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback() { @Override public void onFailure(Throwable caught) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); try { modal.remove(loader); }catch (Exception e) { @@ -220,7 +228,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { alert.setType(AlertType.ERROR); alert.setClose(false); modal.add(alert); - modal.setCloseVisible(true); //resetUI(); geoNaMainForm.enableButtonSave(true); } @@ -235,6 +242,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { switch (result.getState()) { case OK: alert.setType(AlertType.SUCCESS); + projectSavedWithSuccess = true; purgeFileUploaded(); break; case WARN: @@ -250,7 +258,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } alert.setClose(false); modal.add(alert); - modal.setCloseVisible(true); + try { savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms()); }catch (Exception e) { @@ -274,17 +282,22 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { - //means the form was not submitted - if(savedMap.size()==0) { - boolean confirm = Window.confirm("Creating a new project, the current project (is not saved) and will be lost, Confirm?"); - if(confirm) + // means the form was not submitted + if (savedMap.size() == 0) { + boolean confirm = Window.confirm( + "Creating a new project, the current project (is not saved) and will be lost, Confirm?"); + if (confirm) buildNewCards(orderedCards); - }else { + } else if (projectSavedWithSuccess) { + //means the project has been saved + buildNewCards(orderedCards); + } else { + //means the project reported one ore more errors after the submit boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?"); - if(confirm) + if (confirm) buildNewCards(orderedCards); } - + } }); } -- 2.17.1 From ba9a0e92f0b05d0f21ae26469f56e363c6071d8a Mon Sep 17 00:00:00 2001 From: francescomangiacrapa Date: Fri, 6 Nov 2020 12:09:04 +0100 Subject: [PATCH 03/11] added stylesheet --- .../user/geoportaldataentry/client/ui/card/MetadataFormCard.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java index 8a95a87..ca9d64c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java @@ -205,6 +205,7 @@ public class MetadataFormCard { if(bool) { tab.setIcon(IconType.OK_SIGN); tab.asWidget().getElement().removeClassName("red-text"); + tab.asWidget().getElement().addClassName("green-text"); } else { tab.setIcon(IconType.MINUS_SIGN); -- 2.17.1 From 406bb94f8af6d41bce0a01f5b9717d28c4046949 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 9 Nov 2020 11:12:54 +0100 Subject: [PATCH 04/11] merged with trunk --- .classpath | 2 +- .settings/com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 3 --- .../geoportaldataentry/client/GeoPortalDataEntryApp.java | 6 ++---- .../client/ui/GeonaDataEntryMainForm.java | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.classpath b/.classpath index ce272c8..9de8301 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 3f6f7f3..c875387 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/francesco/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.1-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 4ec8b3e..d895209 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -77,9 +77,6 @@ - - uses - 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 93aaee5..a960a8e 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 @@ -234,10 +234,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onSuccess(CommitReport result) { - try { - modal.remove(loader); - }catch (Exception e) { - } + modalContainerPanel.clear(); + modal.setCloseVisible(true); Alert alert = new Alert(result.getMsg()); switch (result.getState()) { case OK: diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.java index 986f2e9..43427af 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.java @@ -133,7 +133,7 @@ public class GeonaDataEntryMainForm extends Composite { } - private void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile){ + public void showAlertOnSaveAction(String text, AlertType type, boolean hideAfterAWhile){ //Window.alert("Called alertOnCreate"); alertFormAction.setText(text); -- 2.17.1 From 3c3013e37045f50fdd3dcb437ac8a67c6235d4d3 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 9 Nov 2020 11:16:16 +0100 Subject: [PATCH 05/11] meged with TRUNK --- .../user/geoportaldataentry/client/GeoPortalDataEntryApp.java | 1 + 1 file changed, 1 insertion(+) 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 a960a8e..ba49642 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 @@ -241,6 +241,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { case OK: alert.setType(AlertType.SUCCESS); projectSavedWithSuccess = true; + geoNaMainForm.showAlertOnSaveAction(result.getMsg(), AlertType.SUCCESS, true); purgeFileUploaded(); break; case WARN: -- 2.17.1 From 6de99eb7a799965b6bbc7745258318afabb2bab8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 9 Nov 2020 15:44:07 +0100 Subject: [PATCH 06/11] Bug fixes #20092 --- .classpath | 4 +- .settings/org.eclipse.wst.common.component | 136 ++---------------- ....eclipse.wst.common.project.facet.core.xml | 2 +- CHANGELOG.md | 9 +- pom.xml | 2 +- .../client/GeoPortalDataEntryApp.java | 2 +- .../client/ui/card/MetadataFormCard.java | 13 +- 7 files changed, 34 insertions(+), 134 deletions(-) diff --git a/.classpath b/.classpath index 9de8301..d34fd2d 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d895209..a54565a 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,129 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + uses + - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index d5270ce..1727216 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -3,5 +3,5 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index d51a196..8a6da95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ 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.1-SNAPSHOT] - 2020-11-04 +## [v1.0.2-SNAPSHOT] - 2020-11-09 + +#### Bug fixes + +[#20092] Repeatible form: validate the card after the create event is fired + + +## [v1.0.1] - 2020-11-04 #### Bug fixes diff --git a/pom.xml b/pom.xml index 447df2e..f342e6a 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 1.0.1-SNAPSHOT + 1.0.2-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 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 ba49642..3929c42 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 @@ -127,7 +127,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { for (GeoNaFormCardModel geonaForm : orderedCards) { //TODO TO TEST - //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO)){ + //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){ CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus); geonaForm.setMetadataForm(baseForm); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java index ca9d64c..4ce7777 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java @@ -10,6 +10,7 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Tab; import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; @@ -109,7 +110,7 @@ public class MetadataFormCard { this.appManagerBus = appManagerBus; this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm(); this.buildCard(geonaFormModel.getMetadataForm()); - geonaFormModel.getMetadataForm().addListener(formCardEventHandler); + //geonaFormModel.getMetadataForm().addListener(formCardEventHandler); } /** @@ -128,6 +129,7 @@ public class MetadataFormCard { @Override public void onClick(ClickEvent event) { CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus); + //newForm.addListener(formCardEventHandler); addNewForm(newForm); //newForm.getCreateButton().setFocus(true); } @@ -162,6 +164,8 @@ public class MetadataFormCard { } }); } + + newForm.addListener(formCardEventHandler); } /** @@ -190,8 +194,11 @@ public class MetadataFormCard { */ public boolean validateForm() { for (CreateMetadataForm createMetadataForm : listForms) { - if(!createMetadataForm.isFormDataValid()) + boolean isFormDataValid = createMetadataForm.isFormDataValid(); + GWT.log("Is form data valid: "+isFormDataValid); + if(!isFormDataValid) { return false; + } } return true; } @@ -209,6 +216,7 @@ public class MetadataFormCard { } else { tab.setIcon(IconType.MINUS_SIGN); + tab.asWidget().getElement().removeClassName("green-text"); tab.asWidget().getElement().addClassName("red-text"); } @@ -226,6 +234,7 @@ public class MetadataFormCard { } else { tab.setIcon(IconType.MINUS_SIGN); + tab.asWidget().getElement().removeClassName("red-text"); tab.asWidget().getElement().addClassName("red-text"); } } -- 2.17.1 From 660b2606cca6b9c02c624ede88251e947f71009b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 30 Nov 2020 13:01:50 +0100 Subject: [PATCH 07/11] 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(); } + } -- 2.17.1 From 96b71440701adb19c27c00fc844f0c23c793430a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 30 Nov 2020 14:23:31 +0100 Subject: [PATCH 08/11] managed max number of form for section --- pom.xml | 24 -------- .../client/ConcessioniFormCardTitle.java | 60 +++++++++++++++++-- .../client/ui/card/MetadataFormCard.java | 15 ++++- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index 8130526..9ee385e 100644 --- a/pom.xml +++ b/pom.xml @@ -114,35 +114,11 @@ [1.0.0, 2.0.0-SNAPSHOT) compile - - - - - - - - - - - - - - org.gcube.application geoportal-client [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) compile - - - org.gcube.resources.discovery - ic-client - - - org.gcube.resources.discovery - discovery-client - - org.gcube.portlets.user diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java index 7aa8b67..0811bf1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConcessioniFormCardTitle.java @@ -1,40 +1,88 @@ package org.gcube.portlets.user.geoportaldataentry.client; + +/** + * The Enum ConcessioniFormCardTitle. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 30, 2020 + */ public enum ConcessioniFormCardTitle { - INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false), - RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false), - IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true), - POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false), - PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true); + INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false, null), + RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false, null), + IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true, 8), + POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false, null), + PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true, null); private String key; private String title; private Integer order; private boolean internalRepeatibleForm; + private Integer maxFormRepeatability; - private ConcessioniFormCardTitle(String key, String title, int order, boolean internalRepeatibleForm) { + /** + * Instantiates a new concessioni form card title. + * + * @param key the key + * @param title the title + * @param order the order + * @param internalRepeatibleForm the internal repeatible form + * @param maxFormRepeatability the max form repeatability + */ + private ConcessioniFormCardTitle(String key, String title, int order, boolean internalRepeatibleForm, Integer maxFormRepeatability) { this.key = key; this.title = title; this.order = order; this.internalRepeatibleForm = internalRepeatibleForm; + this.maxFormRepeatability = maxFormRepeatability; } + /** + * Gets the key. + * + * @return the key + */ public String getKey() { return key; } + /** + * Gets the title. + * + * @return the title + */ public String getTitle() { return title; } + /** + * Gets the order. + * + * @return the order + */ public Integer getOrder() { return order; } + /** + * Checks if is internal repeatible form. + * + * @return true, if is internal repeatible form + */ public boolean isInternalRepeatibleForm() { return internalRepeatibleForm; } + + /** + * Gets the max form repeatability. + * + * @return the max form repeatability + */ + public Integer getMaxFormRepeatability() { + return maxFormRepeatability; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java index 4ce7777..a8363b9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/card/MetadataFormCard.java @@ -14,6 +14,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.client.Window; /** @@ -45,6 +46,8 @@ public class MetadataFormCard { private HandlerManager appManagerBus; + private Integer maxFormRepeatability; + /** * The Class MetadataFormCardEventHandler. * @@ -109,6 +112,7 @@ public class MetadataFormCard { this.geonaFormModel = geonaFormModel; this.appManagerBus = appManagerBus; this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm(); + this.maxFormRepeatability = geonaFormModel.getFormCardTitle().getMaxFormRepeatability()!=null?geonaFormModel.getFormCardTitle().getMaxFormRepeatability():Integer.MAX_VALUE; this.buildCard(geonaFormModel.getMetadataForm()); //geonaFormModel.getMetadataForm().addListener(formCardEventHandler); } @@ -128,9 +132,14 @@ public class MetadataFormCard { @Override public void onClick(ClickEvent event) { - CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus); - //newForm.addListener(formCardEventHandler); - addNewForm(newForm); + + if(listForms.size() < maxFormRepeatability) { + + CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles(),appManagerBus); + //newForm.addListener(formCardEventHandler); + addNewForm(newForm); + }else + Window.alert("Maximun number of data reached for "+geonaFormModel.getFormCardTitle().getTitle()); //newForm.getCreateButton().setFocus(true); } }); -- 2.17.1 From 1aba0ad5c99323e6d64b77edadd65dfbe2e5266c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 1 Dec 2020 11:58:00 +0100 Subject: [PATCH 09/11] Added "Politica di Acesso" and "ID Licenza" to layers --- CHANGELOG.md | 5 +++-- pom.xml | 2 +- .../server/ConvertToServiceModel.java | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d7701..3c650f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +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 +## [v1.1.0-SNAPSHOT] - 2020-12-1 #### Enhancements [#20210] Updating required for data entry facility after the first feedback by domain experts - + Moved to 'geoportal-client' + ## [v1.0.2-SNAPSHOT] - 2020-11-09 diff --git a/pom.xml b/pom.xml index 9ee385e..047f190 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 1.0.3-SNAPSHOT + 1.1.0-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 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 dd2e4ab..8ba8474 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 @@ -256,6 +256,16 @@ public class ConvertToServiceModel { //TODO } + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); + if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + try { + AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0)); + uplaodedImage.setPolicy(ap); + }catch (Exception e) { + LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e); + } + } + List licenzaIdList = mapFields.get("ID Licenza"); if(licenzaIdList!=null && licenzaIdList.size()>0) { uplaodedImage.setLicenseID(licenzaIdList.get(0)); @@ -312,6 +322,11 @@ public class ConvertToServiceModel { layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0)); } + List licenzaIdList = mapFields.get("ID Licenza"); + if(licenzaIdList!=null && licenzaIdList.size()>0) { + layerConcessione.setLicenseID(licenzaIdList.get(0)); + } + List autoreLst = mapFields.get("Autore"); if(autoreLst!=null) { layerConcessione.setAuthors(autoreLst); -- 2.17.1 From 80e5cfe44eebd473849ec211477a36dddbaf5f4c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 1 Dec 2020 17:35:31 +0100 Subject: [PATCH 10/11] revert to geoportal-logic. integrated with geoportal-data-common --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- pom.xml | 14 +- .../GeoPortalDataEntryApp.gwt.xml | 45 +-- .../client/GeoPortalDataEntryApp.java | 26 +- .../client/GeoportalDataEntryService.java | 11 + .../GeoportalDataEntryServiceAsync.java | 4 + .../server/ConvertToServiceModel.java | 10 +- .../server/GeoportalDataEntryServiceImpl.java | 285 +++++++++++------- .../GeoPortalDataEntryApp.gwt.xml | 45 +-- 10 files changed, 281 insertions(+), 167 deletions(-) diff --git a/.classpath b/.classpath index 57d6904..a2aaf05 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 19fd48b..ac58885 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.2-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.1.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/pom.xml b/pom.xml index 047f190..848194d 100644 --- a/pom.xml +++ b/pom.xml @@ -116,10 +116,22 @@ org.gcube.application - geoportal-client + geoportal-data-common [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) compile + + org.gcube.application + geoportal-logic + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + compile + + + javax.servlet + servlet-api + + + org.gcube.portlets.user gcube-widgets 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 62c8534..8e50a33 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 @@ -1,29 +1,34 @@ - - + + - - - - - - - - - - + + + + - - + - + - - + - - - + + + + + + + + + + + + + + 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 3929c42..7641881 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 @@ -7,6 +7,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.TreeMap; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; @@ -30,6 +31,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.RootPanel; @@ -98,7 +100,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { bindEvents(); mainPanel.addFormPanel(geoNaMainForm); RootPanel.get(DIV_PORTLET_ID).add(mainPanel); - } @@ -263,6 +264,29 @@ public class GeoPortalDataEntryApp implements EntryPoint { }catch (Exception e) { // TODO: handle exception } + + final HorizontalPanel hpLoader = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Get link..."); + hpLoader.add(lc); + modal.add(hpLoader); + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getRecordId(), "concessione", new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + hpLoader.clear(); + + } + + @Override + public void onSuccess(GeoNaItemRef result) { + hpLoader.clear(); + String htmlLink = ""; + HTML html = new HTML(htmlLink); + modal.add(html); + } + }); + + //geoNaMainForm.enableButtonSave(true); //resetUI(); 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 07e255f..1bc9224 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 @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -18,4 +19,14 @@ public interface GeoportalDataEntryService extends RemoteService { CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception; GeonaISConfig getGeonaInitConfig(); + + /** + * Gets the links for. + * + * @param itemId the item id + * @param recordType the record type + * @return the links for + * @throws Exception the exception + */ + GeoNaItemRef getLinksFor(Long itemId, String recordType) 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 e4cba31..99830aa 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 @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -39,4 +40,7 @@ public interface GeoportalDataEntryServiceAsync void getGeonaInitConfig(AsyncCallback callback); + + + void getLinksFor(Long itemId, String recordType, AsyncCallback callback); } 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 8ba8474..ec01078 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.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.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.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.vomanagement.usermanagement.model.GCubeUser; 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 2a1e4b1..8af50b6 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,15 +6,19 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -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.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 org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; @@ -31,19 +35,29 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; /** * The server side implementation of the RPC service. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Dec 1, 2020 */ @SuppressWarnings("serial") public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implements GeoportalDataEntryService { - + public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE"; private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class); + /** + * Save geona data forms. + * + * @param listGeonaFormObjects the list geona form objects + * @return the commit report + * @throws Exception the exception + */ @Override public CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception { LOG.info("saveGeonaDataForms called"); - - HashMap> toMap = - new HashMap>(); + + HashMap> toMap = new HashMap>(); for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) { @@ -57,148 +71,158 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen listForm.add(geoNaFormDataObject); toMap.put(theType, listForm); } - if(LOG.isDebugEnabled()) + if (LOG.isDebugEnabled()) prettyPrintClientDataEntryMap(toMap); - - LOG.debug("Built map with form data: "+toMap); - + + LOG.debug("Built map with form data: " + toMap); + GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); - - ConcessioniManager manager = new ConcessioniManager(); - Concessione concessione = null; - boolean registered = false; + + ConcessioneManager manager; + try { - - //Saving Data - //Informazioni di Progetto + + // Saving Data + // Informazioni di Progetto List list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO); - if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) - throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getTitle()); - + if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) + throw new Exception( + "Error: no data found for " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getTitle()); + List listGDB = list.get(0).getListGDB(); GenericDatasetBean idp = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" building with client obj: "+idp); - concessione = ConvertToServiceModel.toConcessione(idp, user); - LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione); - - //saving into back-end - concessione = manager.registerNew(concessione); - registered = true; - - //RELAZIONE_DI_SCAVO + LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp); + Concessione concessione = ConvertToServiceModel.toConcessione(idp, user); + LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione); + + // saving into back-end + manager = ManagerFactory.registerNew(concessione); + + // RELAZIONE_DI_SCAVO list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); - if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) - throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getTitle()); - + if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) + throw new Exception( + "Error: no data found for " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getTitle()); + listGDB = list.get(0).getListGDB(); GenericDatasetBean rds = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO+" building with client obj: "+rds); + LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds); RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds); - LOG.debug("Built "+ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO+" as server obj: "+relazioneDiScavo); - //Should be only one + LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo); + // Should be only one for (FileUploaded fileUploaded : rds.getFilesUploaded()) { FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); - //saving into back-end + // saving into back-end manager.setRelazioneScavo(relazioneDiScavo, isd); } - - - //IMMAGINI_RAPPRESENTATIVE + + // IMMAGINI_RAPPRESENTATIVE list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE); - if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) - throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle()); - + if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) + throw new Exception( + "Error: no data found for " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle()); + List imgRaprsLst = list.get(0).getListGDB(); for (GenericDatasetBean imgRapr : imgRaprsLst) { LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE+" building with client obj: "+imgRapr); + LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + imgRapr); UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr); - LOG.debug("Built "+ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE+" as server obj: "+img); + LOG.debug("Built " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img); for (FileUploaded fileUploaded : imgRapr.getFilesUploaded()) { - LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+img); + LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + img); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); - //saving into back-end - manager.addImmagineRappresentativa(img,isd); + // saving into back-end + manager.addImmagineRappresentativa(img, isd); } } - - //POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + + // POSIZIONAMENTO_DELL_AREA_DI_INDAGINE list = toMap.get(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); - if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) - throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle()); - + if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) + throw new Exception("Error: no data found for " + + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle()); + listGDB = list.get(0).getListGDB(); GenericDatasetBean pad = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" building with client obj: "+pad); + LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: " + + pad); LayerConcessione layerPad = ConvertToServiceModel.toLayerConcessione(pad); - LOG.debug("Built "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" as server obj: "+layerPad); + LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: " + + layerPad); for (FileUploaded fileUploaded : pad.getFilesUploaded()) { - LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPad); + LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPad); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); - //saving into back-end + // saving into back-end manager.setPosizionamento(layerPad, isd); } - - //PIANTA_DI_FINE_SCAVO + + // PIANTA_DI_FINE_SCAVO list = toMap.get(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO); - if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null) - throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle()); - + if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null) + throw new Exception( + "Error: no data found for " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle()); + listGDB = list.get(0).getListGDB(); GenericDatasetBean pfs = listGDB.get(0); LOG.debug("\n\n"); - LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" building with client obj: "+pfs); + LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs); LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs); - LOG.debug("Built "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" as server obj: "+layerPfs); + LOG.debug("Built " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs); for (FileUploaded fileUploaded : pfs.getFilesUploaded()) { - LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPfs); + LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPfs); FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath()); InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName()); - //saving into back-end - manager.addPiantaScavo(layerPfs, isd); + // saving into back-end + manager.addPiantaFineScavo(layerPfs, isd); } - }catch (Exception e) { - LOG.error("Error on converting form data: ",e); - throw new Exception("Error occurred on saving data, try again or contact the support. Error: "+e.getMessage()); + } catch (Exception e) { + LOG.error("Error on converting form data: ", e); + throw new Exception( + "Error occurred on saving data, try again or contact the support. Error: " + e.getMessage()); } try { - - 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"); - + // 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"); + } + return cRep; - }catch (ValidationException e1){ - LOG.error("Error on validating data: ",e1); - 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()); - }finally { + } 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()); + } 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()); + } finally { // if(manager!=null) { // try { // manager.shutdown(); @@ -208,12 +232,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // // } } + } - + + /** + * Gets the geona init config. + * + * @return the geona init config + */ @Override public GeonaISConfig getGeonaInitConfig() { LOG.info("getConfig called"); - + String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), false); String theSecondaryType; try { @@ -225,31 +255,54 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n"); // scope = "/gcube/devsec/devVRE"; - + GeonaISConfig configs = new GeonaISConfig(theSecondaryType, scope); - LOG.info("returning config: "+configs); + LOG.info("returning config: " + configs); return configs; } - - - + + /** + * Gets the links for. + * + * @param itemId the item id + * @param recordType the record type + * @return the links for + * @throws Exception the exception + */ + @Override + public GeoNaItemRef getLinksFor(Long itemId, String recordType) throws Exception { + LOG.info("getLinksFor called"); + + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + GeoportalCommon gc = new GeoportalCommon(); + GeoNaItemRef item = new GeoNaItemRef(itemId, recordType); + item = gc.getPublicLinksFor(item); + LOG.info("Returning: " + item); + return item; + } + + /** + * Pretty print client data entry map. + * + * @param toMap the to map + */ private void prettyPrintClientDataEntryMap(HashMap> toMap) { - + for (ConcessioniFormCardTitle theType : toMap.keySet()) { LOG.debug("\n\n"); LOG.debug(theType.toString()); List list = toMap.get(theType); for (GeoNaFormDataObject geoNaFormDataObject : list) { - LOG.debug("\t has "+geoNaFormDataObject.getListGDB().size() +" data bean/s"); + LOG.debug("\t has " + geoNaFormDataObject.getListGDB().size() + " data bean/s"); int i = 0; for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) { - LOG.debug("\t "+ ++i +") "+GenericDatasetBean.class.getSimpleName()+" entries:"); + LOG.debug("\t " + ++i + ") " + GenericDatasetBean.class.getSimpleName() + " entries:"); Map> map = gbd.getFormDataEntryFields(); for (String keyEntry : map.keySet()) { - LOG.debug("\t "+keyEntry + ": "+map.get(keyEntry)); + LOG.debug("\t " + keyEntry + ": " + map.get(keyEntry)); } for (FileUploaded fup : gbd.getFilesUploaded()) { - LOG.debug("\t "+fup); + LOG.debug("\t " + fup); } } } 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 62c8534..8e50a33 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 @@ -1,29 +1,34 @@ - - + + - - - - - - - - - - + + + + - - + - + - - + - - - + + + + + + + + + + + + + + -- 2.17.1 From 24ee8c373c3f6445ef35ab2431d49e113c3d7c59 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 1 Dec 2020 17:36:16 +0100 Subject: [PATCH 11/11] updated --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c650f5..bc8604c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements [#20210] Updating required for data entry facility after the first feedback by domain experts - Moved to 'geoportal-client' ## [v1.0.2-SNAPSHOT] - 2020-11-09 -- 2.17.1