From a134c87b6d5532c0df7f3f661f76cada02e61d37 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 30 Jul 2021 11:53:12 +0200 Subject: [PATCH 01/32] Passed to mongoId. Passed to Nome Autore, Email, Ruolo --- .settings/org.eclipse.wst.common.component | 65 ++++++++++++------- CHANGELOG.md | 2 + .../client/GeoPortalDataEntryApp.java | 10 +-- .../client/GeoportalDataEntryService.java | 10 +-- .../GeoportalDataEntryServiceAsync.java | 2 +- .../server/ConvertToServiceModel.java | 32 ++++++++- .../server/GeoportalDataEntryServiceImpl.java | 26 ++++++-- .../shared/CommitReport.java | 61 +++++++++-------- .../geoportaldataentry/client/TestClass.java | 8 ++- 9 files changed, 139 insertions(+), 77 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index a4ce841..52dec35 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,31 +1,46 @@ - - - - - - - - - - - - - - - - - uses - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 92b8602..734f6c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#20435] Client integration with MongoConcessioni Moved to maven-portal-bom 3.6.3 +[#21856] Implementing new user feedback +[#21890] Passed to mongoID ## [v1.2.0] - 2020-12-18 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 4aae924..7d8448e 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 @@ -69,7 +69,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { private GeonaMainPanel mainPanel; - private LinkedHashMap> savedMap = new LinkedHashMap>(); + private LinkedHashMap> savedMap = new LinkedHashMap>(); private boolean projectSavedWithSuccess; @@ -276,11 +276,11 @@ public class GeoPortalDataEntryApp implements EntryPoint { modalContainerPanel.add(recordPublished); - if(result.getRecordId()!=null) { - modalContainerPanel.add(new HTML("Record id: "+(result.getRecordId()))); + if(result.getMongoId()!=null) { + modalContainerPanel.add(new HTML("Record id: "+(result.getMongoId()))); try { - savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms()); + savedMap.put(result.getMongoId(), saveGeonaDataFormsEvent.getListGeonaDataForms()); }catch (Exception e) { // TODO: handle exception } @@ -289,7 +289,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { final LoaderIcon lc = new LoaderIcon("Get link..."); hpGetLink.add(lc); modalContainerPanel.add(hpGetLink); - GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getRecordId(), "concessione", new AsyncCallback() { + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getMongoId(), "concessione", new AsyncCallback() { @Override public void onFailure(Throwable caught) { 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 1bc9224..32fc1c1 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 @@ -20,13 +20,5 @@ public interface GeoportalDataEntryService extends RemoteService { 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; + GeoNaItemRef getLinksFor(String 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 99830aa..0a01544 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 @@ -42,5 +42,5 @@ public interface GeoportalDataEntryServiceAsync void getGeonaInitConfig(AsyncCallback callback); - void getLinksFor(Long itemId, String recordType, AsyncCallback callback); + void getLinksFor(String 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 55e6846..86ccaca 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 @@ -52,11 +52,18 @@ public class ConvertToServiceModel { Concessione concessione = new Concessione(); - List authors = mapFields.get("Autore"); + +// List authors = mapFields.get("Autore"); +// if(authors!=null) { +// concessione.setAuthors(authors); +// } + + + List authors = mapFields.get("Nome Autore, Email, Ruolo"); if(authors!=null) { concessione.setAuthors(authors); } - + List contributors = mapFields.get("Contributore"); if(contributors!=null) { for (String contributor : contributors) { @@ -222,6 +229,16 @@ public class ConvertToServiceModel { relazioneScavo.setLicenseID(licenzaIdList.get(0)); } + //TODO + List periodoDiEmbargo = mapFields.get("Periodo di embargo"); + if(periodoDiEmbargo!=null && periodoDiEmbargo.size()>0) { + String dateFromTo = periodoDiEmbargo.get(0); + String[] dates = dateFromTo.split(","); + String dateFrom = dates[0]; + String dateTo = dates[0]; + //TODO MUST BE INTENGRATED IN THE SERVICE + } + return relazioneScavo; } @@ -354,6 +371,17 @@ public class ConvertToServiceModel { layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0)); } + //TODO + List periodoDiEmbargo = mapFields.get("Periodo di embargo"); + if(periodoDiEmbargo!=null && periodoDiEmbargo.size()>0) { + String dateFromTo = periodoDiEmbargo.get(0); + String[] dates = dateFromTo.split(","); + String dateFrom = dates[0]; + String dateTo = dates[0]; + //TODO MUST BE INTENGRATED IN THE SERVICE + } + + List licenzaIdList = mapFields.get("ID Licenza"); if(licenzaIdList!=null && licenzaIdList.size()>0) { layerConcessione.setLicenseID(licenzaIdList.get(0)); 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 6a140c1..f23328c 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 @@ -211,7 +211,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen //UPLOADING FILES LOG.info("Now uploading the files..."); - // Building TempFile for Relazione + //Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + List ardsFiles = serviceUtil.toTemFiles(ards.getFilesUploaded()); + //TODO MUST BE UNIFIED WITH RELAZIONE OPPURE BISOGNA PREVEDERE UN ABSTRACT_RELAZIONE??? + if (ardsFiles!=null && ardsFiles.size() > 0) { + // saving into back-end + AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles); + clientMongo.registerFile(mongoId, request); + LOG.info("Registered the mongoId "+mongoId+" request " + Paths.RELAZIONE + "with "+ardsFiles.size()+" file/s"); + } + + // Building TempFile for RELAZIONE DI SCAVO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); List files = serviceUtil.toTemFiles(rds.getFilesUploaded()); // Upload file to Concessione. Should be one file. @@ -286,16 +297,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("ValidationReport: " + report); //to client CommitReport cRep = new CommitReport(); - cRep.setRecordId(concessione.getId()); + //cRep.setRecordId(concessione.getId()); + cRep.setMongoId(concessione.getMongo_id()); String theJSON = serviceUtil.toJSON(report); cRep.setReport(theJSON); switch (report.getStatus()) { case PASSED: cRep.setState(STATE.OK); - if(cRep.getRecordId()==null) { - LOG.error("The record id is null!!!"); - throw new Exception("Invalid record id"); + if(cRep.getMongoId()==null) { + LOG.error("The mongo id is null!!!"); + throw new Exception("Invalid identifier (mongoId is null) for the concessione"); } break; case WARNING: @@ -362,13 +374,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Gets the links for. * - * @param itemId the item id + * @param itemId the item id is the mongoId * @param recordType the record type * @return the links for * @throws Exception the exception */ @Override - public GeoNaItemRef getLinksFor(Long itemId, String recordType) throws Exception { + public GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception { LOG.info("getLinksFor called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); 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 9e0b07c..e2db0ce 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 @@ -2,13 +2,12 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; - /** * The Class CommitReport. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 30, 2020 + * Jul 30, 2021 */ public class CommitReport implements Serializable { @@ -30,6 +29,7 @@ public class CommitReport implements Serializable { public STATE state = STATE.UNKNOWN; public Long recordId; + public String mongoId; public String msg; public String report; @@ -45,13 +45,14 @@ public class CommitReport implements Serializable { * * @param state the state * @param recordId the record id + * @param mongoId the mongo id * @param msg the msg - * @param report the report + * @param report the report */ - public CommitReport(STATE state, long recordId, String msg, String report) { + public CommitReport(STATE state, long recordId, String mongoId, String msg, String report) { super(); this.state = state; - this.recordId = recordId; + this.mongoId = mongoId; this.msg = msg; this.report = report; } @@ -74,14 +75,14 @@ public class CommitReport implements Serializable { this.state = state; } - /** - * Gets the record id. - * - * @return the record id - */ - public Long getRecordId() { - return recordId; - } +// /** +// * Gets the record id. +// * +// * @return the record id +// */ +// public Long getRecordId() { +// return recordId; +// } /** * Gets the report. @@ -101,14 +102,14 @@ public class CommitReport implements Serializable { this.report = report; } - /** - * Sets the record id. - * - * @param recordId the new record id - */ - public void setRecordId(long recordId) { - this.recordId = recordId; - } +// /** +// * Sets the record id. +// * +// * @param recordId the new record id +// */ +// public void setRecordId(long recordId) { +// this.recordId = recordId; +// } /** * Gets the msg. @@ -119,6 +120,14 @@ public class CommitReport implements Serializable { return msg; } + public String getMongoId() { + return mongoId; + } + + public void setMongoId(String mongoId) { + this.mongoId = mongoId; + } + /** * Sets the msg. * @@ -128,11 +137,6 @@ public class CommitReport implements Serializable { this.msg = msg; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -140,6 +144,8 @@ public class CommitReport implements Serializable { builder.append(state); builder.append(", recordId="); builder.append(recordId); + builder.append(", mongoId="); + builder.append(mongoId); builder.append(", msg="); builder.append(msg); builder.append(", report="); @@ -148,5 +154,6 @@ public class CommitReport implements Serializable { return builder.toString(); } + } diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java index 0422679..3fefedf 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java @@ -3,11 +3,12 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.time.LocalDateTime; import org.gcube.portlets.user.geoportaldataentry.server.ConvertToServiceModel; +import org.gcube.portlets.user.geoportaldataentry.server.GeoportalDataEntryServiceImpl; public class TestClass { - public static void main(String[] args) { + public static void main(String[] args) throws Exception { LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20"); System.out.println(ldt.toString()); @@ -19,6 +20,11 @@ public class TestClass { String longitude = "0"; System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$")); + + + GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl(); + g.getLinksFor("", "concessione"); + } From 5fbb0fa8a7c92804a252e9a556350108b291703f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 2 Aug 2021 12:52:30 +0200 Subject: [PATCH 02/32] added a method --- .settings/org.eclipse.wst.common.component | 30 ++- .../server/GeoportalDataEntryServiceImpl.java | 190 ++++++++++-------- .../server/SessionUtil.java | 41 +++- 3 files changed, 169 insertions(+), 92 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 52dec35..d1324d9 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,45 +1,57 @@ - + + - + + - + + - + + - + + - + + uses + + + - + + - + + - + + 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 f23328c..5cbd991 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 @@ -77,12 +77,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen String mongoId = null; ServiceUtil serviceUtil = new ServiceUtil(); MongoConcessioni clientMongo = null; - + try { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); clientMongo = serviceUtil.getInstanceMongoConcessioni(); - + // Saving Data // Informazioni di Progetto List list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO); @@ -96,17 +96,16 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen 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); - - //Register New Concessione - concessioneNew=clientMongo.createNew(concessione); - + // Register New Concessione + concessioneNew = clientMongo.createNew(concessione); + // ABSTRACT_RELAZIONE_DI_SCAVO list = toMap.get(ConcessioniFormCardTitle.ABSTRACT_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.ABSTRACT_RELAZIONE_DI_SCAVO.getTitle()); - + listGDB = list.get(0).getListGDB(); GenericDatasetBean ards = listGDB.get(0); LOG.debug("\n\n"); @@ -125,10 +124,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds); RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds); LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo); - - //Setting Relazione + + // Setting Relazione concessioneNew.setRelazioneScavo(relazioneDiScavo); - // IMMAGINI_RAPPRESENTATIVE list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE); @@ -138,22 +136,23 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen List imgRaprsLst = list.get(0).getListGDB(); List immaginiRappresentativeService = null; - if(imgRaprsLst.size()>0) { + if (imgRaprsLst.size() > 0) { immaginiRappresentativeService = new ArrayList(imgRaprsLst.size()); 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); immaginiRappresentativeService.add(img); } } - - //Setting Immagini Rappresentative - if(immaginiRappresentativeService!=null) { + + // Setting Immagini Rappresentative + if (immaginiRappresentativeService != null) { concessioneNew.setImmaginiRappresentative(immaginiRappresentativeService); } - + // 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) @@ -163,7 +162,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen listGDB = list.get(0).getListGDB(); GenericDatasetBean pad = listGDB.get(0); LayerConcessione layerPad = null; - if(pad!=null) { + if (pad != null) { LOG.debug("\n\n"); LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: " + pad); @@ -171,9 +170,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: " + layerPad); } - - //Setting Posizionamento Di Scavo - if(layerPad!=null) { + + // Setting Posizionamento Di Scavo + if (layerPad != null) { concessioneNew.setPosizionamentoScavo(layerPad); } @@ -185,9 +184,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen listGDB = list.get(0).getListGDB(); List listPfs = listGDB; - //Managing N:N + // Managing N:N List pianteFineScavo = null; - if(listPfs.size()>0) { + if (listPfs.size() > 0) { pianteFineScavo = new ArrayList(listPfs.size()); for (GenericDatasetBean pfs : listPfs) { LOG.debug("\n\n"); @@ -198,88 +197,98 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } - - //Setting Piante fine Scavo - if(pianteFineScavo!=null) { + + // Setting Piante fine Scavo + if (pianteFineScavo != null) { concessioneNew.setPianteFineScavo(pianteFineScavo); } - - //Registering Meta + + // Registering Meta clientMongo.replace(concessioneNew); mongoId = concessioneNew.getMongo_id(); - LOG.info("Registered the meta. Called mongo.replace for: "+concessioneNew); - - //UPLOADING FILES + LOG.info("Registered the meta. Called mongo.replace for: " + concessioneNew); + + // UPLOADING FILES LOG.info("Now uploading the files..."); - //Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO + // Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); List ardsFiles = serviceUtil.toTemFiles(ards.getFilesUploaded()); - //TODO MUST BE UNIFIED WITH RELAZIONE OPPURE BISOGNA PREVEDERE UN ABSTRACT_RELAZIONE??? - if (ardsFiles!=null && ardsFiles.size() > 0) { + // TODO MUST BE UNIFIED WITH RELAZIONE OPPURE BISOGNA PREVEDERE UN + // ABSTRACT_RELAZIONE??? + if (ardsFiles != null && ardsFiles.size() > 0) { // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles); clientMongo.registerFile(mongoId, request); - LOG.info("Registered the mongoId "+mongoId+" request " + Paths.RELAZIONE + "with "+ardsFiles.size()+" file/s"); + LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + + ardsFiles.size() + " file/s"); } - + // Building TempFile for RELAZIONE DI SCAVO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); List files = serviceUtil.toTemFiles(rds.getFilesUploaded()); // Upload file to Concessione. Should be one file. - if (files!=null && files.size() > 0) { + if (files != null && files.size() > 0) { // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, files); clientMongo.registerFile(mongoId, request); - LOG.info("Registered the mongoId "+mongoId+" request " + Paths.RELAZIONE + "with "+files.size()+" file/s"); + LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + files.size() + + " file/s"); } - - //IMMAGINI RAPPRESENTATIVE - for (int i=0; i 0) { + // Upload file to Concessione. The size is always 1 so it is consistent with the + // 'for' index + if (files != null && files.size() > 0) { // saving into back-end - AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.imgByIndex(i), files); + AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.imgByIndex(i), + files); clientMongo.registerFile(mongoId, request); - LOG.info("Registered the mongoId "+mongoId+" request " + Paths.IMMAGINI + "with "+files.size()+" file/s"); + LOG.info("Registered the mongoId " + mongoId + " request " + Paths.IMMAGINI + "with " + files.size() + + " file/s"); } - + } - - //POSIZIONAMENTO + + // POSIZIONAMENTO // Building TempFile for POSIZIONAMENTO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); files = serviceUtil.toTemFiles(pad.getFilesUploaded()); // Upload file to Concessione - if (files!=null && files.size() > 0) { + if (files != null && files.size() > 0) { // saving into back-end - AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.POSIZIONAMENTO, files); + AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.POSIZIONAMENTO, + files); clientMongo.registerFile(mongoId, request); - LOG.info("Registered the mongoId "+mongoId+" request " + Paths.POSIZIONAMENTO + "with "+files.size()+" file/s"); + LOG.info("Registered the mongoId " + mongoId + " request " + Paths.POSIZIONAMENTO + "with " + + files.size() + " file/s"); } - - //PIANTE FINE SCAVO - if(listPfs.size()>0) { - for (int i=0; i 0) { + for (int i = 0; i < listPfs.size(); i++) { // Building TempFile for PIANTA_DI_FINE_SCAVO GenericDatasetBean pfs = listPfs.get(i); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); files = serviceUtil.toTemFiles(pfs.getFilesUploaded()); // Upload file to Concessione Section by Path 'Relazione' - if (files!=null && files.size() > 0) { + if (files != null && files.size() > 0) { // saving into back-end - AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.piantaByIndex(i), files); + AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest( + Paths.piantaByIndex(i), files); clientMongo.registerFile(mongoId, request); - LOG.info("Registered the mongoId "+mongoId+" request " + Paths.PIANTE + "with "+files.size()+" file/s"); + LOG.info("Registered the mongoId " + mongoId + " request " + Paths.PIANTE + "with " + + files.size() + " file/s"); } } } - + } catch (Exception e) { LOG.error("Error on converting form data: ", e); throw new Exception( @@ -287,25 +296,25 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } try { - + Concessione concessione; - if(clientMongo!=null && mongoId!=null) { + if (clientMongo != null && mongoId != null) { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); concessione = clientMongo.publish(mongoId); - //server report + // server report ValidationReport report = concessione.getReport(); LOG.info("ValidationReport: " + report); - //to client + // to client CommitReport cRep = new CommitReport(); - //cRep.setRecordId(concessione.getId()); + // cRep.setRecordId(concessione.getId()); cRep.setMongoId(concessione.getMongo_id()); String theJSON = serviceUtil.toJSON(report); cRep.setReport(theJSON); - + switch (report.getStatus()) { case PASSED: cRep.setState(STATE.OK); - if(cRep.getMongoId()==null) { + if (cRep.getMongoId() == null) { LOG.error("The mongo id is null!!!"); throw new Exception("Invalid identifier (mongoId is null) for the concessione"); } @@ -318,20 +327,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen cRep.setState(STATE.ERROR); cRep.setMsg(report.getErrorMessages().toString()); break; - + default: cRep.setState(STATE.UNKNOWN); break; } - + return cRep; - }else + } else throw new Exception("MongoId or Client not found"); - + } catch (Exception e) { LOG.error("Error on commiting data: ", e); - throw new Exception( - "Error occurred on saving data. Error: " + e.getMessage()); + throw new Exception("Error occurred on saving data. Error: " + e.getMessage()); } finally { // if(manager!=null) { // try { @@ -390,7 +398,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("Returning: " + item); return item; } - + /** * Gets the links for. * @@ -399,19 +407,37 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @return the links for * @throws Exception the exception */ - //@Override - public void getListConcessioni(Integer startIdx, Integer limit) throws Exception { + // @Override + public void getListConcessioni(Integer start, Integer offset) throws Exception { LOG.info("getListConcessioni called"); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - ServiceUtil serviceUtil = new ServiceUtil(); - MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); - Iterable concessioni = clientMongo.getList(); - - //TODO - LOG.info("Returning: " + concessioni); - } + try { + List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest()); + int maxOffset = listOfConcessioni.size(); + List toReturn = new ArrayList(); + if(start==null && offset==null) { + toReturn.addAll(listOfConcessioni); + } + if(start<0) + start=0; + + if(offset>maxOffset) + offset = maxOffset; + + toReturn.subList(start, offset); + + for (Concessione concessione : toReturn) { + + } + // TODO + //LOG.info("Returning: " + concessioni); + }catch (Exception e) { + LOG.error("Error on loading list of concessioni: ", e); + throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage()); + } + + } /** * Pretty print client data entry map. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 5b3dc08..97f065b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -3,8 +3,14 @@ */ package org.gcube.portlets.user.geoportaldataentry.server; -import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -29,6 +35,7 @@ import com.liferay.portal.service.UserLocalServiceUtil; */ public class SessionUtil { + private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI"; /** The log. */ private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); @@ -111,4 +118,36 @@ public class SessionUtil { return gm.getGroup(groupId); } + + + /** + * Gets the list of concessioni. + * + * @param httpServletRequest the http servlet request + * @return the list of concessioni + * @throws Exception the exception + */ + public static List getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception { + HttpSession session = httpServletRequest.getSession(); + List listOfConcessioni = (List) session.getAttribute(LIST_OF_CONCESSIONI); + List result = new ArrayList(); + + if (listOfConcessioni == null) { + LOG.info("Loading list of concessione from client mongo"); + SessionUtil.getCurrentContext(httpServletRequest, true); + ServiceUtil serviceUtil = new ServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Iterable concessioni = clientMongo.getList(); + if (concessioni != null) { + for (Concessione conc : concessioni) { + result.add(conc); + } + } + LOG.debug("Got list of concessione from client mongo: "+result); + session.setAttribute(LIST_OF_CONCESSIONI, result); + LOG.info("Saved in session list of concessione from client mongo with size: "+result.size()); + } + LOG.info("returning list of concessioni with size: "+result.size()); + return result; + } } From b5ccba55511f32b64eff56f4f713fdfdd96f42eb Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 4 Aug 2021 17:11:46 +0200 Subject: [PATCH 03/32] first List of Records with pagination --- .settings/org.eclipse.wst.common.component | 36 +- CHANGELOG.md | 1 + .../ConstantsGeoPortalDataEntryApp.java | 6 + .../client/GeoPortalDataEntryApp.java | 24 +- .../client/GeoportalDataEntryService.java | 36 ++ .../GeoportalDataEntryServiceAsync.java | 4 + .../client/events/ClickItemEvent.java | 68 +++ .../client/events/ClickItemEventHandler.java | 21 + .../client/events/GetListOfRecordsEvent.java | 65 +++ .../events/GetListOfRecordsEventHandler.java | 22 + .../client/events/ShowItemEvent.java | 68 +++ .../client/events/ShowItemEventHandler.java | 23 + .../client/resource/CellTable.css | 110 ++++ .../client/resource/CellTableResources.java | 23 + .../client/ui/GeonaMainPanel.java | 2 +- .../client/ui/GeonaNavigationBar.java | 32 +- .../client/ui/GeonaNavigationBar.ui.xml | 2 + .../client/ui/GeonaRecordsPaginatedView.java | 310 +++++++++++ .../ui/{ => form}/GeonaDataEntryMainForm.java | 2 +- .../{ => form}/GeonaDataEntryMainForm.ui.xml | 0 .../ui/table/AbstractItemsCellTable.java | 204 +++++++ .../client/ui/table/ItemsTable.java | 516 ++++++++++++++++++ .../client/ui/table/MyToolTipColumn.java | 83 +++ .../client/ui/table/SortedCellTable.java | 302 ++++++++++ .../server/GeoportalDataEntryServiceImpl.java | 84 ++- .../server/SessionUtil.java | 26 +- .../shared/SearchedData.java | 183 +++++++ .../geoportaldataentry/client/TestClass.java | 63 ++- 28 files changed, 2242 insertions(+), 74 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTable.css create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTableResources.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java rename src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/{ => form}/GeonaDataEntryMainForm.java (98%) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/{ => form}/GeonaDataEntryMainForm.ui.xml (100%) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d1324d9..3af9f7e 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,29 +1,39 @@ - + + + - + + + - + + + - + + + - + + + @@ -32,25 +42,33 @@ uses - + + + - + + + - + + + - + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 734f6c7..f9b5eb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm Moved to maven-portal-bom 3.6.3 [#21856] Implementing new user feedback [#21890] Passed to mongoID +[#20599] Get List of Records ## [v1.2.0] - 2020-12-18 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index def5f97..7076afb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -12,4 +12,10 @@ public class ConstantsGeoPortalDataEntryApp { public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!"; + + public enum RECORD_TYPE { + CONCESSIONE + } + + } 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 7d8448e..815d042 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 @@ -8,14 +8,19 @@ import java.util.List; import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; 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.GetListOfRecordsEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler; -import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel; +import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; +import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; +import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; @@ -57,7 +62,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { /** * Create a remote service proxy to talk to the server-side Greeting service. */ - private final GeoportalDataEntryServiceAsync greetingService = GWT.create(GeoportalDataEntryService.class); + public static final GeoportalDataEntryServiceAsync greetingService = GWT.create(GeoportalDataEntryService.class); private final HandlerManager appManagerBus = new HandlerManager(null); @@ -350,6 +355,21 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); + + appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() { + + @Override + public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { + + + Modal modal = new Modal(true); + modal.setCloseVisible(true); + GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME); + modal.add(grpw.getCellPanel()); + modal.add(grpw.getPagerPanel()); + modal.show(); + } + }); } 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 32fc1c1..8b6fba5 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 @@ -6,19 +6,55 @@ 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; +import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; /** * The client side stub for the RPC service. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 4, 2021 */ @RemoteServiceRelativePath("geoportaldataentryservice") public interface GeoportalDataEntryService extends RemoteService { + /** + * Save geona data forms. + * + * @param listGeonaFormObjects the list geona form objects + * @return the commit report + * @throws Exception the exception + */ CommitReport saveGeonaDataForms(List listGeonaFormObjects) throws Exception; + /** + * Gets the geona init config. + * + * @return the geona init config + */ 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(String itemId, String recordType) throws Exception; + + + /** + * Gets the list concessioni. + * + * @param start the start + * @param offset the offset + * @return the list concessioni + * @throws Exception the exception + */ + SearchedData getListConcessioni(Integer start, Integer offset) 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 0a01544..902f1c4 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 @@ -6,6 +6,7 @@ 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; +import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -43,4 +44,7 @@ public interface GeoportalDataEntryServiceAsync void getLinksFor(String itemId, String recordType, AsyncCallback callback); + + + void getListConcessioni(Integer start, Integer offset, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEvent.java new file mode 100644 index 0000000..6578f7a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEvent.java @@ -0,0 +1,68 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import java.util.List; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class ClickItemEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 22, 2021 + * @param the generic type + */ +public class ClickItemEvent extends GwtEvent { + public static Type TYPE = new Type(); + private List selectItems; + + /** + * Instantiates a new click item event. + * + * @param selectItems the select items + */ + public ClickItemEvent(List selectItems) { + this.selectItems = selectItems; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) + */ + @Override + protected void dispatch(ClickItemEventHandler handler) { + handler.onClick(this); + } + + /** + * Gets the select items. + * + * @return the select items + */ + public List getSelectItems() { + return selectItems; + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEventHandler.java new file mode 100644 index 0000000..9b9097e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ClickItemEventHandler.java @@ -0,0 +1,21 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import com.google.gwt.event.shared.EventHandler; + + +/** + * The Interface ClickItemEventHandler. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jul 6, 2015 + */ +public interface ClickItemEventHandler extends EventHandler { + + /** + * On click. + * + * @param the generic type + * @param moreInfoShowEvent the more info show event + */ + void onClick(ClickItemEvent moreInfoShowEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java new file mode 100644 index 0000000..9fb313f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java @@ -0,0 +1,65 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class CreateNewProjectEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Oct 13, 2020 + */ +public class GetListOfRecordsEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + private RECORD_TYPE recordType; + + + /** + * Instantiates a new cancel upload event. + */ + public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType) { + this.recordType = recordType; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) + */ + @Override + protected void dispatch(GetListOfRecordsEventHandler handler) { + handler.onGetList(this); + } + + public RECORD_TYPE getRecordType() { + return recordType; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEventHandler.java new file mode 100644 index 0000000..7933d78 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEventHandler.java @@ -0,0 +1,22 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import com.google.gwt.event.shared.EventHandler; + + +/** + * The Interface GetListOfRecordsEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 4, 2021 + */ +public interface GetListOfRecordsEventHandler extends EventHandler { + + + /** + * On get list. + * + * @param getListOfRecordsEvent the get list of records event + */ + void onGetList(GetListOfRecordsEvent getListOfRecordsEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java new file mode 100644 index 0000000..fe6afc3 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java @@ -0,0 +1,68 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import java.util.List; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class ShowItemEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 22, 2021 + * @param the generic type + */ +public class ShowItemEvent extends GwtEvent { + public static Type TYPE = new Type(); + private List selectItems; + + /** + * Instantiates a new click item event. + * + * @param selectItems the select items + */ + public ShowItemEvent(List selectItems) { + this.selectItems = selectItems; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) + */ + @Override + protected void dispatch(ShowItemEventHandler handler) { + handler.onShowItemClicked(this); + } + + /** + * Gets the select items. + * + * @return the select items + */ + public List getSelectItems() { + return selectItems; + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java new file mode 100644 index 0000000..7713908 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java @@ -0,0 +1,23 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import com.google.gwt.event.shared.EventHandler; + + +// TODO: Auto-generated Javadoc +/** + * The Interface ShowItemEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 22, 2021 + */ +public interface ShowItemEventHandler extends EventHandler { + + /** + * On show item clicked. + * + * @param the generic type + * @param showItemEvent the show item event + */ + void onShowItemClicked(ShowItemEvent showItemEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTable.css b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTable.css new file mode 100644 index 0000000..c0939d4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTable.css @@ -0,0 +1,110 @@ +@def selectionBorderWidth 1px ; .cellTableWidget { + +} + +.cellTableFirstColumn { + +} + +.cellTableLastColumn { + +} + +.cellTableFooter { + +} + +.cellTableHeader { +} + +.cellTableCell { + +} + +.cellTableFirstColumnFooter { + +} + +.cellTableFirstColumnHeader { + +} + +.cellTableLastColumnFooter { + +} + +.cellTableLastColumnHeader { + +} + +.cellTableSortableHeader { + +} + +.cellTableSortableHeader:hover { + +} + +.cellTableSortedHeaderAscending { + +} + +.cellTableSortedHeaderDescending { + +} + +.cellTableEvenRow { + +} + +.cellTableEvenRowCell { + +} + +.cellTableOddRow { + +} + +.cellTableOddRowCell { + +} + +.cellTableHoveredRow { + background: #D9EDF7 !important; + cursor: pointer; +} + +.cellTableHoveredRowCell { + background: #D9EDF7 !important; + cursor: pointer; +} + +.cellTableKeyboardSelectedRow, .cellTableKeyboardSelectedRow td, .cellTableKeyboardSelectedRow th { + background: #3A87AD !important; +} + +.cellTableSelectedRow, .cellTableSelectedRow td, .cellTableSelectedRow th + { + /* background: #D9EDF7 !important; */ + /* color: white !important; */ + /* height: auto; */ + /* overflow: auto; */ + +} + +.cellTableSelectedRowCell, .cellTableSelectedRow td.cellTableSelectedRowCell { + background: #3A87AD !important; +} + +.cellTableKeyboardSelectedRowCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedRowCell{ + background: #3A87AD !important; +} + +.cellTableKeyboardSelectedCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedCell{ + background: #3A87AD !important; + color: white !important; +} + +.cellTableLoading { + margin: 30px; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTableResources.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTableResources.java new file mode 100644 index 0000000..ade9aae --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/resource/CellTableResources.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.gcube.portlets.user.geoportaldataentry.client.resource; + +import com.github.gwtbootstrap.client.ui.CellTable; +import com.github.gwtbootstrap.client.ui.CellTable.Resources; +import com.google.gwt.core.shared.GWT; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Jun 23, 2015 + */ +public interface CellTableResources extends Resources { + + public CellTableResources INSTANCE = GWT.create(CellTableResources.class); + + // The styles used in this widget. + @Override + @Source("CellTable.css") + CellTable.Style cellTableStyle(); +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java index 77790f5..c3b1db6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; +import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import com.google.gwt.core.client.GWT; @@ -10,7 +11,6 @@ import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; -// TODO: Auto-generated Javadoc /** * The Class GeonaMainPanel. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java index 86d3ab3..53b2b01 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java @@ -1,15 +1,17 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; import com.github.gwtbootstrap.client.ui.NavLink; 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.EventBus; 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.uibinder.client.UiHandler; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; @@ -24,28 +26,42 @@ public class GeonaNavigationBar extends Composite { public GeonaNavigationBar() { initWidget(uiBinder.createAndBindUi(this)); + bindEvents(); } private void bindEvents() { - // TODO Auto-generated method stub + linkCreateNewProject.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new CreateNewProjectEvent()); + + } + }); + + linkGetListOfRecords.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); + + } + }); } @UiField NavLink linkCreateNewProject; + @UiField + NavLink linkGetListOfRecords; + private HandlerManager appManagerBus; public GeonaNavigationBar(String firstName) { initWidget(uiBinder.createAndBindUi(this)); } - @UiHandler("linkCreateNewProject") - void onClick(ClickEvent e) { - appManagerBus.fireEvent(new CreateNewProjectEvent()); - } - - /** * Sets the app manager bus. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml index 8d8abea..6a54199 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml @@ -12,6 +12,8 @@ Create new Project + Get List of Concessioni diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java new file mode 100644 index 0000000..010307d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -0,0 +1,310 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui; + +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; +import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable; +import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; +import org.gcube.portlets.user.geoportaldataentry.client.ui.table.SortedCellTable; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; +import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.user.cellview.client.SimplePager.TextLocation; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.view.client.AsyncDataProvider; +import com.google.gwt.view.client.HasData; +import com.google.gwt.view.client.MultiSelectionModel; +import com.google.gwt.view.client.Range; +import com.google.gwt.view.client.SelectionModel; +import com.google.gwt.view.client.SingleSelectionModel; + + +/** + * The Class GeonaRecordsPaginatedView. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 4, 2021 + */ +public class GeonaRecordsPaginatedView { + + private static final int ITEM_START_INDEX = 0; + private static final int ITEMS_PER_PAGE = 30; + private VerticalPanel vPanel = new VerticalPanel(); + private FlowPanel pagerPanel = new FlowPanel(); + private Boolean initClassFirstRangeChanged = false; + private ItemsTable itemsTable; + private MyCustomDataProvider dataProvider = new MyCustomDataProvider(); + protected Widget orginalLoadingIndicator = null; + private LoaderIcon loadingPanel = new LoaderIcon("Loading data..."); + private int serverStartIndex; + private HandlerManager eventBus; + private RECORD_TYPE recordType; + + + /** + * Instantiates a new geona records paginated view. + * + * @param eventbus the eventbus + * @param recordType the record type + * @param displayFields the display fields + * @param sortByField the sort by field + */ + public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields, + DISPLAY_FIELD sortByField) { + this.recordType = recordType; + this.initClassFirstRangeChanged = true; + this.eventBus = eventbus; + itemsTable = new ItemsTable(eventbus, displayFields, sortByField); + itemsTable.initTable(null, null, dataProvider); + + orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); + initPagination(ITEMS_PER_PAGE); + // loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false); + loadItemsForStatus(recordType); + } + + /** + * Gets the asycn data provider. + * + * @return the asycn data provider + */ + public AsyncDataProvider getAsycnDataProvider() { + return (AsyncDataProvider) getCellTable().getDataProvider(); + } + + /** + * Gets the cell tale. + * + * @return the cell tale + */ + private SortedCellTable getCellTable() { + return itemsTable.getCellTable(); + } + + /** + * Inits the pagination. + * + * @param itemsPerPage the items per page + */ + public void initPagination(int itemsPerPage) { + + SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); + SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); + pager.setDisplay(getCellTable()); + pager.setPageSize(itemsPerPage); + pager.getElement().getStyle().setProperty("margin", "auto"); + vPanel.add(loadingPanel); + vPanel.add(getCellTable()); + vPanel.getElement().addClassName("vPanel"); + pagerPanel.add(pager); + } + + /** + * Gets the pager panel. + * + * @return the pager panel + */ + public VerticalPanel getCellPanel() { + return vPanel; + } + + /** + * Set the panel in loading mode. + * + * @param show the show + */ + protected void showLoading(boolean show) { + loadingPanel.setVisible(show); + } + + /** + * Gets the pager panel. + * + * @return the pager panel + */ + public FlowPanel getPagerPanel() { + return pagerPanel; + } + + /** + * Load new page. + * + * @param startIdx the start idx + * @param limit the limit + * @param resetStore the reset store + */ + private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) { + // initFirstRangeChanged = resetStore; + GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" + + resetStore + "]"); + // showLoading(true); + + int newStartIndex = startIdx; + + if (resetStore) { + GWT.log("Cleaning all data..."); + newStartIndex = 0; + serverStartIndex = 0; + GWT.log("Store reset performed start index is: " + newStartIndex); + getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false); + } + + loadItemsForStatus(newStartIndex, limit, serverStartIndex); + + } + + /** + * Load items for status. + * + * @param recordType the record type + */ + public void loadItemsForStatus(RECORD_TYPE recordType) { + this.recordType = recordType; + getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false); + loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true); + } + + /** + * Sets the new page result. + * + * @param result the new new page result + */ + private void setNewPageResult(SearchedData result) { + GWT.log("setNewPageResult: " + result); + serverStartIndex = result.getServerEndIndex(); + SelectionModel sm = getCellTable().getSelectionModel(); + + if (sm instanceof SingleSelectionModel) { + SingleSelectionModel ssm = (SingleSelectionModel) sm; + ssm.clear(); + } else if (sm instanceof MultiSelectionModel) { + MultiSelectionModel msm = (MultiSelectionModel) sm; + msm.clear(); + } + + getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true); + getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData()); + + if (result.getData().size() == 0) { + getCellTable().setLoadingIndicator(new Label("No data")); + } else { + getCellTable().setLoadingIndicator(orginalLoadingIndicator); + } + + GWT.log("Updating row data startIndex: " + result.getClientStartIndex() + " children size: " + + result.getData().size()); + GWT.log("getAsycnDataProvider().getDataDisplays().size(): " + getCellTable().getRowCount()); + + if (result.isServerSearchFinished()) { + GWT.log("Search finished!!!"); + getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true); + } + // initFirstRangeChanged = false; + + } + + /** + * Load items for status. + * + * @param the generic type + * @param offset the offset + * @param limit the limit + * @param serverIndex the server index + */ + private void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) { + showLoading(true); + + GWT.log("calling getDataForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit + + ", serverIndex:" + serverIndex + "]"); + + GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + showLoading(false); + + } + + @Override + public void onSuccess(SearchedData result) { + showLoading(false); + setNewPageResult(result); + + } + }); + + } + + /** + * Select items. + * + * @param select the select + * @param limitToPage the limit to page + */ + public void selectItems(boolean select, boolean limitToPage) { + SortedCellTable table = getCellTable(); + int rowSize = table.getVisibleItemCount(); + + for (int i = 0; i < rowSize; i++) { + ConcessioneDV item = table.getVisibleItem(i); + itemsTable.getSelectionModel().setSelected(item, select); + } + } + + /** + * Gets the select items. + * + * @return the select items + */ + public List getSelectItems() { + return itemsTable.getSelectedItems(); + } + + /** + * A custom {@link AsyncDataProvider}. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 5, 2017 + * @param the generic type + */ + public class MyCustomDataProvider extends AsyncDataProvider { + + /** + * {@link #onRangeChanged(HasData)} is called when the table requests a new + * range of data. You can push data back to the displays using + * {@link #updateRowData(int, List)}. + * + * @param display the display + */ + @Override + public void onRangeChanged(HasData display) { + + // Get the new range. + final Range range = display.getVisibleRange(); + + int start = range.getStart(); + int length = range.getLength(); + + if (initClassFirstRangeChanged) { + GWT.log("initClassFirstRangeChanged is true.. returning"); + initClassFirstRangeChanged = false; + return; + } + GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); + loadNewPage(start, length, false); + //eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); + + } + + } + +} 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/form/GeonaDataEntryMainForm.java similarity index 98% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.java index 43427af..033575d 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/form/GeonaDataEntryMainForm.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataentry.client.ui; +package org.gcube.portlets.user.geoportaldataentry.client.ui.form; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.ui.xml similarity index 100% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaDataEntryMainForm.ui.xml rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/form/GeonaDataEntryMainForm.ui.xml diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java new file mode 100644 index 0000000..37d50b5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java @@ -0,0 +1,204 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.table; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.gcube.portlets.user.geoportaldataentry.client.events.ClickItemEvent; + +import com.github.gwtbootstrap.client.ui.Pagination; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.core.shared.GWT; +import com.google.gwt.dom.client.Style.BorderStyle; +import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.event.dom.client.ContextMenuHandler; +import com.google.gwt.event.dom.client.DoubleClickEvent; +import com.google.gwt.event.dom.client.DoubleClickHandler; +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.MenuBar; +import com.google.gwt.user.client.ui.MenuItem; +import com.google.gwt.view.client.AbstractDataProvider; +import com.google.gwt.view.client.AsyncDataProvider; +import com.google.gwt.view.client.DefaultSelectionEventManager; +import com.google.gwt.view.client.ListDataProvider; +import com.google.gwt.view.client.MultiSelectionModel; +import com.google.gwt.view.client.SelectionChangeEvent; +import com.google.gwt.view.client.SelectionChangeEvent.Handler; +import com.google.gwt.view.client.SelectionModel; +import com.google.gwt.view.client.SingleSelectionModel; + + +/** + * The Class AbstractItemsCellTable. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 11, 2017 + * @param the generic type + */ +public abstract class AbstractItemsCellTable { + + protected SortedCellTable sortedCellTable; + protected T itemContextMenu = null; + protected boolean fireEventOnClick = true; + protected SelectionModel theSelectionModel; + protected HandlerManager eventBus; + + /** + * Inits the table. + * + * @param pager the pager + * @param pagination the pagination + * @param dataProvider the data provider + */ + public abstract void initTable(final SimplePager pager, final Pagination pagination, + AbstractDataProvider dataProvider); + + /** + * Inits the abstract table. + * + * @param eventBus the event bus + * @param fireOnClick the fire on click + * @param dataProvider the data provider + * @param selectionModel the selection model + * @param pageSize the page size + */ + protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider dataProvider, + SelectionModel selectionModel, int pageSize) { + this.eventBus = eventBus; + this.fireEventOnClick = fireOnClick; + this.theSelectionModel = selectionModel; + sortedCellTable = new SortedCellTable(pageSize, dataProvider); +// sortedCellTable.addStyleName("table-cms-widget"); +// sortedCellTable.addStyleName("table-cms-widget-vertical-middle"); + sortedCellTable.setStriped(true); + sortedCellTable.setCondensed(true); + sortedCellTable.setWidth("100%", true); +// dataProvider.addDataDisplay(sortedCellTable); +// initTable(cellTable, null, null); + //sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); + + DefaultSelectionEventManager checkBoxManager = DefaultSelectionEventManager. createCheckboxManager(); + sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager); + + theSelectionModel.addSelectionChangeHandler(new Handler() { + @Override + public void onSelectionChange(final SelectionChangeEvent event) { + + if (theSelectionModel instanceof SingleSelectionModel) { + SingleSelectionModel ssm = (SingleSelectionModel) theSelectionModel; + final T selectedObject = ssm.getSelectedObject(); + if (selectedObject != null) { + GWT.log("Clicked: " + selectedObject); +// selectedItem(selectedObject); + if (fireEventOnClick) + AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent(Arrays.asList(selectedObject))); + } + }else if (theSelectionModel instanceof MultiSelectionModel) { + Set selected = ((MultiSelectionModel) theSelectionModel).getSelectedSet(); + GWT.log("Selected are:" +selected); + if (fireEventOnClick) + AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent(new ArrayList(selected))); + } + } + }); + + sortedCellTable.addDomHandler(new DoubleClickHandler() { + + @Override + public void onDoubleClick(final DoubleClickEvent event) { + if (theSelectionModel instanceof SingleSelectionModel) { + SingleSelectionModel ssm = (SingleSelectionModel) theSelectionModel; + T selected = ssm.getSelectedObject(); + if (selected != null) { + GWT.log("Double Click: " + selected); + // AbstractItemsCellTable.this.eventBus.fireEvent(new + // org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent(selected)); + } + } + + } + }, DoubleClickEvent.getType()); + + MenuBar options = new MenuBar(true); + ScheduledCommand openCommand = new ScheduledCommand() { + + @Override + public void execute() { + GWT.log("Context menu shown: " + itemContextMenu); + // AbstractItemsCellTable.this.eventBus.fireEvent(new + // org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent(itemContextMenu)); + } + }; + + MenuItem openItem = new MenuItem("Open", openCommand); + options.addItem(openItem); + final DialogBox menuWrapper = new DialogBox(true); + menuWrapper.getElement().getStyle().setBorderStyle(BorderStyle.NONE); + menuWrapper.getElement().getStyle().setZIndex(10000); + menuWrapper.add(options); + sortedCellTable.sinkEvents(Event.ONCONTEXTMENU); + + sortedCellTable.addHandler(new ContextMenuHandler() { + @Override + public void onContextMenu(ContextMenuEvent event) { + } + }, ContextMenuEvent.getType()); + + } + + /** + * Gets the cell tables. + * + * @return the cell tables + */ + public SortedCellTable getCellTable() { + return sortedCellTable; + } + + /** + * Checks if is fire event on click. + * + * @return the fireEventOnClick + */ + public boolean isFireEventOnClick() { + + return fireEventOnClick; + } + + /** + * Sets the fire event on click. + * + * @param fireEventOnClick the fireEventOnClick to set + */ + public void setFireEventOnClick(boolean fireEventOnClick) { + + this.fireEventOnClick = fireEventOnClick; + } + + /** + * Adds the items. + * + * @param items the items + */ + public void addItems(List items) { + + AbstractDataProvider dataProvider = sortedCellTable.getDataProvider(); + + if (dataProvider instanceof ListDataProvider) { + List ldp = ((ListDataProvider) dataProvider).getList(); + for (int i = 0; i < items.size(); i++) { + ldp.add(i, items.get(i)); + } + + sortedCellTable.setPageSize(items.size() + 1); + sortedCellTable.redraw(); + } else if (dataProvider instanceof AsyncDataProvider) { + + // TODO ??? + + } + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java new file mode 100644 index 0000000..4b8f96c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -0,0 +1,516 @@ +/** + * + */ +package org.gcube.portlets.user.geoportaldataentry.client.ui.table; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.events.ShowItemEvent; + +import com.github.gwtbootstrap.client.ui.Pagination; +import com.google.gwt.cell.client.ButtonCell; +import com.google.gwt.cell.client.DateCell; +import com.google.gwt.cell.client.FieldUpdater; +import com.google.gwt.core.shared.GWT; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.user.cellview.client.ColumnSortEvent; +import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo; +import com.google.gwt.user.cellview.client.SimplePager; +import com.google.gwt.user.cellview.client.TextColumn; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.view.client.AbstractDataProvider; +import com.google.gwt.view.client.ListDataProvider; +import com.google.gwt.view.client.MultiSelectionModel; +import com.google.gwt.view.client.SelectionModel; +import com.google.gwt.view.client.SingleSelectionModel; + +/** + * The Class ItemsTable. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2021 + * @param the generic type + */ +public class ItemsTable extends AbstractItemsCellTable { + + private static final int ITEMS_PER_PAGE = 10; + private static final String NO_DATA = "No data"; + private TextColumn name; + private TextColumn introduction; + private TextColumn author; + public static DateTimeFormat dtformat = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT); + + private AbstractDataProvider dataProvider; + + /** + * The Enum DISPLAY_FIELD. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 + */ + public static enum DISPLAY_FIELD { + NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE + }; + + private List displayFields; + private Column startProjectDateColumn; + private Column endProjectDateColumn; + private DISPLAY_FIELD startSortByColumn; + private boolean isAsyncronusTable; + + /** + * Instantiates a new items table. + * + * @param eventBus the event bus + * @param fields the fields + * @param startSortByColumn the start sort by column + */ + public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields, DISPLAY_FIELD startSortByColumn) { + this.eventBus = eventBus; + this.startSortByColumn = startSortByColumn; + setDisplayFields(fields); + } + + /** + * Adds the items. + * + * @param items the items + */ + public void addItems(List items) { + super.addItems(items); + } + + /** + * Inits the table. + * + * @param pager the pager + * @param pagination the pagination + * @param dataProvider the data provider + */ + @Override + public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider dataProvider) { + this.dataProvider = dataProvider; + this.theSelectionModel = new SingleSelectionModel(); + initAbstractTable(eventBus, fireEventOnClick, dataProvider, theSelectionModel, ITEMS_PER_PAGE); + this.dataProvider.addDataDisplay(sortedCellTable); + + this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; + setEmptyTableMessage(NO_DATA); + +// final CheckboxCell cellCheckBox = new CheckboxCell(true, false); +// Column checkColumn = new Column(cellCheckBox) { +// @Override +// public Boolean getValue(T object) { +// // Get the value from the selection model. +// return theSelectionModel.isSelected(object); +// } +// +// @Override +// public void render(Context context, T object, SafeHtmlBuilder sb) { +// super.render(context, object, sb); +// GWT.log("added checkbox: " + cellCheckBox + " to object: " + object); +// } +// +// }; +// +// sortedCellTable.addColumn(checkColumn, "", false); +// sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX); + + ButtonCell previewButton = new ButtonCell(); + Column showdItemColumn = new Column(previewButton) { + public String getValue(T object) { + return "Show"; + } + }; + + showdItemColumn.setFieldUpdater(new FieldUpdater() { + @Override + public void update(int index, T object, String value) { + GWT.log("clicked show"); + eventBus.fireEvent(new ShowItemEvent(Arrays.asList(object))); + } + }); + sortedCellTable.addColumn(showdItemColumn); + sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX); + + if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { + + // NAME + name = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + return ((ConcessioneDV) object).getNome(); + } + + // ADDING TOOLTIP + @Override + public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) { + if (object == null) + return; + sb.appendHtmlConstant("
"); + super.render(context, object, sb); + sb.appendHtmlConstant("
"); + }; + }; + + sortedCellTable.addColumn(name, "Name", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + return ((ConcessioneDV) o1).getNome().compareTo(((ConcessioneDV) o2).getNome()); + } + }; + + sortedCellTable.setComparator(name, c); + } + + } + + if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) { + + introduction = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + return ((ConcessioneDV) object).getIntroduzione() != null + ? ((ConcessioneDV) object).getIntroduzione() + : ""; + } + }; + + sortedCellTable.addColumn(introduction, "Intro", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + return ((ConcessioneDV) o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione()); + } + }; + sortedCellTable.setComparator(introduction, c); + } + + } + + if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { + + author = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + + String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors()); + return toDisplay; + } + }; + + sortedCellTable.addColumn(author, "Author/s", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + String toDisplay1 = toDisplayAuthors(((ConcessioneDV) o1).getAuthors()); + String toDisplay2 = toDisplayAuthors(((ConcessioneDV) o2).getAuthors()); + return toDisplay1.compareTo(toDisplay2); + } + }; + sortedCellTable.setComparator(author, c); + } + + } + + if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { + + DateCell date = new DateCell(dtformat); + startProjectDateColumn = new Column(date) { + + @Override + public Date getValue(T object) { + if (object == null) + return null; + + return (((ConcessioneDV) object).getDataInizioProgetto()); + } + }; + sortedCellTable.addColumn(startProjectDateColumn, "Project Start Date", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + if (o1 == null) + return -1; + + if (o2 == null) + return 1; + + Date d1 = (((ConcessioneDV) o1).getDataInizioProgetto()); + Date d2 = (((ConcessioneDV) o2).getDataInizioProgetto()); + + // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1)); + + if (d1.after(d2)) + return 1; + else + return -1; + } + }; + GWT.log("date colum sortable"); + sortedCellTable.setComparator(startProjectDateColumn, c); + } + + } + + if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) { + + DateCell date = new DateCell(dtformat); + endProjectDateColumn = new Column(date) { + + @Override + public Date getValue(T object) { + if (object == null) + return null; + + return (((ConcessioneDV) object).getDataFineProgetto()); + } + }; + sortedCellTable.addColumn(startProjectDateColumn, "Project End Date", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + if (o1 == null) + return -1; + + if (o2 == null) + return 1; + + Date d1 = (((ConcessioneDV) o1).getDataFineProgetto()); + Date d2 = (((ConcessioneDV) o2).getDataFineProgetto()); + + // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1)); + + if (d1.after(d2)) + return 1; + else + return -1; + } + }; + GWT.log("date colum sortable"); + sortedCellTable.setComparator(endProjectDateColumn, c); + } + + } + + GWT.log("startSortByColumn: " + startSortByColumn); + + if (startSortByColumn != null) + switch (startSortByColumn) { + case NAME: + if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { + sortedCellTable.setInitialSortColumn(name); + } + break; + case INTRO: + if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) { + sortedCellTable.setInitialSortColumn(introduction); + } + break; + case AUTHOR: + if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { + sortedCellTable.setInitialSortColumn(author); + } + break; + case PROJECT_START_DATE: + if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { + sortedCellTable.setDefaultSortOrder(startProjectDateColumn, false); // sorts ascending on first + // click + sortedCellTable.setInitialSortColumn(startProjectDateColumn); + GWT.log("sortedCellTable: " + sortedCellTable); + } + break; + case PROJECT_END_DATE: + if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { + sortedCellTable.setDefaultSortOrder(endProjectDateColumn, false); // sorts ascending on first click + sortedCellTable.setInitialSortColumn(endProjectDateColumn); + GWT.log("sortedCellTable: " + sortedCellTable); + } + break; + default: + break; + } + + } + +// /** +// * To date format string. +// * +// * @param dateTime the date time +// * @return the string +// */ +// public static Date toDisplayDate(Date dateTime) { +// +// if(dateTime==null) +// return null; +// +// return new Date(dtformat.format(dateTime)); +// } + + private String toDisplayAuthors(List authors) { + String toDisplay = ""; + if (authors == null) + return toDisplay; + + for (String author : authors) { + toDisplay += author + "; "; + } + return toDisplay; + } + + /** + * Displays the appropriate sorted icon in the header of the column for the + * given index. + * + * @param columnIndex of the column to mark as sorted + * @param ascending true for ascending icon, false + * for descending icon + */ + public void setSortedColumn(int columnIndex, boolean ascending) { + GWT.log("Column index: " + columnIndex); + GWT.log("ascending: " + ascending); + Column column = sortedCellTable.getColumn(columnIndex); + if (column != null && column.isSortable()) { + ColumnSortInfo info = sortedCellTable.getColumnSortList().push(column); +// ColumnSortEvent.fire(cellTable, cellTable.getColumnSortList()); + GWT.log("info.isAscending(): " + info.isAscending()); + if (info.isAscending() != ascending) { + sortedCellTable.getColumnSortList().push(column); + ColumnSortEvent.fire(sortedCellTable, sortedCellTable.getColumnSortList()); + } + } + } + + /** + * Sets the display fields. + * + * @param fields the new display fields + */ + public void setDisplayFields(DISPLAY_FIELD[] fields) { + this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields) + : Arrays.asList(DISPLAY_FIELD.values()); + } + + /** + * Reset columns table. + */ + public void reInitColumnsTable() { + int count = sortedCellTable.getColumnCount(); + for (int i = 0; i < count; i++) { + sortedCellTable.removeColumn(0); + } + initTable(null, null, dataProvider); + } + + /** + * Gets the display fields. + * + * @return the displayFields + */ + public List getDisplayFields() { + return displayFields; + } + + /** + * The Class ButtonImageCell. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 + */ + public class ButtonImageCell extends ButtonCell { + + /** + * Render. + * + * @param context the context + * @param value the value + * @param sb the sb + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.cell.client.AbstractSafeHtmlCell#render(com.google.gwt.cell. + * client.Cell.Context, java.lang.Object, + * com.google.gwt.safehtml.shared.SafeHtmlBuilder) + */ + @Override + public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) { + SafeHtml html = SafeHtmlUtils.fromTrustedString(new Image(value).toString()); + sb.append(html); + } + } + + /** + * Gets the selected item. + * + * @return the selected item + */ + public List getSelectedItems() { + if (theSelectionModel instanceof SingleSelectionModel) { + T selected = ((SingleSelectionModel) theSelectionModel).getSelectedObject(); + if (selected != null) { + return Arrays.asList(selected); + } + + } else if (theSelectionModel instanceof MultiSelectionModel) { + Set selected = ((MultiSelectionModel) theSelectionModel).getSelectedSet(); + if (selected != null) { + return new ArrayList(selected); + } + } + + return null; + } + + /** + * Sets the empty table message. + * + * @param msg the new empty table message + */ + public void setEmptyTableMessage(String msg) { + msg = msg != null ? msg : NO_DATA; + if (sortedCellTable != null) + sortedCellTable.setEmptyTableWidget(new Label(msg)); + } + + /** + * Gets the selection model. + * + * @return the selection model + */ + public SelectionModel getSelectionModel() { + return theSelectionModel; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java new file mode 100644 index 0000000..1de211f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java @@ -0,0 +1,83 @@ +/** + * + */ + +package org.gcube.portlets.user.geoportaldataentry.client.ui.table; + +import com.google.gwt.cell.client.Cell; +import com.google.gwt.cell.client.Cell.Context; +import com.google.gwt.core.client.GWT; +import com.google.gwt.safehtml.client.SafeHtmlTemplates; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.cellview.client.Column; + + +/** + * The Class MyToolTipColumn. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2021 + * @param the generic type + * @param the generic type + */ +public abstract class MyToolTipColumn extends Column { + + /** + * The Interface Templates. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2021 + */ + interface Templates extends SafeHtmlTemplates { + + /** + * Start tool tip. + * + * @param toolTipText the tool tip text + * @return the safe html + */ + @Template("
") + SafeHtml startToolTip(String toolTipText); + + /** + * End tool tip. + * + * @return the safe html + */ + @Template("
") + SafeHtml endToolTip(); + } + + private static final Templates TEMPLATES = GWT.create(Templates.class); + private final String toolTipText; + + /** + * Instantiates a new my tool tip column. + * + * @param cell the cell + * @param toolTipText the tool tip text + */ + public MyToolTipColumn(final Cell cell, final String toolTipText) { + + super(cell); + this.toolTipText = toolTipText; + } + + /** + * Render. + * + * @param context the context + * @param object the object + * @param sb the sb + */ + @Override + public void render(final Context context, final T object, final SafeHtmlBuilder sb) { + + sb.append(TEMPLATES.startToolTip(toolTipText)); + super.render(context, object, sb); + sb.append(TEMPLATES.endToolTip()); + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java new file mode 100644 index 0000000..66f82d1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java @@ -0,0 +1,302 @@ +/** + * + */ + +package org.gcube.portlets.user.geoportaldataentry.client.ui.table; + +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.portlets.user.geoportaldataentry.client.resource.CellTableResources; + +import com.github.gwtbootstrap.client.ui.CellTable; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.user.cellview.client.ColumnSortEvent; +import com.google.gwt.user.cellview.client.ColumnSortEvent.AsyncHandler; +import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; +import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo; +import com.google.gwt.user.cellview.client.Header; +import com.google.gwt.view.client.AbstractDataProvider; +import com.google.gwt.view.client.AsyncDataProvider; +import com.google.gwt.view.client.ListDataProvider; + +/** + * The Class SortedCellTable. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2021 + * @param the generic type + */ +public class SortedCellTable extends CellTable { + + /** + * To keep track of the currently sorted column + */ + private Column currentlySortedColumn; + /** + * Tells us which way to sort a column initially + */ + private Map, Boolean> defaultSortOrderMap = new HashMap, Boolean>(); + /** + * Comparators associated with their columns + */ + private Map, Comparator> comparators = new HashMap, Comparator>(); + /** + * Column to sort when the data provider's list is refreshed using + * {@link SortedCellTable#setList(List)} + */ + private Column initialSortColumn; + /** + * Data provider we will attach to this table + */ + private AbstractDataProvider dataProvider; + + /** + * Special column sorting handler that will allow us to do more controlled + * sorting + */ + private ColumnSortEvent.Handler columnSortHandler; + + /** + * Instantiates a new sorted cell table. + * + * @param pageSize the page size + * @param dataProv the data prov + */ + public SortedCellTable(int pageSize, AbstractDataProvider dataProv) { + super(pageSize, CellTableResources.INSTANCE); + this.dataProvider = dataProv; + + if (this.dataProvider instanceof ListDataProvider) { + ListDataProvider listDataProvider = (ListDataProvider) this.dataProvider; + ListHandler listSortHandler = new ListHandler((listDataProvider).getList()) { + + @Override + public void onColumnSort(ColumnSortEvent event) { + + @SuppressWarnings("unchecked") + Column column = (Column) event.getColumn(); + if (column == null) { + return; + } + if (column.equals(currentlySortedColumn)) { + // Default behavior + super.onColumnSort(event); + } else { + // Initial sort; look up which direction we need + final Comparator comparator = comparators.get(column); + if (comparator == null) { + return; + } + Boolean ascending = defaultSortOrderMap.get(column); + if (ascending == null || ascending) { + // Default behavior + super.onColumnSort(event); + } else { + // Sort the column descending + Collections.sort(getList(), new Comparator() { + + public int compare(T o1, T o2) { + + return -comparator.compare(o1, o2); + } + }); + // Set the proper arrow in the header + getColumnSortList().push(new ColumnSortInfo(column, false)); + } + currentlySortedColumn = column; + } + } + + @Override + public void setComparator(Column column, Comparator comparator) { + + comparators.put(column, comparator); + super.setComparator(column, comparator); + } + }; + addColumnSortHandler(listSortHandler); + columnSortHandler = listSortHandler; + } else if (this.dataProvider instanceof AsyncDataProvider) { + //AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) this.dataProvider); + //asyncDataProvider.get + AsyncHandler asyncSortHandler = new AsyncHandler(this) { + @Override + public void onColumnSort(ColumnSortEvent event) { + + @SuppressWarnings("unchecked") + Column column = (Column) event.getColumn(); + if (column == null) { + return; + } + if (column.equals(currentlySortedColumn)) { + // Default behavior + super.onColumnSort(event); + } else { + // Initial sort; look up which direction we need + final Comparator comparator = comparators.get(column); + if (comparator == null) { + return; + } + Boolean ascending = defaultSortOrderMap.get(column); + if (ascending == null || ascending) { + // Default behavior + super.onColumnSort(event); + } else { + // Sort the column descending + Collections.sort(getVisibleItems(), new Comparator() { + + public int compare(T o1, T o2) { + + return -comparator.compare(o1, o2); + } + }); + // Set the proper arrow in the header + getColumnSortList().push(new ColumnSortInfo(column, false)); + } + currentlySortedColumn = column; + } + } + }; + +// addColumnSortHandler(asyncSortHandler); +// columnSortHandler = asyncSortHandler; + } + + } + + /** + * Adds a column to the table and sets its sortable state. + * + * @param column the column + * @param headerName the header name + * @param sortable the sortable + */ + public void addColumn(Column column, String headerName, boolean sortable) { + + addColumn(column, headerName); + column.setSortable(sortable); + if (sortable) { + defaultSortOrderMap.put(column, true); + } + } + + /** + * Adds the column. + * + * @param column the column + * @param headerName the header name + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.user.cellview.client.AbstractCellTable#addColumn(com.google. + * gwt.user.cellview.client.Column, java.lang.String) + */ + public void addColumn(Column column, String headerName) { + + super.addColumn(column, headerName); + } + + /** + * Adds a column to the table and sets its sortable state. + * + * @param column the column + * @param header the header + * @param sortable the sortable + */ + public void addColumn(Column column, Header header, boolean sortable) { + + addColumn(column, header); + column.setSortable(sortable); + if (sortable) { + defaultSortOrderMap.put(column, true); + } + } + + /** + * Sets the column to sort when the data list is reset using + * {@link SortedCellTable#setList(List)}. + * + * @param column the column + */ + public void setInitialSortColumn(Column column) { + + initialSortColumn = column; + } + + /** + * Set the comparator used to sort the specified column in ascending order. + * + * @param column the {@link Column} + * @param comparator the {@link Comparator} to use for the {@link Column} + */ + public void setComparator(Column column, Comparator comparator) { + comparators.put(column, comparator); + } + + /** + * Sets the sort order to use when this column is clicked and it was not + * previously sorted. + * + * @param column the column + * @param ascending the ascending + */ + public void setDefaultSortOrder(Column column, boolean ascending) { + + defaultSortOrderMap.put(column, ascending); + } + + /** + * Sets the table's data provider list and sorts the table based on the column + * given in {@link SortedCellTable#setInitialSortColumn(Column)}. + * + * @param list the new list + */ + public void setList(List list) { + + if (dataProvider instanceof ListDataProvider) { + List myData = ((ListDataProvider) dataProvider).getList(); + myData.clear(); + if (list != null) { + /* + * for (T t : list) { dataProvider.getList().add(t); } + */ + myData.addAll(list); + } + // Do a first-time sort based on which column was set in + // setInitialSortColumn() + if (initialSortColumn != null) { + Collections.sort(myData, new Comparator() { + + @Override + public int compare(T o1, T o2) { + + return (defaultSortOrderMap.get(initialSortColumn) ? 1 : -1) + * comparators.get(initialSortColumn).compare(o1, o2); + } + }); + // Might as well get the little arrow on the header to make it + // official + getColumnSortList().push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn))); + + currentlySortedColumn = initialSortColumn; + } + } + } + + /** + * Gets the data provider. + * + * @return the data provider + */ + public AbstractDataProvider getDataProvider() { + + return dataProvider; + } +} 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 5cbd991..d5c9342 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 @@ -14,14 +14,17 @@ import org.gcube.application.geoportal.common.model.legacy.report.ValidationRepo import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; +import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.vomanagement.usermanagement.model.GCubeUser; @@ -393,50 +396,83 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gc = new GeoportalCommon(); - GeoNaItemRef item = new GeoNaItemRef(itemId, recordType); + GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toLowerCase()); item = gc.getPublicLinksFor(item); LOG.info("Returning: " + item); return item; } /** - * Gets the links for. + * Gets the list concessioni. * - * @param itemId the item id - * @param recordType the record type - * @return the links for + * @param start the start + * @param offset the offset + * @return the list concessioni * @throws Exception the exception */ - // @Override - public void getListConcessioni(Integer start, Integer offset) throws Exception { - LOG.info("getListConcessioni called"); + @Override + public SearchedData getListConcessioni(Integer start, Integer limit) throws Exception { + LOG.info("getListConcessioni called wit start: "+start + ", limit: "+limit); try { List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest()); - int maxOffset = listOfConcessioni.size(); + int listConcessioniSize = listOfConcessioni.size(); + List toReturn = new ArrayList(); - if(start==null && offset==null) { + int startIndex; + int limitIndex = 0; + if (start == null && limit == null) { toReturn.addAll(listOfConcessioni); - } - if(start<0) - start=0; - - if(offset>maxOffset) - offset = maxOffset; - - toReturn.subList(start, offset); - - for (Concessione concessione : toReturn) { + startIndex = 0; + limitIndex = listConcessioniSize; + }else { +// if (start < 0) +// start = 0; +// +// if (start > listConcessioniSize) +// start = listConcessioniSize; +// +// if (limit > listConcessioniSize) +// limit = listConcessioniSize; + startIndex = start; + limitIndex = start + limit; + if(limitIndex>listConcessioniSize) { + limitIndex = listConcessioniSize; + } } - // TODO - //LOG.info("Returning: " + concessioni); - }catch (Exception e) { + + SearchedData searchedData = new SearchedData(start, limit, startIndex, false); + searchedData.setTotalItems(listConcessioniSize); + + + toReturn = listOfConcessioni.subList(startIndex, limitIndex); + + List toReturnList = new ArrayList(toReturn.size()); + + for (Concessione concessione : toReturn) { + ConcessioneDV concessioneDV = ConvertToDataViewModel.toBaseConcessione(concessione); + toReturnList.add(concessioneDV); + } + + searchedData.setData(toReturnList); + + if (listConcessioniSize == limit || listConcessioniSize == 0) { + LOG.debug("Page completed returning " + listConcessioniSize + " items"); + int newOffset = startIndex + start; + searchedData.setServerSearchFinished(newOffset > listConcessioniSize || listConcessioniSize == 0); + LOG.debug("is Search finished: " + searchedData.isServerSearchFinished()); + return searchedData; + } + + LOG.debug("Returning: " + toReturnList); + LOG.info("Returning list of concessioni with size: " + toReturnList.size()); + return searchedData; + } catch (Exception e) { LOG.error("Error on loading list of concessioni: ", e); throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage()); } - } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 97f065b..3a06bde 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -4,6 +4,7 @@ package org.gcube.portlets.user.geoportaldataentry.server; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -130,24 +131,27 @@ public class SessionUtil { public static List getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception { HttpSession session = httpServletRequest.getSession(); List listOfConcessioni = (List) session.getAttribute(LIST_OF_CONCESSIONI); - List result = new ArrayList(); - if (listOfConcessioni == null) { + listOfConcessioni = new ArrayList(); LOG.info("Loading list of concessione from client mongo"); SessionUtil.getCurrentContext(httpServletRequest, true); ServiceUtil serviceUtil = new ServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); - Iterable concessioni = clientMongo.getList(); + Iterator concessioni = clientMongo.getList(); if (concessioni != null) { - for (Concessione conc : concessioni) { - result.add(conc); + while (concessioni.hasNext()) { + Concessione concessione = (Concessione) concessioni.next(); + listOfConcessioni.add(concessione); + } } - LOG.debug("Got list of concessione from client mongo: "+result); - session.setAttribute(LIST_OF_CONCESSIONI, result); - LOG.info("Saved in session list of concessione from client mongo with size: "+result.size()); - } - LOG.info("returning list of concessioni with size: "+result.size()); - return result; + LOG.debug("Got list of concessioni from client mongo: "+listOfConcessioni); + session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni); + LOG.info("Saved in session list of concessioni from client mongo with size: "+listOfConcessioni.size()); + }else + LOG.info("list of concessioni presents in session"); + + LOG.info("read list of concessioni with size: "+listOfConcessioni.size()); + return listOfConcessioni; } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java new file mode 100644 index 0000000..f9bb70c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java @@ -0,0 +1,183 @@ +/** + * + */ +package org.gcube.portlets.user.geoportaldataentry.shared; + +import java.io.Serializable; +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; + + +/** + * The Class SearchedFolder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 16, 2021 + */ +public class SearchedData implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 6800997954077785719L; + private List data; + private int clientStartIndex = 0; + private int limit; + private int serverEndIndex = 0; + private boolean isServerSearchFinished = false; + private long totalItems; + + /** + * Instantiates a new searched folder. + */ + public SearchedData() { + } + + /** + * Instantiates a new searched data. + * + * @param clientStartIndex the client start index + * @param limit the limit + * @param serverEndIndex the server end index + * @param isServerSearchFinished the is server search finished + */ + public SearchedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) { + + this.clientStartIndex = clientStartIndex; + this.limit = limit; + this.serverEndIndex = serverEndIndex; + this.isServerSearchFinished = isServerSearchFinished; + } + + /** + * Gets the data. + * + * @return the data + */ + public List getData() { + return data; + } + + /** + * Gets the client start index. + * + * @return the client start index + */ + public int getClientStartIndex() { + return clientStartIndex; + } + + /** + * Gets the limit. + * + * @return the limit + */ + public int getLimit() { + return limit; + } + + /** + * Gets the server end index. + * + * @return the server end index + */ + public int getServerEndIndex() { + return serverEndIndex; + } + + /** + * Checks if is server search finished. + * + * @return true, if is server search finished + */ + public boolean isServerSearchFinished() { + return isServerSearchFinished; + } + + /** + * Sets the data. + * + * @param data the new data + */ + public void setData(List data) { + this.data = data; + } + + /** + * Sets the client start index. + * + * @param clientStartIndex the new client start index + */ + public void setClientStartIndex(int clientStartIndex) { + this.clientStartIndex = clientStartIndex; + } + + /** + * Sets the limit. + * + * @param limit the new limit + */ + public void setLimit(int limit) { + this.limit = limit; + } + + /** + * Sets the server end index. + * + * @param serverEndIndex the new server end index + */ + public void setServerEndIndex(int serverEndIndex) { + this.serverEndIndex = serverEndIndex; + } + + /** + * Sets the server search finished. + * + * @param isServerSearchFinished the new server search finished + */ + public void setServerSearchFinished(boolean isServerSearchFinished) { + this.isServerSearchFinished = isServerSearchFinished; + } + + /** + * Gets the total items. + * + * @return the total items + */ + public long getTotalItems() { + return totalItems; + } + + /** + * Sets the total items. + * + * @param totalItems the new total items + */ + public void setTotalItems(long totalItems) { + this.totalItems = totalItems; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("SearchedData [data="); + builder.append(data); + builder.append(", clientStartIndex="); + builder.append(clientStartIndex); + builder.append(", limit="); + builder.append(limit); + builder.append(", serverEndIndex="); + builder.append(serverEndIndex); + builder.append(", isServerSearchFinished="); + builder.append(isServerSearchFinished); + builder.append(", totalItems="); + builder.append(totalItems); + builder.append("]"); + return builder.toString(); + } + + + +} diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java index 3fefedf..b3d9e17 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataentry/client/TestClass.java @@ -1,31 +1,58 @@ package org.gcube.portlets.user.geoportaldataentry.client; -import java.time.LocalDateTime; +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni; -import org.gcube.portlets.user.geoportaldataentry.server.ConvertToServiceModel; -import org.gcube.portlets.user.geoportaldataentry.server.GeoportalDataEntryServiceImpl; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.rest.MongoConcessioni; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.scope.api.ScopeProvider; public class TestClass { + + + private static String TOKEN = ""; + private static String CONTEXT ="/gcube/devsec/devVRE"; public static void main(String[] args) throws Exception { + ScopeProvider.instance.set(CONTEXT); + SecurityTokenProvider.instance.set(TOKEN); - LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20"); - System.out.println(ldt.toString()); - - String latitudine = "-899.2986"; - //System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$")); - - - String longitude = "0"; - System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$")); - +// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20"); +// System.out.println(ldt.toString()); +// +// String latitudine = "-899.2986"; +// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$")); +// +// String longitude = "0"; +// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$")); +// +// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl(); +// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString()); + getListOfConcessioni(); - GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl(); - g.getLinksFor("", "concessione"); - } - - + + public static void getListOfConcessioni() throws Exception { + MongoConcessioni clientMongo = mongoConcessioni().build(); + Iterator concessioni = clientMongo.getList(); + List listOfConcessioni = new ArrayList(); + if (concessioni != null) { + while (concessioni.hasNext()) { + Concessione concessione = (Concessione) concessioni.next(); + listOfConcessioni.add(concessione); + + } + } + int i = 0; + for (Concessione concessione : listOfConcessioni) { + System.out.println(++i+" "+concessione); + } + } + } From bd49bd6f4e90466ab19ea7f28df7fa905a5e4585 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 5 Aug 2021 11:21:39 +0200 Subject: [PATCH 04/32] fixed "Get list of Concessioni" table --- .../ConstantsGeoPortalDataEntryApp.java | 14 +- .../client/GeoPortalDataEntryApp.java | 8 +- ...wItemEvent.java => ActionOnItemEvent.java} | 24 ++-- ...ler.java => ActionOnItemEventHandler.java} | 14 +- .../client/ui/GeonaMainPanel.java | 43 ++++-- .../client/ui/GeonaMainPanel.ui.xml | 1 + .../client/ui/GeonaRecordsPaginatedView.java | 128 ++++++++++-------- .../ui/table/AbstractItemsCellTable.java | 9 +- .../client/ui/table/ItemsTable.java | 94 ++++++++++--- .../client/ui/table/SortedCellTable.java | 30 ++-- src/main/webapp/GeoPortalDataEntryApp.css | 21 ++- 11 files changed, 252 insertions(+), 134 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/{ShowItemEvent.java => ActionOnItemEvent.java} (59%) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/{ShowItemEventHandler.java => ActionOnItemEventHandler.java} (50%) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 7076afb..be14eb4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -5,17 +5,19 @@ import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; public class ConstantsGeoPortalDataEntryApp { public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT; - + public static final String TIME_FORMAT = ConstantsMPFormBuilder.TIME_FORMAT; - + public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR; - + public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!"; - - + public enum RECORD_TYPE { CONCESSIONE } - + public enum ACTION_ON_ITEM { + SHOW_ON_MAP, SHOW_METADATA, REMOVE + } + } 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 815d042..7bac626 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 @@ -132,6 +132,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { private void buildNewCards(Collection orderedCards) { projectSavedWithSuccess = false; //resetting state of saving + mainPanel.setFormPanelVisible(true); mainPanel.setLoaderVisible("Loading...", true); resetUI(); //ordered values @@ -361,13 +362,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { - - Modal modal = new Modal(true); - modal.setCloseVisible(true); GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME); - modal.add(grpw.getCellPanel()); - modal.add(grpw.getPagerPanel()); - modal.show(); + mainPanel.showListOfConcessioniView(grpw); } }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java similarity index 59% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index fe6afc3..adad262 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -2,27 +2,31 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import java.util.List; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; + import com.google.gwt.event.shared.GwtEvent; /** - * The Class ShowItemEvent. + * The Class ActionOnItemEvent. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Jun 22, 2021 + * Aug 5, 2021 * @param the generic type */ -public class ShowItemEvent extends GwtEvent { - public static Type TYPE = new Type(); +public class ActionOnItemEvent extends GwtEvent { + public static Type TYPE = new Type(); private List selectItems; + private ACTION_ON_ITEM action; /** * Instantiates a new click item event. * * @param selectItems the select items */ - public ShowItemEvent(List selectItems) { + public ActionOnItemEvent(List selectItems, ACTION_ON_ITEM doAction) { this.selectItems = selectItems; + this.action = doAction; } /** @@ -36,7 +40,7 @@ public class ShowItemEvent extends GwtEvent { * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() */ @Override - public Type getAssociatedType() { + public Type getAssociatedType() { return TYPE; } @@ -53,8 +57,8 @@ public class ShowItemEvent extends GwtEvent { * EventHandler) */ @Override - protected void dispatch(ShowItemEventHandler handler) { - handler.onShowItemClicked(this); + protected void dispatch(ActionOnItemEventHandler handler) { + handler.onDoActionFired(this); } /** @@ -65,4 +69,8 @@ public class ShowItemEvent extends GwtEvent { public List getSelectItems() { return selectItems; } + + public ACTION_ON_ITEM getAction() { + return action; + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java similarity index 50% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java index 7713908..1aca514 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ShowItemEventHandler.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java @@ -2,22 +2,20 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import com.google.gwt.event.shared.EventHandler; - -// TODO: Auto-generated Javadoc /** - * The Interface ShowItemEventHandler. + * The Interface ActionOnItemEventHandler. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Jun 22, 2021 + * Aug 5, 2021 */ -public interface ShowItemEventHandler extends EventHandler { +public interface ActionOnItemEventHandler extends EventHandler { /** - * On show item clicked. + * On do action fired. * - * @param the generic type + * @param the generic type * @param showItemEvent the show item event */ - void onShowItemClicked(ShowItemEvent showItemEvent); + void onDoActionFired(ActionOnItemEvent showItemEvent); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java index c3b1db6..652b6bb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java @@ -9,6 +9,7 @@ import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; /** @@ -16,19 +17,22 @@ import com.google.gwt.user.client.ui.Widget; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 13, 2020 + * Oct 13, 2020 */ public class GeonaMainPanel extends Composite { - + /** The geona main form panel. */ @UiField HTMLPanel geonaMainFormPanel; - + + @UiField + HTMLPanel geonaListOfConcessioniPanel; + /** The loader. */ @UiField LoaderIcon loader; - - @UiField + + @UiField GeonaNavigationBar geonaNavigationBar; private HandlerManager appManagerBus; @@ -41,40 +45,57 @@ public class GeonaMainPanel extends Composite { * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 13, 2020 + * Oct 13, 2020 */ interface GeonaMainPanelUiBinder extends UiBinder { } /** * Instantiates a new geona main panel. - * @param appManagerBus + * + * @param appManagerBus */ public GeonaMainPanel(HandlerManager appManagerBus) { initWidget(uiBinder.createAndBindUi(this)); this.appManagerBus = appManagerBus; geonaNavigationBar.setAppManagerBus(appManagerBus); } - + /** * Adds the form panel. * * @param formPanel the form panel */ public void addFormPanel(GeonaDataEntryMainForm formPanel) { + geonaListOfConcessioniPanel.setVisible(false); geonaMainFormPanel.add(formPanel); + geonaMainFormPanel.setVisible(true); } - - + + public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { + setFormPanelVisible(false); + geonaListOfConcessioniPanel.clear(); + VerticalPanel htmllPanel = new VerticalPanel(); + htmllPanel.add(grpw.getCellPanel()); + htmllPanel.add(grpw.getPagerPanel()); + geonaListOfConcessioniPanel.add(htmllPanel); + } + /** * Sets the loader visible. * * @param txtHTML the txt HTML * @param visible the visible */ - public void setLoaderVisible(String txtHTML, boolean visible){ + public void setLoaderVisible(String txtHTML, boolean visible) { loader.setText(txtHTML); loader.setVisible(visible); } + public void setFormPanelVisible(boolean bool) { + geonaMainFormPanel.setVisible(bool); + geonaListOfConcessioniPanel.setVisible(!bool); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml index b8af370..bec763b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml @@ -23,5 +23,6 @@ + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 010307d..8739d92 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -15,6 +15,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.cellview.client.SimplePager; import com.google.gwt.user.cellview.client.SimplePager.TextLocation; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Label; @@ -27,13 +28,12 @@ import com.google.gwt.view.client.Range; import com.google.gwt.view.client.SelectionModel; import com.google.gwt.view.client.SingleSelectionModel; - /** * The Class GeonaRecordsPaginatedView. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 4, 2021 + * Aug 4, 2021 */ public class GeonaRecordsPaginatedView { @@ -50,14 +50,13 @@ public class GeonaRecordsPaginatedView { private HandlerManager eventBus; private RECORD_TYPE recordType; - /** * Instantiates a new geona records paginated view. * - * @param eventbus the eventbus - * @param recordType the record type + * @param eventbus the eventbus + * @param recordType the record type * @param displayFields the display fields - * @param sortByField the sort by field + * @param sortByField the sort by field */ public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField) { @@ -74,11 +73,11 @@ public class GeonaRecordsPaginatedView { } /** - * Gets the asycn data provider. + * Gets the table data provider. * - * @return the asycn data provider + * @return the table data provider */ - public AsyncDataProvider getAsycnDataProvider() { + public AsyncDataProvider getTableDataProvider() { return (AsyncDataProvider) getCellTable().getDataProvider(); } @@ -109,33 +108,6 @@ public class GeonaRecordsPaginatedView { pagerPanel.add(pager); } - /** - * Gets the pager panel. - * - * @return the pager panel - */ - public VerticalPanel getCellPanel() { - return vPanel; - } - - /** - * Set the panel in loading mode. - * - * @param show the show - */ - protected void showLoading(boolean show) { - loadingPanel.setVisible(show); - } - - /** - * Gets the pager panel. - * - * @return the pager panel - */ - public FlowPanel getPagerPanel() { - return pagerPanel; - } - /** * Load new page. * @@ -156,11 +128,10 @@ public class GeonaRecordsPaginatedView { newStartIndex = 0; serverStartIndex = 0; GWT.log("Store reset performed start index is: " + newStartIndex); - getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false); + getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false); } loadItemsForStatus(newStartIndex, limit, serverStartIndex); - } /** @@ -192,8 +163,8 @@ public class GeonaRecordsPaginatedView { msm.clear(); } - getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true); - getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData()); + getTableDataProvider().updateRowCount((int) result.getTotalItems(), true); + getTableDataProvider().updateRowData(result.getClientStartIndex(), result.getData()); if (result.getData().size() == 0) { getCellTable().setLoadingIndicator(new Label("No data")); @@ -207,7 +178,7 @@ public class GeonaRecordsPaginatedView { if (result.isServerSearchFinished()) { GWT.log("Search finished!!!"); - getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true); + getTableDataProvider().updateRowCount(getCellTable().getRowCount(), true); } // initFirstRangeChanged = false; @@ -216,32 +187,34 @@ public class GeonaRecordsPaginatedView { /** * Load items for status. * - * @param the generic type - * @param offset the offset - * @param limit the limit - * @param serverIndex the server index + * @param the generic type + * @param newStartIndex the new start index + * @param limit the limit + * @param serverIndex the server index */ private void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) { showLoading(true); - GWT.log("calling getDataForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit + GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit + ", serverIndex:" + serverIndex + "]"); - GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, new AsyncCallback() { + GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - showLoading(false); + @Override + public void onFailure(Throwable caught) { + showLoading(false); + Window.alert(caught.getMessage()); - } + } - @Override - public void onSuccess(SearchedData result) { - showLoading(false); - setNewPageResult(result); + @Override + public void onSuccess(SearchedData result) { + showLoading(false); + setNewPageResult(result); - } - }); + } + }); } @@ -269,6 +242,9 @@ public class GeonaRecordsPaginatedView { public List getSelectItems() { return itemsTable.getSelectedItems(); } + +// int latestRangeStart = -1; +// int latestRangeLenght = -1; /** * A custom {@link AsyncDataProvider}. @@ -293,6 +269,15 @@ public class GeonaRecordsPaginatedView { int start = range.getStart(); int length = range.getLength(); + +// if(latestRangeStart!=start || latestRangeLenght!=length) { +// GWT.log("ranges really changed"); +// latestRangeStart = start; +// latestRangeLenght = length; +// }else { +// GWT.log("ranges DO NOT changed"); +// return; +// } if (initClassFirstRangeChanged) { GWT.log("initClassFirstRangeChanged is true.. returning"); @@ -301,10 +286,37 @@ public class GeonaRecordsPaginatedView { } GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); loadNewPage(start, length, false); - //eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); + // eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); } } + /** + * Gets the pager panel. + * + * @return the pager panel + */ + public VerticalPanel getCellPanel() { + return vPanel; + } + + /** + * Set the panel in loading mode. + * + * @param show the show + */ + protected void showLoading(boolean show) { + loadingPanel.setVisible(show); + } + + /** + * Gets the pager panel. + * + * @return the pager panel + */ + public FlowPanel getPagerPanel() { + return pagerPanel; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java index 37d50b5..47b11e8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java @@ -71,11 +71,16 @@ public abstract class AbstractItemsCellTable { this.fireEventOnClick = fireOnClick; this.theSelectionModel = selectionModel; sortedCellTable = new SortedCellTable(pageSize, dataProvider); -// sortedCellTable.addStyleName("table-cms-widget"); -// sortedCellTable.addStyleName("table-cms-widget-vertical-middle"); + sortedCellTable.addStyleName("table-glor"); + sortedCellTable.addStyleName("table-glor-vertical-middle"); sortedCellTable.setStriped(true); sortedCellTable.setCondensed(true); sortedCellTable.setWidth("100%", true); + //sortedCellTable.setBordered(true); + + sortedCellTable.setAutoHeaderRefreshDisabled(true); + sortedCellTable.setAutoFooterRefreshDisabled(true); + // dataProvider.addDataDisplay(sortedCellTable); // initTable(cellTable, null, null); //sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 4b8f96c..c226a1b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -12,7 +12,8 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataentry.client.events.ShowItemEvent; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import com.github.gwtbootstrap.client.ui.Pagination; import com.google.gwt.cell.client.ButtonCell; @@ -63,7 +64,7 @@ public class ItemsTable extends AbstractItemsCellTable< * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 */ public static enum DISPLAY_FIELD { - NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE + NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE, INSERTED_BY }; private List displayFields; @@ -71,6 +72,7 @@ public class ItemsTable extends AbstractItemsCellTable< private Column endProjectDateColumn; private DISPLAY_FIELD startSortByColumn; private boolean isAsyncronusTable; + private TextColumn insertedBy; /** * Instantiates a new items table. @@ -130,23 +132,6 @@ public class ItemsTable extends AbstractItemsCellTable< // sortedCellTable.addColumn(checkColumn, "", false); // sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX); - ButtonCell previewButton = new ButtonCell(); - Column showdItemColumn = new Column(previewButton) { - public String getValue(T object) { - return "Show"; - } - }; - - showdItemColumn.setFieldUpdater(new FieldUpdater() { - @Override - public void update(int index, T object, String value) { - GWT.log("clicked show"); - eventBus.fireEvent(new ShowItemEvent(Arrays.asList(object))); - } - }); - sortedCellTable.addColumn(showdItemColumn); - sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX); - if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { // NAME @@ -197,7 +182,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(introduction, "Intro", true); + sortedCellTable.addColumn(introduction, "Introduction", true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -209,6 +194,8 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setComparator(introduction, c); } + // sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT); + } if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { @@ -238,6 +225,8 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setComparator(author, c); } + sortedCellTable.setColumnWidth(author, 220, Unit.PX); + } if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { @@ -280,6 +269,8 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setComparator(startProjectDateColumn, c); } + sortedCellTable.setColumnWidth(startProjectDateColumn, 150, Unit.PX); + } if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) { @@ -322,8 +313,71 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setComparator(endProjectDateColumn, c); } + sortedCellTable.setColumnWidth(endProjectDateColumn, 150, Unit.PX); + } + if (this.displayFields.contains(DISPLAY_FIELD.INSERTED_BY)) { + + // NAME + insertedBy = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + return ((ConcessioneDV) object).getCreationUser(); + } + }; + + sortedCellTable.addColumn(insertedBy, "Inserted by", true); + + if (!isAsyncronusTable) { + Comparator c = new Comparator() { + @Override + public int compare(T o1, T o2) { + return ((ConcessioneDV) o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser()); + } + }; + + sortedCellTable.setComparator(insertedBy, c); + } + sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); + } + + ButtonCell showOnMapButton = new ButtonCell(); + Column showOnMapColumn = new Column(showOnMapButton) { + public String getValue(T object) { + return "Show on Map"; + } + }; + + showOnMapColumn.setFieldUpdater(new FieldUpdater() { + @Override + public void update(int index, T object, String value) { + GWT.log("clicked show"); + eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP)); + } + }); + sortedCellTable.addColumn(showOnMapColumn); + sortedCellTable.setColumnWidth(showOnMapColumn, 120, Unit.PX); + + ButtonCell deleteRecordButton = new ButtonCell(); + Column deleteRecordColumn = new Column(deleteRecordButton) { + public String getValue(T object) { + return "Delete"; + } + }; + + deleteRecordColumn.setFieldUpdater(new FieldUpdater() { + @Override + public void update(int index, T object, String value) { + + eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.REMOVE)); + } + }); + sortedCellTable.addColumn(deleteRecordColumn); + sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX); + GWT.log("startSortByColumn: " + startSortByColumn); if (startSortByColumn != null) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java index 66f82d1..ffefe5d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/SortedCellTable.java @@ -122,8 +122,9 @@ public class SortedCellTable extends CellTable { addColumnSortHandler(listSortHandler); columnSortHandler = listSortHandler; } else if (this.dataProvider instanceof AsyncDataProvider) { - //AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) this.dataProvider); - //asyncDataProvider.get + // AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) + // this.dataProvider); + // asyncDataProvider.get AsyncHandler asyncSortHandler = new AsyncHandler(this) { @Override public void onColumnSort(ColumnSortEvent event) { @@ -162,7 +163,7 @@ public class SortedCellTable extends CellTable { } } }; - + // addColumnSortHandler(asyncSortHandler); // columnSortHandler = asyncSortHandler; } @@ -229,16 +230,16 @@ public class SortedCellTable extends CellTable { initialSortColumn = column; } - - /** - * Set the comparator used to sort the specified column in ascending order. - * - * @param column the {@link Column} - * @param comparator the {@link Comparator} to use for the {@link Column} - */ - public void setComparator(Column column, Comparator comparator) { - comparators.put(column, comparator); - } + + /** + * Set the comparator used to sort the specified column in ascending order. + * + * @param column the {@link Column} + * @param comparator the {@link Comparator} to use for the {@link Column} + */ + public void setComparator(Column column, Comparator comparator) { + comparators.put(column, comparator); + } /** * Sets the sort order to use when this column is clicked and it was not @@ -283,7 +284,8 @@ public class SortedCellTable extends CellTable { }); // Might as well get the little arrow on the header to make it // official - getColumnSortList().push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn))); + getColumnSortList() + .push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn))); currentlySortedColumn = initialSortColumn; } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 9a6b935..f73fa16 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -52,4 +52,23 @@ h1 { .my-html-table td:first-child { color: gray; -} \ No newline at end of file +} + + +/*** TABLE GET LIST OF RECORDS***/ +.table-glor { + word-wrap: break-word; +} + +.table-glor td, th { + overflow: hidden !important; +} + +.table-glor th { + /*text-align: center !important;*/ +} + +.table-glor-vertical-middle td, th { + height: 50%; + vertical-align: middle !important; +} From 30cedd93766efb4ae8fbbed9f30e604649ff4033 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 5 Aug 2021 16:49:04 +0200 Subject: [PATCH 05/32] Delete Operation done --- .../client/GeoPortalDataEntryApp.java | 565 +++++++++++------- .../client/GeoportalDataEntryService.java | 22 +- .../GeoportalDataEntryServiceAsync.java | 8 +- .../client/ui/GeonaMainPanel.java | 101 ---- .../client/ui/GeonaMainPanel.ui.xml | 28 - .../client/ui/GeonaMainTabPanel.java | 142 +++++ .../client/ui/GeonaMainTabPanel.ui.xml | 52 ++ .../client/ui/GeonaNavigationBar.java | 74 --- .../client/ui/GeonaNavigationBar.ui.xml | 20 - .../client/ui/GeonaRecordsPaginatedView.java | 26 +- .../client/ui/table/ItemsTable.java | 33 - .../client/ui/utils/DialogConfirm.java | 152 +++++ .../client/ui/utils/NewBrowserWindow.java | 30 + .../server/GeoportalDataEntryServiceImpl.java | 64 +- .../server/SessionUtil.java | 85 ++- 15 files changed, 868 insertions(+), 534 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java 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 7bac626..03ef45b 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 @@ -8,22 +8,28 @@ import java.util.List; import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler; 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.GetListOfRecordsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler; -import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel; +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.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -36,6 +42,8 @@ import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.EntryPoint; 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; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -48,7 +56,6 @@ import com.google.gwt.user.client.ui.VerticalPanel; * Entry point classes define onModuleLoad(). */ public class GeoPortalDataEntryApp implements EntryPoint { - /** * The message displayed to the user when the server cannot be reached or @@ -67,27 +74,27 @@ public class GeoPortalDataEntryApp implements EntryPoint { private final HandlerManager appManagerBus = new HandlerManager(null); private LinkedHashMap mapForms = new LinkedHashMap(); - + private GeonaDataEntryMainForm geoNaMainForm; - + private Collection orderedCards; - - private GeonaMainPanel mainPanel; - + + private GeonaMainTabPanel mainTabPanel; + private LinkedHashMap> savedMap = new LinkedHashMap>(); - + private boolean projectSavedWithSuccess; - + /** * This is the entry point method. */ public void onModuleLoad() { - - mainPanel = new GeonaMainPanel(appManagerBus); - mainPanel.setLoaderVisible("Loading...", true); - + + mainTabPanel = new GeonaMainTabPanel(appManagerBus); + mainTabPanel.setLoaderVisible("Loading...", true); + geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); - + GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { @Override @@ -97,131 +104,137 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onSuccess(GeonaISConfig result) { - - if(result!=null && result.getgRSecondaryType()!=null && result.getScope()!=null) { - callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType()); - }else - Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT); - - } - }); - - bindEvents(); - mainPanel.addFormPanel(geoNaMainForm); - RootPanel.get(DIV_PORTLET_ID).add(mainPanel); - } - - - private void callGetMetadataProfiles(String scope, String secondaryType) { - - MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, new AsyncCallback>() { - - @Override - public void onSuccess(List result) { - GWT.log("Returned "+result.size()+ "profile/s"); - orderedCards = setGeoNaFormsOrder(result); - //ordered values - buildNewCards(orderedCards); - } - - @Override - public void onFailure(Throwable caught) { - } - }); - } - - private void buildNewCards(Collection orderedCards) { - projectSavedWithSuccess = false; //resetting state of saving - mainPanel.setFormPanelVisible(true); - mainPanel.setLoaderVisible("Loading...", true); - resetUI(); - //ordered values - for (GeoNaFormCardModel geonaForm : orderedCards) { - - //TODO TO TEST - //if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){ - GWT.log("Adding card: "+geonaForm.getFormCardTitle()); - CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),appManagerBus); - geonaForm.setMetadataForm(baseForm); - String key = geonaForm.getMetadataProfileBean().getType(); - if(geonaForm.getFormCardTitle()!=null) { - key = geonaForm.getFormCardTitle().getTitle(); - } - geoNaMainForm.addForm(key, geonaForm); - mapForms.put(key, geonaForm); - - //} + if (result != null && result.getgRSecondaryType() != null && result.getScope() != null) { + callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType()); + } else + Window.alert( + ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT); + + } + }); + + bindEvents(); + mainTabPanel.addFormPanel(geoNaMainForm); + RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel); + } + + private void callGetMetadataProfiles(String scope, String secondaryType) { + + MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType, + new AsyncCallback>() { + + @Override + public void onSuccess(List result) { + GWT.log("Returned " + result.size() + "profile/s"); + orderedCards = setGeoNaFormsOrder(result); + // ordered values + buildNewCards(orderedCards); + } + + @Override + public void onFailure(Throwable caught) { + } + }); + } + + private void buildNewCards(Collection orderedCards) { + projectSavedWithSuccess = false; // resetting state of saving + mainTabPanel.setLoaderVisible("Loading...", true); + resetUI(); + // ordered values + for (GeoNaFormCardModel geonaForm : orderedCards) { + + // TODO TO TEST + // if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){ + + GWT.log("Adding card: " + geonaForm.getFormCardTitle()); + CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()), + appManagerBus); + geonaForm.setMetadataForm(baseForm); + String key = geonaForm.getMetadataProfileBean().getType(); + if (geonaForm.getFormCardTitle() != null) { + key = geonaForm.getFormCardTitle().getTitle(); + } + geoNaMainForm.addForm(key, geonaForm); + mapForms.put(key, geonaForm); + + // } } geoNaMainForm.enableButtonSave(true); - mainPanel.setLoaderVisible("", false); + mainTabPanel.setLoaderVisible("", false); } - + private void resetUI() { geoNaMainForm.reset(); mapForms.clear(); } - + private Collection setGeoNaFormsOrder(List listMetadataProfilesForGeona) { - + TreeMap treemapOrderedGeoNaProfiles = new TreeMap(); - + List listUnknownType = new ArrayList(); for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) { - + String theMetaType = metaDataProfileBean.getType().toLowerCase(); - GWT.log("Building form card for type: "+theMetaType); + GWT.log("Building form card for type: " + theMetaType); GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, null); - - if(theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) { + + if (theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO); - treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), geonaForm); - }else if(theMetaType.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { + treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), + geonaForm); + } else if (theMetaType + .contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO); - treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(), geonaForm); - }else if(theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { + treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(), + geonaForm); + } else if (theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getOrder(), geonaForm); - }else if(theMetaType.contains(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getKey().toLowerCase())) { + } else if (theMetaType.contains(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE); - treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), geonaForm); - }else if(theMetaType.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) { + treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), + geonaForm); + } else if (theMetaType + .contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE); - treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm); - }else if(theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) { + treemapOrderedGeoNaProfiles + .put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm); + } else if (theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) { geonaForm.setFormCardTitle(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO); treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getOrder(), geonaForm); - }else { - //adding to unknown list + } else { + // adding to unknown list listUnknownType.add(geonaForm); } } - - //adding unknown types + + // adding unknown types for (GeoNaFormCardModel geoNaFormCardModel : listUnknownType) { Integer highestKey = treemapOrderedGeoNaProfiles.lastKey(); highestKey++; treemapOrderedGeoNaProfiles.put(highestKey, geoNaFormCardModel); } - - GWT.log("Map size: "+treemapOrderedGeoNaProfiles.size()); + + GWT.log("Map size: " + treemapOrderedGeoNaProfiles.size()); return treemapOrderedGeoNaProfiles.values(); - + } - - + private void bindEvents() { - + appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() { - + @Override public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) { - + geoNaMainForm.enableButtonSave(false); - - if(saveGeonaDataFormsEvent.getListGeonaDataForms()!=null) { - + + if (saveGeonaDataFormsEvent.getListGeonaDataForms() != null) { + final Modal modal = new Modal(true); modal.setCloseVisible(false); modal.setTitle("Saving project..."); @@ -234,110 +247,120 @@ public class GeoPortalDataEntryApp implements EntryPoint { modalContainerPanel.add(loader); modal.add(modalContainerPanel); - GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback() { + 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) { - } - Alert alert = new Alert(caught.getMessage()); - alert.setType(AlertType.ERROR); - alert.setClose(false); - modal.add(alert); - //resetUI(); - geoNaMainForm.enableButtonSave(true); - } - - @Override - public void onSuccess(CommitReport result) { - modalContainerPanel.clear(); - modal.setCloseVisible(true); - HTML recordPublished = new HTML(); - switch (result.getState()) { - case OK: - String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); - recordPublished.setHTML("Record Published with "+success); - projectSavedWithSuccess = true; - String msg = result.getMsg()!=null?result.getMsg():"Record published with success"; - geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); - purgeFileUploaded(); - break; - case WARN: - String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); - recordPublished.setHTML("Record Published with "+warning); - geoNaMainForm.enableButtonSave(true); - break; - case ERROR: - String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR"); - recordPublished.setHTML(error+" on publishing the Record"); - geoNaMainForm.enableButtonSave(true); - break; - default: - break; - } - - modalContainerPanel.add(recordPublished); - - if(result.getMongoId()!=null) { - modalContainerPanel.add(new HTML("Record id: "+(result.getMongoId()))); - - try { - savedMap.put(result.getMongoId(), saveGeonaDataFormsEvent.getListGeonaDataForms()); - }catch (Exception e) { - // TODO: handle exception + @Override + public void onFailure(Throwable caught) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + try { + modal.remove(loader); + } catch (Exception e) { + } + Alert alert = new Alert(caught.getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + modal.add(alert); + // resetUI(); + geoNaMainForm.enableButtonSave(true); } - - final HorizontalPanel hpGetLink = new HorizontalPanel(); - final LoaderIcon lc = new LoaderIcon("Get link..."); - hpGetLink.add(lc); - modalContainerPanel.add(hpGetLink); - GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(result.getMongoId(), "concessione", new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - hpGetLink.clear(); - - } - - @Override - public void onSuccess(GeoNaItemRef result) { - hpGetLink.clear(); - String theURL = result.getRestrictedLink().getShortURL()!=null?result.getRestrictedLink().getShortURL():result.getRestrictedLink().getCompleteURL(); - String htmlLink = "
Go to record: "+theURL+"
"; - HTML html = new HTML(htmlLink); - hpGetLink.add(html); - //modal.add(html); - } - }); - } - - //geoNaMainForm.enableButtonSave(true); - //resetUI(); - - if(result.getReport()!=null) { - modalContainerPanel.add(new ReportTemplateToHTML(result.getReport())); - } - - } - }); - + @Override + public void onSuccess(CommitReport result) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + HTML recordPublished = new HTML(); + switch (result.getState()) { + case OK: + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, + "SUCCESS"); + recordPublished.setHTML("Record Published with " + success); + projectSavedWithSuccess = true; + String msg = result.getMsg() != null ? result.getMsg() + : "Record published with success"; + geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); + purgeFileUploaded(); + break; + case WARN: + String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, + "WARNING"); + recordPublished.setHTML("Record Published with " + warning); + geoNaMainForm.enableButtonSave(true); + break; + case ERROR: + String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + "ERROR"); + recordPublished.setHTML(error + " on publishing the Record"); + geoNaMainForm.enableButtonSave(true); + break; + default: + break; + } + + modalContainerPanel.add(recordPublished); + + if (result.getMongoId() != null) { + modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); + + try { + savedMap.put(result.getMongoId(), + saveGeonaDataFormsEvent.getListGeonaDataForms()); + } catch (Exception e) { + // TODO: handle exception + } + + final HorizontalPanel hpGetLink = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Get link..."); + hpGetLink.add(lc); + modalContainerPanel.add(hpGetLink); + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor( + result.getMongoId(), RECORD_TYPE.CONCESSIONE, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + hpGetLink.clear(); + + } + + @Override + public void onSuccess(GeoNaItemRef result) { + hpGetLink.clear(); + String theURL = result.getRestrictedLink().getShortURL() != null + ? result.getRestrictedLink().getShortURL() + : result.getRestrictedLink().getCompleteURL(); + String htmlLink = "
Go to record: " + theURL + "
"; + HTML html = new HTML(htmlLink); + hpGetLink.add(html); + // modal.add(html); + } + }); + } + + // geoNaMainForm.enableButtonSave(true); + // resetUI(); + + if (result.getReport() != null) { + modalContainerPanel.add(new ReportTemplateToHTML(result.getReport())); + } + + } + }); + modal.show(); - }else + } else geoNaMainForm.enableButtonSave(true); - + } }); - + appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() { - + @Override public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) { - + // means the form was not submitted if (savedMap.size() == 0) { boolean confirm = Window.confirm( @@ -345,10 +368,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (confirm) buildNewCards(orderedCards); } else if (projectSavedWithSuccess) { - //means the project has been saved + // means the project has been saved buildNewCards(orderedCards); } else { - //means the project reported one ore more errors after the submit + // 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) buildNewCards(orderedCards); @@ -356,37 +379,159 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); - + appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() { - + @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { - - GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME); - mainPanel.showListOfConcessioniView(grpw); + + GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, + null, DISPLAY_FIELD.NAME); + mainTabPanel.showListOfConcessioniView(grpw); + } + }); + + appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() { + + @Override + public void onDoActionFired(ActionOnItemEvent showItemEvent) { + + if (showItemEvent != null) { + + ACTION_ON_ITEM action = showItemEvent.getAction(); + List items = showItemEvent.getSelectItems(); + + if (items == null) + return; + + T item = items.get(0); + + if (item == null) + return; + + if (item instanceof ConcessioneDV) { + + final ConcessioneDV concessione = (ConcessioneDV) item; + GWT.log("ActionOnItemEvente item: " + concessione); + + switch (action) { + case SHOW_ON_MAP: + final Modal modal = new Modal(true, true); + modal.setCloseVisible(true); + final HorizontalPanel hpGetLink = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Get link..."); + hpGetLink.add(lc); + modal.add(hpGetLink); + final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); + + GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), + RECORD_TYPE.CONCESSIONE, new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + hpGetLink.clear(); + Alert alert = new Alert(caught.getMessage(), AlertType.ERROR); + alert.setClose(false); + hpGetLink.add(alert); + newBrowserWindow.close(); + } + + @Override + public void onSuccess(GeoNaItemRef result) { + String theURL = result.getRestrictedLink().getShortURL() != null + ? result.getRestrictedLink().getShortURL() + : result.getRestrictedLink().getCompleteURL(); + newBrowserWindow.setUrl(theURL); + modal.hide(); + } + }); + + modal.show(); + + break; + case REMOVE: + + String htmlMsg = "Going to delete the project with:"; + htmlMsg += "
    "; + htmlMsg += "
  • id: " + concessione.getItemId() + "
  • "; + htmlMsg += "
  • name: " + concessione.getNome() + "
  • "; + htmlMsg += "
"; + htmlMsg += "
"; + htmlMsg += "This operation cannot be undone. Would you like to proceed?"; + + final DialogConfirm dialog = new DialogConfirm(null, "Delete Confirm?", htmlMsg); + dialog.center(); + + dialog.getYesButton().addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + dialog.hide(); + final Modal modal = new Modal(true, true); + modal.setCloseVisible(true); + final HorizontalPanel hp = new HorizontalPanel(); + final LoaderIcon lc = new LoaderIcon("Deleting Project..."); + hp.add(lc); + modal.add(hp); + + GeoportalDataEntryServiceAsync.Util.getInstance().deleteRecord( + concessione.getItemId(), RECORD_TYPE.CONCESSIONE, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + hp.clear(); + Alert alert = new Alert(caught.getMessage(), AlertType.ERROR); + alert.setClose(false); + hp.add(alert); + + } + + @Override + public void onSuccess(Boolean result) { + if (result) { + hp.clear(); + Alert alert = new Alert("Project '" + concessione.getNome() + + "' deleted correclty", AlertType.INFO); + alert.setClose(false); + hp.add(alert); + + appManagerBus.fireEvent( + new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); + } + + } + }); + modal.show(); + } + }); + + default: + break; + } + } + + } + } }); } - private void purgeFileUploaded() { - + MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback() { @Override public void onFailure(Throwable caught) { - //silent - + // silent + } @Override public void onSuccess(Integer result) { - GWT.log("Purged "+result+" file/s uploaded"); - + GWT.log("Purged " + result + " file/s uploaded"); + } }); } - - } 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 8b6fba5..cfefca8 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 @@ -3,6 +3,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.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -16,7 +17,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 4, 2021 + * Aug 4, 2021 */ @RemoteServiceRelativePath("geoportaldataentryservice") public interface GeoportalDataEntryService extends RemoteService { @@ -40,21 +41,30 @@ public interface GeoportalDataEntryService extends RemoteService { /** * Gets the links for. * - * @param itemId the item id + * @param itemId the item id * @param recordType the record type * @return the links for * @throws Exception the exception */ - GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception; - + GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception; /** * Gets the list concessioni. * - * @param start the start + * @param start the start * @param offset the offset + * @param reloadFromService the reload from service * @return the list concessioni * @throws Exception the exception */ - SearchedData getListConcessioni(Integer start, Integer offset) throws Exception; + SearchedData getListConcessioni(Integer start, Integer offset, boolean reloadFromService) throws Exception; + + /** + * Delete record. + * + * @param itemId the item id + * @param recordType the record type + * @return true, if successful + */ + boolean deleteRecord(String itemId, RECORD_TYPE 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 902f1c4..a263630 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 @@ -3,6 +3,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.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -43,8 +44,11 @@ public interface GeoportalDataEntryServiceAsync void getGeonaInitConfig(AsyncCallback callback); - void getLinksFor(String itemId, String recordType, AsyncCallback callback); + void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void getListConcessioni(Integer start, Integer offset, AsyncCallback callback); + void getListConcessioni(Integer start, Integer offset, boolean reloadFromService, AsyncCallback callback); + + + void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java deleted file mode 100644 index 652b6bb..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.gcube.portlets.user.geoportaldataentry.client.ui; - -import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; - -import com.google.gwt.core.client.GWT; -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.ui.Composite; -import com.google.gwt.user.client.ui.HTMLPanel; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * The Class GeonaMainPanel. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Oct 13, 2020 - */ -public class GeonaMainPanel extends Composite { - - /** The geona main form panel. */ - @UiField - HTMLPanel geonaMainFormPanel; - - @UiField - HTMLPanel geonaListOfConcessioniPanel; - - /** The loader. */ - @UiField - LoaderIcon loader; - - @UiField - GeonaNavigationBar geonaNavigationBar; - - private HandlerManager appManagerBus; - - /** The ui binder. */ - private static GeonaMainPanelUiBinder uiBinder = GWT.create(GeonaMainPanelUiBinder.class); - - /** - * The Interface GeonaMainPanelUiBinder. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Oct 13, 2020 - */ - interface GeonaMainPanelUiBinder extends UiBinder { - } - - /** - * Instantiates a new geona main panel. - * - * @param appManagerBus - */ - public GeonaMainPanel(HandlerManager appManagerBus) { - initWidget(uiBinder.createAndBindUi(this)); - this.appManagerBus = appManagerBus; - geonaNavigationBar.setAppManagerBus(appManagerBus); - } - - /** - * Adds the form panel. - * - * @param formPanel the form panel - */ - public void addFormPanel(GeonaDataEntryMainForm formPanel) { - geonaListOfConcessioniPanel.setVisible(false); - geonaMainFormPanel.add(formPanel); - geonaMainFormPanel.setVisible(true); - } - - public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { - setFormPanelVisible(false); - geonaListOfConcessioniPanel.clear(); - VerticalPanel htmllPanel = new VerticalPanel(); - htmllPanel.add(grpw.getCellPanel()); - htmllPanel.add(grpw.getPagerPanel()); - geonaListOfConcessioniPanel.add(htmllPanel); - } - - /** - * Sets the loader visible. - * - * @param txtHTML the txt HTML - * @param visible the visible - */ - public void setLoaderVisible(String txtHTML, boolean visible) { - loader.setText(txtHTML); - loader.setVisible(visible); - } - - public void setFormPanelVisible(boolean bool) { - geonaMainFormPanel.setVisible(bool); - geonaListOfConcessioniPanel.setVisible(!bool); - - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml deleted file mode 100644 index bec763b..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainPanel.ui.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - .important { - font-weight: bold; - } - - .custom-page-header { - padding: 10px; - background-color: #f5f5f5; - margin-bottom: 10px; - border: 1px solid #eee; - } - - - GeoNa - - - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java new file mode 100644 index 0000000..d934650 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -0,0 +1,142 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui; + +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; +import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; +import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; + +import com.github.gwtbootstrap.client.ui.NavLink; +import com.github.gwtbootstrap.client.ui.Tab; +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.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class GeonaMainTabPanel. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 5, 2021 + */ +public class GeonaMainTabPanel extends Composite { + + private static GeonaMainTabPanelUiBinder uiBinder = GWT.create(GeonaMainTabPanelUiBinder.class); + + /** + * The Interface GeonaMainTabPanelUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 5, 2021 + */ + interface GeonaMainTabPanelUiBinder extends UiBinder { + } + + /** The geona main form panel. */ + @UiField + HTMLPanel geonaMainFormPanel; + + @UiField + HTMLPanel geonaListOfConcessioniPanel; + + /** The loader. */ + @UiField + LoaderIcon loader; + + @UiField + NavLink buttCreateNewProject; + + @UiField + NavLink buttonReloadConcessioni; + + @UiField + Tab tabNewProject; + + @UiField + Tab tabGetListOfProjects; + + private HandlerManager appManagerBus; + + /** + * Instantiates a new geona main tab panel. + * + * @param appManagerBus the first name + */ + public GeonaMainTabPanel(HandlerManager appManagerBus) { + initWidget(uiBinder.createAndBindUi(this)); + this.appManagerBus = appManagerBus; + bindEvents(); + + } + + private void bindEvents() { + + buttCreateNewProject.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new CreateNewProjectEvent()); + + } + }); + + buttonReloadConcessioni.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); + + } + }); + + tabGetListOfProjects.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, + null, DISPLAY_FIELD.NAME); + showListOfConcessioniView(grpw); + + } + }); + + } + + /** + * Adds the form panel. + * + * @param formPanel the form panel + */ + public void addFormPanel(GeonaDataEntryMainForm formPanel) { + geonaMainFormPanel.add(formPanel); + } + + public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { + geonaListOfConcessioniPanel.clear(); + VerticalPanel htmllPanel = new VerticalPanel(); + htmllPanel.add(grpw.getCellPanel()); + htmllPanel.add(grpw.getPagerPanel()); + geonaListOfConcessioniPanel.add(htmllPanel); + } + + /** + * Sets the loader visible. + * + * @param txtHTML the txt HTML + * @param visible the visible + */ + public void setLoaderVisible(String txtHTML, boolean visible) { + loader.setText(txtHTML); + loader.setVisible(visible); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml new file mode 100644 index 0000000..9982f00 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -0,0 +1,52 @@ + + + + + .important { + font-weight: bold; + } + + .custom-page-header { + padding: 10px; + background-color: #f5f5f5; + margin-bottom: 10px; + border: 1px solid #eee; + } + + + GeoNa + + + + New Project + + Create New Project + + + + + + + + + + List of Projects + + Reload Projects + + + + + + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java deleted file mode 100644 index 53b2b01..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.gcube.portlets.user.geoportaldataentry.client.ui; - -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; -import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; -import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; - -import com.github.gwtbootstrap.client.ui.NavLink; -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.EventBus; -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.ui.Composite; -import com.google.gwt.user.client.ui.Widget; - -public class GeonaNavigationBar extends Composite { - - private static GeonaNavigationBarUiBinder uiBinder = GWT.create(GeonaNavigationBarUiBinder.class); - - interface GeonaNavigationBarUiBinder extends UiBinder { - } - - private EventBus eventBus; - - public GeonaNavigationBar() { - initWidget(uiBinder.createAndBindUi(this)); - bindEvents(); - } - - private void bindEvents() { - linkCreateNewProject.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new CreateNewProjectEvent()); - - } - }); - - linkGetListOfRecords.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); - - } - }); - - } - - @UiField - NavLink linkCreateNewProject; - - @UiField - NavLink linkGetListOfRecords; - - private HandlerManager appManagerBus; - - public GeonaNavigationBar(String firstName) { - initWidget(uiBinder.createAndBindUi(this)); - } - - /** - * Sets the app manager bus. - * - * @param appManagerBus the new app manager bus - */ - public void setAppManagerBus(HandlerManager appManagerBus) { - this.appManagerBus = appManagerBus; - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml deleted file mode 100644 index 6a54199..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaNavigationBar.ui.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - .important { - font-weight: bold; - } - - - - - Create new Project - Get List of Concessioni - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 8739d92..37e0b0e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -69,7 +69,7 @@ public class GeonaRecordsPaginatedView { orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); initPagination(ITEMS_PER_PAGE); // loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false); - loadItemsForStatus(recordType); + loadItemsForType(recordType); } /** @@ -114,8 +114,10 @@ public class GeonaRecordsPaginatedView { * @param startIdx the start idx * @param limit the limit * @param resetStore the reset store + * @param invalidCache the invalid cache */ - private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) { + private void loadNewPage(final int startIdx, final int limit, final boolean resetStore, + final boolean invalidCache) { // initFirstRangeChanged = resetStore; GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" + resetStore + "]"); @@ -131,18 +133,18 @@ public class GeonaRecordsPaginatedView { getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false); } - loadItemsForStatus(newStartIndex, limit, serverStartIndex); + loadConcessioni(newStartIndex, limit, serverStartIndex, invalidCache); } /** - * Load items for status. + * Load items for type. * * @param recordType the record type */ - public void loadItemsForStatus(RECORD_TYPE recordType) { + public void loadItemsForType(RECORD_TYPE recordType) { this.recordType = recordType; getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false); - loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true); + loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true, true); } /** @@ -185,20 +187,20 @@ public class GeonaRecordsPaginatedView { } /** - * Load items for status. + * Load concessioni. * * @param the generic type * @param newStartIndex the new start index * @param limit the limit * @param serverIndex the server index */ - private void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) { + private void loadConcessioni(int newStartIndex, int limit, int serverIndex, boolean invalidCache) { showLoading(true); GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit + ", serverIndex:" + serverIndex + "]"); - GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, + GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, invalidCache, new AsyncCallback() { @Override @@ -242,7 +244,7 @@ public class GeonaRecordsPaginatedView { public List getSelectItems() { return itemsTable.getSelectedItems(); } - + // int latestRangeStart = -1; // int latestRangeLenght = -1; @@ -269,7 +271,7 @@ public class GeonaRecordsPaginatedView { int start = range.getStart(); int length = range.getLength(); - + // if(latestRangeStart!=start || latestRangeLenght!=length) { // GWT.log("ranges really changed"); // latestRangeStart = start; @@ -285,7 +287,7 @@ public class GeonaRecordsPaginatedView { return; } GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); - loadNewPage(start, length, false); + loadNewPage(start, length, false, false); // eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index c226a1b..fbc93e6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -113,25 +113,6 @@ public class ItemsTable extends AbstractItemsCellTable< this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; setEmptyTableMessage(NO_DATA); -// final CheckboxCell cellCheckBox = new CheckboxCell(true, false); -// Column checkColumn = new Column(cellCheckBox) { -// @Override -// public Boolean getValue(T object) { -// // Get the value from the selection model. -// return theSelectionModel.isSelected(object); -// } -// -// @Override -// public void render(Context context, T object, SafeHtmlBuilder sb) { -// super.render(context, object, sb); -// GWT.log("added checkbox: " + cellCheckBox + " to object: " + object); -// } -// -// }; -// -// sortedCellTable.addColumn(checkColumn, "", false); -// sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX); - if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { // NAME @@ -418,20 +399,6 @@ public class ItemsTable extends AbstractItemsCellTable< } -// /** -// * To date format string. -// * -// * @param dateTime the date time -// * @return the string -// */ -// public static Date toDisplayDate(Date dateTime) { -// -// if(dateTime==null) -// return null; -// -// return new Date(dtformat.format(dateTime)); -// } - private String toDisplayAuthors(List authors) { String toDisplay = ""; if (authors == null) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java new file mode 100644 index 0000000..d3e856f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java @@ -0,0 +1,152 @@ +/** + * + */ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + + + + +import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + + +/** + * The Class DialogConfirm. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Feb 19, 2015 + */ +public class DialogConfirm extends DialogBox implements ClickHandler { + + private DockPanel dock = new DockPanel(); + private Button yesButton; + private VerticalPanel vpContainer; + private ImageResource loading = Images.ICONS.loading(); + private HorizontalPanel hpButtons = new HorizontalPanel(); + private Button noButton; + /** + * Instantiates a new dialog confirm. + * + * @param img the img + * @param caption the caption + * @param text the text + */ + public DialogConfirm(Image img, String caption, String text) { + //getElement().setClassName("gwt-DialogBoxNew"); + dock.setSpacing(4); + dock.setWidth("100%"); + setText(caption); +// setHeading(caption); + + yesButton = new Button("Yes"); + noButton = new Button("No", this); + + noButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + hide(); + } + }); + + vpContainer = new VerticalPanel(); + vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX); + vpContainer.add(new HTML(text)); + hpButtons = new HorizontalPanel(); + hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); +// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX); + hpButtons.setSpacing(3); + yesButton.getElement().getStyle().setMarginRight(20.0, Unit.PX); + hpButtons.add(yesButton); + hpButtons.add(noButton); + + dock.add(hpButtons, DockPanel.SOUTH); + dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER); + + if (img != null) + dock.add(img, DockPanel.WEST); + + dock.add(vpContainer, DockPanel.CENTER); + setWidget(dock); +// add(dock); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event + * .dom.client.ClickEvent) + */ + @Override + public void onClick(ClickEvent event) { +// hide(); + } + + /** + * Loader. + * + * @param message the message + */ + public void loader(String message){ + try{ + dock.remove(hpButtons); + }catch(Exception e){} + vpContainer.clear(); + HorizontalPanel hpMask = new HorizontalPanel(); + hpMask.add(new Image(loading)); + HTML html = new HTML(message); + html.getElement().getStyle().setMarginLeft(5, Unit.PX); + hpMask.add(html); + vpContainer.add(hpMask); + } + + /** + * Adds the to center panel. + * + * @param w the w + */ + public void addToCenterPanel(Widget w) { + vpContainer.add(w); + } + + /** + * Gets the dock. + * + * @return the dock + */ + public DockPanel getDock() { + return dock; + } + + /** + * Gets the yes button. + * + * @return the yes button + */ + public Button getYesButton() { + return yesButton; + } + + /** + * Gets the no button. + * + * @return the no button + */ + public Button getNoButton() { + return noButton; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java new file mode 100644 index 0000000..6cc3d1f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java @@ -0,0 +1,30 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +import com.google.gwt.core.client.JavaScriptObject; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it + * Sep 4, 2013 + * + */ +public final class NewBrowserWindow extends JavaScriptObject { + // All types that extend JavaScriptObject must have a protected, + // no-args constructor. + protected NewBrowserWindow() { + } + + public static native NewBrowserWindow open(String url, String target, + String options) /*-{ + return $wnd.open(url, target, options); + }-*/; + + public native void close() /*-{ + this.close(); + }-*/; + + public native void setUrl(String url) /*-{ + if (this.location) { + this.location = url; + } + }-*/; +} 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 d5c9342..27634c5 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 @@ -16,9 +16,11 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE; @@ -391,12 +393,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception { + public GeoNaItemRef getLinksFor(String itemId, RECORD_TYPE recordType) throws Exception { LOG.info("getLinksFor called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GeoportalCommon gc = new GeoportalCommon(); - GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toLowerCase()); + GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest()); + GeoportalCommon gc = new GeoportalCommon(grViewerProfile); + GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); item = gc.getPublicLinksFor(item); LOG.info("Returning: " + item); return item; @@ -405,17 +408,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Gets the list concessioni. * - * @param start the start - * @param offset the offset + * @param start the start + * @param limit the limit + * @param reloadFromService if true, ignore the concessioni saved in session and + * reload them from service * @return the list concessioni * @throws Exception the exception */ @Override - public SearchedData getListConcessioni(Integer start, Integer limit) throws Exception { - LOG.info("getListConcessioni called wit start: "+start + ", limit: "+limit); + public SearchedData getListConcessioni(Integer start, Integer limit, boolean reloadFromService) throws Exception { + LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit); try { - List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest()); + List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(), + reloadFromService); int listConcessioniSize = listOfConcessioni.size(); List toReturn = new ArrayList(); @@ -425,27 +431,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen toReturn.addAll(listOfConcessioni); startIndex = 0; limitIndex = listConcessioniSize; - }else { -// if (start < 0) -// start = 0; -// -// if (start > listConcessioniSize) -// start = listConcessioniSize; -// -// if (limit > listConcessioniSize) -// limit = listConcessioniSize; - + } else { startIndex = start; limitIndex = start + limit; - if(limitIndex>listConcessioniSize) { + if (limitIndex > listConcessioniSize) { limitIndex = listConcessioniSize; } } - + SearchedData searchedData = new SearchedData(start, limit, startIndex, false); searchedData.setTotalItems(listConcessioniSize); - toReturn = listOfConcessioni.subList(startIndex, limitIndex); List toReturnList = new ArrayList(toReturn.size()); @@ -456,7 +452,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } searchedData.setData(toReturnList); - + if (listConcessioniSize == limit || listConcessioniSize == 0) { LOG.debug("Page completed returning " + listConcessioniSize + " items"); int newOffset = startIndex + start; @@ -502,4 +498,28 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } } + + @Override + public boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception { + try { + + if (itemId == null) + throw new Exception("Item id is null"); + + if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + ServiceUtil serviceUtil = new ServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + clientMongo.deleteById(itemId); + return true; + } + + return false; + + } catch (Exception e) { + LOG.error("Error on deleting the project with item id: " + itemId, e); + throw new Exception( + "Error occurred on deleting the project with id: " + itemId + ". Error: " + e.getMessage()); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 3a06bde..735e6d3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -12,6 +12,8 @@ import javax.servlet.http.HttpSession; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.rest.MongoConcessioni; +import org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -26,16 +28,16 @@ import org.slf4j.LoggerFactory; import com.liferay.portal.service.UserLocalServiceUtil; - /** * The Class SessionUtil. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 20, 2020 + * Oct 20, 2020 */ public class SessionUtil { + private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE"; private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI"; /** The log. */ private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); @@ -49,7 +51,7 @@ public class SessionUtil { try { UserLocalServiceUtil.getService(); return true; - }catch (Exception ex) { + } catch (Exception ex) { LOG.debug("Development Mode ON"); return false; } @@ -61,9 +63,9 @@ public class SessionUtil { * @param request the request * @return a GcubeUser object */ - public static GCubeUser getCurrentUser(HttpServletRequest request){ + public static GCubeUser getCurrentUser(HttpServletRequest request) { - if(request == null) + if (request == null) throw new IllegalArgumentException("HttpServletRequest is null!"); PortalContext pContext = PortalContext.getConfiguration(); @@ -75,26 +77,27 @@ public class SessionUtil { /** * Retrieve the current scope by using the portal manager. * - * @param request the request - * @param setContextsInThread set the scope and the security token into current thread + * @param request the request + * @param setContextsInThread set the scope and the security token into current + * thread * @return a GcubeUser object */ - public static String getCurrentContext(HttpServletRequest request, boolean setContextsInThread){ + public static String getCurrentContext(HttpServletRequest request, boolean setContextsInThread) { - if(request == null) + if (request == null) throw new IllegalArgumentException("HttpServletRequest is null!"); PortalContext pContext = PortalContext.getConfiguration(); String context = pContext.getCurrentScope(request); - - if(setContextsInThread) { + + if (setContextsInThread) { GCubeUser user = getCurrentUser(request); String token = pContext.getCurrentUserToken(context, user.getUsername()); - - if(context!=null) + + if (context != null) ScopeProvider.instance.set(context); - - if(token!=null) + + if (token != null) SecurityTokenProvider.instance.set(token); } @@ -107,11 +110,11 @@ public class SessionUtil { * @param scope the scope * @return the group from scope * @throws UserManagementSystemException the user management system exception - * @throws GroupRetrievalFault the group retrieval fault + * @throws GroupRetrievalFault the group retrieval fault */ - public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault{ + public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault { - if(scope == null || scope.isEmpty()) + if (scope == null || scope.isEmpty()) throw new IllegalArgumentException("Scope is missing here!!"); GroupManager gm = new LiferayGroupManager(); @@ -119,18 +122,24 @@ public class SessionUtil { return gm.getGroup(groupId); } - /** * Gets the list of concessioni. * * @param httpServletRequest the http servlet request + * @param reloadFromService the reload from service * @return the list of concessioni * @throws Exception the exception */ - public static List getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception { + public static List getListOfConcessioni(HttpServletRequest httpServletRequest, + boolean reloadFromService) throws Exception { HttpSession session = httpServletRequest.getSession(); List listOfConcessioni = (List) session.getAttribute(LIST_OF_CONCESSIONI); + + // setting null to force reloading from service + if (reloadFromService) + listOfConcessioni = null; + if (listOfConcessioni == null) { listOfConcessioni = new ArrayList(); LOG.info("Loading list of concessione from client mongo"); @@ -142,16 +151,40 @@ public class SessionUtil { while (concessioni.hasNext()) { Concessione concessione = (Concessione) concessioni.next(); listOfConcessioni.add(concessione); - + } } - LOG.debug("Got list of concessioni from client mongo: "+listOfConcessioni); + LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni); - LOG.info("Saved in session list of concessioni from client mongo with size: "+listOfConcessioni.size()); - }else + LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size()); + } else LOG.info("list of concessioni presents in session"); - - LOG.info("read list of concessioni with size: "+listOfConcessioni.size()); + + LOG.info("read list of concessioni with size: " + listOfConcessioni.size()); return listOfConcessioni; } + + + /** + * Gets the geportal viewer resource profile. + * + * @param httpServletRequest the http servlet request + * @return the geportal viewer resource profile + * @throws Exception the exception + */ + public static GeoNaDataViewerProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest) + throws Exception { + HttpSession session = httpServletRequest.getSession(); + GeoNaDataViewerProfile geoNaDataViewerProfile = (GeoNaDataViewerProfile) session + .getAttribute(GEONA_DATAVIEWER_PROFILE); + + if (geoNaDataViewerProfile == null) { + GeoportalCommon gc = new GeoportalCommon(); + geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null); + session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile); + } + + return geoNaDataViewerProfile; + + } } From f1f14656962f7388f138da06498f93f96918a238 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 5 Aug 2021 17:38:21 +0200 Subject: [PATCH 06/32] revisited the columns --- .../client/ui/table/ItemsTable.java | 106 ++++++------------ 1 file changed, 34 insertions(+), 72 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index fbc93e6..9edee64 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -64,15 +64,17 @@ public class ItemsTable extends AbstractItemsCellTable< * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 */ public static enum DISPLAY_FIELD { - NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE, INSERTED_BY + NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_START_END_DATE, CREATED, CREATED_BY }; private List displayFields; - private Column startProjectDateColumn; - private Column endProjectDateColumn; + private TextColumn startEndProjectColumn; + // private Column startProjectDateColumn; + // private Column endProjectDateColumn; private DISPLAY_FIELD startSortByColumn; private boolean isAsyncronusTable; private TextColumn insertedBy; + private Column createdColumn; /** * Instantiates a new items table. @@ -210,20 +212,39 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { + if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_END_DATE)) { + + startEndProjectColumn = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + + Date dS = (((ConcessioneDV) object).getDataInizioProgetto()); + Date dE = (((ConcessioneDV) object).getDataFineProgetto()); + return dtformat.format(dS) + " / " + dtformat.format(dE); + } + }; + + sortedCellTable.addColumn(startEndProjectColumn, "Start/End Date", false); + sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX); + + } + + if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) { DateCell date = new DateCell(dtformat); - startProjectDateColumn = new Column(date) { + createdColumn = new Column(date) { @Override public Date getValue(T object) { if (object == null) return null; - return (((ConcessioneDV) object).getDataInizioProgetto()); + return (((ConcessioneDV) object).getCreationTime()); } }; - sortedCellTable.addColumn(startProjectDateColumn, "Project Start Date", true); + sortedCellTable.addColumn(createdColumn, "Created", true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -235,8 +256,8 @@ public class ItemsTable extends AbstractItemsCellTable< if (o2 == null) return 1; - Date d1 = (((ConcessioneDV) o1).getDataInizioProgetto()); - Date d2 = (((ConcessioneDV) o2).getDataInizioProgetto()); + Date d1 = (((ConcessioneDV) o1).getCreationTime()); + Date d2 = (((ConcessioneDV) o2).getCreationTime()); // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1)); @@ -247,58 +268,14 @@ public class ItemsTable extends AbstractItemsCellTable< } }; GWT.log("date colum sortable"); - sortedCellTable.setComparator(startProjectDateColumn, c); + sortedCellTable.setComparator(createdColumn, c); } - sortedCellTable.setColumnWidth(startProjectDateColumn, 150, Unit.PX); + sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX); } - if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) { - - DateCell date = new DateCell(dtformat); - endProjectDateColumn = new Column(date) { - - @Override - public Date getValue(T object) { - if (object == null) - return null; - - return (((ConcessioneDV) object).getDataFineProgetto()); - } - }; - sortedCellTable.addColumn(startProjectDateColumn, "Project End Date", true); - - if (!isAsyncronusTable) { - Comparator c = new Comparator() { - @Override - public int compare(T o1, T o2) { - if (o1 == null) - return -1; - - if (o2 == null) - return 1; - - Date d1 = (((ConcessioneDV) o1).getDataFineProgetto()); - Date d2 = (((ConcessioneDV) o2).getDataFineProgetto()); - - // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1)); - - if (d1.after(d2)) - return 1; - else - return -1; - } - }; - GWT.log("date colum sortable"); - sortedCellTable.setComparator(endProjectDateColumn, c); - } - - sortedCellTable.setColumnWidth(endProjectDateColumn, 150, Unit.PX); - - } - - if (this.displayFields.contains(DISPLAY_FIELD.INSERTED_BY)) { + if (this.displayFields.contains(DISPLAY_FIELD.CREATED_BY)) { // NAME insertedBy = new TextColumn() { @@ -310,7 +287,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(insertedBy, "Inserted by", true); + sortedCellTable.addColumn(insertedBy, "Created by", true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -378,21 +355,6 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setInitialSortColumn(author); } break; - case PROJECT_START_DATE: - if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { - sortedCellTable.setDefaultSortOrder(startProjectDateColumn, false); // sorts ascending on first - // click - sortedCellTable.setInitialSortColumn(startProjectDateColumn); - GWT.log("sortedCellTable: " + sortedCellTable); - } - break; - case PROJECT_END_DATE: - if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { - sortedCellTable.setDefaultSortOrder(endProjectDateColumn, false); // sorts ascending on first click - sortedCellTable.setInitialSortColumn(endProjectDateColumn); - GWT.log("sortedCellTable: " + sortedCellTable); - } - break; default: break; } From 8ed729ea5182ff5fc9299b4941766573b46285f2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 6 Aug 2021 16:23:17 +0200 Subject: [PATCH 07/32] moved to gwt.2.9.0. Added Sort By facility --- .settings/org.eclipse.jdt.core.prefs | 4 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- pom.xml | 20 +- .../ConstantsGeoPortalDataEntryApp.java | 54 +++++ .../client/GeoPortalDataEntryApp.java | 16 +- .../client/GeoportalDataEntryService.java | 9 +- .../GeoportalDataEntryServiceAsync.java | 6 +- .../client/events/GetListOfRecordsEvent.java | 12 +- .../client/ui/GeonaMainTabPanel.java | 145 ++++++++++++- .../client/ui/GeonaMainTabPanel.ui.xml | 13 ++ .../client/ui/GeonaRecordsPaginatedView.java | 49 ++--- .../client/ui/table/ItemsTable.java | 61 +++--- .../server/GeoportalDataEntryServiceImpl.java | 193 +++++++++++++++++- .../server/SessionUtil.java | 31 ++- ...dData.java => ResultSetPaginatedData.java} | 26 ++- .../shared/ResultSetSorted.java | 56 +++++ .../geoportaldataentry/shared/SortFilter.java | 99 +++++++++ 17 files changed, 698 insertions(+), 98 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/{SearchedData.java => ResultSetPaginatedData.java} (85%) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 43c8195..cac0df4 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 7812414..d62827e 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,6 +2,6 @@ - + diff --git a/pom.xml b/pom.xml index d9fc82d..1a7a83b 100644 --- a/pom.xml +++ b/pom.xml @@ -25,12 +25,12 @@ - 2.7.0 + 2.9.0 ${project.build.directory}/${project.build.finalName} UTF-8 UTF-8 - 1.7 + 1.8 1.8 @@ -59,6 +59,22 @@ + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + + xml-apis + xml-apis + 1.4.01 + provided + com.google.gwt gwt-user diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index be14eb4..cd372a8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -2,6 +2,13 @@ package org.gcube.portlets.user.geoportaldataentry.client; import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; +/** + * The Class ConstantsGeoPortalDataEntryApp. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ public class ConstantsGeoPortalDataEntryApp { public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT; @@ -12,12 +19,59 @@ public class ConstantsGeoPortalDataEntryApp { public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!"; + /** + * The Enum RECORD_TYPE. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ public enum RECORD_TYPE { CONCESSIONE } + /** + * The Enum ACTION_ON_ITEM. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ public enum ACTION_ON_ITEM { SHOW_ON_MAP, SHOW_METADATA, REMOVE } + /** + * The Enum RECORD_FIELD. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ + public static enum RECORD_FIELD { + NAME, INTRODUCTION, AUTHOR, PROJECT_START, CREATED, CREATED_BY + } + + /** + * The Enum RECORD_FIELD. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ + public static enum RECORD_DISPLAY_FIELD { + NAME, INTRODUCTION, AUTHOR, PROJECT_START_END_DATE, CREATED, CREATED_BY + } + + /** + * The Enum ORDER. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ + public static enum ORDER { + ASC, DESC + } + } 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 03ef45b..0dde10e 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 @@ -10,6 +10,8 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler; @@ -24,7 +26,6 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginate import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; -import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; @@ -33,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWind import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; @@ -90,7 +92,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { */ public void onModuleLoad() { - mainTabPanel = new GeonaMainTabPanel(appManagerBus); + RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START, + RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY }; + + SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); + + mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, initialSortFilter); mainTabPanel.setLoaderVisible("Loading...", true); geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); @@ -386,7 +393,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, - null, DISPLAY_FIELD.NAME); + null, getListOfRecordsEvent.getSortFilter()); mainTabPanel.showListOfConcessioniView(grpw); } }); @@ -496,7 +503,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { hp.add(alert); appManagerBus.fireEvent( - new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); + new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + mainTabPanel.getCurrentSortFilter())); } } 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 cfefca8..2e4a3ca 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 @@ -7,7 +7,8 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataE import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; -import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; +import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -52,12 +53,14 @@ public interface GeoportalDataEntryService extends RemoteService { * Gets the list concessioni. * * @param start the start - * @param offset the offset + * @param limit the limit + * @param filter the filter * @param reloadFromService the reload from service * @return the list concessioni * @throws Exception the exception */ - SearchedData getListConcessioni(Integer start, Integer offset, boolean reloadFromService) throws Exception; + public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter, boolean reloadFromService) throws Exception; + /** * Delete record. 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 a263630..ac5a768 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 @@ -7,7 +7,8 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataE import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; -import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; +import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -47,7 +48,8 @@ public interface GeoportalDataEntryServiceAsync void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void getListConcessioni(Integer start, Integer offset, boolean reloadFromService, AsyncCallback callback); + void getListConcessioni(Integer start, Integer limit, SortFilter filter, boolean reloadFromService, + AsyncCallback callback); void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java index 9fb313f..cbea945 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/GetListOfRecordsEvent.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.google.gwt.event.shared.GwtEvent; @@ -17,13 +18,14 @@ public class GetListOfRecordsEvent extends GwtEvent TYPE = new Type(); private RECORD_TYPE recordType; - + private SortFilter sortFilter; /** * Instantiates a new cancel upload event. */ - public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType) { + public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType, SortFilter sortFilter) { this.recordType = recordType; + this.sortFilter = sortFilter; } /** @@ -57,9 +59,13 @@ public class GetListOfRecordsEvent extends GwtEvent"); + anchorTop = new HTML("Go to top of table"); + + // Anchor bottom + divAnchorBotton = new HTML("
"); + anchorBottom = new HTML("Go to bottom of table"); + } + /** + * Bind events. + */ private void bindEvents() { buttCreateNewProject.addClickHandler(new ClickHandler() { @@ -93,7 +133,7 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE)); + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); } }); @@ -102,13 +142,49 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { + GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, - null, DISPLAY_FIELD.NAME); + null, currentSortFilter); showListOfConcessioniView(grpw); } }); + for (RECORD_FIELD record_FIELD : sortByFields) { + + // ASC + SortFilter sortFilter = new SortFilter(record_FIELD, ORDER.ASC); + String labelASC = toLabelFilter(sortFilter); + NavLink nav = new NavLink(labelASC); + dropdownSortBy.add(nav); + + nav.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + GWT.log("Sort by: " + sortFilter); + setCurrentSortFilter(sortFilter); + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); + } + }); + +// //DESC + SortFilter sortFilter2 = new SortFilter(record_FIELD, ORDER.DESC); + String labelASC2 = toLabelFilter(sortFilter2); + NavLink nav2 = new NavLink(labelASC2); + dropdownSortBy.add(nav2); + + nav2.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + GWT.log("Sort by: " + sortFilter2); + setCurrentSortFilter(sortFilter2); + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); + } + }); + } + } /** @@ -120,11 +196,23 @@ public class GeonaMainTabPanel extends Composite { geonaMainFormPanel.add(formPanel); } + /** + * Show list of concessioni view. + * + * @param grpw the grpw + */ public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { geonaListOfConcessioniPanel.clear(); VerticalPanel htmllPanel = new VerticalPanel(); + + htmllPanel.add(divAnchorTop); + htmllPanel.add(anchorBottom); + htmllPanel.add(grpw.getCellPanel()); htmllPanel.add(grpw.getPagerPanel()); + + htmllPanel.add(anchorTop); + htmllPanel.add(divAnchorBotton); geonaListOfConcessioniPanel.add(htmllPanel); } @@ -139,4 +227,51 @@ public class GeonaMainTabPanel extends Composite { loader.setVisible(visible); } + private void setCurrentSortFilter(SortFilter sortFilter) { + this.currentSortFilter = sortFilter; + this.textBoxSortBy.setText(toLabelFilter(sortFilter)); + } + + /** + * To label filter. + * + * @param sortFilter the sort filter + * @return the string + */ + public String toLabelFilter(SortFilter sortFilter) { + + String labelFilter = sortFilter.getOrderByField().name() + LABEL_FILTER_SEPARATOR + + sortFilter.getOrder().name(); + GWT.log("Got " + sortFilter); + return labelFilter; + } + + /** + * To sort filter. + * + * @param labelFilter the label filter + * @return the sort filter + */ + public SortFilter toSortFilter(String labelFilter) { + + String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); + + SortFilter sortFilter = null; + try { + RECORD_FIELD recordField = RECORD_FIELD.valueOf(array[0]); + ORDER orderField = ORDER.valueOf(array[1]); + sortFilter = new SortFilter(recordField, orderField); + } catch (Exception e) { + + } + + GWT.log("Got " + sortFilter); + return sortFilter; + + } + + public SortFilter getCurrentSortFilter() { + return currentSortFilter; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 9982f00..cdfc9bc 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -16,6 +16,10 @@ margin-bottom: 10px; border: 1px solid #eee; } + + .margin-top-5 { + margin-top: 5px; + } List of Projects + + + + + + + + Reload Projects diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 37e0b0e..595a51a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -3,13 +3,14 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; import java.util.List; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable; -import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ui.table.SortedCellTable; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; -import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; +import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerManager; @@ -49,21 +50,23 @@ public class GeonaRecordsPaginatedView { private int serverStartIndex; private HandlerManager eventBus; private RECORD_TYPE recordType; + private SortFilter currentSortFilter; /** * Instantiates a new geona records paginated view. * - * @param eventbus the eventbus - * @param recordType the record type - * @param displayFields the display fields - * @param sortByField the sort by field + * @param eventbus the eventbus + * @param recordType the record type + * @param displayFields the display fields + * @param currentSortFilter the sort by field */ - public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields, - DISPLAY_FIELD sortByField) { + public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, + RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { this.recordType = recordType; + this.currentSortFilter = currentSortFilter; this.initClassFirstRangeChanged = true; this.eventBus = eventbus; - itemsTable = new ItemsTable(eventbus, displayFields, sortByField); + itemsTable = new ItemsTable(eventbus, displayFields, currentSortFilter); itemsTable.initTable(null, null, dataProvider); orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); @@ -111,13 +114,13 @@ public class GeonaRecordsPaginatedView { /** * Load new page. * - * @param startIdx the start idx - * @param limit the limit - * @param resetStore the reset store + * @param startIdx the start idx + * @param limit the limit + * @param resetStore the reset store * @param invalidCache the invalid cache */ private void loadNewPage(final int startIdx, final int limit, final boolean resetStore, - final boolean invalidCache) { + final SortFilter currentSortFilter, final boolean invalidCache) { // initFirstRangeChanged = resetStore; GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" + resetStore + "]"); @@ -133,7 +136,7 @@ public class GeonaRecordsPaginatedView { getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false); } - loadConcessioni(newStartIndex, limit, serverStartIndex, invalidCache); + loadConcessioni(newStartIndex, limit, serverStartIndex, currentSortFilter, invalidCache); } /** @@ -144,7 +147,7 @@ public class GeonaRecordsPaginatedView { public void loadItemsForType(RECORD_TYPE recordType) { this.recordType = recordType; getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false); - loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true, true); + loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true, currentSortFilter, true); } /** @@ -152,7 +155,7 @@ public class GeonaRecordsPaginatedView { * * @param result the new new page result */ - private void setNewPageResult(SearchedData result) { + private void setNewPageResult(ResultSetPaginatedData result) { GWT.log("setNewPageResult: " + result); serverStartIndex = result.getServerEndIndex(); SelectionModel sm = getCellTable().getSelectionModel(); @@ -194,14 +197,14 @@ public class GeonaRecordsPaginatedView { * @param limit the limit * @param serverIndex the server index */ - private void loadConcessioni(int newStartIndex, int limit, int serverIndex, boolean invalidCache) { + private void loadConcessioni(int newStartIndex, int limit, int serverIndex, SortFilter sortFilter, + boolean invalidCache) { showLoading(true); GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit - + ", serverIndex:" + serverIndex + "]"); - - GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, invalidCache, - new AsyncCallback() { + + ", serverIndex:" + serverIndex + ", sortFilter: " + sortFilter + "]"); + GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, sortFilter, invalidCache, + new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -211,7 +214,7 @@ public class GeonaRecordsPaginatedView { } @Override - public void onSuccess(SearchedData result) { + public void onSuccess(ResultSetPaginatedData result) { showLoading(false); setNewPageResult(result); @@ -287,7 +290,7 @@ public class GeonaRecordsPaginatedView { return; } GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); - loadNewPage(start, length, false, false); + loadNewPage(start, length, false, currentSortFilter, false); // eventBus.fireEvent(new TableRangeViewChangedEvent(start, length)); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 9edee64..bdd7649 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -13,7 +13,9 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.github.gwtbootstrap.client.ui.Pagination; import com.google.gwt.cell.client.ButtonCell; @@ -58,35 +60,26 @@ public class ItemsTable extends AbstractItemsCellTable< private AbstractDataProvider dataProvider; - /** - * The Enum DISPLAY_FIELD. - * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 - */ - public static enum DISPLAY_FIELD { - NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_START_END_DATE, CREATED, CREATED_BY - }; - - private List displayFields; + private List displayFields; private TextColumn startEndProjectColumn; // private Column startProjectDateColumn; // private Column endProjectDateColumn; - private DISPLAY_FIELD startSortByColumn; private boolean isAsyncronusTable; private TextColumn insertedBy; private Column createdColumn; + private SortFilter currentSortFilter; /** * Instantiates a new items table. * * @param eventBus the event bus - * @param fields the fields + * @param displayFields the display fields * @param startSortByColumn the start sort by column */ - public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields, DISPLAY_FIELD startSortByColumn) { + public ItemsTable(HandlerManager eventBus, RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { this.eventBus = eventBus; - this.startSortByColumn = startSortByColumn; - setDisplayFields(fields); + this.currentSortFilter = currentSortFilter; + setDisplayFields(displayFields); } /** @@ -115,7 +108,7 @@ public class ItemsTable extends AbstractItemsCellTable< this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; setEmptyTableMessage(NO_DATA); - if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { // NAME name = new TextColumn() { @@ -152,7 +145,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { introduction = new TextColumn() { @Override @@ -181,7 +174,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { author = new TextColumn() { @Override @@ -212,7 +205,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_END_DATE)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.PROJECT_START_END_DATE)) { startEndProjectColumn = new TextColumn() { @Override @@ -231,7 +224,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED)) { DateCell date = new DateCell(dtformat); createdColumn = new Column(date) { @@ -275,7 +268,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(DISPLAY_FIELD.CREATED_BY)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED_BY)) { // NAME insertedBy = new TextColumn() { @@ -336,22 +329,22 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.addColumn(deleteRecordColumn); sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX); - GWT.log("startSortByColumn: " + startSortByColumn); + GWT.log("currentSortFilter: " + currentSortFilter); - if (startSortByColumn != null) - switch (startSortByColumn) { + if (currentSortFilter != null) + switch (currentSortFilter.getOrderByField()) { case NAME: - if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { sortedCellTable.setInitialSortColumn(name); } break; - case INTRO: - if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) { + case INTRODUCTION: + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { sortedCellTable.setInitialSortColumn(introduction); } break; case AUTHOR: - if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { sortedCellTable.setInitialSortColumn(author); } break; @@ -361,6 +354,12 @@ public class ItemsTable extends AbstractItemsCellTable< } + /** + * To display authors. + * + * @param authors the authors + * @return the string + */ private String toDisplayAuthors(List authors) { String toDisplay = ""; if (authors == null) @@ -400,9 +399,9 @@ public class ItemsTable extends AbstractItemsCellTable< * * @param fields the new display fields */ - public void setDisplayFields(DISPLAY_FIELD[] fields) { + public void setDisplayFields(RECORD_DISPLAY_FIELD[] fields) { this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields) - : Arrays.asList(DISPLAY_FIELD.values()); + : Arrays.asList(RECORD_DISPLAY_FIELD.values()); } /** @@ -421,7 +420,7 @@ public class ItemsTable extends AbstractItemsCellTable< * * @return the displayFields */ - public List getDisplayFields() { + public List getDisplayFields() { return displayFields; } 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 27634c5..445cf01 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 @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.server; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,19 +21,23 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; -import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData; +import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.server.rpc.RemoteServiceServlet; /** @@ -405,19 +410,124 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return item; } + /* + * @Override public ResultSetPaginatedData getListConcessioni(Integer start, + * Integer limit, SortFilter filter, boolean reloadFromService) throws Exception + * { LOG.info("getListConcessioni called wit start: " + start + ", limit: " + + * limit + ", filter: " + filter); + * + * try { List listOfConcessioni = + * SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService); + * int listConcessioniSize = listOfConcessioni.size(); + * + * List toReturn = new ArrayList(); int startIndex; + * int limitIndex = 0; if (start == null && limit == null) { startIndex = 0; + * limitIndex = listConcessioniSize; } else { startIndex = start; limitIndex = + * start + limit; if (limitIndex > listConcessioniSize) { limitIndex = + * listConcessioniSize; } } + * + * ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, + * limit, startIndex, false); searchedData.setTotalItems(listConcessioniSize); + * + * if (filter == null) { // unsorted list of records toReturn = + * listOfConcessioni.subList(startIndex, limitIndex); } else { + * + * RECORD_FIELD orderBy = filter.getOrderByField(); ORDER order = + * filter.getOrder(); + * + * if (orderBy == null) orderBy = RECORD_FIELD.NAME; + * + * if (order == null) order = ORDER.ASC; + * + * ResultSetSorted resultSetSorted = + * SessionUtil.getLatestResultSetSorted(getThreadLocalRequest()); boolean + * latestOrderBy = + * resultSetSorted.getSearchFilter().getOrderByField().equals(orderBy); boolean + * latestOrder = resultSetSorted.getSearchFilter().getOrder().equals(order); + * + * //Checking if SortFilter is new (different to previous one used). If yes + * sorting again if(resultSetSorted==null || !latestOrderBy || !latestOrder) { + * + * // CASE INSENSITIVE COMPARATOR Comparator comparator = null; + * switch (orderBy) { case NAME: if (order.equals(ORDER.ASC)) { comparator = + * Comparator.comparing(Concessione::getNome, + * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); } else { comparator = + * Comparator .comparing(Concessione::getNome, + * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)) .reversed(); } + * + * break; case CREATED: if (order.equals(ORDER.ASC)) { comparator = + * Comparator.comparing(Concessione::getCreationTime, + * Comparator.nullsLast(Comparator.naturalOrder())); } else { comparator = + * Comparator.comparing(Concessione::getCreationTime, + * Comparator.nullsLast(Comparator.naturalOrder())).reversed(); } break; + * + * case CREATED_BY: if (order.equals(ORDER.ASC)) { comparator = + * Comparator.comparing(Concessione::getCreationUser, + * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); } else { comparator = + * Comparator.comparing(Concessione::getCreationUser, + * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).reversed(); } break; + * + * case PROJECT_START: if (order.equals(ORDER.ASC)) { comparator = + * Comparator.comparing(Concessione::getDataInizioProgetto, + * Comparator.nullsLast(Comparator.naturalOrder())); } else { comparator = + * Comparator.comparing(Concessione::getDataInizioProgetto, + * Comparator.nullsLast(Comparator.naturalOrder())).reversed(); } break; + * + * default: break; } + * + * // sorting with nullsLast + * listOfConcessioni.sort(Comparator.nullsLast(comparator)); + * Log.debug("sorted list: " + listOfConcessioni); //saving in session the + * ResultSetSorted with SortFilter and ordered data ResultSetSorted rsSorted = + * new ResultSetSorted(new SortFilter(orderBy, order), listOfConcessioni); + * SessionUtil.setLatestResultSetSorted(getThreadLocalRequest(),rsSorted); + * + * }else { //Using the ResultSet sorted at previous request listOfConcessioni = + * resultSetSorted.getData(); } + * + * // pagination toReturn = listOfConcessioni.subList(startIndex, limitIndex); } + * + * List toReturnList = new + * ArrayList(toReturn.size()); + * + * for (Concessione concessione : toReturn) { ConcessioneDV concessioneDV = + * ConvertToDataViewModel.toBaseConcessione(concessione); + * toReturnList.add(concessioneDV); } + * + * + * searchedData.setData(toReturnList); + * + * if (listConcessioniSize == limit || listConcessioniSize == 0) { + * LOG.debug("Page completed returning " + listConcessioniSize + " items"); int + * newOffset = startIndex + start; + * searchedData.setServerSearchFinished(newOffset > listConcessioniSize || + * listConcessioniSize == 0); LOG.debug("is Search finished: " + + * searchedData.isServerSearchFinished()); return searchedData; } + * + * LOG.debug("Returning: " + toReturnList); + * LOG.info("Returning list of concessioni with size: " + toReturnList.size()); + * return searchedData; } catch (Exception e) { + * LOG.error("Error on loading list of concessioni: ", e); throw new + * Exception("Error occurred on loading list of Concessioni. Error: " + + * e.getMessage()); } + * + * } + */ + /** * Gets the list concessioni. * * @param start the start * @param limit the limit - * @param reloadFromService if true, ignore the concessioni saved in session and - * reload them from service + * @param filter the filter + * @param reloadFromService the reload from service * @return the list concessioni * @throws Exception the exception */ @Override - public SearchedData getListConcessioni(Integer start, Integer limit, boolean reloadFromService) throws Exception { - LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit); + public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter, + boolean reloadFromService) throws Exception { + LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter); try { List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(), @@ -428,7 +538,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen int startIndex; int limitIndex = 0; if (start == null && limit == null) { - toReturn.addAll(listOfConcessioni); startIndex = 0; limitIndex = listConcessioniSize; } else { @@ -439,10 +548,78 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } - SearchedData searchedData = new SearchedData(start, limit, startIndex, false); + ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false); searchedData.setTotalItems(listConcessioniSize); - toReturn = listOfConcessioni.subList(startIndex, limitIndex); + if (filter == null) { + // unsorted list of records + toReturn = listOfConcessioni.subList(startIndex, limitIndex); + } else { + + RECORD_FIELD orderBy = filter.getOrderByField(); + ORDER order = filter.getOrder(); + + if (orderBy == null) + orderBy = RECORD_FIELD.NAME; + + if (order == null) + order = ORDER.ASC; + + // CASE INSENSITIVE COMPARATOR + Comparator comparator = null; + switch (orderBy) { + case NAME: + if (order.equals(ORDER.ASC)) { + comparator = Comparator.comparing(Concessione::getNome, + Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); + } else { + comparator = Comparator + .comparing(Concessione::getNome, Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)) + .reversed(); + } + + break; + case CREATED: + if (order.equals(ORDER.ASC)) { + comparator = Comparator.comparing(Concessione::getCreationTime, + Comparator.nullsLast(Comparator.naturalOrder())); + } else { + comparator = Comparator.comparing(Concessione::getCreationTime, + Comparator.nullsLast(Comparator.naturalOrder())).reversed(); + } + break; + + case CREATED_BY: + if (order.equals(ORDER.ASC)) { + comparator = Comparator.comparing(Concessione::getCreationUser, + Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); + } else { + comparator = Comparator.comparing(Concessione::getCreationUser, + Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).reversed(); + } + break; + + case PROJECT_START: + if (order.equals(ORDER.ASC)) { + comparator = Comparator.comparing(Concessione::getDataInizioProgetto, + Comparator.nullsLast(Comparator.naturalOrder())); + } else { + comparator = Comparator.comparing(Concessione::getDataInizioProgetto, + Comparator.nullsLast(Comparator.naturalOrder())).reversed(); + } + break; + + default: + break; + } + + // sorting with nullsLast + listOfConcessioni.sort(Comparator.nullsLast(comparator)); + Log.debug("sorted list: " + listOfConcessioni); + + // pagination + toReturn = listOfConcessioni.subList(startIndex, limitIndex); + } List toReturnList = new ArrayList(toReturn.size()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 735e6d3..549cf8a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -17,6 +17,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetSorted; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; @@ -154,17 +155,16 @@ public class SessionUtil { } } - LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni); + // LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni); LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size()); } else - LOG.info("list of concessioni presents in session"); + LOG.info("list of concessioni presents in session, using it"); LOG.info("read list of concessioni with size: " + listOfConcessioni.size()); return listOfConcessioni; } - /** * Gets the geportal viewer resource profile. * @@ -183,8 +183,31 @@ public class SessionUtil { geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null); session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile); } - + return geoNaDataViewerProfile; } + + /** + * Gets the latest result set sorted. + * + * @param httpServletRequest the http servlet request + * @return the latest result set sorted + */ + public static ResultSetSorted getLatestResultSetSorted(HttpServletRequest httpServletRequest) { + HttpSession session = httpServletRequest.getSession(); + return (ResultSetSorted) session.getAttribute("LATEST_RESULT_SET_SORTED"); + } + + /** + * Gets the latest sort filter. + * + * @param httpServletRequest the http servlet request + * @return the latest sort filter + */ + public static void setLatestResultSetSorted(HttpServletRequest httpServletRequest, ResultSetSorted rsSorted) { + HttpSession session = httpServletRequest.getSession(); + session.setAttribute("LATEST_RESULT_SET_SORTED", rsSorted); + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java similarity index 85% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java index f9bb70c..d838915 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SearchedData.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetPaginatedData.java @@ -10,13 +10,13 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; /** - * The Class SearchedFolder. + * The Class ResultSetPaginatedData. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Jun 16, 2021 + * Aug 6, 2021 */ -public class SearchedData implements Serializable { +public class ResultSetPaginatedData implements Serializable { /** * @@ -32,18 +32,19 @@ public class SearchedData implements Serializable { /** * Instantiates a new searched folder. */ - public SearchedData() { + public ResultSetPaginatedData() { } + /** - * Instantiates a new searched data. + * Instantiates a new result set paginated data. * - * @param clientStartIndex the client start index - * @param limit the limit - * @param serverEndIndex the server end index + * @param clientStartIndex the client start index + * @param limit the limit + * @param serverEndIndex the server end index * @param isServerSearchFinished the is server search finished */ - public SearchedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) { + public ResultSetPaginatedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) { this.clientStartIndex = clientStartIndex; this.limit = limit; @@ -159,10 +160,15 @@ public class SearchedData implements Serializable { this.totalItems = totalItems; } + /** + * To string. + * + * @return the string + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("SearchedData [data="); + builder.append("ResultSetPaginatedData [data="); builder.append(data); builder.append(", clientStartIndex="); builder.append(clientStartIndex); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java new file mode 100644 index 0000000..412d1a0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/ResultSetSorted.java @@ -0,0 +1,56 @@ +package org.gcube.portlets.user.geoportaldataentry.shared; + +import java.io.Serializable; +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.Concessione; + +public class ResultSetSorted implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 889420364685643758L; + + private SortFilter searchFilter; + + private List data; + + ResultSetSorted() { + + } + + public ResultSetSorted(SortFilter searchFilter, List data) { + super(); + this.searchFilter = searchFilter; + this.data = data; + } + + public SortFilter getSearchFilter() { + return searchFilter; + } + + public List getData() { + return data; + } + + public void setSearchFilter(SortFilter searchFilter) { + this.searchFilter = searchFilter; + } + + public void setData(List data) { + this.data = data; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("ResultSetSorted [searchFilter="); + builder.append(searchFilter); + builder.append(", data="); + builder.append(data); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java new file mode 100644 index 0000000..aca6e31 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java @@ -0,0 +1,99 @@ +package org.gcube.portlets.user.geoportaldataentry.shared; + +import java.io.Serializable; + +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; + + +/** + * The Class SortFilter. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ +public class SortFilter implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -4004094263090373626L; + + private RECORD_FIELD orderByField; + + private ORDER order; + + + /** + * Instantiates a new sort filter. + */ + public SortFilter() { + + } + + + /** + * Instantiates a new sort filter. + * + * @param orderByField the order by field + * @param order the order + */ + public SortFilter(RECORD_FIELD orderByField, ORDER order) { + this.orderByField = orderByField; + this.order = order; + } + + /** + * Gets the order by field. + * + * @return the order by field + */ + public RECORD_FIELD getOrderByField() { + return orderByField; + } + + /** + * Gets the order. + * + * @return the order + */ + public ORDER getOrder() { + return order; + } + + /** + * Sets the order by field. + * + * @param orderByField the new order by field + */ + public void setOrderByField(RECORD_FIELD orderByField) { + this.orderByField = orderByField; + } + + /** + * Sets the order. + * + * @param order the new order + */ + public void setOrder(ORDER order) { + this.order = order; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("SortFilter [orderByField="); + builder.append(orderByField); + builder.append(", order="); + builder.append(order); + builder.append("]"); + return builder.toString(); + } + +} From 16484549ed155a78f0b9043fab799c5d799188df Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 6 Aug 2021 16:47:07 +0200 Subject: [PATCH 08/32] updated css --- .../geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index cdfc9bc..1380058 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -17,8 +17,8 @@ border: 1px solid #eee; } - .margin-top-5 { - margin-top: 5px; + .margin-top-8 { + margin-top: 8px !important; } @@ -50,7 +50,7 @@ + addStyleNames="{style.margin-top-8}"> Date: Fri, 6 Aug 2021 17:42:22 +0200 Subject: [PATCH 09/32] updated uibinder with anchors to page --- .../client/ui/GeonaMainTabPanel.java | 24 ------------- .../client/ui/GeonaMainTabPanel.ui.xml | 35 +++++++++++++++---- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index f65ea43..a340890 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -20,7 +20,6 @@ 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.ui.Composite; -import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; @@ -83,14 +82,6 @@ public class GeonaMainTabPanel extends Composite { private SortFilter currentSortFilter; - private HTML divAnchorTop; - - private HTML anchorTop; - - private HTML divAnchorBotton; - - private HTML anchorBottom; - /** * Instantiates a new geona main tab panel. * @@ -105,14 +96,6 @@ public class GeonaMainTabPanel extends Composite { setCurrentSortFilter(initialSortFilter); bindEvents(); - // Anchor top - divAnchorTop = new HTML("
"); - anchorTop = new HTML("Go to top of table"); - - // Anchor bottom - divAnchorBotton = new HTML("
"); - anchorBottom = new HTML("Go to bottom of table"); - } /** @@ -204,15 +187,8 @@ public class GeonaMainTabPanel extends Composite { public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { geonaListOfConcessioniPanel.clear(); VerticalPanel htmllPanel = new VerticalPanel(); - - htmllPanel.add(divAnchorTop); - htmllPanel.add(anchorBottom); - htmllPanel.add(grpw.getCellPanel()); htmllPanel.add(grpw.getPagerPanel()); - - htmllPanel.add(anchorTop); - htmllPanel.add(divAnchorBotton); geonaListOfConcessioniPanel.add(htmllPanel); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 1380058..73272de 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -20,6 +20,17 @@ .margin-top-8 { margin-top: 8px !important; } + + .margin-top-5 { + margin-top: 5px !important; + } + + .float-right { + display: block; + width: 100%; + font-size: 12px; + text-align: right; + } - New Project + New Project Create New Project - + +
+ Go to bottom +
- + +
+ Go to top +
- List of Projects + List of Projects - Reload Projects - + +
+ Go to bottom +
+ +
+ Go to top +
From 2208adec46fd4e7c8b44305f6be9e39361afb2ec Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 2 Sep 2021 18:14:49 +0200 Subject: [PATCH 10/32] refactoring --- .../ConstantsGeoPortalDataEntryApp.java | 46 ++++++++++--------- .../client/GeoPortalDataEntryApp.java | 4 +- .../client/ui/GeonaMainTabPanel.java | 8 ++-- .../client/ui/GeonaRecordsPaginatedView.java | 4 +- .../client/ui/table/ItemsTable.java | 42 ++++++++--------- .../server/GeoportalDataEntryServiceImpl.java | 7 +-- .../server/SessionUtil.java | 1 + .../geoportaldataentry/shared/SortFilter.java | 29 +++++++++--- 8 files changed, 81 insertions(+), 60 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index cd372a8..08e58b4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -46,32 +46,34 @@ public class ConstantsGeoPortalDataEntryApp { * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 6, 2021 + * Sep 2, 2021 */ public static enum RECORD_FIELD { - NAME, INTRODUCTION, AUTHOR, PROJECT_START, CREATED, CREATED_BY - } + NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"), + PROJECT_START_END_DATE("", "Project Start/End Date"), CREATED("created", "Created"), + CREATED_BY("createdBy", "Created by"); - /** - * The Enum RECORD_FIELD. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Aug 6, 2021 - */ - public static enum RECORD_DISPLAY_FIELD { - NAME, INTRODUCTION, AUTHOR, PROJECT_START_END_DATE, CREATED, CREATED_BY - } + String jsonFieldName; + String displayName; - /** - * The Enum ORDER. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Aug 6, 2021 - */ - public static enum ORDER { - ASC, DESC + /** + * Instantiates a new record field. + * + * @param jsonFieldName the json field name + * @param displayName the display name + */ + RECORD_FIELD(String jsonFieldName, String displayName) { + this.jsonFieldName = jsonFieldName; + this.displayName = displayName; + } + + public String getJsonFieldName() { + return jsonFieldName; + } + + public String getDisplayName() { + return displayName; + } } } 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 0dde10e..8533789 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 @@ -10,7 +10,6 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; @@ -35,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; @@ -92,7 +92,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { */ public void onModuleLoad() { - RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START, + RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE, RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY }; SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index a340890..e2a33b7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -1,6 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; @@ -8,6 +7,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecords import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.NavLink; @@ -216,7 +216,7 @@ public class GeonaMainTabPanel extends Composite { */ public String toLabelFilter(SortFilter sortFilter) { - String labelFilter = sortFilter.getOrderByField().name() + LABEL_FILTER_SEPARATOR + String labelFilter = sortFilter.getOrderByField().getDisplayName() + LABEL_FILTER_SEPARATOR + sortFilter.getOrder().name(); GWT.log("Got " + sortFilter); return labelFilter; @@ -228,7 +228,7 @@ public class GeonaMainTabPanel extends Composite { * @param labelFilter the label filter * @return the sort filter */ - public SortFilter toSortFilter(String labelFilter) { + /*public SortFilter toSortFilter(String labelFilter) { String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); @@ -244,7 +244,7 @@ public class GeonaMainTabPanel extends Composite { GWT.log("Got " + sortFilter); return sortFilter; - } + }*/ public SortFilter getCurrentSortFilter() { return currentSortFilter; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index 595a51a..a9ec117 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; import java.util.List; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_FIELD; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable; @@ -61,7 +61,7 @@ public class GeonaRecordsPaginatedView { * @param currentSortFilter the sort by field */ public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, - RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { + RECORD_FIELD[] displayFields, SortFilter currentSortFilter) { this.recordType = recordType; this.currentSortFilter = currentSortFilter; this.initClassFirstRangeChanged = true; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index bdd7649..cb30087 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -13,7 +13,7 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_DISPLAY_FIELD; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; @@ -60,7 +60,7 @@ public class ItemsTable extends AbstractItemsCellTable< private AbstractDataProvider dataProvider; - private List displayFields; + private List displayFields; private TextColumn startEndProjectColumn; // private Column startProjectDateColumn; // private Column endProjectDateColumn; @@ -76,7 +76,7 @@ public class ItemsTable extends AbstractItemsCellTable< * @param displayFields the display fields * @param startSortByColumn the start sort by column */ - public ItemsTable(HandlerManager eventBus, RECORD_DISPLAY_FIELD[] displayFields, SortFilter currentSortFilter) { + public ItemsTable(HandlerManager eventBus, RECORD_FIELD[] displayFields, SortFilter currentSortFilter) { this.eventBus = eventBus; this.currentSortFilter = currentSortFilter; setDisplayFields(displayFields); @@ -108,7 +108,7 @@ public class ItemsTable extends AbstractItemsCellTable< this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true; setEmptyTableMessage(NO_DATA); - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_FIELD.NAME)) { // NAME name = new TextColumn() { @@ -130,7 +130,7 @@ public class ItemsTable extends AbstractItemsCellTable< }; }; - sortedCellTable.addColumn(name, "Name", true); + sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -145,7 +145,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { + if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) { introduction = new TextColumn() { @Override @@ -158,7 +158,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(introduction, "Introduction", true); + sortedCellTable.addColumn(introduction, RECORD_FIELD.INTRODUCTION.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -174,7 +174,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) { author = new TextColumn() { @Override @@ -187,7 +187,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(author, "Author/s", true); + sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -205,7 +205,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.PROJECT_START_END_DATE)) { + if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) { startEndProjectColumn = new TextColumn() { @Override @@ -219,12 +219,12 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(startEndProjectColumn, "Start/End Date", false); + sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false); sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX); } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED)) { + if (this.displayFields.contains(RECORD_FIELD.CREATED)) { DateCell date = new DateCell(dtformat); createdColumn = new Column(date) { @@ -237,7 +237,7 @@ public class ItemsTable extends AbstractItemsCellTable< return (((ConcessioneDV) object).getCreationTime()); } }; - sortedCellTable.addColumn(createdColumn, "Created", true); + sortedCellTable.addColumn(createdColumn, RECORD_FIELD.CREATED.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -268,7 +268,7 @@ public class ItemsTable extends AbstractItemsCellTable< } - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.CREATED_BY)) { + if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) { // NAME insertedBy = new TextColumn() { @@ -280,7 +280,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(insertedBy, "Created by", true); + sortedCellTable.addColumn(insertedBy, RECORD_FIELD.CREATED_BY.getDisplayName(), true); if (!isAsyncronusTable) { Comparator c = new Comparator() { @@ -334,17 +334,17 @@ public class ItemsTable extends AbstractItemsCellTable< if (currentSortFilter != null) switch (currentSortFilter.getOrderByField()) { case NAME: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.NAME)) { + if (this.displayFields.contains(RECORD_FIELD.NAME)) { sortedCellTable.setInitialSortColumn(name); } break; case INTRODUCTION: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.INTRODUCTION)) { + if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) { sortedCellTable.setInitialSortColumn(introduction); } break; case AUTHOR: - if (this.displayFields.contains(RECORD_DISPLAY_FIELD.AUTHOR)) { + if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) { sortedCellTable.setInitialSortColumn(author); } break; @@ -399,9 +399,9 @@ public class ItemsTable extends AbstractItemsCellTable< * * @param fields the new display fields */ - public void setDisplayFields(RECORD_DISPLAY_FIELD[] fields) { + public void setDisplayFields(RECORD_FIELD[] fields) { this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields) - : Arrays.asList(RECORD_DISPLAY_FIELD.values()); + : Arrays.asList(RECORD_FIELD.values()); } /** @@ -420,7 +420,7 @@ public class ItemsTable extends AbstractItemsCellTable< * * @return the displayFields */ - public List getDisplayFields() { + public List getDisplayFields() { return displayFields; } 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 445cf01..f13752c 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 @@ -12,7 +12,7 @@ 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.ValidationReport; -import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest; +import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; @@ -21,7 +21,6 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; @@ -31,6 +30,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.vomanagement.usermanagement.model.GCubeUser; @@ -599,7 +599,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } break; - case PROJECT_START: + //TODO is buggy must be performed by service + case PROJECT_START_END_DATE: if (order.equals(ORDER.ASC)) { comparator = Comparator.comparing(Concessione::getDataInizioProgetto, Comparator.nullsLast(Comparator.naturalOrder())); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 549cf8a..03f06c2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -147,6 +147,7 @@ public class SessionUtil { SessionUtil.getCurrentContext(httpServletRequest, true); ServiceUtil serviceUtil = new ServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Iterator concessioni = clientMongo.getList(); if (concessioni != null) { while (concessioni.hasNext()) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java index aca6e31..5226711 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/SortFilter.java @@ -2,19 +2,38 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ORDER; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; - /** * The Class SortFilter. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 6, 2021 + * Aug 6, 2021 */ public class SortFilter implements Serializable { + /** + * The Enum ORDER. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 6, 2021 + */ + public static enum ORDER { + ASC("ASCENDING"), DESC("DESCENDING"); + + String label; + + ORDER(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + } + /** * */ @@ -24,7 +43,6 @@ public class SortFilter implements Serializable { private ORDER order; - /** * Instantiates a new sort filter. */ @@ -32,12 +50,11 @@ public class SortFilter implements Serializable { } - /** * Instantiates a new sort filter. * * @param orderByField the order by field - * @param order the order + * @param order the order */ public SortFilter(RECORD_FIELD orderByField, ORDER order) { this.orderByField = orderByField; From 296703f5fbe65b0997b359bdc148fbe7967981ab Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 14 Sep 2021 13:08:55 +0200 Subject: [PATCH 11/32] #22002 Integrated with ValidationReport and status --- CHANGELOG.md | 1 + .../ConstantsGeoPortalDataEntryApp.java | 10 +- .../client/GeoPortalDataEntryApp.java | 34 +++-- .../ui/report/BuildValidationReport.java | 57 ++++++++ .../ui/report/ReportTemplateToHTML.java | 66 ++++----- .../ui/report/ReportTemplateToHTML.ui.xml | 3 +- .../client/ui/table/ItemsTable.java | 44 +++++- .../client/ui/utils/NewBrowserWindow.java | 7 +- .../server/GeoportalDataEntryServiceImpl.java | 63 +++++---- .../shared/CommitReport.java | 125 +++--------------- src/main/webapp/GeoPortalDataEntryApp.html | 9 ++ 11 files changed, 222 insertions(+), 197 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f9b5eb2..ddf49a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Moved to maven-portal-bom 3.6.3 [#21856] Implementing new user feedback [#21890] Passed to mongoID [#20599] Get List of Records +[#22002] Integrated with ValidationReport and status ## [v1.2.0] - 2020-12-18 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 08e58b4..8eb2bf2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -38,7 +38,7 @@ public class ConstantsGeoPortalDataEntryApp { * Aug 6, 2021 */ public enum ACTION_ON_ITEM { - SHOW_ON_MAP, SHOW_METADATA, REMOVE + SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, REMOVE } /** @@ -50,7 +50,7 @@ public class ConstantsGeoPortalDataEntryApp { */ public static enum RECORD_FIELD { NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"), - PROJECT_START_END_DATE("", "Project Start/End Date"), CREATED("created", "Created"), + PROJECT_START_END_DATE("", "Project Start/End Date"), PUBLISHING_STATUS("publishingStatus", "Publishing Status"), CREATED("created", "Created"), CREATED_BY("createdBy", "Created by"); String jsonFieldName; @@ -60,17 +60,17 @@ public class ConstantsGeoPortalDataEntryApp { * Instantiates a new record field. * * @param jsonFieldName the json field name - * @param displayName the display name + * @param displayName the display name */ RECORD_FIELD(String jsonFieldName, String displayName) { this.jsonFieldName = jsonFieldName; this.displayName = displayName; } - + public String getJsonFieldName() { return jsonFieldName; } - + public String getDisplayName() { return displayName; } 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 8533789..6282481 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 @@ -9,6 +9,7 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; @@ -24,6 +25,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.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; +import org.gcube.portlets.user.geoportaldataentry.client.ui.report.BuildValidationReport; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; @@ -278,18 +280,18 @@ public class GeoPortalDataEntryApp implements EntryPoint { modalContainerPanel.clear(); modal.setCloseVisible(true); HTML recordPublished = new HTML(); - switch (result.getState()) { - case OK: + ValidationReportDV vr = result.getValidationReportDV(); + switch (vr.getStatus()) { + case PASSED: String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); recordPublished.setHTML("Record Published with " + success); projectSavedWithSuccess = true; - String msg = result.getMsg() != null ? result.getMsg() - : "Record published with success"; + String msg = "Record published with success"; geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); purgeFileUploaded(); break; - case WARN: + case WARNING: String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); recordPublished.setHTML("Record Published with " + warning); @@ -349,8 +351,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // geoNaMainForm.enableButtonSave(true); // resetUI(); - if (result.getReport() != null) { - modalContainerPanel.add(new ReportTemplateToHTML(result.getReport())); + if (vr.getAsJSONString() != null) { + modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString())); } } @@ -426,9 +428,10 @@ public class GeoPortalDataEntryApp implements EntryPoint { final Modal modal = new Modal(true, true); modal.setCloseVisible(true); final HorizontalPanel hpGetLink = new HorizontalPanel(); - final LoaderIcon lc = new LoaderIcon("Get link..."); + final LoaderIcon lc = new LoaderIcon("Just moment getting link..."); hpGetLink.add(lc); modal.add(hpGetLink); + final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), @@ -454,6 +457,21 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.show(); + break; + + case SHOW_REPORT: + final Modal modal2 = new Modal(true, true); + modal2.setWidth(800); + modal2.setCloseVisible(true); + if (concessione.getValidationReport() == null) { + modal2.add(new HTML("No report available for: "+concessione.getNome())); + } else { + BuildValidationReport buildValidationReport = new BuildValidationReport( + concessione.getValidationReport()); + modal2.add(buildValidationReport); + } + modal2.show(); + break; case REMOVE: diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java new file mode 100644 index 0000000..f1aa06d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java @@ -0,0 +1,57 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.report; + +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG; + +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; + +/** + * The Class BuildValidationReport. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 14, 2021 + */ +public class BuildValidationReport extends FlowPanel { + private HTML recordPublished = new HTML(); + private ReportTemplateToHTML rTToHTML; + + /** + * Instantiates a new builds the validation report. + * + * @param validationReport the validation report + */ + public BuildValidationReport(ValidationReportDV validationReport) { + + if(validationReport==null) + return; + + ValidationStatus status = validationReport.getStatus(); + switch (status) { + case PASSED: + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, "SUCCESS"); + recordPublished.setHTML("Record Published with " + success); + break; + case WARNING: + String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, "WARNING"); + recordPublished.setHTML("Record Published with " + warning); + + break; + case ERROR: + String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", "ERROR"); + recordPublished.setHTML(error + " on publishing the Record"); + break; + default: + break; + } + + rTToHTML = new ReportTemplateToHTML(validationReport.getAsJSONString()); + + add(recordPublished); + add(rTToHTML); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java index fb017d1..61b8afa 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java @@ -13,13 +13,12 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; - /** * The Class ReportTemplateToHTML. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Jan 25, 2021 + * Jan 25, 2021 */ public class ReportTemplateToHTML extends Composite { @@ -30,7 +29,7 @@ public class ReportTemplateToHTML extends Composite { * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Jan 25, 2021 + * Jan 25, 2021 */ interface ReportTemplateToHTMLUiBinder extends UiBinder { } @@ -43,66 +42,54 @@ public class ReportTemplateToHTML extends Composite { @UiField Paragraph reportJSON; - + boolean toJSONERROR = false; /** * Instantiates a new report template to HTML. * - * @param report the report + * @param reportAsJSON the report as JSON */ - public ReportTemplateToHTML(String report) { + public ReportTemplateToHTML(String reportAsJSON) { initWidget(uiBinder.createAndBindUi(this)); vpContainer.setVisible(false); - if (report != null) { - GWT.log("report is: " + report); + if (reportAsJSON != null) { + GWT.log("report is: " + reportAsJSON); vpContainer.setVisible(true); try { - JSONValue jsonObj = JSONParser.parse(report); + JSONValue jsonObj = JSONParser.parse(reportAsJSON); JSONObject json = (JSONObject) jsonObj; JSONValue valueChildren = json.get("children"); JSONArray jsonChildren = (JSONArray) valueChildren; - /*JSONObject jsonChildrenObject = (JSONObject) jsonChildren.get(0); - if (jsonChildrenObject.containsKey("objectName")) { - JSONValue validationReportON = jsonChildrenObject.get("objectName"); - String titleValue = HTMLUtil.getHTMLElement(HTML_TAG.div, 14, "000", "bold", validationReportON.toString()); - htmlContainer.add(new HTML(titleValue)); - } - - String toTableHTML = jsonToHTML(jsonChildrenObject.get("children").toString()); - GWT.log("toJSONERROR is: " + toJSONERROR); - GWT.log("toTableHTML is: " + toTableHTML); - - Set keySet = jsonChildrenObject.keySet();*/ - String toTableHTML = null; - for (int i=0; i" + toPrettyPrintJSON(reportAsJSON) + "")); } } + public static native String toPrettyPrintJSON(String jsonData)/*-{ + console.log(jsonData); + var objJSON = JSON.parse(jsonData); + return $wnd.prettyPrintJson.toHtml(objJSON); + }-*/; + /** * Json to HTML. * @@ -147,16 +134,15 @@ public class ReportTemplateToHTML extends Composite { var tabCell = tr.insertCell(-1); var theValue = jsonObj[j][col[i]]; //console.log("the value: "+theValue); - if(Object.prototype.toString.call(theValue) === '[object Array]'){ + if (Object.prototype.toString.call(theValue) === '[object Array]') { var formattedValueArray = ""; - for(var k = 0; k < theValue.length; k++) { - var theValueArray = theValue[k]; - //console.log(theValueArray); - formattedValueArray += theValueArray+"
"; + for (var k = 0; k < theValue.length; k++) { + var theValueArray = theValue[k]; + //console.log(theValueArray); + formattedValueArray += theValueArray + "
"; } tabCell.innerHTML = formattedValueArray; - } - else{ + } else { tabCell.innerHTML = theValue; } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml index 38beaaa..0081bcb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml @@ -15,7 +15,8 @@ Publication Report: - + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index cb30087..40566d0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -12,6 +12,7 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; @@ -62,6 +63,7 @@ public class ItemsTable extends AbstractItemsCellTable< private List displayFields; private TextColumn startEndProjectColumn; + private TextColumn statusColumn; // private Column startProjectDateColumn; // private Column endProjectDateColumn; private boolean isAsyncronusTable; @@ -219,7 +221,8 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false); + sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), + false); sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX); } @@ -295,6 +298,26 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); } + if (this.displayFields.contains(RECORD_FIELD.PUBLISHING_STATUS)) { + + statusColumn = new TextColumn() { + @Override + public String getValue(T object) { + if (object == null) + return ""; + + ValidationReportDV vd = ((ConcessioneDV) object).getValidationReport(); + if (vd != null) + return vd.getStatus().getLabel(); + return ""; + } + }; + + sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false); + sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX); + + } + ButtonCell showOnMapButton = new ButtonCell(); Column showOnMapColumn = new Column(showOnMapButton) { public String getValue(T object) { @@ -310,7 +333,24 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(showOnMapColumn); - sortedCellTable.setColumnWidth(showOnMapColumn, 120, Unit.PX); + sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX); + + ButtonCell showReportRecordButton = new ButtonCell(); + Column showReportRecordColumn = new Column(showReportRecordButton) { + public String getValue(T object) { + return "P. Report"; + } + }; + + showReportRecordColumn.setFieldUpdater(new FieldUpdater() { + @Override + public void update(int index, T object, String value) { + + eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT)); + } + }); + sortedCellTable.addColumn(showReportRecordColumn); + sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX); ButtonCell deleteRecordButton = new ButtonCell(); Column deleteRecordColumn = new Column(deleteRecordButton) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java index 6cc3d1f..b164e74 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/NewBrowserWindow.java @@ -4,7 +4,7 @@ import com.google.gwt.core.client.JavaScriptObject; /** * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 4, 2013 + * Sep 4, 2013 * */ public final class NewBrowserWindow extends JavaScriptObject { @@ -13,9 +13,8 @@ public final class NewBrowserWindow extends JavaScriptObject { protected NewBrowserWindow() { } - public static native NewBrowserWindow open(String url, String target, - String options) /*-{ - return $wnd.open(url, target, options); + public static native NewBrowserWindow open(String url, String target, String options) /*-{ + return $wnd.open(url, target, options) }-*/; public native void close() /*-{ 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 f13752c..8d574ca 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 @@ -20,12 +20,12 @@ import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; -import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; @@ -228,7 +228,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen if (ardsFiles != null && ardsFiles.size() > 0) { // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles); - clientMongo.registerFile(mongoId, request); + clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + ardsFiles.size() + " file/s"); } @@ -240,7 +240,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen if (files != null && files.size() > 0) { // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, files); - clientMongo.registerFile(mongoId, request); + clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + files.size() + " file/s"); } @@ -258,7 +258,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.imgByIndex(i), files); - clientMongo.registerFile(mongoId, request); + clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.IMMAGINI + "with " + files.size() + " file/s"); } @@ -274,7 +274,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.POSIZIONAMENTO, files); - clientMongo.registerFile(mongoId, request); + clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.POSIZIONAMENTO + "with " + files.size() + " file/s"); } @@ -291,7 +291,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // saving into back-end AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest( Paths.piantaByIndex(i), files); - clientMongo.registerFile(mongoId, request); + clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.PIANTE + "with " + files.size() + " file/s"); } @@ -314,34 +314,31 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // server report ValidationReport report = concessione.getReport(); LOG.info("ValidationReport: " + report); + // to client CommitReport cRep = new CommitReport(); // cRep.setRecordId(concessione.getId()); cRep.setMongoId(concessione.getMongo_id()); - String theJSON = serviceUtil.toJSON(report); - cRep.setReport(theJSON); - - switch (report.getStatus()) { - case PASSED: - cRep.setState(STATE.OK); - if (cRep.getMongoId() == null) { - LOG.error("The mongo id is null!!!"); - throw new Exception("Invalid identifier (mongoId is null) for the concessione"); - } - break; - case WARNING: - cRep.setState(STATE.WARN); - cRep.setMsg(report.getWarningMessages().toString()); - break; - case ERROR: - cRep.setState(STATE.ERROR); - cRep.setMsg(report.getErrorMessages().toString()); - break; - - default: - cRep.setState(STATE.UNKNOWN); - break; - } + ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); + cRep.setValidationReportDV(vr); +// switch (report.getStatus()) { +// case PASSED: +// if (cRep.getMongoId() == null) { +// LOG.error("The mongo id is null!!!"); +// throw new Exception("Invalid identifier (mongoId is null) for the concessione"); +// } +// cRep.setMsg("OK"); +// break; +// case WARNING: +// cRep.setMsg(report.getWarningMessages().toString()); +// break; +// case ERROR: +// cRep.setMsg(report.getErrorMessages().toString()); +// break; +// +// default: +// break; +// } return cRep; } else @@ -405,7 +402,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest()); GeoportalCommon gc = new GeoportalCommon(grViewerProfile); GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase()); - item = gc.getPublicLinksFor(item); + item = gc.getPublicLinksFor(item, false); LOG.info("Returning: " + item); return item; } @@ -599,7 +596,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } break; - //TODO is buggy must be performed by service + // TODO is buggy must be performed by service case PROJECT_START_END_DATE: if (order.equals(ORDER.ASC)) { comparator = Comparator.comparing(Concessione::getDataInizioProgetto, @@ -625,7 +622,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen List toReturnList = new ArrayList(toReturn.size()); for (Concessione concessione : toReturn) { - ConcessioneDV concessioneDV = ConvertToDataViewModel.toBaseConcessione(concessione); + ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); toReturnList.add(concessioneDV); } 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 e2db0ce..0750f2f 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 @@ -2,6 +2,8 @@ package org.gcube.portlets.user.geoportaldataentry.shared; import java.io.Serializable; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; + /** * The Class CommitReport. * @@ -16,22 +18,9 @@ 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 - */ - public enum STATE { - ERROR, WARN, OK, UNKNOWN - } - - public STATE state = STATE.UNKNOWN; public Long recordId; public String mongoId; - public String msg; - public String report; + public ValidationReportDV validationReportDV; /** * Instantiates a new commit report. @@ -40,120 +29,48 @@ public class CommitReport implements Serializable { } - /** - * Instantiates a new commit report. - * - * @param state the state - * @param recordId the record id - * @param mongoId the mongo id - * @param msg the msg - * @param report the report - */ - public CommitReport(STATE state, long recordId, String mongoId, String msg, String report) { + public CommitReport(Long recordId, String mongoId, ValidationReportDV validationReportDV) { super(); - this.state = state; + this.recordId = recordId; this.mongoId = mongoId; - this.msg = msg; - this.report = report; + this.validationReportDV = validationReportDV; } - /** - * Gets the state. - * - * @return the state - */ - public STATE getState() { - return state; - } - - /** - * Sets the state. - * - * @param state the new state - */ - public void setState(STATE state) { - this.state = state; - } - -// /** -// * Gets the record id. -// * -// * @return the record id -// */ -// public Long getRecordId() { -// 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. -// * -// * @param recordId the new record id -// */ -// public void setRecordId(long recordId) { -// this.recordId = recordId; -// } - - /** - * Gets the msg. - * - * @return the msg - */ - public String getMsg() { - return msg; + public Long getRecordId() { + return recordId; } public String getMongoId() { return mongoId; } + public ValidationReportDV getValidationReportDV() { + return validationReportDV; + } + + public void setRecordId(Long recordId) { + this.recordId = recordId; + } + public void setMongoId(String mongoId) { this.mongoId = mongoId; } - /** - * Sets the msg. - * - * @param msg the new msg - */ - public void setMsg(String msg) { - this.msg = msg; + public void setValidationReportDV(ValidationReportDV validationReportDV) { + this.validationReportDV = validationReportDV; } @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("CommitReport [state="); - builder.append(state); - builder.append(", recordId="); + builder.append("CommitReport [recordId="); builder.append(recordId); builder.append(", mongoId="); builder.append(mongoId); - builder.append(", msg="); - builder.append(msg); - builder.append(", report="); - builder.append(report); + builder.append(", validationReportDV="); + builder.append(validationReportDV); builder.append("]"); return builder.toString(); } - - } diff --git a/src/main/webapp/GeoPortalDataEntryApp.html b/src/main/webapp/GeoPortalDataEntryApp.html index dd319ab..0558c96 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.html +++ b/src/main/webapp/GeoPortalDataEntryApp.html @@ -14,6 +14,15 @@ + + + + + From 8a74c1f0d07d3a4402f713ffdf02365a79ef2592 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 14 Sep 2021 17:51:20 +0200 Subject: [PATCH 12/32] customized rendering of table according to status --- .../client/GeoPortalDataEntryApp.java | 6 +- .../ui/table/AbstractItemsCellTable.java | 2 +- .../client/ui/table/ItemsTable.java | 56 ++++++++++++---- .../client/ui/table/MyToolTipColumn.java | 5 +- .../server/GeoportalDataEntryServiceImpl.java | 28 ++++++-- .../server/ServiceUtil.java | 64 +++++++++++++++++-- src/main/webapp/GeoPortalDataEntryApp.css | 4 +- .../jsp/GeoPortalDataEntryAppPortlet_view.jsp | 7 ++ 8 files changed, 137 insertions(+), 35 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 6282481..89b9cce 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 @@ -95,7 +95,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onModuleLoad() { RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE, - RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY }; + RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.PUBLISHING_STATUS }; SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); @@ -431,7 +431,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { final LoaderIcon lc = new LoaderIcon("Just moment getting link..."); hpGetLink.add(lc); modal.add(hpGetLink); - + final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", ""); GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(), @@ -464,7 +464,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal2.setWidth(800); modal2.setCloseVisible(true); if (concessione.getValidationReport() == null) { - modal2.add(new HTML("No report available for: "+concessione.getNome())); + modal2.add(new HTML("No report available for: " + concessione.getNome())); } else { BuildValidationReport buildValidationReport = new BuildValidationReport( concessione.getValidationReport()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java index 47b11e8..53b1659 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java @@ -73,7 +73,7 @@ public abstract class AbstractItemsCellTable { sortedCellTable = new SortedCellTable(pageSize, dataProvider); sortedCellTable.addStyleName("table-glor"); sortedCellTable.addStyleName("table-glor-vertical-middle"); - sortedCellTable.setStriped(true); + //sortedCellTable.setStriped(true); sortedCellTable.setCondensed(true); sortedCellTable.setWidth("100%", true); //sortedCellTable.setBordered(true); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 40566d0..91b560e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -13,13 +13,16 @@ import java.util.Set; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; +import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import com.github.gwtbootstrap.client.ui.ButtonCell; import com.github.gwtbootstrap.client.ui.Pagination; -import com.google.gwt.cell.client.ButtonCell; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.cell.client.Cell.Context; import com.google.gwt.cell.client.DateCell; import com.google.gwt.cell.client.FieldUpdater; import com.google.gwt.core.shared.GWT; @@ -306,11 +309,30 @@ public class ItemsTable extends AbstractItemsCellTable< if (object == null) return ""; - ValidationReportDV vd = ((ConcessioneDV) object).getValidationReport(); - if (vd != null) - return vd.getStatus().getLabel(); + ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); + if (vr != null && vr.getStatus() != null) + return vr.getStatus().getLabel(); return ""; } + + @Override + public void render(Context context, T object, SafeHtmlBuilder sb) { + // TODO Auto-generated method stub + + String value = getValue(object); + String color = "#000"; + if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) { + color = "#32CD32"; + } else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) { + color = "#FF8000"; + } else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) { + color = "red"; + } + sb.appendHtmlConstant(""); + super.render(context, object, sb); + sb.appendHtmlConstant(""); + + } }; sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false); @@ -319,9 +341,13 @@ public class ItemsTable extends AbstractItemsCellTable< } ButtonCell showOnMapButton = new ButtonCell(); - Column showOnMapColumn = new Column(showOnMapButton) { + showOnMapButton.setIcon(IconType.MAP_MARKER); + + MyToolTipColumn showOnMapColumn = new MyToolTipColumn(showOnMapButton, "Show on Map") { + + @Override public String getValue(T object) { - return "Show on Map"; + return ""; } }; @@ -333,12 +359,14 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(showOnMapColumn); - sortedCellTable.setColumnWidth(showOnMapColumn, 110, Unit.PX); + sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX); ButtonCell showReportRecordButton = new ButtonCell(); - Column showReportRecordColumn = new Column(showReportRecordButton) { + showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT); + MyToolTipColumn showReportRecordColumn = new MyToolTipColumn(showReportRecordButton, + "Show Publication Report") { public String getValue(T object) { - return "P. Report"; + return ""; } }; @@ -350,12 +378,14 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(showReportRecordColumn); - sortedCellTable.setColumnWidth(showReportRecordColumn, 80, Unit.PX); + sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX); ButtonCell deleteRecordButton = new ButtonCell(); - Column deleteRecordColumn = new Column(deleteRecordButton) { + deleteRecordButton.setIcon(IconType.TRASH); + MyToolTipColumn deleteRecordColumn = new MyToolTipColumn(deleteRecordButton, + "Delete Project") { public String getValue(T object) { - return "Delete"; + return ""; } }; @@ -367,7 +397,7 @@ public class ItemsTable extends AbstractItemsCellTable< } }); sortedCellTable.addColumn(deleteRecordColumn); - sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX); + sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX); GWT.log("currentSortFilter: " + currentSortFilter); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java index 1de211f..fe99a3c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/MyToolTipColumn.java @@ -39,7 +39,7 @@ public abstract class MyToolTipColumn extends Column { * @param toolTipText the tool tip text * @return the safe html */ - @Template("
") + @Template("") SafeHtml startToolTip(String toolTipText); /** @@ -47,7 +47,7 @@ public abstract class MyToolTipColumn extends Column { * * @return the safe html */ - @Template("
") + @Template("") SafeHtml endToolTip(); } @@ -75,7 +75,6 @@ public abstract class MyToolTipColumn extends Column { */ @Override public void render(final Context context, final T object, final SafeHtmlBuilder sb) { - sb.append(TEMPLATES.startToolTip(toolTipText)); super.render(context, object, sb); sb.append(TEMPLATES.endToolTip()); 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 8d574ca..b2d5250 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 @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.server; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -25,6 +26,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitl import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; +import org.gcube.portlets.user.geoportaldataentry.server.ServiceUtil.ConcessioneDVValidationReportStatusComparator; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -37,7 +39,6 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.server.rpc.RemoteServiceServlet; /** @@ -548,13 +549,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false); searchedData.setTotalItems(listConcessioniSize); + RECORD_FIELD orderBy = null; + ORDER order = null; + ConcessioneDVValidationReportStatusComparator statusComparator = null; + if (filter == null) { // unsorted list of records toReturn = listOfConcessioni.subList(startIndex, limitIndex); } else { - RECORD_FIELD orderBy = filter.getOrderByField(); - ORDER order = filter.getOrder(); + orderBy = filter.getOrderByField(); + order = filter.getOrder(); if (orderBy == null) orderBy = RECORD_FIELD.NAME; @@ -564,6 +569,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // CASE INSENSITIVE COMPARATOR Comparator comparator = null; + switch (orderBy) { case NAME: if (order.equals(ORDER.ASC)) { @@ -607,14 +613,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } break; + case PUBLISHING_STATUS: + statusComparator = new ConcessioneDVValidationReportStatusComparator(); default: break; } // sorting with nullsLast - listOfConcessioni.sort(Comparator.nullsLast(comparator)); - Log.debug("sorted list: " + listOfConcessioni); + if (comparator != null) + listOfConcessioni.sort(Comparator.nullsLast(comparator)); + LOG.debug("sorted list: " + listOfConcessioni); // pagination toReturn = listOfConcessioni.subList(startIndex, limitIndex); } @@ -625,7 +634,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); toReturnList.add(concessioneDV); } - + + if(statusComparator!=null) { + toReturnList.sort(statusComparator); + if (order.equals(ORDER.DESC)) { + Collections.sort(toReturnList, Collections.reverseOrder(new ConcessioneDVValidationReportStatusComparator())); + } + } + searchedData.setData(toReturnList); if (listConcessioniSize == limit || listConcessioniSize == 0) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java index 3160e6b..f0a270b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java @@ -7,11 +7,14 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.io.Serializable; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportal.common.utils.StorageUtils; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.slf4j.Logger; @@ -83,28 +86,75 @@ public class ServiceUtil { } return files; } - - + /** * To JSON. * - * @param the generic type - * @param report the report + * @param theObj the the obj * @return the string */ public String toJSON(Object theObj) { LOG.debug("toJSON called"); try { - - if(theObj instanceof Serializable) { + + if (theObj instanceof Serializable) { return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); } throw new Exception("The input object is not serializable"); - + } catch (Exception e) { LOG.warn("Error on deserializing: ", e); return null; } } + /** + * The Class ConcessioneValidationReportStatusComparator. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 14, 2021 + */ + public static class ConcessioneValidationReportStatusComparator implements Comparator { + + /** + * Compare. + * + * @param o1 the o 1 + * @param o2 the o 2 + * @return the int + */ + @Override + public int compare(Concessione o1, Concessione o2) { + if (o1 == null || o1.getReport() == null || o1.getReport().getStatus() == null) + return 1; + if (o2 == null || o2.getReport() == null || o2.getReport().getStatus() == null) + return -1; + + return o1.getReport().getStatus().name().compareTo(o2.getReport().getStatus().name()); + } + + } + + public static class ConcessioneDVValidationReportStatusComparator implements Comparator { + + /** + * Compare. + * + * @param o1 the o 1 + * @param o2 the o 2 + * @return the int + */ + @Override + public int compare(ConcessioneDV o1, ConcessioneDV o2) { + if (o1 == null || o1.getValidationStatus() == null) + return 1; + if (o2 == null || o2.getValidationStatus() == null) + return -1; + + return o1.getValidationStatus().name().compareTo(o2.getValidationStatus().name()); + } + + } + } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index f73fa16..7545a72 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -64,8 +64,8 @@ h1 { overflow: hidden !important; } -.table-glor th { - /*text-align: center !important;*/ +.table-glor td:nth-last-child(-n+4) { + background-color: #d9edf7 !important; } .table-glor-vertical-middle td, th { diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp index 351526b..d9e7da1 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp @@ -16,6 +16,13 @@ + + + From 1bcd52cc946c95cacf5e6ea9a43ba766c0dfe965 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 15 Sep 2021 16:14:27 +0200 Subject: [PATCH 13/32] fixing NavBar with actions for "List of Project" --- .../ConstantsGeoPortalDataEntryApp.java | 4 +- .../client/GeoPortalDataEntryApp.java | 58 +++++++- .../client/events/ActionOnItemEvent.java | 23 ++- .../events/ActionOnItemEventHandler.java | 4 +- .../client/ui/GeonaMainTabPanel.java | 123 +++++++++++++--- .../client/ui/GeonaMainTabPanel.ui.xml | 106 ++++++++------ .../ui/table/AbstractItemsCellTable.java | 9 +- .../client/ui/table/ItemsTable.java | 131 +++++++++--------- .../server/GeoportalDataEntryServiceImpl.java | 30 ++-- .../server/ServiceUtil.java | 4 +- src/main/webapp/GeoPortalDataEntryApp.css | 15 +- 11 files changed, 352 insertions(+), 155 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 8eb2bf2..538c8f9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -38,7 +38,7 @@ public class ConstantsGeoPortalDataEntryApp { * Aug 6, 2021 */ public enum ACTION_ON_ITEM { - SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, REMOVE + SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, DELETE_RECORD, EDIT_RECORD } /** @@ -50,7 +50,7 @@ public class ConstantsGeoPortalDataEntryApp { */ public static enum RECORD_FIELD { NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"), - PROJECT_START_END_DATE("", "Project Start/End Date"), PUBLISHING_STATUS("publishingStatus", "Publishing Status"), CREATED("created", "Created"), + PROJECT_START_END_DATE("", "Project Start/End Date"), RECORD_STATUS("recordStatus", "Published with"), CREATED("created", "Created"), CREATED_BY("createdBy", "Created by"); String jsonFieldName; 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 89b9cce..2452bd9 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 @@ -9,6 +9,7 @@ import java.util.TreeMap; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; @@ -48,6 +49,8 @@ import com.google.gwt.core.client.EntryPoint; 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.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -89,13 +92,15 @@ public class GeoPortalDataEntryApp implements EntryPoint { private boolean projectSavedWithSuccess; + private GeonaRecordsPaginatedView grpw = null; + /** * This is the entry point method. */ public void onModuleLoad() { RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE, - RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.PUBLISHING_STATUS }; + RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.RECORD_STATUS }; SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC); @@ -126,6 +131,35 @@ public class GeoPortalDataEntryApp implements EntryPoint { bindEvents(); mainTabPanel.addFormPanel(geoNaMainForm); RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel); + + Window.addResizeHandler(new ResizeHandler() { + @Override + public void onResize(ResizeEvent event) { + GWT.log("onWindowResized width: " + event.getWidth() + " height: " + event.getHeight()); + updateSize(); + } + }); + + updateSize(); + } + + /** + * Update window size + */ + public void updateSize() { + + RootPanel workspace = RootPanel.get(DIV_PORTLET_ID); + int topBorder = workspace.getAbsoluteTop(); + int footer = 85; // footer is bottombar + sponsor + int headerSize = 90; + int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer == + // null)?0:(footer.getOffsetHeight()-15)); + + GWT.log("New workspace dimension Height: " + rootHeight); + mainTabPanel.setInternalHeight(rootHeight); + // appController.getMainPanel().setHeight(rootHeight); + // appController.getMainPanel().setWidth(rootWidth); + } private void callGetMetadataProfiles(String scope, String secondaryType) { @@ -394,8 +428,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { - GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, - null, getListOfRecordsEvent.getSortFilter()); + grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, + getListOfRecordsEvent.getSortFilter()); mainTabPanel.showListOfConcessioniView(grpw); } }); @@ -403,15 +437,25 @@ public class GeoPortalDataEntryApp implements EntryPoint { appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() { @Override - public void onDoActionFired(ActionOnItemEvent showItemEvent) { + public void onDoActionFired(ActionOnItemEvent showItemEvent) { + + GWT.log("Fired event: " + showItemEvent); if (showItemEvent != null) { ACTION_ON_ITEM action = showItemEvent.getAction(); List items = showItemEvent.getSelectItems(); - if (items == null) + if (items == null) { + if (grpw != null) { + items = (List) grpw.getSelectItems(); + } + } + + if (items == null || items.size() == 0) { + Window.alert("You must select a record in the table"); return; + } T item = items.get(0); @@ -461,6 +505,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { case SHOW_REPORT: final Modal modal2 = new Modal(true, true); + modal2.setTitle(concessione.getNome()); modal2.setWidth(800); modal2.setCloseVisible(true); if (concessione.getValidationReport() == null) { @@ -473,7 +518,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal2.show(); break; - case REMOVE: + case DELETE_RECORD: String htmlMsg = "Going to delete the project with:"; htmlMsg += "
    "; @@ -539,6 +584,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } } + }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index adad262..b1d3594 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import java.util.List; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import com.google.gwt.event.shared.GwtEvent; @@ -11,10 +12,10 @@ import com.google.gwt.event.shared.GwtEvent; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Aug 5, 2021 + * Sep 15, 2021 * @param the generic type */ -public class ActionOnItemEvent extends GwtEvent { +public class ActionOnItemEvent extends GwtEvent { public static Type TYPE = new Type(); private List selectItems; private ACTION_ON_ITEM action; @@ -23,6 +24,7 @@ public class ActionOnItemEvent extends GwtEvent { * Instantiates a new click item event. * * @param selectItems the select items + * @param doAction the do action */ public ActionOnItemEvent(List selectItems, ACTION_ON_ITEM doAction) { this.selectItems = selectItems; @@ -70,7 +72,24 @@ public class ActionOnItemEvent extends GwtEvent { return selectItems; } + /** + * Gets the action. + * + * @return the action + */ public ACTION_ON_ITEM getAction() { return action; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("ActionOnItemEvent [selectItems="); + builder.append(selectItems); + builder.append(", action="); + builder.append(action); + builder.append("]"); + return builder.toString(); + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java index 1aca514..b333e0b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEventHandler.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; + import com.google.gwt.event.shared.EventHandler; /** @@ -17,5 +19,5 @@ public interface ActionOnItemEventHandler extends EventHandler { * @param the generic type * @param showItemEvent the show item event */ - void onDoActionFired(ActionOnItemEvent showItemEvent); + void onDoActionFired(ActionOnItemEvent showItemEvent); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index e2a33b7..dc5d99d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -1,7 +1,12 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; @@ -33,6 +38,8 @@ import com.google.gwt.user.client.ui.Widget; */ public class GeonaMainTabPanel extends Composite { + private static final String YOU_MUST_TO_SELECT_A_PROJECT_IN_THE_TABLE = "You must to select a Project in the table"; + private static final String LABEL_FILTER_SEPARATOR = " - "; private static GeonaMainTabPanelUiBinder uiBinder = GWT.create(GeonaMainTabPanelUiBinder.class); @@ -54,6 +61,13 @@ public class GeonaMainTabPanel extends Composite { @UiField HTMLPanel geonaListOfConcessioniPanel; + /** The geona main form panel. */ + @UiField + HTMLPanel contTabNewProject; + + @UiField + HTMLPanel contTabGetListOfProjects; + /** The loader. */ @UiField LoaderIcon loader; @@ -76,12 +90,26 @@ public class GeonaMainTabPanel extends Composite { @UiField TextBox textBoxSortBy; + @UiField + NavLink navShowOnMap; + + @UiField + NavLink navShowReport; + + @UiField + NavLink navEditMode; + + @UiField + NavLink navDelete; + private HandlerManager appManagerBus; private RECORD_FIELD[] sortByFields; private SortFilter currentSortFilter; + private GeonaRecordsPaginatedView grpw = null; + /** * Instantiates a new geona main tab panel. * @@ -98,6 +126,11 @@ public class GeonaMainTabPanel extends Composite { } + public void setInternalHeight(int height) { + contTabNewProject.asWidget().setHeight(height + "px"); + contTabGetListOfProjects.asWidget().setHeight(height + "px"); + } + /** * Bind events. */ @@ -126,8 +159,7 @@ public class GeonaMainTabPanel extends Composite { @Override public void onClick(ClickEvent event) { - GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, - null, currentSortFilter); + grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, currentSortFilter); showListOfConcessioniView(grpw); } @@ -168,6 +200,60 @@ public class GeonaMainTabPanel extends Composite { }); } + navShowOnMap.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.SHOW_ON_MAP)); + + } + }); + + navShowReport.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.SHOW_REPORT)); + } + }); + + navEditMode.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.EDIT_RECORD)); + } + }); + + navDelete.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.DELETE_RECORD)); + } + }); + } /** @@ -185,6 +271,7 @@ public class GeonaMainTabPanel extends Composite { * @param grpw the grpw */ public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) { + this.grpw = grpw; geonaListOfConcessioniPanel.clear(); VerticalPanel htmllPanel = new VerticalPanel(); htmllPanel.add(grpw.getCellPanel()); @@ -228,23 +315,21 @@ public class GeonaMainTabPanel extends Composite { * @param labelFilter the label filter * @return the sort filter */ - /*public SortFilter toSortFilter(String labelFilter) { - - String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); - - SortFilter sortFilter = null; - try { - RECORD_FIELD recordField = RECORD_FIELD.valueOf(array[0]); - ORDER orderField = ORDER.valueOf(array[1]); - sortFilter = new SortFilter(recordField, orderField); - } catch (Exception e) { - - } - - GWT.log("Got " + sortFilter); - return sortFilter; - - }*/ + /* + * public SortFilter toSortFilter(String labelFilter) { + * + * String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); + * + * SortFilter sortFilter = null; try { RECORD_FIELD recordField = + * RECORD_FIELD.valueOf(array[0]); ORDER orderField = ORDER.valueOf(array[1]); + * sortFilter = new SortFilter(recordField, orderField); } catch (Exception e) { + * + * } + * + * GWT.log("Got " + sortFilter); return sortFilter; + * + * } + */ public SortFilter getCurrentSortFilter() { return currentSortFilter; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 73272de..34fec38 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -31,6 +31,10 @@ font-size: 12px; text-align: right; } + + .max-height-300 { + max-height: auto; + } - - New Project - - Create New Project - - - -
    - Go to bottom -
    - - - -
    - Go to top -
    + + + + New Project + + Create New Project + + + +
    + Go to bottom +
    + + + +
    + Go to top +
    +
    +
    - - List of Projects - - - - - - - - - Reload Projects - - - -
    - Go to bottom -
    - - -
    - Go to top -
    + + + + List of Projects + + + + + + + + + Reload Projects + + + + + Show on Map + Show Publication Report + Edit + Delete Project + + + +
    + Go to bottom +
    + + +
    + Go to top +
    +
    +
    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java index 53b1659..9050724 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/AbstractItemsCellTable.java @@ -23,7 +23,6 @@ import com.google.gwt.user.client.ui.MenuBar; import com.google.gwt.user.client.ui.MenuItem; import com.google.gwt.view.client.AbstractDataProvider; import com.google.gwt.view.client.AsyncDataProvider; -import com.google.gwt.view.client.DefaultSelectionEventManager; import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.MultiSelectionModel; import com.google.gwt.view.client.SelectionChangeEvent; @@ -76,8 +75,7 @@ public abstract class AbstractItemsCellTable { //sortedCellTable.setStriped(true); sortedCellTable.setCondensed(true); sortedCellTable.setWidth("100%", true); - //sortedCellTable.setBordered(true); - + sortedCellTable.setAutoHeaderRefreshDisabled(true); sortedCellTable.setAutoFooterRefreshDisabled(true); @@ -85,8 +83,9 @@ public abstract class AbstractItemsCellTable { // initTable(cellTable, null, null); //sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); - DefaultSelectionEventManager checkBoxManager = DefaultSelectionEventManager. createCheckboxManager(); - sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager); +// DefaultSelectionEventManager checkBoxManager = DefaultSelectionEventManager. createCheckboxManager(); +// sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager); + sortedCellTable.setSelectionModel(theSelectionModel); theSelectionModel.addSelectionChangeHandler(new Handler() { @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java index 91b560e..f801244 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/table/ItemsTable.java @@ -14,17 +14,13 @@ import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus; -import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; -import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; import com.github.gwtbootstrap.client.ui.ButtonCell; import com.github.gwtbootstrap.client.ui.Pagination; -import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.cell.client.Cell.Context; import com.google.gwt.cell.client.DateCell; -import com.google.gwt.cell.client.FieldUpdater; import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.shared.HandlerManager; @@ -232,7 +228,7 @@ public class ItemsTable extends AbstractItemsCellTable< if (this.displayFields.contains(RECORD_FIELD.CREATED)) { - DateCell date = new DateCell(dtformat); + DateCell date = new DateCell(DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT+" "+ConvertToDataViewModel.TIME_FORMAT)); createdColumn = new Column(date) { @Override @@ -301,7 +297,7 @@ public class ItemsTable extends AbstractItemsCellTable< sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); } - if (this.displayFields.contains(RECORD_FIELD.PUBLISHING_STATUS)) { + if (this.displayFields.contains(RECORD_FIELD.RECORD_STATUS)) { statusColumn = new TextColumn() { @Override @@ -335,69 +331,69 @@ public class ItemsTable extends AbstractItemsCellTable< } }; - sortedCellTable.addColumn(statusColumn, RECORD_FIELD.PUBLISHING_STATUS.getDisplayName(), false); + sortedCellTable.addColumn(statusColumn, RECORD_FIELD.RECORD_STATUS.getDisplayName(), false); sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX); } - ButtonCell showOnMapButton = new ButtonCell(); - showOnMapButton.setIcon(IconType.MAP_MARKER); - - MyToolTipColumn showOnMapColumn = new MyToolTipColumn(showOnMapButton, "Show on Map") { - - @Override - public String getValue(T object) { - return ""; - } - }; - - showOnMapColumn.setFieldUpdater(new FieldUpdater() { - @Override - public void update(int index, T object, String value) { - GWT.log("clicked show"); - eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP)); - } - }); - sortedCellTable.addColumn(showOnMapColumn); - sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX); - - ButtonCell showReportRecordButton = new ButtonCell(); - showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT); - MyToolTipColumn showReportRecordColumn = new MyToolTipColumn(showReportRecordButton, - "Show Publication Report") { - public String getValue(T object) { - return ""; - } - }; - - showReportRecordColumn.setFieldUpdater(new FieldUpdater() { - @Override - public void update(int index, T object, String value) { - - eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT)); - } - }); - sortedCellTable.addColumn(showReportRecordColumn); - sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX); - - ButtonCell deleteRecordButton = new ButtonCell(); - deleteRecordButton.setIcon(IconType.TRASH); - MyToolTipColumn deleteRecordColumn = new MyToolTipColumn(deleteRecordButton, - "Delete Project") { - public String getValue(T object) { - return ""; - } - }; - - deleteRecordColumn.setFieldUpdater(new FieldUpdater() { - @Override - public void update(int index, T object, String value) { - - eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.REMOVE)); - } - }); - sortedCellTable.addColumn(deleteRecordColumn); - sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX); +// ButtonCell showOnMapButton = new ButtonCell(); +// showOnMapButton.setIcon(IconType.MAP_MARKER); +// +// MyToolTipColumn showOnMapColumn = new MyToolTipColumn(showOnMapButton, "Show on Map") { +// +// @Override +// public String getValue(T object) { +// return ""; +// } +// }; +// +// showOnMapColumn.setFieldUpdater(new FieldUpdater() { +// @Override +// public void update(int index, T object, String value) { +// GWT.log("clicked show"); +// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP)); +// } +// }); +// sortedCellTable.addColumn(showOnMapColumn); +// sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX); +// +// ButtonCell showReportRecordButton = new ButtonCell(); +// showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT); +// MyToolTipColumn showReportRecordColumn = new MyToolTipColumn(showReportRecordButton, +// "Show Publication Report") { +// public String getValue(T object) { +// return ""; +// } +// }; +// +// showReportRecordColumn.setFieldUpdater(new FieldUpdater() { +// @Override +// public void update(int index, T object, String value) { +// +// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT)); +// } +// }); +// sortedCellTable.addColumn(showReportRecordColumn); +// sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX); +// +// ButtonCell deleteRecordButton = new ButtonCell(); +// deleteRecordButton.setIcon(IconType.TRASH); +// MyToolTipColumn deleteRecordColumn = new MyToolTipColumn(deleteRecordButton, +// "Delete Project") { +// public String getValue(T object) { +// return ""; +// } +// }; +// +// deleteRecordColumn.setFieldUpdater(new FieldUpdater() { +// @Override +// public void update(int index, T object, String value) { +// +// eventBus.fireEvent(new ActionOnItemEvent(Arrays.asList(object), ACTION_ON_ITEM.DELETE_RECORD)); +// } +// }); +// sortedCellTable.addColumn(deleteRecordColumn); +// sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX); GWT.log("currentSortFilter: " + currentSortFilter); @@ -423,6 +419,11 @@ public class ItemsTable extends AbstractItemsCellTable< } } + + + public void enableWriteOperations() { + + } /** * To display authors. 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 b2d5250..b235e07 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 @@ -26,7 +26,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitl import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; -import org.gcube.portlets.user.geoportaldataentry.server.ServiceUtil.ConcessioneDVValidationReportStatusComparator; +import org.gcube.portlets.user.geoportaldataentry.server.ServiceUtil.ConcessioneValidationReportStatusComparator; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -551,7 +551,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen RECORD_FIELD orderBy = null; ORDER order = null; - ConcessioneDVValidationReportStatusComparator statusComparator = null; + ConcessioneValidationReportStatusComparator statusComparator = null; if (filter == null) { // unsorted list of records @@ -613,8 +613,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } break; - case PUBLISHING_STATUS: - statusComparator = new ConcessioneDVValidationReportStatusComparator(); + case RECORD_STATUS: + statusComparator = new ConcessioneValidationReportStatusComparator(); default: break; } @@ -622,6 +622,21 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // sorting with nullsLast if (comparator != null) listOfConcessioni.sort(Comparator.nullsLast(comparator)); + + //solution quick&dirty + try { + if(statusComparator!=null) { + if(order.equals(ORDER.ASC)) { + listOfConcessioni.sort(Comparator.nullsLast(statusComparator)); + } + else { + Collections.sort(listOfConcessioni, Comparator.nullsLast(Collections.reverseOrder(new ConcessioneValidationReportStatusComparator()))); + } + } + }catch (Exception e) { + LOG.warn("comparator Exception: " + e.getMessage()); + } + LOG.debug("sorted list: " + listOfConcessioni); // pagination @@ -635,13 +650,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen toReturnList.add(concessioneDV); } - if(statusComparator!=null) { - toReturnList.sort(statusComparator); - if (order.equals(ORDER.DESC)) { - Collections.sort(toReturnList, Collections.reverseOrder(new ConcessioneDVValidationReportStatusComparator())); - } - } - searchedData.setData(toReturnList); if (listConcessioniSize == limit || listConcessioniSize == 0) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java index f0a270b..e63c458 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java @@ -147,9 +147,9 @@ public class ServiceUtil { */ @Override public int compare(ConcessioneDV o1, ConcessioneDV o2) { - if (o1 == null || o1.getValidationStatus() == null) + if (o1.getValidationStatus() == null) return 1; - if (o2 == null || o2.getValidationStatus() == null) + if (o2.getValidationStatus() == null) return -1; return o1.getValidationStatus().name().compareTo(o2.getValidationStatus().name()); diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 7545a72..0d68ffb 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -1,5 +1,11 @@ /** Add css rules here for your application. */ /** Example rules used by the template application (remove for your app) */ + +/** JUST to override the gwt-boostrap body */ +body { + padding: 0px !important; +} + h1 { font-size: 2em; font-weight: bold; @@ -64,7 +70,7 @@ h1 { overflow: hidden !important; } -.table-glor td:nth-last-child(-n+4) { +.table-glor td:nth-last-child(-n+3) { background-color: #d9edf7 !important; } @@ -72,3 +78,10 @@ h1 { height: 50%; vertical-align: middle !important; } + +.move-sticky { + position: -webkit-sticky; + position: sticky; + top: 0; + background-color: #eeeeee; +} From 234fd875cf80f9ae80a16e84aff646c0d7c8a4fe Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 15 Sep 2021 16:33:24 +0200 Subject: [PATCH 14/32] improved the Modal GUI --- .../client/GeoPortalDataEntryApp.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 2452bd9..8cb43db 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 @@ -43,6 +43,7 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Heading; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.EntryPoint; @@ -505,7 +506,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { case SHOW_REPORT: final Modal modal2 = new Modal(true, true); - modal2.setTitle(concessione.getNome()); + modal2.setTitle("Report
    "+concessione.getNome()+"
    "); modal2.setWidth(800); modal2.setCloseVisible(true); if (concessione.getValidationReport() == null) { @@ -517,6 +518,16 @@ public class GeoPortalDataEntryApp implements EntryPoint { } modal2.show(); + break; + + case EDIT_RECORD: + final Modal modal3 = new Modal(true, true); + modal3.setTitle("Edit
    "+concessione.getNome()+"
    "); + modal3.setWidth(800); + modal3.setCloseVisible(true); + modal3.add(new Heading(1, "Under construction...")); + modal3.show(); + break; case DELETE_RECORD: From a551e572c58192bb010de74d3a6b191f47cfc2b8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 16 Sep 2021 12:15:07 +0200 Subject: [PATCH 15/32] completed REAMDE. Added calls server-side --- CHANGELOG.md | 3 +- README.md | 7 + .../client/GeoportalDataEntryService.java | 4 + .../GeoportalDataEntryServiceAsync.java | 6 + .../server/GeoportalDataEntryServiceImpl.java | 210 ++++++++---------- ...ServiceUtil.java => MongoServiceUtil.java} | 26 ++- .../server/SessionUtil.java | 2 +- 7 files changed, 128 insertions(+), 130 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/server/{ServiceUtil.java => MongoServiceUtil.java} (91%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf49a5..9013656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,10 +10,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#20435] Client integration with MongoConcessioni Moved to maven-portal-bom 3.6.3 -[#21856] Implementing new user feedback +[#21856] Implemented new user feedback [#21890] Passed to mongoID [#20599] Get List of Records [#22002] Integrated with ValidationReport and status +[#21990] Provide the (first version of) edit mode ## [v1.2.0] - 2020-12-18 diff --git a/README.md b/README.md index c5195e3..30b0a92 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,13 @@ The GeoPortal Data Entry App is an application to build the web forms for data e * [OpenJDK](https://openjdk.java.net/) - The JDK used * [Maven](https://maven.apache.org/) - Dependency Management +**Uses** + +* GWT v.2.9.0. [GWT](http://www.gwtproject.org) is licensed under [Apache License 2.0](http://www.gwtproject.org/terms.html) +* GWT-Bootstrap v.2.3.2.0. [GWT-Bootstrap](https://github.com/gwtbootstrap) is licensed under [[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) +* pretty-print-json v.1.1. [pretty-print-json](https://github.com/center-key/pretty-print-json) is licensed under [MIT](https://github.com/center-key/pretty-print-json/blob/main/LICENSE.txt) +* jsoneditor v.9.5.5. [jsoneditor](https://github.com/josdejong/jsoneditor) is licensed under [Apache License 2.0](https://github.com/josdejong/jsoneditor/blob/master/LICENSE) + ## Documentation N/A 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 2e4a3ca..0c8ab0e 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 @@ -70,4 +70,8 @@ public interface GeoportalDataEntryService extends RemoteService { * @return true, if successful */ boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception; + + String getJSONRecord(String itemId, RECORD_TYPE recordType) throws Exception; + + String updateRecord(String itemId, String jsonUpdate, RECORD_TYPE 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 ac5a768..806af14 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 @@ -53,4 +53,10 @@ public interface GeoportalDataEntryServiceAsync void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); + + + void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); + + + void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); } 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 b235e07..94c963a 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 @@ -26,7 +26,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitl import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; -import org.gcube.portlets.user.geoportaldataentry.server.ServiceUtil.ConcessioneValidationReportStatusComparator; +import org.gcube.portlets.user.geoportaldataentry.server.MongoServiceUtil.ConcessioneValidationReportStatusComparator; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; @@ -86,7 +86,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Concessione concessioneNew; String mongoId = null; - ServiceUtil serviceUtil = new ServiceUtil(); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = null; try { @@ -224,7 +224,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); List ardsFiles = serviceUtil.toTemFiles(ards.getFilesUploaded()); - // TODO MUST BE UNIFIED WITH RELAZIONE OPPURE BISOGNA PREVEDERE UN + // TODO DEVE ESSERE PASSATO CON PATH RELAZIONE OPPURE BISOGNA PREVEDERE UN // ABSTRACT_RELAZIONE??? if (ardsFiles != null && ardsFiles.size() > 0) { // saving into back-end @@ -408,110 +408,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return item; } - /* - * @Override public ResultSetPaginatedData getListConcessioni(Integer start, - * Integer limit, SortFilter filter, boolean reloadFromService) throws Exception - * { LOG.info("getListConcessioni called wit start: " + start + ", limit: " + - * limit + ", filter: " + filter); - * - * try { List listOfConcessioni = - * SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService); - * int listConcessioniSize = listOfConcessioni.size(); - * - * List toReturn = new ArrayList(); int startIndex; - * int limitIndex = 0; if (start == null && limit == null) { startIndex = 0; - * limitIndex = listConcessioniSize; } else { startIndex = start; limitIndex = - * start + limit; if (limitIndex > listConcessioniSize) { limitIndex = - * listConcessioniSize; } } - * - * ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, - * limit, startIndex, false); searchedData.setTotalItems(listConcessioniSize); - * - * if (filter == null) { // unsorted list of records toReturn = - * listOfConcessioni.subList(startIndex, limitIndex); } else { - * - * RECORD_FIELD orderBy = filter.getOrderByField(); ORDER order = - * filter.getOrder(); - * - * if (orderBy == null) orderBy = RECORD_FIELD.NAME; - * - * if (order == null) order = ORDER.ASC; - * - * ResultSetSorted resultSetSorted = - * SessionUtil.getLatestResultSetSorted(getThreadLocalRequest()); boolean - * latestOrderBy = - * resultSetSorted.getSearchFilter().getOrderByField().equals(orderBy); boolean - * latestOrder = resultSetSorted.getSearchFilter().getOrder().equals(order); - * - * //Checking if SortFilter is new (different to previous one used). If yes - * sorting again if(resultSetSorted==null || !latestOrderBy || !latestOrder) { - * - * // CASE INSENSITIVE COMPARATOR Comparator comparator = null; - * switch (orderBy) { case NAME: if (order.equals(ORDER.ASC)) { comparator = - * Comparator.comparing(Concessione::getNome, - * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); } else { comparator = - * Comparator .comparing(Concessione::getNome, - * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)) .reversed(); } - * - * break; case CREATED: if (order.equals(ORDER.ASC)) { comparator = - * Comparator.comparing(Concessione::getCreationTime, - * Comparator.nullsLast(Comparator.naturalOrder())); } else { comparator = - * Comparator.comparing(Concessione::getCreationTime, - * Comparator.nullsLast(Comparator.naturalOrder())).reversed(); } break; - * - * case CREATED_BY: if (order.equals(ORDER.ASC)) { comparator = - * Comparator.comparing(Concessione::getCreationUser, - * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)); } else { comparator = - * Comparator.comparing(Concessione::getCreationUser, - * Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).reversed(); } break; - * - * case PROJECT_START: if (order.equals(ORDER.ASC)) { comparator = - * Comparator.comparing(Concessione::getDataInizioProgetto, - * Comparator.nullsLast(Comparator.naturalOrder())); } else { comparator = - * Comparator.comparing(Concessione::getDataInizioProgetto, - * Comparator.nullsLast(Comparator.naturalOrder())).reversed(); } break; - * - * default: break; } - * - * // sorting with nullsLast - * listOfConcessioni.sort(Comparator.nullsLast(comparator)); - * Log.debug("sorted list: " + listOfConcessioni); //saving in session the - * ResultSetSorted with SortFilter and ordered data ResultSetSorted rsSorted = - * new ResultSetSorted(new SortFilter(orderBy, order), listOfConcessioni); - * SessionUtil.setLatestResultSetSorted(getThreadLocalRequest(),rsSorted); - * - * }else { //Using the ResultSet sorted at previous request listOfConcessioni = - * resultSetSorted.getData(); } - * - * // pagination toReturn = listOfConcessioni.subList(startIndex, limitIndex); } - * - * List toReturnList = new - * ArrayList(toReturn.size()); - * - * for (Concessione concessione : toReturn) { ConcessioneDV concessioneDV = - * ConvertToDataViewModel.toBaseConcessione(concessione); - * toReturnList.add(concessioneDV); } - * - * - * searchedData.setData(toReturnList); - * - * if (listConcessioniSize == limit || listConcessioniSize == 0) { - * LOG.debug("Page completed returning " + listConcessioniSize + " items"); int - * newOffset = startIndex + start; - * searchedData.setServerSearchFinished(newOffset > listConcessioniSize || - * listConcessioniSize == 0); LOG.debug("is Search finished: " + - * searchedData.isServerSearchFinished()); return searchedData; } - * - * LOG.debug("Returning: " + toReturnList); - * LOG.info("Returning list of concessioni with size: " + toReturnList.size()); - * return searchedData; } catch (Exception e) { - * LOG.error("Error on loading list of concessioni: ", e); throw new - * Exception("Error occurred on loading list of Concessioni. Error: " + - * e.getMessage()); } - * - * } - */ - /** * Gets the list concessioni. * @@ -552,7 +448,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen RECORD_FIELD orderBy = null; ORDER order = null; ConcessioneValidationReportStatusComparator statusComparator = null; - + if (filter == null) { // unsorted list of records toReturn = listOfConcessioni.subList(startIndex, limitIndex); @@ -622,21 +518,20 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // sorting with nullsLast if (comparator != null) listOfConcessioni.sort(Comparator.nullsLast(comparator)); - - //solution quick&dirty + + // solution quick&dirty try { - if(statusComparator!=null) { - if(order.equals(ORDER.ASC)) { + if (statusComparator != null) { + if (order.equals(ORDER.ASC)) { listOfConcessioni.sort(Comparator.nullsLast(statusComparator)); - } - else { - Collections.sort(listOfConcessioni, Comparator.nullsLast(Collections.reverseOrder(new ConcessioneValidationReportStatusComparator()))); + } else { + Collections.sort(listOfConcessioni, Comparator.nullsLast( + Collections.reverseOrder(new ConcessioneValidationReportStatusComparator()))); } } - }catch (Exception e) { + } catch (Exception e) { LOG.warn("comparator Exception: " + e.getMessage()); } - LOG.debug("sorted list: " + listOfConcessioni); // pagination @@ -649,7 +544,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); toReturnList.add(concessioneDV); } - + searchedData.setData(toReturnList); if (listConcessioniSize == limit || listConcessioniSize == 0) { @@ -698,8 +593,17 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } + /** + * Delete record. + * + * @param itemId the item id + * @param recordType the record type + * @return true, if successful + * @throws Exception the exception + */ @Override public boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception { + LOG.info("deleteRecord called with itemId: " + itemId + ", recordType: " + recordType); try { if (itemId == null) @@ -707,7 +611,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - ServiceUtil serviceUtil = new ServiceUtil(); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); clientMongo.deleteById(itemId); return true; @@ -721,4 +625,72 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on deleting the project with id: " + itemId + ". Error: " + e.getMessage()); } } + + /** + * Update record. + * + * @param itemId the item id + * @param jsonUpdate the json update + * @param recordType the record type + * @return the updated JSON string representing the itemId + * @throws Exception the exception + */ + @Override + public String updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception { + LOG.info("updateRecord called with itemId: " + itemId + ", recordType: " + recordType); + try { + + if (itemId == null) + throw new Exception("Item id is null"); + + LOG.debug("jsonUpdate is: " + jsonUpdate); + if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Concessione concessione = clientMongo.update(itemId, jsonUpdate); + return serviceUtil.toJSON(concessione); + } + + return null; + + } catch (Exception e) { + LOG.error("Error on updating the project with item id: " + itemId, e); + throw new Exception( + "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); + } + } + + /** + * Gets the JSON record. + * + * @param itemId the item id + * @param recordType the record type + * @return the JSON record representing the itemId + * @throws Exception the exception + */ + @Override + public String getJSONRecord(String itemId, RECORD_TYPE recordType) throws Exception { + LOG.info("getJSONRecord called with itemId: " + itemId + ", recordType: " + recordType); + try { + + if (itemId == null) + throw new Exception("Item id is null"); + + if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Concessione concessione = clientMongo.getById(itemId); + return serviceUtil.toJSON(concessione); + } + + return null; + + } catch (Exception e) { + LOG.error("Error on reading the JSON project with item id: " + itemId, e); + throw new Exception( + "Error occurred on reading the JSON project with id: " + itemId + ". Error: " + e.getMessage()); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java similarity index 91% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java index e63c458..e10ac71 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/ServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java @@ -20,16 +20,17 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * The Class ServiceUtil. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Jan 28, 2021 - */ -public class ServiceUtil { - private static Logger LOG = LoggerFactory.getLogger(ServiceUtil.class); +/** + * The Class MongoServiceUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 16, 2021 + */ +public class MongoServiceUtil { + + private static Logger LOG = LoggerFactory.getLogger(MongoServiceUtil.class); /** * Gets the instance mongo concessioni. @@ -136,6 +137,13 @@ public class ServiceUtil { } + /** + * The Class ConcessioneDVValidationReportStatusComparator. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 16, 2021 + */ public static class ConcessioneDVValidationReportStatusComparator implements Comparator { /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java index 03f06c2..0b6e5eb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/SessionUtil.java @@ -145,7 +145,7 @@ public class SessionUtil { listOfConcessioni = new ArrayList(); LOG.info("Loading list of concessione from client mongo"); SessionUtil.getCurrentContext(httpServletRequest, true); - ServiceUtil serviceUtil = new ServiceUtil(); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); Iterator concessioni = clientMongo.getList(); From 48d19b6f105408be798b035e0e19ac8119e7c02e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 20 Sep 2021 18:08:43 +0200 Subject: [PATCH 16/32] #21990 Integrated with JSONEditor, Improved general CSS --- .../client/GeoPortalDataEntryApp.java | 15 ++- .../client/ui/GeonaMainTabPanel.ui.xml | 12 +- .../client/ui/GeonaRecordsPaginatedView.java | 2 +- .../client/ui/edit/EditModeRecord.java | 111 ++++++++++++++++++ .../client/ui/edit/EditModeRecord.ui.xml | 31 +++++ .../client/ui/edit/jseditor/MyJSONEditor.java | 48 ++++++++ .../ui/report/ReportTemplateToHTML.java | 10 +- .../client/ui/utils/ExternalLib.java | 23 ++++ .../server/MongoServiceUtil.java | 7 +- src/main/webapp/GeoPortalDataEntryApp.html | 9 ++ .../jsp/GeoPortalDataEntryAppPortlet_view.jsp | 19 ++- 11 files changed, 258 insertions(+), 29 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExternalLib.java 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 8cb43db..8770435 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 @@ -25,6 +25,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFor 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.card.GeoNaFormCardModel; +import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.BuildValidationReport; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; @@ -43,7 +44,6 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import com.github.gwtbootstrap.client.ui.Alert; -import com.github.gwtbootstrap.client.ui.Heading; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.EntryPoint; @@ -74,10 +74,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { private static final String DIV_PORTLET_ID = "geoportal-data-entry"; - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ - public static final GeoportalDataEntryServiceAsync greetingService = GWT.create(GeoportalDataEntryService.class); + public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT.create(GeoportalDataEntryService.class); private final HandlerManager appManagerBus = new HandlerManager(null); @@ -153,6 +150,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { int topBorder = workspace.getAbsoluteTop(); int footer = 85; // footer is bottombar + sponsor int headerSize = 90; + //int headerSize = 30; int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer == // null)?0:(footer.getOffsetHeight()-15)); @@ -523,11 +521,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { case EDIT_RECORD: final Modal modal3 = new Modal(true, true); modal3.setTitle("Edit
    "+concessione.getNome()+"
    "); - modal3.setWidth(800); + modal3.setWidth(950); + modal3.setHeight("700px"); modal3.setCloseVisible(true); - modal3.add(new Heading(1, "Under construction...")); + EditModeRecord emr = new EditModeRecord(concessione,RECORD_TYPE.CONCESSIONE); + modal3.add(emr); modal3.show(); - break; case DELETE_RECORD: diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 34fec38..48e3a6c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -35,16 +35,20 @@ .max-height-300 { max-height: auto; } + + .margin-botttom-5 { + margin-bottom: 5px !important; + } GeoNa - + - - + + New Project - + List of Projects diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java index a9ec117..ca84a21 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaRecordsPaginatedView.java @@ -203,7 +203,7 @@ public class GeonaRecordsPaginatedView { GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit + ", serverIndex:" + serverIndex + ", sortFilter: " + sortFilter + "]"); - GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, sortFilter, invalidCache, + GeoPortalDataEntryApp.geoportalDataEntryService.getListConcessioni(newStartIndex, limit, sortFilter, invalidCache, new AsyncCallback() { @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java new file mode 100644 index 0000000..cd4fe3e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -0,0 +1,111 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; + +import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; +import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.MyJSONEditor; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Random; +import com.google.gwt.user.client.Timer; +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.Widget; + +/** + * The Class EditModeRecord. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 17, 2021 + */ +public class EditModeRecord extends Composite { + + private static EditModeRecordUiBinder uiBinder = GWT.create(EditModeRecordUiBinder.class); + + @UiField + FlowPanel rawUpdatePanel; + + @UiField + FlowPanel filesUpdatePanel; + + private BaseConcessioneDV selectedConcessione; + + /** + * The Interface EditModeRecordUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 17, 2021 + */ + interface EditModeRecordUiBinder extends UiBinder { + } + + /** + * Instantiates a new edits the mode record. + * + * @param selectedConcessione the selected concessione + * @param type the type + */ + public EditModeRecord(BaseConcessioneDV selectedConcessione, RECORD_TYPE type) { + initWidget(uiBinder.createAndBindUi(this)); + this.selectedConcessione = selectedConcessione; + + final FlowPanel fp = new FlowPanel(); + fp.getElement().setId("jsoneditor"+Random.nextInt()); + fp.setHeight("400px"); + rawUpdatePanel.add(fp); + + GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), type, new AsyncCallback() { + + @Override + public void onSuccess(String jsonData) { + GWT.log("Instance JSON Editor with: "+jsonData); + //jsonEditor = ExternalLib.instanceJSONEditor(fp.getElement().getId(), jsonData); + //String updated = ExternalLib.getUpdatedJSON(jsonEditor); + + //JSONEditor constuctor = new JSONEditor(fp.getElement(),"{}"); + final MyJSONEditor jsEditor = MyJSONEditor.init(fp.getElement().getId()); + jsEditor.setName(selectedConcessione.getNome()); +// JSONValue jsValue = JSONParser.parse(jsonData); +// JSONObject extraJSONObject = jsValue.isObject(); + jsEditor.set(jsonData); + + new Timer() { + + @Override + public void run() { + jsEditor.setMode("tree"); + + } + }.schedule(200); + + + //GWT.log("Updated: "+updated.toString()); + //org.gcube.portlets.user.geoportaldataentry.client.ui.utils.JSONEditor editor = JE.jsoneditor(fp.getElement(), jsonData); + //rawUpdatePanel.add(new Widget(editor)); + + + } + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub + + } + }); + + bindEvents(); + } + + /** + * Bind events. + */ + private void bindEvents() { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml new file mode 100644 index 0000000..8ccecb8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -0,0 +1,31 @@ + + + + .important { + font-weight: bold; + } + + + + + + + Raw Project Editor + + + + + Update the file/s + By choosing a section (e.g. "RELAZIONE di + SCAVO") and + uploading new file/s the old one/s will be replaced + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java new file mode 100644 index 0000000..30d2db0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java @@ -0,0 +1,48 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor; + +import com.google.gwt.core.client.JavaScriptObject; + +public class MyJSONEditor extends JavaScriptObject { + + // 6131f0d902ad3d2580412d14 + + protected MyJSONEditor() { + } + + public static native MyJSONEditor init(String divID) /*-{ + var container = $doc.getElementById(divID); + var options = { + modes : ['code','tree'], + search: true, + onError : function(error) { + console.log("MyJSONEditor error: " + error) + } + }; + console.log("container is: " + container); + return new $wnd.JSONEditor(container, options); + }-*/; + + public final native void set(String json) /*-{ + var toJSONObject = JSON.parse(json); + // set json + console.log("displayng JSON: " + toJSONObject); + this.set(toJSONObject); + this.refresh(); + }-*/; + + public final native void get() /*-{ + this.get(); + }-*/; + + public final native void onError() /*-{ + this.onError(error); + }-*/; + + public final native void setMode(String mode) /*-{ + this.setMode(mode); + }-*/; + + public final native void setName(String rootName) /*-{ + this.setName(rootName); + }-*/; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java index 61b8afa..5bf287e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.report; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ExternalLib; + import com.github.gwtbootstrap.client.ui.Paragraph; import com.google.gwt.core.client.GWT; import com.google.gwt.json.client.JSONArray; @@ -80,16 +82,10 @@ public class ReportTemplateToHTML extends Composite { e.printStackTrace(); GWT.log("error: " + e.getMessage()); } - reportJSON.add(new HTML("
    " + toPrettyPrintJSON(reportAsJSON) + "
    ")); + reportJSON.add(new HTML("
    " + ExternalLib.toPrettyPrintJSON(reportAsJSON) + "
    ")); } } - public static native String toPrettyPrintJSON(String jsonData)/*-{ - console.log(jsonData); - var objJSON = JSON.parse(jsonData); - return $wnd.prettyPrintJson.toHtml(objJSON); - }-*/; - /** * Json to HTML. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExternalLib.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExternalLib.java new file mode 100644 index 0000000..3b89653 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/ExternalLib.java @@ -0,0 +1,23 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +/** + * The Class ExternalLib. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 17, 2021 + */ +public class ExternalLib { + + /** + * To pretty print JSON. calls the externa js lib 'pretty-print-json' + * + * @param jsonData the json data + * @return the string + */ + public static native String toPrettyPrintJSON(String jsonData)/*-{ + //console.log(jsonData); + var objJSON = JSON.parse(jsonData); + return $wnd.prettyPrintJson.toHtml(objJSON); + }-*/; +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java index e10ac71..5cb11c9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java @@ -5,7 +5,6 @@ import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mon import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import java.io.Serializable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -98,10 +97,10 @@ public class MongoServiceUtil { LOG.debug("toJSON called"); try { - if (theObj instanceof Serializable) { +// if (theObj instanceof Serializable) { return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); - } - throw new Exception("The input object is not serializable"); +// } +// throw new Exception("The input object is not serializable"); } catch (Exception e) { LOG.warn("Error on deserializing: ", e); diff --git a/src/main/webapp/GeoPortalDataEntryApp.html b/src/main/webapp/GeoPortalDataEntryApp.html index 0558c96..26b1cc3 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.html +++ b/src/main/webapp/GeoPortalDataEntryApp.html @@ -22,6 +22,15 @@ src="//cdn.jsdelivr.net/npm/pretty-print-json@1.1/dist/pretty-print-json.min.js" type="text/javascript"> + + + + + diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp index d9e7da1..04ca825 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataEntryAppPortlet_view.jsp @@ -13,10 +13,6 @@ - - @@ -24,15 +20,28 @@ src="//cdn.jsdelivr.net/npm/pretty-print-json@1.1/dist/pretty-print-json.min.js" type="text/javascript"> + + + + + + + - + From 71cbc96d10577b6ec9f90b1339a19f640853f645 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 22 Sep 2021 11:38:52 +0200 Subject: [PATCH 17/32] improved JSON update part --- .../client/GeoPortalDataEntryApp.java | 2 + .../client/GeoportalDataEntryService.java | 3 +- .../GeoportalDataEntryServiceAsync.java | 3 +- .../client/ui/edit/EditModeRecord.java | 131 ++++++++++++------ .../client/ui/edit/EditModeRecord.ui.xml | 38 ++++- ...JSONEditor.java => JSONEditorWrapper.java} | 13 +- .../server/ConvertToServiceModel.java | 13 +- .../server/GeoportalDataEntryServiceImpl.java | 7 +- src/main/webapp/GeoPortalDataEntryApp.css | 8 ++ 9 files changed, 165 insertions(+), 53 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/{MyJSONEditor.java => JSONEditorWrapper.java} (72%) 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 8770435..a0c8c51 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 @@ -48,6 +48,7 @@ import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -524,6 +525,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal3.setWidth(950); modal3.setHeight("700px"); modal3.setCloseVisible(true); + ((Element)modal3.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); EditModeRecord emr = new EditModeRecord(concessione,RECORD_TYPE.CONCESSIONE); modal3.add(emr); modal3.show(); 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 0c8ab0e..e5edde1 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 @@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -73,5 +74,5 @@ public interface GeoportalDataEntryService extends RemoteService { String getJSONRecord(String itemId, RECORD_TYPE recordType) throws Exception; - String updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception; + ConcessioneDV updateRecord(String itemId, String jsonUpdate, RECORD_TYPE 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 806af14..24183fb 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 @@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -58,5 +59,5 @@ public interface GeoportalDataEntryServiceAsync void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); - void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); + void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index cd4fe3e..7550036 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -1,15 +1,22 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; -import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.MyJSONEditor; +import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Tab; 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.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Timer; +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; @@ -26,14 +33,24 @@ public class EditModeRecord extends Composite { private static EditModeRecordUiBinder uiBinder = GWT.create(EditModeRecordUiBinder.class); + @UiField + Tab tabRawUpdate; + @UiField FlowPanel rawUpdatePanel; @UiField FlowPanel filesUpdatePanel; + @UiField + Button buttonJSONUpdate; + private BaseConcessioneDV selectedConcessione; + private RECORD_TYPE recordType; + + private JSONEditorWrapper jsEditor; + /** * The Interface EditModeRecordUiBinder. * @@ -53,59 +70,95 @@ public class EditModeRecord extends Composite { public EditModeRecord(BaseConcessioneDV selectedConcessione, RECORD_TYPE type) { initWidget(uiBinder.createAndBindUi(this)); this.selectedConcessione = selectedConcessione; + this.recordType = type; + instanceJSONEditor(); + bindEvents(); + } + + private void instanceJSONEditor() { + + rawUpdatePanel.clear(); final FlowPanel fp = new FlowPanel(); - fp.getElement().setId("jsoneditor"+Random.nextInt()); + fp.getElement().setId("jsoneditor" + Random.nextInt()); fp.setHeight("400px"); rawUpdatePanel.add(fp); + + GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), recordType, + new AsyncCallback() { - GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), type, new AsyncCallback() { - - @Override - public void onSuccess(String jsonData) { - GWT.log("Instance JSON Editor with: "+jsonData); - //jsonEditor = ExternalLib.instanceJSONEditor(fp.getElement().getId(), jsonData); - //String updated = ExternalLib.getUpdatedJSON(jsonEditor); - - //JSONEditor constuctor = new JSONEditor(fp.getElement(),"{}"); - final MyJSONEditor jsEditor = MyJSONEditor.init(fp.getElement().getId()); - jsEditor.setName(selectedConcessione.getNome()); -// JSONValue jsValue = JSONParser.parse(jsonData); -// JSONObject extraJSONObject = jsValue.isObject(); - jsEditor.set(jsonData); - - new Timer() { - @Override - public void run() { - jsEditor.setMode("tree"); - + public void onSuccess(String jsonData) { + GWT.log("Instance JSON Editor with: " + jsonData); + jsEditor = JSONEditorWrapper.init(fp.getElement().getId()); + jsEditor.setName(selectedConcessione.getNome()); + jsEditor.set(jsonData); + + new Timer() { + + @Override + public void run() { + jsEditor.setMode("tree"); + + } + }.schedule(200); + } - }.schedule(200); - - - //GWT.log("Updated: "+updated.toString()); - //org.gcube.portlets.user.geoportaldataentry.client.ui.utils.JSONEditor editor = JE.jsoneditor(fp.getElement(), jsonData); - //rawUpdatePanel.add(new Widget(editor)); - - } - - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub - - } - }); + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub - bindEvents(); + } + }); } /** * Bind events. */ private void bindEvents() { - // TODO Auto-generated method stub + buttonJSONUpdate.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + rawUpdatePanel.getElement().addClassName("disable-div"); + buttonJSONUpdate.setEnabled(false); + final LoaderIcon loader = new LoaderIcon("Updating the project..."); + tabRawUpdate.add(loader); + GeoPortalDataEntryApp.geoportalDataEntryService.updateRecord(selectedConcessione.getItemId(), + jsEditor.getText(), recordType, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + buttonJSONUpdate.setEnabled(true); + try { + rawUpdatePanel.getElement().removeClassName("disable-div"); + tabRawUpdate.remove(loader); + } catch (Exception e) { + // TODO: handle exception + } + + } + + @Override + public void onSuccess(ConcessioneDV result) { + buttonJSONUpdate.setEnabled(true); + try { + rawUpdatePanel.getElement().removeClassName("disable-div"); + tabRawUpdate.remove(loader); + } catch (Exception e) { + // TODO: handle exception + } + selectedConcessione = result; + instanceJSONEditor(); + + Window.alert("Project '"+result.getNome()+"' updated correctly"); + + } + }); + + } + }); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index 8ccecb8..ceab188 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -6,16 +6,50 @@ .important { font-weight: bold; } + + .button-save-style { + margin-top: 10px; + float: right; + } + + .info-panel { + width: 100%; + word-break: break-word; + } - - Raw Project Editor + Source Project Editor + You can update the Source Project by editing its JSON model + data displayed in the following Editor. + +

    + Be careful not to change the + keys (e.g. nome, introduzione, + licenzaID and so + on..) reported in + black. + Update only their values + (e.g. "il nome + del + progetto", + "introduzione + del progetto") reported in + green + by the + Editor
    + At the end of the changes press the "Update" button to make + them persistent on the service +

    +
    + UPDATE
    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java similarity index 72% rename from src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java rename to src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java index 30d2db0..953f177 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/MyJSONEditor.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java @@ -2,20 +2,20 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor; import com.google.gwt.core.client.JavaScriptObject; -public class MyJSONEditor extends JavaScriptObject { +public class JSONEditorWrapper extends JavaScriptObject { // 6131f0d902ad3d2580412d14 - protected MyJSONEditor() { + protected JSONEditorWrapper() { } - public static native MyJSONEditor init(String divID) /*-{ + public static native JSONEditorWrapper init(String divID) /*-{ var container = $doc.getElementById(divID); var options = { modes : ['code','tree'], search: true, onError : function(error) { - console.log("MyJSONEditor error: " + error) + console.log("JSONEditorWrapper error: " + error) } }; console.log("container is: " + container); @@ -30,8 +30,9 @@ public class MyJSONEditor extends JavaScriptObject { this.refresh(); }-*/; - public final native void get() /*-{ - this.get(); + public final native String getText() /*-{ + console.log("this.get(): " +this.getText()); + return this.getText(); }-*/; public final native void onError() /*-{ 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 86ccaca..e758a53 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 @@ -250,12 +250,21 @@ public class ConvertToServiceModel { List abstractLstIta = mapFields.get("Abstract in Italiano"); if(abstractLstIta!=null && abstractLstIta.size()>0) { - relazioneScavo.setAbstractIta(abstractLstIta.get(0)); + + /** + * TODO + */ + LOG.warn("TODO ABSTRACT RELAZIONE DI SCAVO IN ITA"); + //relazioneScavo.setAbstractIta(abstractLstIta.get(0)); } List abstractLstEng = mapFields.get("Abstract in Inglese"); if(abstractLstEng!=null && abstractLstEng.size()>0) { - relazioneScavo.setAbstractEng(abstractLstEng.get(0)); + /** + * TODO + */ + LOG.warn("TODO ABSTRACT RELAZIONE DI SCAVO IN ENG"); + //relazioneScavo.setAbstractEng(abstractLstEng.get(0)); } //TODO IN FUTURE WHEN THE MODEL WILL BE UPDATED 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 94c963a..82172e8 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 @@ -636,7 +636,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public String updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception { + public ConcessioneDV updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception { LOG.info("updateRecord called with itemId: " + itemId + ", recordType: " + recordType); try { @@ -649,7 +649,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); Concessione concessione = clientMongo.update(itemId, jsonUpdate); - return serviceUtil.toJSON(concessione); + LOG.debug("Got Record updated: "+concessione); + ConcessioneDV concessionDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); + LOG.info("Record with id "+concessionDV.getItemId()+"updated correclty"); + return concessionDV; } return null; diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 0d68ffb..aaec5ed 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -85,3 +85,11 @@ h1 { top: 0; background-color: #eeeeee; } + +.modal-body-custom { + max-height: 700px !important; +} + +.disable-div { + pointer-events: none; +} From 486418a6b35226878c05f7912959cef3cc7e58a0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 Sep 2021 12:06:53 +0200 Subject: [PATCH 18/32] #22040 Revisited the "Abstract Relazione di Scavo" --- CHANGELOG.md | 1 + .../server/ConvertToServiceModel.java | 337 +++++++++--------- .../server/GeoportalDataEntryServiceImpl.java | 39 +- 3 files changed, 176 insertions(+), 201 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9013656..a5ee362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Moved to maven-portal-bom 3.6.3 [#20599] Get List of Records [#22002] Integrated with ValidationReport and status [#21990] Provide the (first version of) edit mode +[#22040] Revisited the "Abstract Relazione di Scavo" ## [v1.2.0] - 2020-12-18 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 e758a53..d6ee1ac 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,6 +8,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.gcube.application.geoportal.common.model.legacy.AbstractRelazione; 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; @@ -19,392 +20,383 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class ConvertToServiceModel. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 21, 2020 + * Oct 21, 2020 */ public class ConvertToServiceModel { - + /** The Constant LOG. */ private static final Logger LOG = LoggerFactory.getLogger(ConvertToServiceModel.class); - + public static final String HOURS_MINUTES_SEPARATOR = ConstantsGeoPortalDataEntryApp.HOURS_MINUTES_SEPARATOR; - + public static final String DATE_FORMAT = ConstantsGeoPortalDataEntryApp.DATE_FORMAT; - + public static final String TIME_FORMAT = ConstantsGeoPortalDataEntryApp.TIME_FORMAT; /** * To concessione. * - * @param gdb the gdb + * @param gdb the gdb * @param user the user * @return the concessione - * @throws Exception + * @throws Exception the exception */ public static Concessione toConcessione(GenericDatasetBean gdb, GCubeUser user) throws Exception { - + Map> mapFields = gdb.getFormDataEntryFields(); - + Concessione concessione = new Concessione(); - - + // List authors = mapFields.get("Autore"); // if(authors!=null) { // concessione.setAuthors(authors); // } - - + List authors = mapFields.get("Nome Autore, Email, Ruolo"); - if(authors!=null) { + if (authors != null) { concessione.setAuthors(authors); } List contributors = mapFields.get("Contributore"); - if(contributors!=null) { + if (contributors != null) { for (String contributor : contributors) { concessione.setContributore(contributor); } } - - //concessione.setCreationTime(Instant.now()); + + // concessione.setCreationTime(Instant.now()); concessione.setCreationUser(user.getUsername()); - + List dataInizProgettoList = mapFields.get("Data inizio Progetto"); - if(dataInizProgettoList!=null && dataInizProgettoList.size()>0) { + if (dataInizProgettoList != null && dataInizProgettoList.size() > 0) { String inizioProgetto = dataInizProgettoList.get(0); LocalDateTime theLDT = toLocalDateTime(inizioProgetto); concessione.setDataInizioProgetto(theLDT); } - + List dataFineProgettoList = mapFields.get("Data fine Progetto"); - if(dataFineProgettoList!=null && dataFineProgettoList.size()>0) { + if (dataFineProgettoList != null && dataFineProgettoList.size() > 0) { String fineProgetto = dataFineProgettoList.get(0); LocalDateTime theLDT = toLocalDateTime(fineProgetto); concessione.setDataFineProgetto(theLDT); } - - + List descrizioneLst = mapFields.get("Descrizione del contenuto"); - if(descrizioneLst!=null && descrizioneLst.size()>0) { + if (descrizioneLst != null && descrizioneLst.size() > 0) { concessione.setDescrizioneContenuto(descrizioneLst.get(0)); } - + List editors = mapFields.get("Editore"); - if(editors!=null && editors.size()>0) { + if (editors != null && editors.size() > 0) { concessione.setEditore(editors.get(0)); } - + List fontiFinanziamento = mapFields.get("Fonte del finanziamento"); - if(fontiFinanziamento!=null) { + if (fontiFinanziamento != null) { concessione.setFontiFinanziamento(fontiFinanziamento); } - + List licenzaLst = mapFields.get("ID Licenza"); - if(licenzaLst!=null && licenzaLst.size()>0) { + if (licenzaLst != null && licenzaLst.size() > 0) { concessione.setLicenzaID(licenzaLst.get(0)); } - + List introduzioneLst = mapFields.get("Introduzione"); - if(introduzioneLst!=null && introduzioneLst.size()>0) { + if (introduzioneLst != null && introduzioneLst.size() > 0) { concessione.setIntroduzione(introduzioneLst.get(0)); } - + List nomeLst = mapFields.get("Nome del progetto"); - if(nomeLst!=null && nomeLst.size()>0) { + if (nomeLst != null && nomeLst.size() > 0) { concessione.setNome(nomeLst.get(0)); } - + List paroleChiaveLibereLst = mapFields.get("Parola chiave a scelta libera"); - //LOG.debug("Parola chiave a scelta libera: "+paroleChiaveLibereLst); - if(paroleChiaveLibereLst!=null){ + // LOG.debug("Parola chiave a scelta libera: "+paroleChiaveLibereLst); + if (paroleChiaveLibereLst != null) { concessione.setParoleChiaveLibere(paroleChiaveLibereLst); } - + List paroleChiaveICCDLst = mapFields.get("Parola chiave relativa alla cronologia"); - //LOG.debug("Parola chiave relativa alla cronologia: "+paroleChiaveICCDLst); - if(paroleChiaveICCDLst!=null){ + // LOG.debug("Parola chiave relativa alla cronologia: "+paroleChiaveICCDLst); + if (paroleChiaveICCDLst != null) { concessione.setParoleChiaveICCD(paroleChiaveICCDLst); } - + List risorsaCorrelataLst = mapFields.get("Risorsa correlata"); - if(risorsaCorrelataLst!=null){ + if (risorsaCorrelataLst != null) { concessione.setRisorseCorrelate(risorsaCorrelataLst); } - + List responsabileLst = mapFields.get("Responsabile"); - if(responsabileLst!=null && responsabileLst.size()>0){ + if (responsabileLst != null && responsabileLst.size() > 0) { concessione.setResponsabile(responsabileLst.get(0)); } - + List soggettoLst = mapFields.get("Soggetto"); - if(soggettoLst!=null){ + if (soggettoLst != null) { concessione.setSoggetto(soggettoLst); } - + List titolareCopyrightLst = mapFields.get("Titolare Copyright"); - if(titolareCopyrightLst!=null){ + if (titolareCopyrightLst != null) { concessione.setTitolareCopyright(titolareCopyrightLst); } - + List titolareLicenzaLst = mapFields.get("Titolare Licenza"); - if(titolareLicenzaLst!=null){ + if (titolareLicenzaLst != null) { concessione.setTitolareLicenza(titolareLicenzaLst); } - + List titolareDatiLst = mapFields.get("Titolare dei dati"); - if(titolareDatiLst!=null){ + if (titolareDatiLst != null) { concessione.setTitolari(titolareDatiLst); } - + List latList = mapFields.get("Latitudine Centroide"); - if(latList!=null && latList.size()>0){ + if (latList != null && latList.size() > 0) { try { String theLat = latList.get(0); - if(theLat!=null && !theLat.isEmpty()) { + if (theLat != null && !theLat.isEmpty()) { Double centroidLat = Double.parseDouble(theLat); concessione.setCentroidLat(centroidLat); } - }catch (Exception e) { - throw new Exception("Unable to parse "+latList.get(0)+" as valid latitude"); + } catch (Exception e) { + throw new Exception("Unable to parse " + latList.get(0) + " as valid latitude"); } } - + List longList = mapFields.get("Longitudine Centroide"); - if(longList!=null && longList.size()>0){ + if (longList != null && longList.size() > 0) { try { String theLong = longList.get(0); - if(theLong!=null && !theLong.isEmpty()) { + if (theLong != null && !theLong.isEmpty()) { Double centroidLong = Double.parseDouble(theLong); concessione.setCentroidLong(centroidLong); } - }catch (Exception e) { - throw new Exception("Unable to parse "+longList.get(0)+" as valid longitude"); + } catch (Exception e) { + throw new Exception("Unable to parse " + longList.get(0) + " as valid longitude"); } } - + return concessione; - + } - + /** * To relazione scavo. * - * @param abstractRelazioneScavo the abstract relazione scavo * @param gdb the gdb * @return the relazione scavo */ - public static RelazioneScavo toRelazioneScavo(RelazioneScavo abstractRelazioneScavo, GenericDatasetBean gdb){ - + public static RelazioneScavo toRelazioneScavo(GenericDatasetBean gdb) { + Map> mapFields = gdb.getFormDataEntryFields(); - - RelazioneScavo relazioneScavo = abstractRelazioneScavo == null?new RelazioneScavo():abstractRelazioneScavo; - + + RelazioneScavo relazioneScavo = new RelazioneScavo(); + List responsabiliLst = mapFields.get("Responsabile del documento"); - if(responsabiliLst!=null) { + if (responsabiliLst != null) { relazioneScavo.setResponsabili(responsabiliLst); } - + List autoreList = mapFields.get("Autore del documento"); - if(autoreList!=null) { - //TODO + if (autoreList != null) { + // TODO } - + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); - if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + if (politicaDiAccessoLst != null && politicaDiAccessoLst.size() > 0) { try { AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0)); relazioneScavo.setPolicy(ap); - }catch (Exception e) { - LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e); + } 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) { + if (licenzaIdList != null && licenzaIdList.size() > 0) { relazioneScavo.setLicenseID(licenzaIdList.get(0)); } - - //TODO + + // TODO List periodoDiEmbargo = mapFields.get("Periodo di embargo"); - if(periodoDiEmbargo!=null && periodoDiEmbargo.size()>0) { + if (periodoDiEmbargo != null && periodoDiEmbargo.size() > 0) { String dateFromTo = periodoDiEmbargo.get(0); String[] dates = dateFromTo.split(","); String dateFrom = dates[0]; String dateTo = dates[0]; - //TODO MUST BE INTENGRATED IN THE SERVICE + // TODO MUST BE INTENGRATED IN THE SERVICE } - + return relazioneScavo; } - - public static RelazioneScavo toAbstractRelazioneScavo(GenericDatasetBean gdb) { - + + /** + * To abstract relazione scavo. + * + * @param gdb the gdb + * @return the abstract relazione + */ + public static AbstractRelazione toAbstractRelazioneScavo(GenericDatasetBean gdb) { + Map> mapFields = gdb.getFormDataEntryFields(); - - RelazioneScavo relazioneScavo = new RelazioneScavo(); - + + AbstractRelazione abstractrelazione = new AbstractRelazione(); + List abstractLstIta = mapFields.get("Abstract in Italiano"); - if(abstractLstIta!=null && abstractLstIta.size()>0) { - - /** - * TODO - */ - LOG.warn("TODO ABSTRACT RELAZIONE DI SCAVO IN ITA"); - //relazioneScavo.setAbstractIta(abstractLstIta.get(0)); + if (abstractLstIta != null && abstractLstIta.size() > 0) { + abstractrelazione.setAbstractIta(abstractLstIta.get(0)); } - + List abstractLstEng = mapFields.get("Abstract in Inglese"); - if(abstractLstEng!=null && abstractLstEng.size()>0) { - /** - * TODO - */ - LOG.warn("TODO ABSTRACT RELAZIONE DI SCAVO IN ENG"); - //relazioneScavo.setAbstractEng(abstractLstEng.get(0)); + if (abstractLstEng != null && abstractLstEng.size() > 0) { + abstractrelazione.setAbstractEng(abstractLstEng.get(0)); } - - //TODO IN FUTURE WHEN THE MODEL WILL BE UPDATED - /*List politicaDiAccessoLst = mapFields.get("Politica di accesso"); - if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + + // THIS SHOULD BE ALWAYS "OPEN" + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); + if (politicaDiAccessoLst != null && politicaDiAccessoLst.size() > 0) { try { AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0)); - relazioneScavo.setPolicy(ap); - }catch (Exception e) { - LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e); + abstractrelazione.setPolicy(ap); + } catch (Exception e) { + LOG.warn("I cannot cast " + politicaDiAccessoLst.get(0) + " to " + AccessPolicy.values(), e); } } - + + // THIS SHOULD BE ALWAYS "CC-BY-4.0" List licenzaIdList = mapFields.get("ID Licenza"); - if(licenzaIdList!=null && licenzaIdList.size()>0) { - relazioneScavo.setLicenseID(licenzaIdList.get(0)); - }*/ - - return relazioneScavo; + if (licenzaIdList != null && licenzaIdList.size() > 0) { + abstractrelazione.setLicenseID(licenzaIdList.get(0)); + } + + return abstractrelazione; } - + /** * To immagini rappresentative. * * @param gdb the gdb * @return the uploaded image */ - public static UploadedImage toImmaginiRappresentative(GenericDatasetBean gdb){ - + public static UploadedImage toImmaginiRappresentative(GenericDatasetBean gdb) { + Map> mapFields = gdb.getFormDataEntryFields(); - + UploadedImage uplaodedImage = new UploadedImage(); - + // List titoloLst = mapFields.get("Titolo"); // if(titoloLst!=null && titoloLst.size()>0) { // uplaodedImage.setTitolo(titoloLst.get(0)); // } // List didascaliaLst = mapFields.get("Didascalia"); - if(didascaliaLst!=null && didascaliaLst.size()>0) { + if (didascaliaLst != null && didascaliaLst.size() > 0) { uplaodedImage.setDidascalia(didascaliaLst.get(0)); } - - //NB here is setResponsabili but should be setAuthor + + // NB here is setResponsabili but should be setAuthor List responsabileLst = mapFields.get("Autore"); - if(responsabileLst!=null) { + if (responsabileLst != null) { uplaodedImage.setResponsabili(responsabileLst); - //uplaodedImage.setAuthor is missing!!! + // uplaodedImage.setAuthor is missing!!! } - + // List autoreList = mapFields.get("Autore"); // if(autoreList!=null) { // //TODO // } - + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); - if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + 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); + } 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) { + if (licenzaIdList != null && licenzaIdList.size() > 0) { uplaodedImage.setLicenseID(licenzaIdList.get(0)); } - + return uplaodedImage; } - + /** * To layer concessione. * * @param gdb the gdb * @return the layer concessione */ - public static LayerConcessione toLayerConcessione(GenericDatasetBean gdb){ - + public static LayerConcessione toLayerConcessione(GenericDatasetBean gdb) { + Map> mapFields = gdb.getFormDataEntryFields(); - + LayerConcessione layerConcessione = new LayerConcessione(); - + List titoloLst = mapFields.get("Titolo"); - if(titoloLst!=null && titoloLst.size()>0) { + if (titoloLst != null && titoloLst.size() > 0) { layerConcessione.setTitolo(titoloLst.get(0)); } - + List politicaDiAccessoLst = mapFields.get("Politica di accesso"); - if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) { + if (politicaDiAccessoLst != null && politicaDiAccessoLst.size() > 0) { try { AccessPolicy ap = AccessPolicy.valueOf(politicaDiAccessoLst.get(0)); layerConcessione.setPolicy(ap); - }catch (Exception e) { - LOG.warn("I cannot cast "+politicaDiAccessoLst.get(0) +" to "+AccessPolicy.values(),e); + } catch (Exception e) { + LOG.warn("I cannot cast " + politicaDiAccessoLst.get(0) + " to " + AccessPolicy.values(), e); } } List valutazioneQualitaLst = mapFields.get("Valutazione della qualità"); - if(valutazioneQualitaLst!=null && valutazioneQualitaLst.size()>0) { + if (valutazioneQualitaLst != null && valutazioneQualitaLst.size() > 0) { layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0)); } List metodoRaccoltaDatiLst = mapFields.get("Metodo di raccolta dei dati"); - if(metodoRaccoltaDatiLst!=null && metodoRaccoltaDatiLst.size()>0) { + if (metodoRaccoltaDatiLst != null && metodoRaccoltaDatiLst.size() > 0) { layerConcessione.setMetodoRaccoltaDati(metodoRaccoltaDatiLst.get(0)); } - + List scalaAcquisizioneLst = mapFields.get("Scala di acquisizione dei dati"); - if(scalaAcquisizioneLst!=null && scalaAcquisizioneLst.size()>0) { + if (scalaAcquisizioneLst != null && scalaAcquisizioneLst.size() > 0) { layerConcessione.setScalaAcquisizione(scalaAcquisizioneLst.get(0)); } - - //TODO + + // TODO List periodoDiEmbargo = mapFields.get("Periodo di embargo"); - if(periodoDiEmbargo!=null && periodoDiEmbargo.size()>0) { + if (periodoDiEmbargo != null && periodoDiEmbargo.size() > 0) { String dateFromTo = periodoDiEmbargo.get(0); String[] dates = dateFromTo.split(","); String dateFrom = dates[0]; String dateTo = dates[0]; - //TODO MUST BE INTENGRATED IN THE SERVICE + // TODO MUST BE INTENGRATED IN THE SERVICE } - - + List licenzaIdList = mapFields.get("ID Licenza"); - if(licenzaIdList!=null && licenzaIdList.size()>0) { + if (licenzaIdList != null && licenzaIdList.size() > 0) { layerConcessione.setLicenseID(licenzaIdList.get(0)); } - + List autoreLst = mapFields.get("Autore"); - if(autoreLst!=null) { + if (autoreLst != null) { layerConcessione.setAuthors(autoreLst); } - + return layerConcessione; } - /** * To local date time. * @@ -416,20 +408,19 @@ public class ConvertToServiceModel { try { date = date.trim(); SimpleDateFormat dateFormat = null; - if(date.contains(HOURS_MINUTES_SEPARATOR)) { - dateFormat = new SimpleDateFormat(DATE_FORMAT+" "+TIME_FORMAT); - }else + if (date.contains(HOURS_MINUTES_SEPARATOR)) { + dateFormat = new SimpleDateFormat(DATE_FORMAT + " " + TIME_FORMAT); + } else dateFormat = new SimpleDateFormat(DATE_FORMAT); - + Date theDate = dateFormat.parse(date); theLocalDT = convertToLocalDateTimeViaInstant(theDate); } catch (ParseException e) { - LOG.error("No able to parse: "+date, e); + LOG.error("No able to parse: " + date, e); } return theLocalDT; } - - + /** * Convert to local date time via instant. * @@ -437,9 +428,7 @@ public class ConvertToServiceModel { * @return the local date time */ public static LocalDateTime convertToLocalDateTimeViaInstant(Date dateToConvert) { - return dateToConvert.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDateTime(); + return dateToConvert.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); } - + } 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 82172e8..6938db8 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 @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.gcube.application.geoportal.common.model.legacy.AbstractRelazione; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; @@ -121,7 +122,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GenericDatasetBean ards = listGDB.get(0); LOG.debug("\n\n"); LOG.debug(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO + " building with client obj: " + ards); - RelazioneScavo abstractRelazioneDiScavo = ConvertToServiceModel.toAbstractRelazioneScavo(ards); + AbstractRelazione abstractRelazioneDiScavo = ConvertToServiceModel.toAbstractRelazioneScavo(ards); + // Setting Abstract Relazione + concessioneNew.setAbstractRelazione(abstractRelazioneDiScavo); // RELAZIONE_DI_SCAVO list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO); @@ -133,7 +136,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GenericDatasetBean rds = listGDB.get(0); LOG.debug("\n\n"); LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds); - RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds); + RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds); LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo); // Setting Relazione @@ -224,11 +227,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); List ardsFiles = serviceUtil.toTemFiles(ards.getFilesUploaded()); - // TODO DEVE ESSERE PASSATO CON PATH RELAZIONE OPPURE BISOGNA PREVEDERE UN - // ABSTRACT_RELAZIONE??? + // Building TempFile for ABSTRACT RELAZIONE if (ardsFiles != null && ardsFiles.size() > 0) { // saving into back-end - AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.RELAZIONE, ardsFiles); + AddSectionToConcessioneRequest request = new AddSectionToConcessioneRequest(Paths.ABSTRACT_RELAZIONE, + ardsFiles); clientMongo.registerFileSet(mongoId, request); LOG.info("Registered the mongoId " + mongoId + " request " + Paths.RELAZIONE + "with " + ardsFiles.size() + " file/s"); @@ -322,24 +325,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen cRep.setMongoId(concessione.getMongo_id()); ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); cRep.setValidationReportDV(vr); -// switch (report.getStatus()) { -// case PASSED: -// if (cRep.getMongoId() == null) { -// LOG.error("The mongo id is null!!!"); -// throw new Exception("Invalid identifier (mongoId is null) for the concessione"); -// } -// cRep.setMsg("OK"); -// break; -// case WARNING: -// cRep.setMsg(report.getWarningMessages().toString()); -// break; -// case ERROR: -// cRep.setMsg(report.getErrorMessages().toString()); -// break; -// -// default: -// break; -// } return cRep; } else @@ -632,7 +617,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @param itemId the item id * @param jsonUpdate the json update * @param recordType the record type - * @return the updated JSON string representing the itemId + * @return the updated JSON string representing the itemId * @throws Exception the exception */ @Override @@ -649,9 +634,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); Concessione concessione = clientMongo.update(itemId, jsonUpdate); - LOG.debug("Got Record updated: "+concessione); + LOG.debug("Got Record updated: " + concessione); ConcessioneDV concessionDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true); - LOG.info("Record with id "+concessionDV.getItemId()+"updated correclty"); + LOG.info("Record with id " + concessionDV.getItemId() + "updated correclty"); return concessionDV; } @@ -669,7 +654,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * * @param itemId the item id * @param recordType the record type - * @return the JSON record representing the itemId + * @return the JSON record representing the itemId * @throws Exception the exception */ @Override From 9d3f3bf38079dac743cc8fc86ed9277f6ca58890 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 Sep 2021 17:26:46 +0200 Subject: [PATCH 19/32] updated label --- .../user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml | 2 +- .../user/geoportaldataentry/client/ui/edit/EditModeRecord.java | 2 +- .../client/ui/edit/jseditor/JSONEditorWrapper.java | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 48e3a6c..58d031d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -92,7 +92,7 @@ Show on Map Show Publication Report + title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report
    Edit Date: Mon, 27 Sep 2021 15:28:36 +0200 Subject: [PATCH 20/32] Fired event after Record Updated --- .../ConstantsGeoPortalDataEntryApp.java | 2 +- .../client/GeoPortalDataEntryApp.java | 33 +++++++++++---- .../client/events/ActionOnItemEvent.java | 7 +++- .../client/ui/GeonaMainTabPanel.java | 2 +- .../client/ui/edit/EditModeRecord.java | 21 +++++++--- .../ui/edit/jseditor/JSONEditorWrapper.java | 42 +++++++++++++++++++ 6 files changed, 90 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 538c8f9..dea88f1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -38,7 +38,7 @@ public class ConstantsGeoPortalDataEntryApp { * Aug 6, 2021 */ public enum ACTION_ON_ITEM { - SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, DELETE_RECORD, EDIT_RECORD + SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, SHOW_EDIT_MODE, DELETE_RECORD, UPDATED_RECORD } /** 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 a0c8c51..6a51d43 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 @@ -75,7 +75,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { private static final String DIV_PORTLET_ID = "geoportal-data-entry"; - public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT.create(GeoportalDataEntryService.class); + public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT + .create(GeoportalDataEntryService.class); private final HandlerManager appManagerBus = new HandlerManager(null); @@ -151,7 +152,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { int topBorder = workspace.getAbsoluteTop(); int footer = 85; // footer is bottombar + sponsor int headerSize = 90; - //int headerSize = 30; + // int headerSize = 30; int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer == // null)?0:(footer.getOffsetHeight()-15)); @@ -428,8 +429,12 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { + SortFilter sortFilter = getListOfRecordsEvent.getSortFilter(); + if(sortFilter==null){ + sortFilter = mainTabPanel.getCurrentSortFilter(); + } grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, - getListOfRecordsEvent.getSortFilter()); + sortFilter); mainTabPanel.showListOfConcessioniView(grpw); } }); @@ -505,7 +510,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { case SHOW_REPORT: final Modal modal2 = new Modal(true, true); - modal2.setTitle("Report
    "+concessione.getNome()+"
    "); + modal2.setTitle("Report
    " + concessione.getNome() + + "
    "); modal2.setWidth(800); modal2.setCloseVisible(true); if (concessione.getValidationReport() == null) { @@ -518,18 +524,27 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal2.show(); break; - - case EDIT_RECORD: + + case SHOW_EDIT_MODE: final Modal modal3 = new Modal(true, true); - modal3.setTitle("Edit
    "+concessione.getNome()+"
    "); + modal3.setTitle("Edit
    " + concessione.getNome() + + "
    "); modal3.setWidth(950); modal3.setHeight("700px"); modal3.setCloseVisible(true); - ((Element)modal3.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); - EditModeRecord emr = new EditModeRecord(concessione,RECORD_TYPE.CONCESSIONE); + ((Element) modal3.getElement().getChildNodes().getItem(1)) + .addClassName("modal-body-custom"); + EditModeRecord emr = new EditModeRecord(appManagerBus, concessione, + RECORD_TYPE.CONCESSIONE); modal3.add(emr); modal3.show(); break; + + case UPDATED_RECORD: + appManagerBus.fireEvent( + new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + mainTabPanel.getCurrentSortFilter())); + break; case DELETE_RECORD: String htmlMsg = "Going to delete the project with:"; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java index b1d3594..11386db 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/ActionOnItemEvent.java @@ -21,7 +21,7 @@ public class ActionOnItemEvent extends GwtEvent extends GwtEvent(listConcessioni, ACTION_ON_ITEM.EDIT_RECORD)); + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.SHOW_EDIT_MODE)); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index 001b801..afe6fcd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -2,7 +2,9 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; @@ -12,6 +14,7 @@ import com.github.gwtbootstrap.client.ui.Tab; 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.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Random; @@ -51,6 +54,8 @@ public class EditModeRecord extends Composite { private JSONEditorWrapper jsEditor; + private HandlerManager appManagerBus; + /** * The Interface EditModeRecordUiBinder. * @@ -64,26 +69,28 @@ public class EditModeRecord extends Composite { /** * Instantiates a new edits the mode record. * + * @param appManagerBus the app manager bus * @param selectedConcessione the selected concessione * @param type the type */ - public EditModeRecord(BaseConcessioneDV selectedConcessione, RECORD_TYPE type) { + public EditModeRecord(HandlerManager appManagerBus, BaseConcessioneDV selectedConcessione, RECORD_TYPE type) { initWidget(uiBinder.createAndBindUi(this)); this.selectedConcessione = selectedConcessione; this.recordType = type; + this.appManagerBus = appManagerBus; instanceJSONEditor(); bindEvents(); } private void instanceJSONEditor() { - + rawUpdatePanel.clear(); final FlowPanel fp = new FlowPanel(); fp.getElement().setId("jsoneditor" + Random.nextInt()); fp.setHeight("400px"); rawUpdatePanel.add(fp); - + GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), recordType, new AsyncCallback() { @@ -138,6 +145,9 @@ public class EditModeRecord extends Composite { // TODO: handle exception } + appManagerBus.fireEvent( + new ActionOnItemEvent(null, ACTION_ON_ITEM.UPDATED_RECORD)); + } @Override @@ -152,8 +162,9 @@ public class EditModeRecord extends Composite { selectedConcessione = result; instanceJSONEditor(); - Window.alert("Project '"+result.getNome()+"' updated correctly"); - + Window.alert("Project '" + result.getNome() + "' updated correctly"); + appManagerBus.fireEvent( + new ActionOnItemEvent(null, ACTION_ON_ITEM.UPDATED_RECORD)); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java index 6c85d5c..b8b43b1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/jseditor/JSONEditorWrapper.java @@ -2,11 +2,30 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor; import com.google.gwt.core.client.JavaScriptObject; + +/** + * The Class JSONEditorWrapper. + * + * Wrapper for https://github.com/josdejong/jsoneditor + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 27, 2021 + */ public class JSONEditorWrapper extends JavaScriptObject { + /** + * Instantiates a new JSON editor wrapper. + */ protected JSONEditorWrapper() { } + /** + * Inits the. + * + * @param divID the div ID + * @return the JSON editor wrapper + */ public static native JSONEditorWrapper init(String divID) /*-{ var container = $doc.getElementById(divID); var options = { @@ -20,6 +39,11 @@ public class JSONEditorWrapper extends JavaScriptObject { return new $wnd.JSONEditor(container, options); }-*/; + /** + * Sets the. + * + * @param json the json + */ public final native void set(String json) /*-{ var toJSONObject = JSON.parse(json); // set json @@ -28,19 +52,37 @@ public class JSONEditorWrapper extends JavaScriptObject { this.refresh(); }-*/; + /** + * Gets the text. + * + * @return the text + */ public final native String getText() /*-{ console.log("this.get(): " +this.getText()); return this.getText(); }-*/; + /** + * On error. + */ public final native void onError() /*-{ this.onError(error); }-*/; + /** + * Sets the mode. + * + * @param mode the new mode + */ public final native void setMode(String mode) /*-{ this.setMode(mode); }-*/; + /** + * Sets the name. + * + * @param rootName the new name + */ public final native void setName(String rootName) /*-{ this.setName(rootName); }-*/; From 541c190820d9ad0a32b72573b503a1e239d6865f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 27 Sep 2021 18:32:19 +0200 Subject: [PATCH 21/32] FileSet upload in progress --- .settings/org.eclipse.wst.common.component | 36 +++- .../client/GeoportalDataEntryService.java | 18 ++ .../GeoportalDataEntryServiceAsync.java | 6 + .../client/ui/edit/EditModeRecord.java | 23 +- .../client/ui/edit/EditModeRecord.ui.xml | 5 +- .../client/ui/edit/UpdateFileset.java | 199 ++++++++++++++++++ .../client/ui/edit/UpdateFileset.ui.xml | 29 +++ .../server/GeoportalDataEntryServiceImpl.java | 55 ++++- 8 files changed, 357 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 3af9f7e..50f8241 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -7,7 +9,9 @@ - + + + @@ -15,7 +19,9 @@ - + + + @@ -23,7 +29,9 @@ - + + + @@ -31,7 +39,9 @@ - + + + @@ -42,7 +52,9 @@ uses - + + + @@ -50,7 +62,9 @@ - + + + @@ -58,7 +72,9 @@ - + + + @@ -66,7 +82,9 @@ - + + + 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 e5edde1..768eefb 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 @@ -75,4 +75,22 @@ public interface GeoportalDataEntryService extends RemoteService { String getJSONRecord(String itemId, RECORD_TYPE recordType) throws Exception; ConcessioneDV updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception; + + /** + * Read file set paths. + * + * @return the list + * @throws Exception the exception + */ + List readFileSetPaths() throws Exception; + + /** + * Gets the record. + * + * @param itemId the item id + * @param recordType the record type + * @return the record + * @throws Exception the exception + */ + ConcessioneDV getRecord(String itemId, RECORD_TYPE 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 24183fb..3143c1a 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 @@ -60,4 +60,10 @@ public interface GeoportalDataEntryServiceAsync void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); + + + void readFileSetPaths(AsyncCallback> callback); + + + void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index afe6fcd..e05ad80 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -1,11 +1,13 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; -import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; @@ -80,9 +82,28 @@ public class EditModeRecord extends Composite { this.appManagerBus = appManagerBus; instanceJSONEditor(); + instanceUpdateFilesetEditor(); bindEvents(); } + private void instanceUpdateFilesetEditor() { + GeoPortalDataEntryApp.geoportalDataEntryService.readFileSetPaths(new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub + + } + + @Override + public void onSuccess(List listFileSetPaths) { + UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, listFileSetPaths); + filesUpdatePanel.add(updateFileset); + } + }); + + } + private void instanceJSONEditor() { rawUpdatePanel.clear(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index ceab188..aa39d47 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -24,7 +24,7 @@ Source Project Editor - You can update the Source Project by editing its JSON model + You can update the Source Project by editing its JSON model data displayed in the following Editor.

    @@ -54,8 +54,7 @@ Update the file/s - By choosing a section (e.g. "RELAZIONE di - SCAVO") and + By choosing a section (e.g. "relazione") and uploading new file/s the old one/s will be replaced diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java new file mode 100644 index 0000000..b73bf5c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -0,0 +1,199 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; + +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; +import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload; + +import com.github.gwtbootstrap.client.ui.ControlGroup; +import com.github.gwtbootstrap.client.ui.Label; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.constants.LabelType; +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.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.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class UpdateFileset. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 27, 2021 + */ +public class UpdateFileset extends Composite { + + private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); + + /** + * The Interface UpdateFilesetUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 27, 2021 + */ + interface UpdateFilesetUiBinder extends UiBinder { + } + + @UiField + ListBox listBoxPaths; + + @UiField + ListBox listBoxIndex; + + @UiField + ControlGroup cgSelectFile; + + @UiField + HTMLPanel uploadFileContainer; + + private List listFileSetPaths; + + private boolean placeholderRemoved = false; + + private String recordId; + + private BaseConcessioneDV selectedConcessione; + + private ConcessioneDV fullConcessione; + + private RECORD_TYPE recordType; + + /** + * Instantiates a new update fileset. + * + * @param listFileSetPaths the list file set paths + */ + public UpdateFileset(BaseConcessioneDV selectedConcessione, RECORD_TYPE recordType, List listFileSetPaths) { + initWidget(uiBinder.createAndBindUi(this)); + this.selectedConcessione = selectedConcessione; + this.recordType = recordType; + this.listFileSetPaths = listFileSetPaths; + listBoxPaths.addItem("Select a section..."); + for (String path : listFileSetPaths) { + listBoxPaths.addItem(path); + } + + // add handler on select + listBoxPaths.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + GWT.log("Profile type selection changed..."); + cgSelectFile.setVisible(false); + + if (!placeholderRemoved) { + listBoxPaths.removeItem(0); // this is the placeholder + placeholderRemoved = true; + } + showUploadFileGUI(); + } + + }); + + GeoPortalDataEntryApp.geoportalDataEntryService.getRecord(selectedConcessione.getItemId(), recordType, + new AsyncCallback() { + + @Override + public void onSuccess(ConcessioneDV theRecord) { + fullConcessione = theRecord; + } + + @Override + public void onFailure(Throwable caught) { + Window.alert(caught.getMessage()); + } + }); + + } + + /** + * Show upload file GUI. + */ + private void showUploadFileGUI() { + uploadFileContainer.setVisible(true); + uploadFileContainer.clear(); + + listBoxIndex.clear(); + cgSelectFile.setVisible(true); + + if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { + AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); + if (ar == null) { + showMessage("abstract_relazione " + " NOT AVAILABLE", LabelType.WARNING); + return; + } + fillListBoxToBeReplaced("abstract_relazione", ar.getListWsContent()); + } else if (listBoxPaths.getSelectedItemText().contains("immagini")) { + List listImmagini = fullConcessione.getImmaginiRappresentative(); + if (listImmagini == null || listImmagini.isEmpty()) { + showMessage("immagini " + " NOT AVAILABLE", LabelType.WARNING); + return; + } + for (UploadedImageDV uploadedImageDV : listImmagini) { + fillListBoxToBeReplaced("immagini", uploadedImageDV.getListWsContent()); + } + + } + + if (listBoxIndex.getItemCount() > 1) { + listBoxIndex.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + showFileUploadInteraction(); + } + }); + } + + } + + private void fillListBoxToBeReplaced(String section, List listWSC) { + + listBoxIndex.clear(); + + listBoxIndex.addItem("Select a file..."); + + if (listWSC == null || listWSC.isEmpty()) { + showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); + return; + } + + for (WorkspaceContentDV wsContent : listWSC) { + String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink() + : wsContent.getName(); + listBoxIndex.addItem(name); + } + } + + private void showFileUploadInteraction() { + uploadFileContainer.clear(); + HTML label = new HTML(); + label.setHTML("Going to replace the file into section: " + listBoxIndex.getSelectedItemText() + " with"); + + uploadFileContainer.add(label); + MultipleDilaogUpload holder = new MultipleDilaogUpload(); + uploadFileContainer.add(holder); + } + + private void showMessage(String txt, LabelType type) { + Label l = new Label(); + l.setType(type); + l.setText(txt); + uploadFileContainer.add(l); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml new file mode 100644 index 0000000..a161c10 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -0,0 +1,29 @@ + + + + .important { + font-weight: bold; + } + + + + + + Section + + + + + + Select File to be replaced + + + + + + + + + \ No newline at end of file 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 6938db8..12bc97a 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 @@ -672,7 +672,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Concessione concessione = clientMongo.getById(itemId); return serviceUtil.toJSON(concessione); } - + return null; } catch (Exception e) { @@ -681,4 +681,57 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on reading the JSON project with id: " + itemId + ". Error: " + e.getMessage()); } } + + + /** + * Gets the record. + * + * @param itemId the item id + * @param recordType the record type + * @return the record + * @throws Exception the exception + */ + @Override + public ConcessioneDV getRecord(String itemId, RECORD_TYPE recordType) throws Exception { + LOG.info("getRecord called with itemId: " + itemId + ", recordType: " + recordType); + try { + + if (itemId == null) + throw new Exception("Item id is null"); + + if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + Concessione concessione = clientMongo.getById(itemId); + return ConvertToDataViewModel.toConcessione(concessione); + } + + return null; + + } catch (Exception e) { + LOG.error("Error on reading the record with item id: " + itemId, e); + throw new Exception( + "Error occurred on reading the record with id: " + itemId + ". Error: " + e.getMessage()); + } + } + + /** + * Read file set paths. + * + * @return the list + * @throws Exception the exception + */ + @Override + public List readFileSetPaths() throws Exception { + LOG.info("readFileSetPaths called"); + List fileSetPaths = new ArrayList(); + fileSetPaths.add(Concessione.Paths.ABSTRACT_RELAZIONE); + fileSetPaths.add(Concessione.Paths.RELAZIONE); + fileSetPaths.add(Concessione.Paths.IMMAGINI); + fileSetPaths.add(Concessione.Paths.POSIZIONAMENTO); + fileSetPaths.add(Concessione.Paths.PIANTE); + return fileSetPaths; + + } } From 282ad3980d89ce2b388a7875e6e896f80b78b372 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 28 Sep 2021 17:31:16 +0200 Subject: [PATCH 22/32] Edit FileSet on-going --- .../client/ui/edit/EditModeRecord.ui.xml | 2 +- .../client/ui/edit/UpdateFileset.java | 153 +++++++++++++++--- .../client/ui/edit/UpdateFileset.ui.xml | 37 ++++- 3 files changed, 159 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index aa39d47..a8bea29 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -24,7 +24,7 @@ Source Project Editor - You can update the Source Project by editing its JSON model + You can update the Source Project by editing its model data displayed in the following Editor.

    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index b73bf5c..8afa341 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -6,18 +6,24 @@ import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload; +import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; +import com.github.gwtbootstrap.client.ui.Controls; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.LabelType; 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.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; @@ -36,6 +42,8 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { + private static final String UPLOAD_MISSING_FILE = "You must upload a file"; + private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); /** @@ -51,15 +59,18 @@ public class UpdateFileset extends Composite { @UiField ListBox listBoxPaths; - @UiField - ListBox listBoxIndex; - @UiField ControlGroup cgSelectFile; + @UiField + Controls controlsContent; + @UiField HTMLPanel uploadFileContainer; + @UiField + Button buttonUpdate; + private List listFileSetPaths; private boolean placeholderRemoved = false; @@ -72,6 +83,10 @@ public class UpdateFileset extends Composite { private RECORD_TYPE recordType; + private MultipleDilaogUpload mDU; + + private ChangeHandler listBoxIndexHandler; + /** * Instantiates a new update fileset. * @@ -118,6 +133,22 @@ public class UpdateFileset extends Composite { } }); + buttonUpdate.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + if (mDU != null) { + if (checkValidUpload()) { + Window.alert("I can save..."); + } else { + Window.alert("New file not found. " + UPLOAD_MISSING_FILE); + } + } + + } + }); + } /** @@ -125,68 +156,140 @@ public class UpdateFileset extends Composite { */ private void showUploadFileGUI() { uploadFileContainer.setVisible(true); + buttonUpdate.setVisible(false); uploadFileContainer.clear(); + controlsContent.clear(); - listBoxIndex.clear(); +// listBoxIndex.clear(); cgSelectFile.setVisible(true); + ListBox listBoxIndex = new ListBox(); + listBoxIndex.setWidth("550px"); + listBoxIndex.addItem("Select a content..."); + if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); if (ar == null) { - showMessage("abstract_relazione " + " NOT AVAILABLE", LabelType.WARNING); + showMessage("abstract_relazione" + " NOT AVAILABLE", LabelType.WARNING); return; } - fillListBoxToBeReplaced("abstract_relazione", ar.getListWsContent()); + + int posizIndex = 0; + fillListBoxToBeReplaced(listBoxIndex, "abstract_relazione", posizIndex, ar.getTitolo(), + ar.getListWsContent()); + } else if (listBoxPaths.getSelectedItemText().contains("immagini")) { List listImmagini = fullConcessione.getImmaginiRappresentative(); if (listImmagini == null || listImmagini.isEmpty()) { - showMessage("immagini " + " NOT AVAILABLE", LabelType.WARNING); + showMessage("immagini" + " NOT AVAILABLE", LabelType.WARNING); return; } + int posizIndex = 0; for (UploadedImageDV uploadedImageDV : listImmagini) { - fillListBoxToBeReplaced("immagini", uploadedImageDV.getListWsContent()); + fillListBoxToBeReplaced(listBoxIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(), + uploadedImageDV.getListWsContent()); + posizIndex++; + } + + } else if (listBoxPaths.getSelectedItemText().contains("relazione")) { + RelazioneScavoDV realzione = fullConcessione.getRelazioneScavo(); + if (realzione == null || realzione.getListWsContent() == null) { + showMessage("relazione" + " NOT AVAILABLE", LabelType.WARNING); + return; + } + int posizIndex = 0; + fillListBoxToBeReplaced(listBoxIndex, "relazione", posizIndex, realzione.getTitolo(), + realzione.getListWsContent()); + + } else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) { + LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo(); + if (posiz == null || posiz.getListWsContent() == null || posiz.getListWsContent().isEmpty()) { + showMessage("posizionamentoScavo" + " NOT AVAILABLE", LabelType.WARNING); + return; + } + int posizIndex = 0; + fillListBoxToBeReplaced(listBoxIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(), + posiz.getListWsContent()); + + } else if (listBoxPaths.getSelectedItemText().contains("piante")) { + List piante = fullConcessione.getPianteFineScavo(); + if (piante == null || piante.isEmpty()) { + showMessage("piante" + " NOT AVAILABLE", LabelType.WARNING); + return; + } + int posizIndex = 0; + for (LayerConcessioneDV lcDV : piante) { + fillListBoxToBeReplaced(listBoxIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent()); + posizIndex++; } } - if (listBoxIndex.getItemCount() > 1) { - listBoxIndex.addChangeHandler(new ChangeHandler() { + controlsContent.add(listBoxIndex); - @Override - public void onChange(ChangeEvent event) { - showFileUploadInteraction(); - } - }); - } +// if (listBoxIndex.getItemCount() > 1) { +// listBoxIndex.addChangeHandler(new ChangeHandler() { +// +// @Override +// public void onChange(ChangeEvent event) { +// showFileBrowseInteraction(); +// } +// }); +// } } - private void fillListBoxToBeReplaced(String section, List listWSC) { + private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title, + List listWSC) { - listBoxIndex.clear(); - - listBoxIndex.addItem("Select a file..."); +// ListBox listBoxIndex = new ListBox(); +// listBoxIndex.addItem("Select a content..."); if (listWSC == null || listWSC.isEmpty()) { showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); return; } + listBoxIndex.addItem(title, posizIndex + ""); + + // adding handler once + if (posizIndex == 0) { + listBoxIndex.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + showFileBrowseInteraction(); + } + }); + } +// +// controlsContent.add(listBoxIndex); + for (WorkspaceContentDV wsContent : listWSC) { String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink() : wsContent.getName(); - listBoxIndex.addItem(name); } } - private void showFileUploadInteraction() { + private void showFileBrowseInteraction() { uploadFileContainer.clear(); HTML label = new HTML(); - label.setHTML("Going to replace the file into section: " + listBoxIndex.getSelectedItemText() + " with"); + label.setHTML("With new one:"); uploadFileContainer.add(label); - MultipleDilaogUpload holder = new MultipleDilaogUpload(); - uploadFileContainer.add(holder); + mDU = new MultipleDilaogUpload(); + uploadFileContainer.add(mDU); + buttonUpdate.setVisible(true); + } + + private boolean checkValidUpload() { + GWT.log("Checking is valid File"); + + if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) { + return mDU.getFileUploadingState().getFile().getTempSystemPath() != null; + } + + return false; } private void showMessage(String txt, LabelType type) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index a161c10..3168485 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -6,24 +6,47 @@ .important { font-weight: bold; } + + .button-save-style { + margin-top: 10px; + float: right; + } + + .width-550 { + width: 550px; + } + + .form-fielset { + margin: 10px 0px; + border: 1px groove #ddd; + padding: 10px; + } - + Section - + - - Select File to be replaced - - + + Replace the content + + + + + + - + UPDATE \ No newline at end of file From 86f9234c83366a877a41107917fe985cb3a8ff40 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 29 Sep 2021 11:08:15 +0200 Subject: [PATCH 23/32] moved to 2.0.0-SNAPSHOT --- .classpath | 6 +-- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 52 ++++++++++++++----- CHANGELOG.md | 2 +- pom.xml | 6 ++- .../client/ui/edit/UpdateFileset.java | 5 +- .../client/ui/edit/UpdateFileset.ui.xml | 19 ++----- src/main/webapp/GeoPortalDataEntryApp.css | 6 +++ 8 files changed, 62 insertions(+), 36 deletions(-) diff --git a/.classpath b/.classpath index 60e5a76..f66ef9e 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 2b6aaa6..1a6fa73 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.3.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 50f8241..c4e9c0b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + @@ -8,8 +8,14 @@ - - + + + + + + + + @@ -19,7 +25,10 @@ - + + + + @@ -29,7 +38,10 @@ - + + + + @@ -39,7 +51,10 @@ - + + + + @@ -49,10 +64,10 @@ - - uses - - + + + + @@ -62,7 +77,7 @@ - + @@ -71,8 +86,14 @@ - - + + + + + + + + @@ -82,7 +103,10 @@ - + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ee362..7f88f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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.3.0-SNAPSHOT] - 2021-07-22 +## [v2.0.0-SNAPSHOT] - 2021-09-29 #### Enhancements diff --git a/pom.xml b/pom.xml index 1a7a83b..abc93a3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 1.3.0-SNAPSHOT + 2.0.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 @@ -146,6 +146,10 @@ javax.servlet servlet-api + + org.projectlombok + lombok + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index 8afa341..a281a56 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -42,6 +42,8 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { + private static final String _700PX = "700px"; + private static final String UPLOAD_MISSING_FILE = "You must upload a file"; private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); @@ -101,6 +103,7 @@ public class UpdateFileset extends Composite { for (String path : listFileSetPaths) { listBoxPaths.addItem(path); } + listBoxPaths.setWidth(_700PX); // add handler on select listBoxPaths.addChangeHandler(new ChangeHandler() { @@ -164,7 +167,7 @@ public class UpdateFileset extends Composite { cgSelectFile.setVisible(true); ListBox listBoxIndex = new ListBox(); - listBoxIndex.setWidth("550px"); + listBoxIndex.setWidth(_700PX); listBoxIndex.addItem("Select a content..."); if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index 3168485..b60810d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -11,33 +11,22 @@ margin-top: 10px; float: right; } - - .width-550 { - width: 550px; - } - - .form-fielset { - margin: 10px 0px; - border: 1px groove #ddd; - padding: 10px; - } - + Section - + Replace the content - - + + diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index aaec5ed..59e5c1c 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -93,3 +93,9 @@ h1 { .disable-div { pointer-events: none; } + +.form-fielset-edit { + margin: 10px 0px; + border: 1px groove #ddd; + padding: 10px; +} From d358a21182d38ea61d31c40356f7188b8d27388b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 29 Sep 2021 11:38:24 +0200 Subject: [PATCH 24/32] passing object instead of List into GWT-RPC --- .settings/org.eclipse.wst.common.component | 27 +++++++++----- pom.xml | 8 +++- .../client/GeoportalDataEntryService.java | 37 ++++++++++++++----- .../GeoportalDataEntryServiceAsync.java | 3 +- .../client/ui/edit/EditModeRecord.java | 7 ++-- .../server/GeoportalDataEntryServiceImpl.java | 11 ++---- src/main/webapp/GeoPortalDataEntryApp.css | 6 +-- 7 files changed, 65 insertions(+), 34 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index c4e9c0b..354d1cb 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -12,7 +13,8 @@ - + + @@ -25,7 +27,8 @@ - + + @@ -38,7 +41,8 @@ - + + @@ -51,7 +55,8 @@ - + + @@ -64,7 +69,8 @@ - + + @@ -77,7 +83,8 @@ - + + @@ -90,7 +97,8 @@ - + + @@ -103,7 +111,8 @@ - + + diff --git a/pom.xml b/pom.xml index abc93a3..a21a5ff 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ - + javax.servlet @@ -87,6 +87,12 @@ ${gwtVersion} provided + + com.google.gwt + gwt-servlet + ${gwtVersion} + runtime + com.github.gwtbootstrap gwt-bootstrap 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 768eefb..410b42a 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 @@ -4,6 +4,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -53,41 +54,59 @@ public interface GeoportalDataEntryService extends RemoteService { /** * Gets the list concessioni. * - * @param start the start - * @param limit the limit - * @param filter the filter + * @param start the start + * @param limit the limit + * @param filter the filter * @param reloadFromService the reload from service * @return the list concessioni * @throws Exception the exception */ - public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter, boolean reloadFromService) throws Exception; - + public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter, + boolean reloadFromService) throws Exception; /** * Delete record. * - * @param itemId the item id + * @param itemId the item id * @param recordType the record type * @return true, if successful + * @throws Exception the exception */ boolean deleteRecord(String itemId, RECORD_TYPE recordType) throws Exception; + /** + * Gets the JSON record. + * + * @param itemId the item id + * @param recordType the record type + * @return the JSON record + * @throws Exception the exception + */ String getJSONRecord(String itemId, RECORD_TYPE recordType) throws Exception; + /** + * Update record. + * + * @param itemId the item id + * @param jsonUpdate the json update + * @param recordType the record type + * @return the concessione DV + * @throws Exception the exception + */ ConcessioneDV updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType) throws Exception; /** * Read file set paths. * - * @return the list + * @return the file set paths DV * @throws Exception the exception */ - List readFileSetPaths() throws Exception; + FileSetPathsDV readFileSetPaths() throws Exception; /** * Gets the record. * - * @param itemId the item id + * @param itemId the item id * @param recordType the record type * @return the record * @throws Exception the 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 3143c1a..1df72e8 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 @@ -4,6 +4,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; @@ -62,7 +63,7 @@ public interface GeoportalDataEntryServiceAsync void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback callback); - void readFileSetPaths(AsyncCallback> callback); + void readFileSetPaths(AsyncCallback callback); void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index e05ad80..fc43957 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -4,6 +4,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; @@ -87,7 +88,7 @@ public class EditModeRecord extends Composite { } private void instanceUpdateFilesetEditor() { - GeoPortalDataEntryApp.geoportalDataEntryService.readFileSetPaths(new AsyncCallback>() { + GeoPortalDataEntryApp.geoportalDataEntryService.readFileSetPaths(new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -96,8 +97,8 @@ public class EditModeRecord extends Composite { } @Override - public void onSuccess(List listFileSetPaths) { - UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, listFileSetPaths); + public void onSuccess(FileSetPathsDV fileSetPaths) { + UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); filesUpdatePanel.add(updateFileset); } }); 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 12bc97a..72e8e3f 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 @@ -23,6 +23,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; +import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; @@ -723,15 +724,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen * @throws Exception the exception */ @Override - public List readFileSetPaths() throws Exception { + public FileSetPathsDV readFileSetPaths() throws Exception { LOG.info("readFileSetPaths called"); - List fileSetPaths = new ArrayList(); - fileSetPaths.add(Concessione.Paths.ABSTRACT_RELAZIONE); - fileSetPaths.add(Concessione.Paths.RELAZIONE); - fileSetPaths.add(Concessione.Paths.IMMAGINI); - fileSetPaths.add(Concessione.Paths.POSIZIONAMENTO); - fileSetPaths.add(Concessione.Paths.PIANTE); - return fileSetPaths; + return ConvertToDataViewModel.getFileSetPaths(); } } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 59e5c1c..0a9a0ce 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -95,7 +95,7 @@ h1 { } .form-fielset-edit { - margin: 10px 0px; - border: 1px groove #ddd; - padding: 10px; + margin: 10px 0px !important; + border: 1px groove #ddd !important; + padding: 10px !important; } From 86274164005120d42226779ddb38e48dfa9d25b6 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 29 Sep 2021 12:00:52 +0200 Subject: [PATCH 25/32] removed exclusion of lombok --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index a21a5ff..89373cb 100644 --- a/pom.xml +++ b/pom.xml @@ -152,10 +152,6 @@ javax.servlet servlet-api - - org.projectlombok - lombok - From 378f9419a67121b0c42264ebbda0aec2ca2a2ff9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 29 Sep 2021 16:13:39 +0200 Subject: [PATCH 26/32] in progress Edit Mode --- .../client/ui/edit/EditModeRecord.java | 11 +- .../client/ui/edit/EditModeRecord.ui.xml | 20 ++- .../client/ui/edit/UpdateFileset.java | 145 ++++++++++++------ .../client/ui/edit/UpdateFileset.ui.xml | 6 +- src/main/webapp/GeoPortalDataEntryApp.css | 11 +- 5 files changed, 133 insertions(+), 60 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index fc43957..878b145 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -1,7 +1,5 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; -import java.util.List; - import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; @@ -26,6 +24,7 @@ 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.ScrollPanel; import com.google.gwt.user.client.ui.Widget; /** @@ -41,12 +40,15 @@ public class EditModeRecord extends Composite { @UiField Tab tabRawUpdate; + + @UiField + Tab tabUploadFiles; @UiField FlowPanel rawUpdatePanel; @UiField - FlowPanel filesUpdatePanel; + ScrollPanel filesUpdatePanel; @UiField Button buttonJSONUpdate; @@ -81,6 +83,8 @@ public class EditModeRecord extends Composite { this.selectedConcessione = selectedConcessione; this.recordType = type; this.appManagerBus = appManagerBus; + this.filesUpdatePanel.setHeight("490px"); + //filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px"); instanceJSONEditor(); instanceUpdateFilesetEditor(); @@ -99,6 +103,7 @@ public class EditModeRecord extends Composite { @Override public void onSuccess(FileSetPathsDV fileSetPaths) { UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); + //updateFileset.setHeight("300px !important"); filesUpdatePanel.add(updateFileset); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index a8bea29..fdeac36 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -24,7 +24,8 @@ Source Project Editor - You can update the Source Project by editing its model + You can update the Source Project by editing + its model data displayed in the following Editor.

    @@ -41,7 +42,8 @@ del progetto") reported in green by the - Editor
    + Editor +
    At the end of the changes press the "Update" button to make them persistent on the service

    @@ -49,15 +51,23 @@ UPDATE + addStyleNames="{style.button-save-style}" + ui:field="buttonJSONUpdate">UPDATE
    Update the file/s By choosing a section (e.g. "relazione") and uploading new file/s the old one/s will be replaced - - + +

    + At the end of the changes press the "Update" button to + make + them persistent on the service +

    +
    + +
    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index a281a56..d6c73a6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -11,7 +11,10 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; -import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload; +import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; +import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; +import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; +import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; @@ -20,15 +23,18 @@ import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; 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.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.FlexTable; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; @@ -42,7 +48,7 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { - private static final String _700PX = "700px"; + private static final String _FORM_FIELDS_SIZE = "740px"; private static final String UPLOAD_MISSING_FILE = "You must upload a file"; @@ -75,7 +81,7 @@ public class UpdateFileset extends Composite { private List listFileSetPaths; - private boolean placeholderRemoved = false; + private boolean listBoxPathsPlaceholder = true; private String recordId; @@ -85,9 +91,13 @@ public class UpdateFileset extends Composite { private RECORD_TYPE recordType; - private MultipleDilaogUpload mDU; + // private MultipleDilaogUpload mDU; - private ChangeHandler listBoxIndexHandler; + private boolean listBoxIndexPlaceholder = true; + + private HandlerManager uiBus = new HandlerManager(null); + + private MetaDataField fieldUploadWidget; /** * Instantiates a new update fileset. @@ -103,7 +113,7 @@ public class UpdateFileset extends Composite { for (String path : listFileSetPaths) { listBoxPaths.addItem(path); } - listBoxPaths.setWidth(_700PX); + listBoxPaths.setWidth(_FORM_FIELDS_SIZE); // add handler on select listBoxPaths.addChangeHandler(new ChangeHandler() { @@ -113,9 +123,9 @@ public class UpdateFileset extends Composite { GWT.log("Profile type selection changed..."); cgSelectFile.setVisible(false); - if (!placeholderRemoved) { - listBoxPaths.removeItem(0); // this is the placeholder - placeholderRemoved = true; + if (listBoxPathsPlaceholder) { + listBoxPaths.removeItem(0); // this is the placeholder, removing it once + listBoxPathsPlaceholder = false; } showUploadFileGUI(); } @@ -141,12 +151,10 @@ public class UpdateFileset extends Composite { @Override public void onClick(ClickEvent event) { - if (mDU != null) { - if (checkValidUpload()) { - Window.alert("I can save..."); - } else { - Window.alert("New file not found. " + UPLOAD_MISSING_FILE); - } + if (checkValidUpload() == null) { + Window.alert("I can save..."); + } else { + Window.alert("New file not found. " + UPLOAD_MISSING_FILE); } } @@ -162,12 +170,14 @@ public class UpdateFileset extends Composite { buttonUpdate.setVisible(false); uploadFileContainer.clear(); controlsContent.clear(); + listBoxIndexPlaceholder = true; + fieldUploadWidget = null; // listBoxIndex.clear(); cgSelectFile.setVisible(true); ListBox listBoxIndex = new ListBox(); - listBoxIndex.setWidth(_700PX); + listBoxIndex.setWidth(_FORM_FIELDS_SIZE); listBoxIndex.addItem("Select a content..."); if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { @@ -230,24 +240,11 @@ public class UpdateFileset extends Composite { controlsContent.add(listBoxIndex); -// if (listBoxIndex.getItemCount() > 1) { -// listBoxIndex.addChangeHandler(new ChangeHandler() { -// -// @Override -// public void onChange(ChangeEvent event) { -// showFileBrowseInteraction(); -// } -// }); -// } - } private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title, List listWSC) { -// ListBox listBoxIndex = new ListBox(); -// listBoxIndex.addItem("Select a content..."); - if (listWSC == null || listWSC.isEmpty()) { showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); return; @@ -257,42 +254,92 @@ public class UpdateFileset extends Composite { // adding handler once if (posizIndex == 0) { + listBoxIndex.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { - showFileBrowseInteraction(); + + if (listBoxIndexPlaceholder) { + listBoxIndex.removeItem(0); // this is the placeholder, removing it once + listBoxIndexPlaceholder = false; + } + + showFileBrowseInteraction(listWSC); } }); } // -// controlsContent.add(listBoxIndex); - for (WorkspaceContentDV wsContent : listWSC) { - String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink() - : wsContent.getName(); - } } - private void showFileBrowseInteraction() { + private void showFileBrowseInteraction(List listWSC) { uploadFileContainer.clear(); - HTML label = new HTML(); - label.setHTML("With new one:"); - uploadFileContainer.add(label); - mDU = new MultipleDilaogUpload(); - uploadFileContainer.add(mDU); - buttonUpdate.setVisible(true); - } + if (listWSC.size() > 0) { + FlexTable table = new FlexTable(); + table.addStyleName("table-current-content"); + table.setHTML(0, 0, "Current content:"); + table.setHTML(1, 0, "Filename"); + table.setHTML(1, 1, "MimeType"); + table.setHTML(1, 2, "Link"); + int i = 2; + for (WorkspaceContentDV wsContent : listWSC) { + table.setHTML(i, 0, wsContent.getName()); + table.setHTML(i, 1, wsContent.getMimetype()); + String link = "Download"; + table.setHTML(i, 2, link); + i++; + } - private boolean checkValidUpload() { - GWT.log("Checking is valid File"); - - if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) { - return mDU.getFileUploadingState().getFile().getTempSystemPath() != null; + uploadFileContainer.add(table); } - return false; + HTML label = new HTML(); + label.getElement().getStyle().setMarginTop(10, Unit.PX); + label.setHTML("With new content:"); + uploadFileContainer.add(label); + // mDU = new MultipleDilaogUpload(); + + MetadataFieldWrapper uploadField = new MetadataFieldWrapper(); + uploadField.setFieldName("File"); + uploadField.setMandatory(true); + uploadField.setType(DataTypeWrapper.File); + uploadField.setMaxOccurs(1000); + + try { + fieldUploadWidget = new MetaDataField(uploadField, uiBus); + //BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget); + uploadFileContainer.add(fieldUploadWidget); + + buttonUpdate.setVisible(true); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * Test if profile data are valid. + * + * @return the string + */ + private String checkValidUpload() { + + for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) { + + field.removeError(); + + String error = field.isFieldValueValid(); + if (error != null) { + field.showError(); + String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error; + return errorMsg; + } + } + + return null; } private void showMessage(String txt, LabelType type) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index b60810d..ac27ab0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -14,7 +14,7 @@ - + Section @@ -30,7 +30,9 @@ - + + + diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 0a9a0ce..e5e8797 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -94,8 +94,17 @@ h1 { pointer-events: none; } -.form-fielset-edit { +.form-fieldset-edit { margin: 10px 0px !important; border: 1px groove #ddd !important; padding: 10px !important; } + +.table-current-content { + width: 100%; + background-color: #efefef; +} + +.table-current-content td { + padding: 5px; +} From 765ca9f6216143d993849d4d8aed0a0dffe33acc Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 29 Sep 2021 18:27:22 +0200 Subject: [PATCH 27/32] in progress on Edit Mode --- .settings/org.eclipse.wst.common.component | 3 + .../client/GeoportalDataEntryService.java | 13 +++ .../GeoportalDataEntryServiceAsync.java | 5 ++ .../client/ui/edit/EditModeRecord.java | 1 - .../client/ui/edit/UpdateFileset.java | 90 ++++++++++++------- .../server/GeoportalDataEntryServiceImpl.java | 84 +++++++++++++++++ 6 files changed, 161 insertions(+), 35 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 354d1cb..811d676 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -69,6 +69,9 @@ + + uses + 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 410b42a..13ef04b 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 @@ -11,6 +11,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -112,4 +113,16 @@ public interface GeoportalDataEntryService extends RemoteService { * @throws Exception the exception */ ConcessioneDV getRecord(String itemId, RECORD_TYPE recordType) throws Exception; + + /** + * Update record. + * + * @param itemId the item id + * @param jsonUpdate the json update + * @param recordType the record type + * @return the updated JSON string representing the itemId + * @throws Exception the exception + */ + ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, + GenericDatasetBean gDBean) 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 1df72e8..60ddcb5 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 @@ -11,6 +11,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData; import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter; +import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -67,4 +68,8 @@ public interface GeoportalDataEntryServiceAsync void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback callback); + + + void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, + GenericDatasetBean gDBean, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index 878b145..3c94e7a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -103,7 +103,6 @@ public class EditModeRecord extends Composite { @Override public void onSuccess(FileSetPathsDV fileSetPaths) { UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); - //updateFileset.setHeight("300px !important"); filesUpdatePanel.add(updateFileset); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index d6c73a6..b7617f3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; +import java.util.ArrayList; import java.util.List; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; @@ -13,8 +14,11 @@ import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataE import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; +import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload; +import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper; +import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; @@ -50,8 +54,6 @@ public class UpdateFileset extends Composite { private static final String _FORM_FIELDS_SIZE = "740px"; - private static final String UPLOAD_MISSING_FILE = "You must upload a file"; - private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); /** @@ -81,9 +83,7 @@ public class UpdateFileset extends Composite { private List listFileSetPaths; - private boolean listBoxPathsPlaceholder = true; - - private String recordId; + private boolean placeholderListBoxPaths = true; private BaseConcessioneDV selectedConcessione; @@ -91,13 +91,13 @@ public class UpdateFileset extends Composite { private RECORD_TYPE recordType; - // private MultipleDilaogUpload mDU; - - private boolean listBoxIndexPlaceholder = true; + private boolean placeholderListBoxIndex = true; private HandlerManager uiBus = new HandlerManager(null); private MetaDataField fieldUploadWidget; + + private Integer pathIndex = null; /** * Instantiates a new update fileset. @@ -123,9 +123,9 @@ public class UpdateFileset extends Composite { GWT.log("Profile type selection changed..."); cgSelectFile.setVisible(false); - if (listBoxPathsPlaceholder) { + if (placeholderListBoxPaths) { listBoxPaths.removeItem(0); // this is the placeholder, removing it once - listBoxPathsPlaceholder = false; + placeholderListBoxPaths = false; } showUploadFileGUI(); } @@ -151,10 +151,27 @@ public class UpdateFileset extends Composite { @Override public void onClick(ClickEvent event) { - if (checkValidUpload() == null) { - Window.alert("I can save..."); + String errorMsg = checkValidUpload(); + if (errorMsg == null) { + List listFilesUploaded = new ArrayList(); + List listMetaDataFieldSkeleton = fieldUploadWidget.getListOfMetadataFields(); + for (MetaDataFieldSkeleton field : listMetaDataFieldSkeleton) { + DialogUpload dUpload = (DialogUpload) field.getHolder(); + // adding it only if exists + if (dUpload.getFileUploadingState() != null) + listFilesUploaded.add(dUpload.getFileUploadingState().getFile()); + } + + GenericDatasetBean gdb = new GenericDatasetBean(); + gdb.setFilesUploaded(listFilesUploaded); + // adding it only if exists + + GWT.log("Section selected: " + listBoxPaths.getSelectedItemText()); + GWT.log("Content index selected: " + pathIndex); + GWT.log("FileUploaded selected: " + gdb.getFilesUploaded()); + } else { - Window.alert("New file not found. " + UPLOAD_MISSING_FILE); + Window.alert(errorMsg); } } @@ -170,15 +187,16 @@ public class UpdateFileset extends Composite { buttonUpdate.setVisible(false); uploadFileContainer.clear(); controlsContent.clear(); - listBoxIndexPlaceholder = true; + placeholderListBoxIndex = true; fieldUploadWidget = null; + pathIndex = null; // listBoxIndex.clear(); cgSelectFile.setVisible(true); - ListBox listBoxIndex = new ListBox(); - listBoxIndex.setWidth(_FORM_FIELDS_SIZE); - listBoxIndex.addItem("Select a content..."); + ListBox listBoxContentIndex = new ListBox(); + listBoxContentIndex.setWidth(_FORM_FIELDS_SIZE); + listBoxContentIndex.addItem("Select a content..."); if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); @@ -188,7 +206,7 @@ public class UpdateFileset extends Composite { } int posizIndex = 0; - fillListBoxToBeReplaced(listBoxIndex, "abstract_relazione", posizIndex, ar.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, "abstract_relazione", posizIndex, ar.getTitolo(), ar.getListWsContent()); } else if (listBoxPaths.getSelectedItemText().contains("immagini")) { @@ -199,7 +217,7 @@ public class UpdateFileset extends Composite { } int posizIndex = 0; for (UploadedImageDV uploadedImageDV : listImmagini) { - fillListBoxToBeReplaced(listBoxIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(), uploadedImageDV.getListWsContent()); posizIndex++; } @@ -211,7 +229,7 @@ public class UpdateFileset extends Composite { return; } int posizIndex = 0; - fillListBoxToBeReplaced(listBoxIndex, "relazione", posizIndex, realzione.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, "relazione", posizIndex, realzione.getTitolo(), realzione.getListWsContent()); } else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) { @@ -221,7 +239,7 @@ public class UpdateFileset extends Composite { return; } int posizIndex = 0; - fillListBoxToBeReplaced(listBoxIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(), posiz.getListWsContent()); } else if (listBoxPaths.getSelectedItemText().contains("piante")) { @@ -232,17 +250,17 @@ public class UpdateFileset extends Composite { } int posizIndex = 0; for (LayerConcessioneDV lcDV : piante) { - fillListBoxToBeReplaced(listBoxIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent()); + fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent()); posizIndex++; } } - controlsContent.add(listBoxIndex); + controlsContent.add(listBoxContentIndex); } - private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title, + private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title, List listWSC) { if (listWSC == null || listWSC.isEmpty()) { @@ -250,22 +268,22 @@ public class UpdateFileset extends Composite { return; } - listBoxIndex.addItem(title, posizIndex + ""); + listBoxContentIndex.addItem(title, posizIndex + ""); // adding handler once if (posizIndex == 0) { - listBoxIndex.addChangeHandler(new ChangeHandler() { + listBoxContentIndex.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { - if (listBoxIndexPlaceholder) { - listBoxIndex.removeItem(0); // this is the placeholder, removing it once - listBoxIndexPlaceholder = false; + if (placeholderListBoxIndex) { + listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once + placeholderListBoxIndex = false; } - showFileBrowseInteraction(listWSC); + showFileBrowseInteraction(listBoxContentIndex.getSelectedIndex(), listWSC); } }); } @@ -273,9 +291,10 @@ public class UpdateFileset extends Composite { } - private void showFileBrowseInteraction(List listWSC) { + private void showFileBrowseInteraction(int pathContentIndex, List listWSC) { uploadFileContainer.clear(); - + pathIndex = pathContentIndex; + if (listWSC.size() > 0) { FlexTable table = new FlexTable(); table.addStyleName("table-current-content"); @@ -309,9 +328,9 @@ public class UpdateFileset extends Composite { try { fieldUploadWidget = new MetaDataField(uploadField, uiBus); - //BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget); + // BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget); uploadFileContainer.add(fieldUploadWidget); - + buttonUpdate.setVisible(true); } catch (Exception e) { // TODO Auto-generated catch block @@ -327,6 +346,9 @@ public class UpdateFileset extends Composite { */ private String checkValidUpload() { + if (fieldUploadWidget == null) + return "No file uploaded"; + for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) { field.removeError(); 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 72e8e3f..a6be44c 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 @@ -649,6 +649,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); } } + /** * Gets the JSON record. @@ -729,4 +730,87 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return ConvertToDataViewModel.getFileSetPaths(); } + + /** + * Update record. + * + * @param itemId the item id + * @param jsonUpdate the json update + * @param recordType the record type + * @return the updated JSON string representing the itemId + * @throws Exception the exception + */ + @Override + public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, GenericDatasetBean gDBean) throws Exception { + LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section+", pathIndex: " + pathIndex+", gDBean: " + gDBean, ""); + try { + + if (itemId == null) + throw new Exception("Item id is null"); + + if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + + String toEditPath = null; + AddSectionToConcessioneRequest request = null; + + List files = serviceUtil.toTemFiles(gDBean.getFilesUploaded()); + if(files==null || files.isEmpty()) + throw new Exception("Sorry, an error occurred on reading temp files. Refresh and try again"); + + if (section.contains("abstract_relazione")) { + + toEditPath = Paths.ABSTRACT_RELAZIONE; + request = new AddSectionToConcessioneRequest(toEditPath, files); + + } else if (section.contains("immagini")) { + toEditPath = Paths.imgByIndex(pathIndex); + request = new AddSectionToConcessioneRequest(toEditPath, files); + + } else if (section.contains("relazione")) { + toEditPath = Paths.RELAZIONE; + request = new AddSectionToConcessioneRequest(toEditPath, files); + + } else if (section.contains("posizionamentoScavo")) { + toEditPath = Paths.POSIZIONAMENTO; + request = new AddSectionToConcessioneRequest(toEditPath, + files); + + } else if (section.contains("piante")) { + toEditPath = Paths.piantaByIndex(pathIndex); + request = new AddSectionToConcessioneRequest( + toEditPath, files); + } + // Unpublish + System.out.println("Unpublishing "+itemId); + clientMongo.unPublish(itemId); + + // update Fileset + System.out.println("Removing old fileset.. "); + clientMongo.cleanFileSet(itemId,toEditPath); + + System.out.println("Sending new Fileset .."); + + //StorageUtils storage=new StorageUtils(); + // Building TempFile + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + LOG.info("Registering FileSet into recordId " + itemId + " with request path: " +toEditPath + " and: " + files.size() + + " file/s"); + Concessione concessione = clientMongo.registerFileSet(itemId,request); + concessione = clientMongo.publish(itemId); + + return ConvertToDataViewModel.toConcessione(concessione); + } + + return null; + + } catch (Exception e) { + LOG.error("Error on updating the project with item id: " + itemId, e); + throw new Exception( + "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); + } + } + } From b4ec07371b528f57a4dfe44c7b59ddaac60d79a7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 30 Sep 2021 13:06:14 +0200 Subject: [PATCH 28/32] in progress on edit mode --- .../client/GeoPortalDataEntryApp.java | 2 +- .../client/ui/GeonaMainTabPanel.ui.xml | 81 ++++++++++--------- .../client/ui/edit/EditModeRecord.ui.xml | 6 +- .../client/ui/edit/UpdateFileset.java | 58 ++++++++++--- .../client/ui/edit/UpdateFileset.ui.xml | 4 +- .../ui/report/BuildValidationReport.java | 2 +- .../ui/report/ReportTemplateToHTML.java | 39 ++++++++- .../ui/report/ReportTemplateToHTML.ui.xml | 2 +- src/main/webapp/GeoPortalDataEntryApp.css | 11 ++- 9 files changed, 145 insertions(+), 60 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 6a51d43..81867e6 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 @@ -387,7 +387,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // resetUI(); if (vr.getAsJSONString() != null) { - modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString())); + modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false)); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 58d031d..346c494 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -70,46 +70,49 @@ - - - - List of Projects - - - - - - - - - Reload Projects - - - - - Show on Map - Publication Report - Edit - Delete Project - - - -
    - Go to bottom + + + + Show on Map + Publication Report + Edit + Delete Project + + + + + + List of Projects + + + + + + + + + Reload Projects + + + + +
    + Go to bottom +
    + + +
    + Go to top +
    - - -
    - Go to top -
    -
    -
    + +
    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index fdeac36..c9d898c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -56,9 +56,9 @@ - Update the file/s - By choosing a section (e.g. "relazione") and - uploading new file/s the old one/s will be replaced + Manage the file/s + You can choose a section (e.g. "piante") and + manage the existing file/s (by removing it/them) and uploading new one/s

    At the end of the changes press the "Update" button to diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index b7617f3..2f75123 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -1,7 +1,9 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -25,6 +27,7 @@ import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.Controls; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; @@ -52,7 +55,7 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { - private static final String _FORM_FIELDS_SIZE = "740px"; + private static final String _FORM_WIDTH_FIELDS_SIZE = "730px"; private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); @@ -96,9 +99,11 @@ public class UpdateFileset extends Composite { private HandlerManager uiBus = new HandlerManager(null); private MetaDataField fieldUploadWidget; - + private Integer pathIndex = null; + private Map mapForCCUploading = null; + /** * Instantiates a new update fileset. * @@ -113,7 +118,7 @@ public class UpdateFileset extends Composite { for (String path : listFileSetPaths) { listBoxPaths.addItem(path); } - listBoxPaths.setWidth(_FORM_FIELDS_SIZE); + listBoxPaths.setWidth(_FORM_WIDTH_FIELDS_SIZE); // add handler on select listBoxPaths.addChangeHandler(new ChangeHandler() { @@ -190,12 +195,13 @@ public class UpdateFileset extends Composite { placeholderListBoxIndex = true; fieldUploadWidget = null; pathIndex = null; + mapForCCUploading = null; // listBoxIndex.clear(); cgSelectFile.setVisible(true); ListBox listBoxContentIndex = new ListBox(); - listBoxContentIndex.setWidth(_FORM_FIELDS_SIZE); + listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE); listBoxContentIndex.addItem("Select a content..."); if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { @@ -250,13 +256,20 @@ public class UpdateFileset extends Composite { } int posizIndex = 0; for (LayerConcessioneDV lcDV : piante) { - fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(), lcDV.getListWsContent()); + fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(), + lcDV.getListWsContent()); posizIndex++; } } controlsContent.add(listBoxContentIndex); + + + if(listBoxContentIndex.getItemCount()==1) { + listBoxContentIndex.setSelectedIndex(0); + listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(0)); + } } @@ -294,7 +307,16 @@ public class UpdateFileset extends Composite { private void showFileBrowseInteraction(int pathContentIndex, List listWSC) { uploadFileContainer.clear(); pathIndex = pathContentIndex; - + + // map for current content uploading + mapForCCUploading = new HashMap(listWSC.size()); + int index = 0; + for (WorkspaceContentDV workspaceContentDV : listWSC) { + workspaceContentDV.setCliendId(index); + mapForCCUploading.put(index, workspaceContentDV); + index++; + } + if (listWSC.size() > 0) { FlexTable table = new FlexTable(); table.addStyleName("table-current-content"); @@ -302,12 +324,27 @@ public class UpdateFileset extends Composite { table.setHTML(1, 0, "Filename"); table.setHTML(1, 1, "MimeType"); table.setHTML(1, 2, "Link"); + int i = 2; - for (WorkspaceContentDV wsContent : listWSC) { + for (final WorkspaceContentDV wsContent : listWSC) { table.setHTML(i, 0, wsContent.getName()); table.setHTML(i, 1, wsContent.getMimetype()); - String link = "Download"; + String link = "View"; table.setHTML(i, 2, link); + + final int rowIndexToRem = i; + Button buttonRemoveFile = new Button(); + buttonRemoveFile.setIcon(IconType.TRASH); + buttonRemoveFile.setTitle("Remove this file"); + buttonRemoveFile.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + mapForCCUploading.remove(wsContent.getCliendId()); + table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden"); + } + }); + table.setWidget(i, 3, buttonRemoveFile); i++; } @@ -316,7 +353,8 @@ public class UpdateFileset extends Composite { HTML label = new HTML(); label.getElement().getStyle().setMarginTop(10, Unit.PX); - label.setHTML("With new content:"); + label.getElement().getStyle().setMarginBottom(10, Unit.PX); + label.setHTML("Add new file/s:"); uploadFileContainer.add(label); // mDU = new MultipleDilaogUpload(); @@ -328,12 +366,10 @@ public class UpdateFileset extends Composite { try { fieldUploadWidget = new MetaDataField(uploadField, uiBus); - // BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget); uploadFileContainer.add(fieldUploadWidget); buttonUpdate.setVisible(true); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index ac27ab0..47d529b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -23,7 +23,7 @@ - Replace the content + Manage the content of @@ -31,7 +31,7 @@ - + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java index f1aa06d..1b68850 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/BuildValidationReport.java @@ -48,7 +48,7 @@ public class BuildValidationReport extends FlowPanel { break; } - rTToHTML = new ReportTemplateToHTML(validationReport.getAsJSONString()); + rTToHTML = new ReportTemplateToHTML(validationReport.getAsJSONString(), true); add(recordPublished); add(rTToHTML); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java index 5bf287e..329f95c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.java @@ -2,7 +2,13 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.report; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ExternalLib; +import com.github.gwtbootstrap.client.ui.AccordionGroup; import com.github.gwtbootstrap.client.ui.Paragraph; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.github.gwtbootstrap.client.ui.event.HiddenEvent; +import com.github.gwtbootstrap.client.ui.event.HiddenHandler; +import com.github.gwtbootstrap.client.ui.event.ShowEvent; +import com.github.gwtbootstrap.client.ui.event.ShowHandler; import com.google.gwt.core.client.GWT; import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONObject; @@ -41,6 +47,9 @@ public class ReportTemplateToHTML extends Composite { @UiField VerticalPanel htmlContainer; + + @UiField + AccordionGroup showReportAsJSON; @UiField Paragraph reportJSON; @@ -52,9 +61,37 @@ public class ReportTemplateToHTML extends Composite { * * @param reportAsJSON the report as JSON */ - public ReportTemplateToHTML(String reportAsJSON) { + public ReportTemplateToHTML(String reportAsJSON, boolean openJSONReport) { initWidget(uiBinder.createAndBindUi(this)); vpContainer.setVisible(false); + showReportAsJSON.setDefaultOpen(openJSONReport); + //showReportAsJSON.setIconPosition(IconPosition.RIGHT); + + if(openJSONReport) { + showReportAsJSON.setIcon(IconType.ARROW_DOWN); + }else { + showReportAsJSON.setIcon(IconType.ARROW_RIGHT); + } + + showReportAsJSON.addShowHandler(new ShowHandler() { + + @Override + public void onShow(ShowEvent showEvent) { + showReportAsJSON.setIcon(IconType.ARROW_DOWN); + + } + }); + + showReportAsJSON.addHiddenHandler(new HiddenHandler() { + + @Override + public void onHidden(HiddenEvent hiddenEvent) { + showReportAsJSON.setIcon(IconType.ARROW_RIGHT); + + } + }); + + if (reportAsJSON != null) { GWT.log("report is: " + reportAsJSON); vpContainer.setVisible(true); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml index 0081bcb..572b030 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/report/ReportTemplateToHTML.ui.xml @@ -17,7 +17,7 @@ Publication Report: - + diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index e5e8797..384138f 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -83,7 +83,8 @@ h1 { position: -webkit-sticky; position: sticky; top: 0; - background-color: #eeeeee; + background-color: #f8f8f8; + border-radius: 20px; } .modal-body-custom { @@ -108,3 +109,11 @@ h1 { .table-current-content td { padding: 5px; } + +.upload-file-container .control-group { + display: inline-flex; +} + +.upload-file-container .control-group div { + margin-left: 10px; +} From 3bda56a55cb0d41063a6911d8eefa4d160eae812 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 5 Oct 2021 19:17:05 +0200 Subject: [PATCH 29/32] in progress on registerFileSet --- .settings/org.eclipse.wst.common.component | 27 ++- .../client/GeoportalDataEntryService.java | 4 +- .../GeoportalDataEntryServiceAsync.java | 4 +- .../client/ui/edit/EditModeRecord.ui.xml | 2 +- .../client/ui/edit/UpdateFileset.java | 85 ++++++++- .../client/ui/utils/DialogConfirm.java | 22 +-- .../client/ui/utils/DialogInform.java | 172 ++++++++++++++++++ .../server/GeoportalDataEntryServiceImpl.java | 104 ++++++----- .../server/MongoServiceUtil.java | 37 +++- 9 files changed, 381 insertions(+), 76 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogInform.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 811d676..27a98b3 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -13,7 +14,8 @@ - + + @@ -27,7 +29,8 @@ - + + @@ -41,7 +44,8 @@ - + + @@ -55,7 +59,8 @@ - + + @@ -72,7 +77,8 @@ uses - + + @@ -86,7 +92,8 @@ - + + @@ -100,7 +107,8 @@ - + + @@ -114,7 +122,8 @@ - + + 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 13ef04b..e85bd00 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 @@ -4,6 +4,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; @@ -124,5 +125,6 @@ public interface GeoportalDataEntryService extends RemoteService { * @throws Exception the exception */ ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, - GenericDatasetBean gDBean) throws Exception; + List keepCurrentContent, GenericDatasetBean gDBean) 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 60ddcb5..0dc4486 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 @@ -4,6 +4,7 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; @@ -71,5 +72,6 @@ public interface GeoportalDataEntryServiceAsync void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, - GenericDatasetBean gDBean, AsyncCallback callback); + List keepCurrentContent, GenericDatasetBean gDBean, + AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index c9d898c..d85b3d7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -54,7 +54,7 @@ addStyleNames="{style.button-save-style}" ui:field="buttonJSONUpdate">UPDATE - Manage the file/s You can choose a section (e.g. "piante") and diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index 2f75123..17dd804 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,6 +15,9 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; +import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload; @@ -30,11 +34,13 @@ import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -103,6 +109,7 @@ public class UpdateFileset extends Composite { private Integer pathIndex = null; private Map mapForCCUploading = null; + /** * Instantiates a new update fileset. @@ -175,6 +182,71 @@ public class UpdateFileset extends Composite { GWT.log("Content index selected: " + pathIndex); GWT.log("FileUploaded selected: " + gdb.getFilesUploaded()); + List listCurrentContent = new ArrayList(); + if (mapForCCUploading != null) { + Collection currentContent = mapForCCUploading.values(); + if (currentContent != null) + listCurrentContent.addAll(currentContent); + } + + String htmlMsg = "Going to update the section " + listBoxPaths.getSelectedItemText() + ":"; + htmlMsg += "

      "; + htmlMsg += "
    • keeping " + listCurrentContent.size() + " current file/s
    • "; + htmlMsg += "
    • uploading " + listFilesUploaded.size() + " new file/s
    • "; + htmlMsg += "
    "; + htmlMsg += "
    "; + htmlMsg += "This operation cannot be undone. Would you like to proceed?"; + + GWT.log(htmlMsg); + + final DialogConfirm dialogConfirm = new DialogConfirm(null, "Update Confirm?", htmlMsg); + dialogConfirm.getElement().getStyle().setZIndex(100000); + dialogConfirm.getYesButton().addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + dialogConfirm.hide(); + buttonUpdate.setEnabled(false); + + final DialogInform dialogInf = new DialogInform(null, "Updating Project", ""); + dialogInf.setZIndex(100000); + dialogInf.showLoader("updating file/s for project: "+fullConcessione.getNome()); + //dialogInf.setWidth("400px"); + dialogInf.center(); + + GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord( + fullConcessione.getItemId(), fullConcessione.getRecordType(), + listBoxPaths.getSelectedItemText(), pathIndex, listCurrentContent, gdb, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + dialogInf.hideLoader(); + dialogInf.setMsg( + "Sorry error occurred during project update. Error reported: " + + caught.getMessage()); + buttonUpdate.setEnabled(true); + showUploadFileGUI(); + + } + + @Override + public void onSuccess(ConcessioneDV result) { + dialogInf.hideLoader(); + dialogInf.setText("Project updated!"); + dialogInf.setMsg(result.getNome() + " updated correclty"); + dialogInf.center(); + fullConcessione = result; + buttonUpdate.setEnabled(true); + showUploadFileGUI(); + + } + }); + dialogInf.center(); + } + }); + dialogConfirm.center(); + } else { Window.alert(errorMsg); } @@ -264,11 +336,12 @@ public class UpdateFileset extends Composite { } controlsContent.add(listBoxContentIndex); - - - if(listBoxContentIndex.getItemCount()==1) { - listBoxContentIndex.setSelectedIndex(0); - listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(0)); + + if (listBoxContentIndex.getItemCount() == 2) { + // listBoxContentIndex.setSelectedIndex(1); + listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(1)); + + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxContentIndex); } } @@ -360,7 +433,7 @@ public class UpdateFileset extends Composite { MetadataFieldWrapper uploadField = new MetadataFieldWrapper(); uploadField.setFieldName("File"); - uploadField.setMandatory(true); + uploadField.setMandatory(false); uploadField.setType(DataTypeWrapper.File); uploadField.setMaxOccurs(1000); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java index d3e856f..69edbde 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogConfirm.java @@ -3,9 +3,6 @@ */ package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; - - - import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; import com.google.gwt.dom.client.Style.Unit; @@ -22,12 +19,10 @@ import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; - /** * The Class DialogConfirm. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Feb 19, 2015 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 19, 2015 */ public class DialogConfirm extends DialogBox implements ClickHandler { @@ -37,15 +32,16 @@ public class DialogConfirm extends DialogBox implements ClickHandler { private ImageResource loading = Images.ICONS.loading(); private HorizontalPanel hpButtons = new HorizontalPanel(); private Button noButton; + /** * Instantiates a new dialog confirm. * - * @param img the img + * @param img the img * @param caption the caption - * @param text the text + * @param text the text */ public DialogConfirm(Image img, String caption, String text) { - //getElement().setClassName("gwt-DialogBoxNew"); + // getElement().setClassName("gwt-DialogBoxNew"); dock.setSpacing(4); dock.setWidth("100%"); setText(caption); @@ -81,7 +77,6 @@ public class DialogConfirm extends DialogBox implements ClickHandler { dock.add(vpContainer, DockPanel.CENTER); setWidget(dock); -// add(dock); } /* @@ -101,10 +96,11 @@ public class DialogConfirm extends DialogBox implements ClickHandler { * * @param message the message */ - public void loader(String message){ - try{ + public void loader(String message) { + try { dock.remove(hpButtons); - }catch(Exception e){} + } catch (Exception e) { + } vpContainer.clear(); HorizontalPanel hpMask = new HorizontalPanel(); hpMask.add(new Image(loading)); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogInform.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogInform.java new file mode 100644 index 0000000..87cfb6c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/utils/DialogInform.java @@ -0,0 +1,172 @@ +/** + * + */ +package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; + +import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class DialogInform. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Oct 5, 2021 + */ +public class DialogInform extends DialogBox implements ClickHandler { + + private DockPanel dock = new DockPanel(); + private Button okButton; + private VerticalPanel vpContainer = new VerticalPanel(); + private ImageResource loading = Images.ICONS.loading(); + private HorizontalPanel hpButtons = new HorizontalPanel(); + private HorizontalPanel hpMask = new HorizontalPanel(); + private DialogInform instance = this; + + /** + * Instantiates a new dialog inform. + * + * @param img the img + * @param caption the caption + * @param msg the msg + */ + public DialogInform(Image img, String caption, String msg) { + // getElement().setClassName("gwt-DialogBoxNew"); + dock.setSpacing(4); + dock.setWidth("100%"); + setText(caption); +// setHeading(caption); + + okButton = new Button("OK"); + + vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX); + vpContainer.add(new HTML(msg)); + hpButtons = new HorizontalPanel(); + hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); +// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX); + hpButtons.setSpacing(3); + okButton.getElement().getStyle().setMarginRight(20.0, Unit.PX); + hpButtons.add(okButton); + + okButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + instance.hide(); + } + }); + + dock.add(hpButtons, DockPanel.SOUTH); + dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER); + + if (img != null) + dock.add(img, DockPanel.WEST); + + vpContainer.add(hpMask); + dock.add(vpContainer, DockPanel.CENTER); + setWidget(dock); + } + + /** + * Sets the msg. + * + * @param msg the new msg + */ + public void setMsg(String msg) { + vpContainer.clear(); + vpContainer.add(new HTML(msg)); + hpButtons.setVisible(true); + } + + /** + * On click. + * + * @param event the event + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event + * .dom.client.ClickEvent) + */ + @Override + public void onClick(ClickEvent event) { +// hide(); + } + + /** + * Hide loader. + */ + public void hideLoader() { + hpMask.clear(); + hpButtons.setVisible(true); + } + + /** + * Loader. + * + * @param message the message + */ + public void showLoader(String message) { + try { + hpButtons.setVisible(false); + } catch (Exception e) { + } + hpMask.clear(); + hpMask.add(new Image(loading)); + HTML html = new HTML(message); + html.getElement().getStyle().setMarginLeft(5, Unit.PX); + hpMask.add(html); + } + + /** + * Adds the to center panel. + * + * @param w the w + */ + public void addToCenterPanel(Widget w) { + vpContainer.add(w); + } + + /** + * Gets the dock. + * + * @return the dock + */ + public DockPanel getDock() { + return dock; + } + + /** + * Gets the yes button. + * + * @return the yes button + */ + public Button getOKButton() { + return okButton; + } + + /** + * Sets the z index. + * + * @param value the new z index + */ + public void setZIndex(int value) { + this.getElement().getStyle().setZIndex(value); + } + +} \ No newline at end of file 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 a6be44c..030ad2c 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 @@ -22,6 +22,7 @@ import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle; @@ -649,7 +650,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); } } - /** * Gets the JSON record. @@ -674,7 +674,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Concessione concessione = clientMongo.getById(itemId); return serviceUtil.toJSON(concessione); } - + return null; } catch (Exception e) { @@ -683,12 +683,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on reading the JSON project with id: " + itemId + ". Error: " + e.getMessage()); } } - /** * Gets the record. * - * @param itemId the item id + * @param itemId the item id * @param recordType the record type * @return the record * @throws Exception the exception @@ -708,7 +707,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Concessione concessione = clientMongo.getById(itemId); return ConvertToDataViewModel.toConcessione(concessione); } - + return null; } catch (Exception e) { @@ -730,78 +729,101 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return ConvertToDataViewModel.getFileSetPaths(); } - + /** * Update record. * - * @param itemId the item id - * @param jsonUpdate the json update - * @param recordType the record type + * @param itemId the item id + * @param recordType the record type + * @param section the section + * @param pathIndex the path index + * @param keepCurrentContent the keep current content + * @param gDBean the g D bean * @return the updated JSON string representing the itemId * @throws Exception the exception */ @Override - public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, GenericDatasetBean gDBean) throws Exception { - LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section+", pathIndex: " + pathIndex+", gDBean: " + gDBean, ""); + public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, + List keepCurrentContent, GenericDatasetBean gDBean) throws Exception { + LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section + ", pathIndex: " + + pathIndex + ", gDBean: " + gDBean, ""); try { if (itemId == null) throw new Exception("Item id is null"); - if (recordType.equals(RECORD_TYPE.CONCESSIONE)) { + if (recordType.equalsIgnoreCase(RECORD_TYPE.CONCESSIONE.name())) { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); - + String toEditPath = null; AddSectionToConcessioneRequest request = null; + List files = new ArrayList(); - List files = serviceUtil.toTemFiles(gDBean.getFilesUploaded()); - if(files==null || files.isEmpty()) - throw new Exception("Sorry, an error occurred on reading temp files. Refresh and try again"); - + // Managing files already present as current content and kept by user + List keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent); + if (keepFiles != null) { + files.addAll(keepFiles); + LOG.debug(keepFiles.size() +" current corrent file/s has/have been added to list of files"); + } + + // Managing new files uploaded by user + List newFiles = serviceUtil.toTemFiles(gDBean.getFilesUploaded()); + if (newFiles != null) { + files.addAll(newFiles); + LOG.debug(newFiles.size() +" new file/s has/have been added to list of files"); + } + +// if (files == null || files.isEmpty()) +// throw new Exception("Sorry, an error occurred on reading temp files. Refresh and try again"); + if (section.contains("abstract_relazione")) { - + toEditPath = Paths.ABSTRACT_RELAZIONE; request = new AddSectionToConcessioneRequest(toEditPath, files); - + } else if (section.contains("immagini")) { toEditPath = Paths.imgByIndex(pathIndex); request = new AddSectionToConcessioneRequest(toEditPath, files); - + } else if (section.contains("relazione")) { toEditPath = Paths.RELAZIONE; request = new AddSectionToConcessioneRequest(toEditPath, files); - + } else if (section.contains("posizionamentoScavo")) { toEditPath = Paths.POSIZIONAMENTO; - request = new AddSectionToConcessioneRequest(toEditPath, - files); + request = new AddSectionToConcessioneRequest(toEditPath, files); } else if (section.contains("piante")) { toEditPath = Paths.piantaByIndex(pathIndex); - request = new AddSectionToConcessioneRequest( - toEditPath, files); + request = new AddSectionToConcessioneRequest(toEditPath, files); } - // Unpublish - System.out.println("Unpublishing "+itemId); - clientMongo.unPublish(itemId); + // Unpublish + LOG.info("Unpublishing " + itemId); + clientMongo.unPublish(itemId); - // update Fileset - System.out.println("Removing old fileset.. "); - clientMongo.cleanFileSet(itemId,toEditPath); + // update Fileset + LOG.info("Removing old fileset.. "); + Concessione concessione = clientMongo.cleanFileSet(itemId, toEditPath); - System.out.println("Sending new Fileset .."); - - //StorageUtils storage=new StorageUtils(); - // Building TempFile - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - LOG.info("Registering FileSet into recordId " + itemId + " with request path: " +toEditPath + " and: " + files.size() - + " file/s"); - Concessione concessione = clientMongo.registerFileSet(itemId,request); + LOG.debug("Sending new Fileset .."); + if(files.size()>0) { + // StorageUtils storage=new StorageUtils(); + // Building TempFile + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath + " and: " + + files.size() + " file/s"); + concessione = clientMongo.registerFileSet(itemId, request); + }else { + LOG.info("Fileset is empty, skipping registerFileSet"); + } + + LOG.info("Publishings itemId: "+itemId); concessione = clientMongo.publish(itemId); - - return ConvertToDataViewModel.toConcessione(concessione); + + LOG.trace("returning concessione: "+concessione); + return ConvertToDataViewModel.toConcessione(concessione); } return null; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java index 5cb11c9..42bad84 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java @@ -4,7 +4,9 @@ import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mon import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -14,18 +16,18 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportal.common.rest.TempFile; import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class MongoServiceUtil. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Sep 16, 2021 + * Sep 16, 2021 */ public class MongoServiceUtil { @@ -87,6 +89,33 @@ public class MongoServiceUtil { return files; } + /** + * To tem files from WSC. + * + * @param listFiles the list files + * @return the list + */ + public List toTemFilesFromWSC(List listFiles) { + LOG.debug("toTemFilesFromWSC called"); + if (listFiles == null || listFiles.isEmpty()) + return null; + + // Building TempFile + List files = new ArrayList(listFiles.size()); + for (WorkspaceContentDV fileUploaded : listFiles) { + InputStream is; + try { + is = new URL(fileUploaded.getLink()).openStream(); + // Creating TempFile + TempFile storageTempFile = createTempFileOnStorage(is, fileUploaded.getName()); + files.add(storageTempFile); + } catch (IOException e) { + LOG.error("Error on creating temp file from URL: " + fileUploaded.getLink(), e); + } + } + return files; + } + /** * To JSON. * @@ -98,7 +127,7 @@ public class MongoServiceUtil { try { // if (theObj instanceof Serializable) { - return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); + return org.gcube.application.geoportal.client.utils.Serialization.write(theObj); // } // throw new Exception("The input object is not serializable"); @@ -141,7 +170,7 @@ public class MongoServiceUtil { * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Sep 16, 2021 + * Sep 16, 2021 */ public static class ConcessioneDVValidationReportStatusComparator implements Comparator { From 9690b09cb1be8564a25681081ed6712583ee27a8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 6 Oct 2021 16:01:39 +0200 Subject: [PATCH 30/32] #21990 completed edit mode for registerFileSet --- CHANGELOG.md | 26 ++-- .../client/GeoPortalDataEntryApp.java | 8 +- .../client/ui/edit/EditModeRecord.java | 57 ++++++-- .../client/ui/edit/EditModeRecord.ui.xml | 6 +- .../client/ui/edit/UpdateFileset.java | 124 +++++++++++++----- .../client/ui/edit/UpdateFileset.ui.xml | 53 ++++---- .../server/GeoportalDataEntryServiceImpl.java | 2 +- src/main/webapp/GeoPortalDataEntryApp.css | 2 + 8 files changed, 188 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f88f94..1819302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,44 +8,44 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements -[#20435] Client integration with MongoConcessioni -Moved to maven-portal-bom 3.6.3 -[#21856] Implemented new user feedback -[#21890] Passed to mongoID -[#20599] Get List of Records -[#22002] Integrated with ValidationReport and status -[#21990] Provide the (first version of) edit mode -[#22040] Revisited the "Abstract Relazione di Scavo" +- [#20435] Client integration with MongoConcessioni +- Moved to maven-portal-bom 3.6.3 +- [#21856] Implemented new user feedback +- [#21890] Passed to mongoID +- [#20599] Get List of Records +- [#22002] Integrated with ValidationReport and status +- [#21990] Provide the (first version of) edit mode +- [#22040] Revisited the "Abstract Relazione di Scavo" ## [v1.2.0] - 2020-12-18 #### Enhancements -[#20357] new requirements +- [#20357] new requirements ## [v1.1.0] - 2020-12-1 #### Enhancements -[#20210] Updating required for data entry facility after the first feedback by domain experts +- [#20210] Updating required for data entry facility after the first feedback by domain experts ## [v1.0.2] - 2020-11-09 #### Bug fixes -[#20092] Repeatible form: validate the card after the create event is fired +- [#20092] Repeatible form: validate the card after the create event is fired ## [v1.0.1] - 2020-11-04 #### Bug fixes -[#20063] Fixes for data-entry components +- [#20063] Fixes for data-entry components ## [v1.0.0] - 2020-10-07 -[#19916] First release +- [#19916] First release 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 81867e6..d4430bd 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 @@ -510,8 +510,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { case SHOW_REPORT: final Modal modal2 = new Modal(true, true); - modal2.setTitle("Report
    " + concessione.getNome() - + "
    "); + modal2.setTitle("Report: " + concessione.getNome() + + ""); modal2.setWidth(800); modal2.setCloseVisible(true); if (concessione.getValidationReport() == null) { @@ -527,8 +527,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { case SHOW_EDIT_MODE: final Modal modal3 = new Modal(true, true); - modal3.setTitle("Edit
    " + concessione.getNome() - + "
    "); + modal3.setTitle("Edit: " + concessione.getNome() + + ""); modal3.setWidth(950); modal3.setHeight("700px"); modal3.setCloseVisible(true); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java index 3c94e7a..f7a0330 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.java @@ -1,13 +1,19 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; +import java.util.Arrays; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper; +import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import com.github.gwtbootstrap.client.ui.Button; @@ -24,7 +30,7 @@ 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.ScrollPanel; +import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; /** @@ -40,7 +46,7 @@ public class EditModeRecord extends Composite { @UiField Tab tabRawUpdate; - + @UiField Tab tabUploadFiles; @@ -48,7 +54,7 @@ public class EditModeRecord extends Composite { FlowPanel rawUpdatePanel; @UiField - ScrollPanel filesUpdatePanel; + HTMLPanel filesUpdatePanel; @UiField Button buttonJSONUpdate; @@ -60,6 +66,8 @@ public class EditModeRecord extends Composite { private JSONEditorWrapper jsEditor; private HandlerManager appManagerBus; + + private final HandlerManager editorManagerBus = new HandlerManager(null); /** * The Interface EditModeRecordUiBinder. @@ -84,7 +92,7 @@ public class EditModeRecord extends Composite { this.recordType = type; this.appManagerBus = appManagerBus; this.filesUpdatePanel.setHeight("490px"); - //filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px"); + // filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px"); instanceJSONEditor(); instanceUpdateFilesetEditor(); @@ -102,7 +110,8 @@ public class EditModeRecord extends Composite { @Override public void onSuccess(FileSetPathsDV fileSetPaths) { - UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); + UpdateFileset updateFileset = new UpdateFileset(editorManagerBus, selectedConcessione, recordType, + fileSetPaths.getFileSetPaths()); filesUpdatePanel.add(updateFileset); } }); @@ -114,7 +123,7 @@ public class EditModeRecord extends Composite { rawUpdatePanel.clear(); final FlowPanel fp = new FlowPanel(); fp.getElement().setId("jsoneditor" + Random.nextInt()); - fp.setHeight("400px"); + fp.setHeight("410px"); rawUpdatePanel.add(fp); GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), recordType, @@ -150,6 +159,7 @@ public class EditModeRecord extends Composite { * Bind events. */ private void bindEvents() { + buttonJSONUpdate.addClickHandler(new ClickHandler() { @Override @@ -171,7 +181,7 @@ public class EditModeRecord extends Composite { // TODO: handle exception } - appManagerBus.fireEvent( + editorManagerBus.fireEvent( new ActionOnItemEvent(null, ACTION_ON_ITEM.UPDATED_RECORD)); } @@ -185,17 +195,38 @@ public class EditModeRecord extends Composite { } catch (Exception e) { // TODO: handle exception } - selectedConcessione = result; - instanceJSONEditor(); - - Window.alert("Project '" + result.getNome() + "' updated correctly"); - appManagerBus.fireEvent( - new ActionOnItemEvent(null, ACTION_ON_ITEM.UPDATED_RECORD)); + + DialogInform di = new DialogInform(null, "Project updated!", "Project '" + result.getNome() + "' updated correctly"); + di.setZIndex(100000); + di.center(); + editorManagerBus.fireEvent( + new ActionOnItemEvent(Arrays.asList(result), ACTION_ON_ITEM.UPDATED_RECORD)); } }); } }); + + editorManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() { + + @Override + public void onDoActionFired(ActionOnItemEvent showItemEvent) { + + ACTION_ON_ITEM action = showItemEvent.getAction(); + List items = showItemEvent.getSelectItems(); + + if(items!=null) { + selectedConcessione = (BaseConcessioneDV) items.get(0); + instanceJSONEditor(); + + if(action.equals(ACTION_ON_ITEM.UPDATED_RECORD)) { + appManagerBus.fireEvent( + new ActionOnItemEvent((List) items, ACTION_ON_ITEM.UPDATED_RECORD)); + } + } + + } + }); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml index d85b3d7..a22fb9b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/EditModeRecord.ui.xml @@ -21,7 +21,7 @@ - Source Project Editor You can update the Source Project by editing @@ -66,8 +66,8 @@ them persistent on the service

    - - + +
    diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index 17dd804..30499c3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -13,9 +14,11 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; +import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; @@ -61,6 +64,16 @@ import com.google.gwt.user.client.ui.Widget; */ public class UpdateFileset extends Composite { + private static final String SECTION_PIANTE = "piante"; + + private static final String SECTION_POSIZIONAMENTO_SCAVO = "posizionamentoScavo"; + + private static final String SECTION_RELAZIONE = "relazione"; + + private static final String SECTION_IMMAGINI = "immagini"; + + private static final String SECTION_ABSTRACT_RELAZIONE = "abstract_relazione"; + private static final String _FORM_WIDTH_FIELDS_SIZE = "730px"; private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); @@ -110,14 +123,22 @@ public class UpdateFileset extends Composite { private Map mapForCCUploading = null; + private Map> mapWSContentListBox = null; + + private HandlerManager editorManagerBus; + /** * Instantiates a new update fileset. * + * @param editorManagerBus the editor manager bus + * @param selectedConcessione the selected concessione + * @param recordType the record type * @param listFileSetPaths the list file set paths */ - public UpdateFileset(BaseConcessioneDV selectedConcessione, RECORD_TYPE recordType, List listFileSetPaths) { + public UpdateFileset(HandlerManager editorManagerBus, BaseConcessioneDV selectedConcessione, RECORD_TYPE recordType, List listFileSetPaths) { initWidget(uiBinder.createAndBindUi(this)); + this.editorManagerBus = editorManagerBus; this.selectedConcessione = selectedConcessione; this.recordType = recordType; this.listFileSetPaths = listFileSetPaths; @@ -208,11 +229,10 @@ public class UpdateFileset extends Composite { dialogConfirm.hide(); buttonUpdate.setEnabled(false); - final DialogInform dialogInf = new DialogInform(null, "Updating Project", ""); + final DialogInform dialogInf = new DialogInform(null, "Updating Project...", ""); dialogInf.setZIndex(100000); - dialogInf.showLoader("updating file/s for project: "+fullConcessione.getNome()); + dialogInf.showLoader("Updating file/s for project: "+fullConcessione.getNome()); //dialogInf.setWidth("400px"); - dialogInf.center(); GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord( fullConcessione.getItemId(), fullConcessione.getRecordType(), @@ -237,8 +257,11 @@ public class UpdateFileset extends Composite { dialogInf.setMsg(result.getNome() + " updated correclty"); dialogInf.center(); fullConcessione = result; + GWT.log("new concessione: "+fullConcessione); buttonUpdate.setEnabled(true); showUploadFileGUI(); + editorManagerBus.fireEvent( + new ActionOnItemEvent(Arrays.asList(fullConcessione), ACTION_ON_ITEM.UPDATED_RECORD)); } }); @@ -268,6 +291,7 @@ public class UpdateFileset extends Composite { fieldUploadWidget = null; pathIndex = null; mapForCCUploading = null; + mapWSContentListBox = null; // listBoxIndex.clear(); cgSelectFile.setVisible(true); @@ -275,60 +299,76 @@ public class UpdateFileset extends Composite { ListBox listBoxContentIndex = new ListBox(); listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE); listBoxContentIndex.addItem("Select a content..."); - - if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { + String section = null; + Integer posizIndex = 0; + if (listBoxPaths.getSelectedItemText().contains(SECTION_ABSTRACT_RELAZIONE)) { + section = SECTION_ABSTRACT_RELAZIONE; AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); + if (ar == null) { - showMessage("abstract_relazione" + " NOT AVAILABLE", LabelType.WARNING); + showMessage(SECTION_ABSTRACT_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); +// pathIndex = 0; +// showNewFileUpload(); return; } - int posizIndex = 0; - fillListBoxToBeReplaced(listBoxContentIndex, "abstract_relazione", posizIndex, ar.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, ar.getTitolo(), ar.getListWsContent()); - } else if (listBoxPaths.getSelectedItemText().contains("immagini")) { + } else if (listBoxPaths.getSelectedItemText().contains(SECTION_IMMAGINI)) { + section = SECTION_IMMAGINI; List listImmagini = fullConcessione.getImmaginiRappresentative(); if (listImmagini == null || listImmagini.isEmpty()) { - showMessage("immagini" + " NOT AVAILABLE", LabelType.WARNING); + showMessage(SECTION_IMMAGINI + " NOT AVAILABLE", LabelType.WARNING); +// pathIndex = 0; +// showNewFileUpload(); return; } - int posizIndex = 0; + for (UploadedImageDV uploadedImageDV : listImmagini) { - fillListBoxToBeReplaced(listBoxContentIndex, "immagini", posizIndex, uploadedImageDV.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, uploadedImageDV.getTitolo(), uploadedImageDV.getListWsContent()); posizIndex++; } - } else if (listBoxPaths.getSelectedItemText().contains("relazione")) { - RelazioneScavoDV realzione = fullConcessione.getRelazioneScavo(); - if (realzione == null || realzione.getListWsContent() == null) { - showMessage("relazione" + " NOT AVAILABLE", LabelType.WARNING); + } else if (listBoxPaths.getSelectedItemText().contains(SECTION_RELAZIONE)) { + section = SECTION_RELAZIONE; + RelazioneScavoDV relazioneScavo = fullConcessione.getRelazioneScavo(); + if (relazioneScavo == null) { + showMessage(SECTION_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); +// pathIndex = 0; +// showNewFileUpload(); return; } - int posizIndex = 0; - fillListBoxToBeReplaced(listBoxContentIndex, "relazione", posizIndex, realzione.getTitolo(), - realzione.getListWsContent()); - } else if (listBoxPaths.getSelectedItemText().contains("posizionamentoScavo")) { + fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, relazioneScavo.getTitolo(), + relazioneScavo.getListWsContent()); + + } else if (listBoxPaths.getSelectedItemText().contains(SECTION_POSIZIONAMENTO_SCAVO)) { + section = SECTION_POSIZIONAMENTO_SCAVO; LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo(); - if (posiz == null || posiz.getListWsContent() == null || posiz.getListWsContent().isEmpty()) { - showMessage("posizionamentoScavo" + " NOT AVAILABLE", LabelType.WARNING); + if (posiz == null) { + showMessage(SECTION_POSIZIONAMENTO_SCAVO + " NOT AVAILABLE", LabelType.WARNING); +// pathIndex = 0; +// showNewFileUpload(); return; } - int posizIndex = 0; - fillListBoxToBeReplaced(listBoxContentIndex, "posizionamentoScavo", posizIndex, posiz.getTitolo(), + + fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, posiz.getTitolo(), posiz.getListWsContent()); - } else if (listBoxPaths.getSelectedItemText().contains("piante")) { + } else if (listBoxPaths.getSelectedItemText().contains(SECTION_PIANTE)) { + section = SECTION_PIANTE; List piante = fullConcessione.getPianteFineScavo(); if (piante == null || piante.isEmpty()) { - showMessage("piante" + " NOT AVAILABLE", LabelType.WARNING); + showMessage(SECTION_PIANTE + " NOT AVAILABLE", LabelType.WARNING); +// pathIndex = 0; +// showNewFileUpload(); return; } - int posizIndex = 0; + for (LayerConcessioneDV lcDV : piante) { - fillListBoxToBeReplaced(listBoxContentIndex, "piante", posizIndex, lcDV.getTitolo(), + fillListBoxToBeReplaced(listBoxContentIndex, SECTION_PIANTE, posizIndex, lcDV.getTitolo(), lcDV.getListWsContent()); posizIndex++; } @@ -348,13 +388,21 @@ public class UpdateFileset extends Composite { private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title, List listWSC) { + GWT.log("fillListBoxToBeReplaced called, posizIndex: "+posizIndex+", listWSC: "+listWSC); if (listWSC == null || listWSC.isEmpty()) { - showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); + showMessage(section + " does not contain file!", LabelType.WARNING); + pathIndex = posizIndex; + showNewFileUpload(); return; } + + if(mapWSContentListBox==null) { + mapWSContentListBox = new HashMap>(); + } listBoxContentIndex.addItem(title, posizIndex + ""); + mapWSContentListBox.put(posizIndex, listWSC); // adding handler once if (posizIndex == 0) { @@ -363,13 +411,15 @@ public class UpdateFileset extends Composite { @Override public void onChange(ChangeEvent event) { - + GWT.log("listBoxContentIndex changed, posizIndex: "+posizIndex); + if (placeholderListBoxIndex) { listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once placeholderListBoxIndex = false; } - - showFileBrowseInteraction(listBoxContentIndex.getSelectedIndex(), listWSC); + int selectedIndex = listBoxContentIndex.getSelectedIndex(); + GWT.log("selected index: "+selectedIndex); + showFileBrowseInteraction(selectedIndex, mapWSContentListBox.get(selectedIndex)); } }); } @@ -380,6 +430,8 @@ public class UpdateFileset extends Composite { private void showFileBrowseInteraction(int pathContentIndex, List listWSC) { uploadFileContainer.clear(); pathIndex = pathContentIndex; + GWT.log("showing pathContentIndex: "+pathContentIndex); + GWT.log("showing ws content: "+listWSC); // map for current content uploading mapForCCUploading = new HashMap(listWSC.size()); @@ -424,6 +476,12 @@ public class UpdateFileset extends Composite { uploadFileContainer.add(table); } + showNewFileUpload(); + } + + + private void showNewFileUpload() { + HTML label = new HTML(); label.getElement().getStyle().setMarginTop(10, Unit.PX); label.getElement().getStyle().setMarginBottom(10, Unit.PX); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index 47d529b..b2715e4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -11,31 +11,38 @@ margin-top: 10px; float: right; } + + .max-height-500 { + max-height: 450px; + } - - - - Section - - - - - - Manage the content of - - - - - - - - - - - - + + + + + Section + + + + + + Manage the content of + + + + + + + + + + + + + UPDATE 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 030ad2c..7aa210e 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 @@ -822,7 +822,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.info("Publishings itemId: "+itemId); concessione = clientMongo.publish(itemId); - LOG.trace("returning concessione: "+concessione); + LOG.debug("returning concessione: "+concessione); return ConvertToDataViewModel.toConcessione(concessione); } diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index 384138f..c1c9d4f 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -112,8 +112,10 @@ h1 { .upload-file-container .control-group { display: inline-flex; + width: 95%; } .upload-file-container .control-group div { margin-left: 10px; + width: 95%; } From a2a61f9e7c233d2852bcaa0d46116aafac673ad0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 6 Oct 2021 16:28:19 +0200 Subject: [PATCH 31/32] fixed css --- src/main/webapp/GeoPortalDataEntryApp.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/GeoPortalDataEntryApp.css b/src/main/webapp/GeoPortalDataEntryApp.css index c1c9d4f..3965771 100644 --- a/src/main/webapp/GeoPortalDataEntryApp.css +++ b/src/main/webapp/GeoPortalDataEntryApp.css @@ -103,7 +103,7 @@ h1 { .table-current-content { width: 100%; - background-color: #efefef; + background-color: #efefef !important; } .table-current-content td { From 883850d3f888451ff038009f3e981d9cee987cb7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 6 Oct 2021 16:31:31 +0200 Subject: [PATCH 32/32] moved log to trace --- .../server/GeoportalDataEntryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7aa210e..aae3fa7 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 @@ -520,7 +520,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen LOG.warn("comparator Exception: " + e.getMessage()); } - LOG.debug("sorted list: " + listOfConcessioni); + LOG.trace("sorted list: " + listOfConcessioni); // pagination toReturn = listOfConcessioni.subList(startIndex, limitIndex); }