completed REAMDE. Added calls server-side

pull/4/head
Francesco Mangiacrapa 3 years ago
parent 234fd875cf
commit a551e572c5

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

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

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

@ -53,4 +53,10 @@ public interface GeoportalDataEntryServiceAsync
void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback);
void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<String> callback);
void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback<String> callback);
}

@ -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<TempFile> 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<Concessione> listOfConcessioni =
* SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService);
* int listConcessioniSize = listOfConcessioni.size();
*
* List<Concessione> toReturn = new ArrayList<Concessione>(); 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<Concessione> 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<ConcessioneDV> toReturnList = new
* ArrayList<ConcessioneDV>(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());
}
}
}

@ -20,16 +20,17 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class ServiceUtil.
* The Class MongoServiceUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 28, 2021
* Sep 16, 2021
*/
public class ServiceUtil {
public class MongoServiceUtil {
private static Logger LOG = LoggerFactory.getLogger(ServiceUtil.class);
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<ConcessioneDV> {
/**

@ -145,7 +145,7 @@ public class SessionUtil {
listOfConcessioni = new ArrayList<Concessione>();
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<Concessione> concessioni = clientMongo.getList();

Loading…
Cancel
Save