Compare commits
5 Commits
master
...
task_20357
Author | SHA1 | Date |
---|---|---|
Francesco Mangiacrapa | a3aacc6412 | |
Francesco Mangiacrapa | 2e0f09fc5a | |
Francesco Mangiacrapa | 4a095277e9 | |
Francesco Mangiacrapa | 729c1d8f1a | |
Francesco Mangiacrapa | ae01d80937 |
|
@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [v1.2.0-SNAPSHOT] - 2020-12-18
|
||||
|
||||
#### Enhancements
|
||||
|
||||
[#20357] new requirements
|
||||
|
||||
|
||||
## [v1.1.0] - 2020-12-1
|
||||
|
||||
#### Enhancements
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-entry-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<name>GeoPortal Data Entry App</name>
|
||||
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description>
|
||||
<scm>
|
||||
|
|
|
@ -11,10 +11,11 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
public enum ConcessioniFormCardTitle {
|
||||
|
||||
INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false, null),
|
||||
RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false, null),
|
||||
IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true, 8),
|
||||
POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false, null),
|
||||
PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true, null);
|
||||
ABSTRACT_RELAZIONE_DI_SCAVO("Abstract Relazione di Scavo", "Abstract Relazione di Scavo", 2, false, null),
|
||||
RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 3, false, null),
|
||||
IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 4, true, 8),
|
||||
POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 5, false, null),
|
||||
PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 6, true, null);
|
||||
|
||||
private String key;
|
||||
private String title;
|
||||
|
|
|
@ -109,6 +109,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
@Override
|
||||
public void onSuccess(List<MetaDataProfileBean> result) {
|
||||
GWT.log("Returned "+result.size()+ "profile/s");
|
||||
orderedCards = setGeoNaFormsOrder(result);
|
||||
//ordered values
|
||||
buildNewCards(orderedCards);
|
||||
|
@ -130,6 +131,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
//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();
|
||||
|
@ -159,11 +161,15 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) {
|
||||
|
||||
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
||||
GWT.log("Building form card for type: "+theMetaType);
|
||||
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, null);
|
||||
|
||||
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())) {
|
||||
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())) {
|
||||
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
||||
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getOrder(), geonaForm);
|
||||
|
@ -249,10 +255,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
case WARN:
|
||||
alert.setType(AlertType.WARNING);
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
if(result.getReport()!=null)
|
||||
modal.add(new Alert(result.getReport(), AlertType.INFO));
|
||||
break;
|
||||
case ERROR:
|
||||
alert.setType(AlertType.ERROR);
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
if(result.getReport()!=null)
|
||||
modal.add(new Alert(result.getReport(), AlertType.INFO));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -343,5 +353,55 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static native String jsonToHTML(String jsonTxt)/*-{
|
||||
try
|
||||
{
|
||||
var jsonObj = JSON.parse(jsonTxt);
|
||||
|
||||
if(jsonObj.length==undefined)
|
||||
jsonObj = [jsonObj]
|
||||
//console.log(jsonObj.length)
|
||||
|
||||
// EXTRACT VALUE FOR HTML HEADER.
|
||||
var col = [];
|
||||
for (var i = 0; i < jsonObj.length; i++) {
|
||||
for (var key in jsonObj[i]) {
|
||||
//console.log('key json' +key)
|
||||
if (col.indexOf(key) === -1) {
|
||||
col.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CREATE DYNAMIC TABLE.
|
||||
var table = document.createElement("table");
|
||||
try{
|
||||
table.classList.add("my-html-table");
|
||||
|
||||
}catch(e){
|
||||
console.log('invalid css add', e);
|
||||
}
|
||||
|
||||
// ADD JSON DATA TO THE TABLE AS ROWS.
|
||||
for (var i = 0; i < col.length; i++) {
|
||||
tr = table.insertRow(-1);
|
||||
var firstCell = tr.insertCell(-1);
|
||||
//firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
|
||||
firstCell.innerHTML = col[i];
|
||||
for (var j = 0; j < jsonObj.length; j++) {
|
||||
var tabCell = tr.insertCell(-1);
|
||||
var theValue = jsonObj[j][col[i]];
|
||||
tabCell.innerHTML = theValue;
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
catch(e){
|
||||
console.log('invalid json', e);
|
||||
}
|
||||
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.ui.FlowPanel;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,6 +48,8 @@ public class MetadataFormCard {
|
|||
private HandlerManager appManagerBus;
|
||||
|
||||
private Integer maxFormRepeatability;
|
||||
|
||||
private FlowPanel tabContainer = new FlowPanel();
|
||||
|
||||
/**
|
||||
* The Class MetadataFormCardEventHandler.
|
||||
|
@ -145,6 +148,7 @@ public class MetadataFormCard {
|
|||
});
|
||||
}
|
||||
|
||||
tab.add(tabContainer);
|
||||
addNewForm(createMetadataForm);
|
||||
}
|
||||
|
||||
|
@ -154,21 +158,21 @@ public class MetadataFormCard {
|
|||
* @param newForm the new form
|
||||
*/
|
||||
private void addNewForm(final CreateMetadataForm newForm) {
|
||||
tab.add(newForm);
|
||||
tabContainer.insert(newForm,0);
|
||||
listForms.add(newForm);
|
||||
|
||||
if(listForms.size()>1) {
|
||||
final Button buttonRemoveLatestForm = new Button("Remove");
|
||||
buttonRemoveLatestForm.setIcon(IconType.TRASH);
|
||||
tab.add(buttonRemoveLatestForm);
|
||||
tabContainer.insert(buttonRemoveLatestForm,1);
|
||||
|
||||
buttonRemoveLatestForm.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
tab.remove(newForm);
|
||||
tabContainer.remove(newForm);
|
||||
listForms.remove(newForm);
|
||||
tab.remove(buttonRemoveLatestForm);
|
||||
tabContainer.remove(buttonRemoveLatestForm);
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -187,19 +187,15 @@ public class ConvertToServiceModel {
|
|||
/**
|
||||
* To relazione scavo.
|
||||
*
|
||||
* @param abstractRelazioneScavo the abstract relazione scavo
|
||||
* @param gdb the gdb
|
||||
* @return the relazione scavo
|
||||
*/
|
||||
public static RelazioneScavo toRelazioneScavo(GenericDatasetBean gdb){
|
||||
public static RelazioneScavo toRelazioneScavo(RelazioneScavo abstractRelazioneScavo, GenericDatasetBean gdb){
|
||||
|
||||
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
||||
|
||||
RelazioneScavo relazioneScavo = new RelazioneScavo();
|
||||
|
||||
List<String> abstractLst = mapFields.get("Abstract");
|
||||
if(abstractLst!=null && abstractLst.size()>0) {
|
||||
relazioneScavo.setAbstractSection(abstractLst.get(0));
|
||||
}
|
||||
RelazioneScavo relazioneScavo = abstractRelazioneScavo == null?new RelazioneScavo():abstractRelazioneScavo;
|
||||
|
||||
List<String> responsabiliLst = mapFields.get("Responsabile del documento");
|
||||
if(responsabiliLst!=null) {
|
||||
|
@ -229,6 +225,41 @@ public class ConvertToServiceModel {
|
|||
return relazioneScavo;
|
||||
}
|
||||
|
||||
public static RelazioneScavo toAbstractRelazioneScavo(GenericDatasetBean gdb) {
|
||||
|
||||
Map<String, List<String>> mapFields = gdb.getFormDataEntryFields();
|
||||
|
||||
RelazioneScavo relazioneScavo = new RelazioneScavo();
|
||||
|
||||
List<String> abstractLstIta = mapFields.get("Abstract in Italiano");
|
||||
if(abstractLstIta!=null && abstractLstIta.size()>0) {
|
||||
relazioneScavo.setAbstractIta(abstractLstIta.get(0));
|
||||
}
|
||||
|
||||
List<String> abstractLstEng = mapFields.get("Abstract in Inglese");
|
||||
if(abstractLstEng!=null && abstractLstEng.size()>0) {
|
||||
relazioneScavo.setAbstractEng(abstractLstIta.get(0));
|
||||
}
|
||||
|
||||
//TODO IN FUTURE WHEN THE MODEL WILL BE UPDATED
|
||||
/*List<String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> licenzaIdList = mapFields.get("ID Licenza");
|
||||
if(licenzaIdList!=null && licenzaIdList.size()>0) {
|
||||
relazioneScavo.setLicenseID(licenzaIdList.get(0));
|
||||
}*/
|
||||
|
||||
return relazioneScavo;
|
||||
}
|
||||
|
||||
/**
|
||||
* To immagini rappresentative.
|
||||
*
|
||||
|
@ -241,26 +272,27 @@ public class ConvertToServiceModel {
|
|||
|
||||
UploadedImage uplaodedImage = new UploadedImage();
|
||||
|
||||
List<String> titoloLst = mapFields.get("Titolo");
|
||||
if(titoloLst!=null && titoloLst.size()>0) {
|
||||
uplaodedImage.setTitolo(titoloLst.get(0));
|
||||
}
|
||||
|
||||
// List<String> titoloLst = mapFields.get("Titolo");
|
||||
// if(titoloLst!=null && titoloLst.size()>0) {
|
||||
// uplaodedImage.setTitolo(titoloLst.get(0));
|
||||
// }
|
||||
//
|
||||
List<String> didascaliaLst = mapFields.get("Didascalia");
|
||||
if(didascaliaLst!=null && didascaliaLst.size()>0) {
|
||||
uplaodedImage.setDidascalia(didascaliaLst.get(0));
|
||||
}
|
||||
|
||||
|
||||
List<String> responsabileLst = mapFields.get("Responsabile");
|
||||
//NB here is setResponsabili but should be setAuthor
|
||||
List<String> responsabileLst = mapFields.get("Autore");
|
||||
if(responsabileLst!=null) {
|
||||
uplaodedImage.setResponsabili(responsabileLst);
|
||||
//uplaodedImage.setAuthor is missing!!!
|
||||
}
|
||||
|
||||
List<String> autoreList = mapFields.get("Autore");
|
||||
if(autoreList!=null) {
|
||||
//TODO
|
||||
}
|
||||
// List<String> autoreList = mapFields.get("Autore");
|
||||
// if(autoreList!=null) {
|
||||
// //TODO
|
||||
// }
|
||||
|
||||
List<String> politicaDiAccessoLst = mapFields.get("Politica di accesso");
|
||||
if(politicaDiAccessoLst!=null && politicaDiAccessoLst.size()>0) {
|
||||
|
@ -277,12 +309,6 @@ public class ConvertToServiceModel {
|
|||
uplaodedImage.setLicenseID(licenzaIdList.get(0));
|
||||
}
|
||||
|
||||
//TODO???
|
||||
List<String> autoreLst = mapFields.get("Autore");
|
||||
if(autoreLst!=null) {
|
||||
|
||||
}
|
||||
|
||||
return uplaodedImage;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,14 +9,12 @@ import java.util.Map;
|
|||
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
||||
import org.gcube.application.geoportal.managers.ManagerFactory;
|
||||
import org.gcube.application.geoportal.model.InputStreamDescriptor;
|
||||
import org.gcube.application.geoportal.model.Record;
|
||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||
import org.gcube.application.geoportal.model.content.WorkspaceContent;
|
||||
import org.gcube.application.geoportal.model.fault.PublishException;
|
||||
import org.gcube.application.geoportal.model.fault.ValidationException;
|
||||
import org.gcube.application.geoportal.utils.Serialization;
|
||||
import org.gcube.application.geoportal.model.report.PublicationReport;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
|
@ -98,6 +96,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
// saving into back-end
|
||||
manager = ManagerFactory.registerNew(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");
|
||||
LOG.debug(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO + " building with client obj: " + ards);
|
||||
RelazioneScavo abstractRelazioneDiScavo = ConvertToServiceModel.toAbstractRelazioneScavo(ards);
|
||||
|
||||
// RELAZIONE_DI_SCAVO
|
||||
list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
||||
|
@ -109,7 +119,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(rds);
|
||||
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds);
|
||||
LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo);
|
||||
// Should be only one
|
||||
for (FileUploaded fileUploaded : rds.getFilesUploaded()) {
|
||||
|
@ -191,37 +201,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
// If true -> data are published into the SDI
|
||||
Boolean publish = true;
|
||||
Concessione registered = manager.commit(publish);
|
||||
LOG.info("Registered: " + registered);
|
||||
String link = null;
|
||||
try {
|
||||
link = ((WorkspaceContent) registered.getRelazioneScavo().getActualContent().get(0)).getLink();
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Not able to check public link ", e);
|
||||
}
|
||||
PublicationReport report = manager.commitSafely(publish);
|
||||
LOG.info("PublicationReport: " + report);
|
||||
Record registered = report.getTheRecord();
|
||||
|
||||
// String link = "toTest";
|
||||
CommitReport cRep = new CommitReport();
|
||||
cRep.setRecordId(registered.getId());
|
||||
if (link != null) {
|
||||
|
||||
if(registered!=null)
|
||||
cRep.setRecordId(registered.getId());
|
||||
|
||||
cRep.setReport(report.prettyPrint());
|
||||
|
||||
switch (report.getStatus()) {
|
||||
case PASSED:
|
||||
cRep.setState(STATE.OK);
|
||||
cRep.setMsg("Project saved successfully");
|
||||
} else {
|
||||
if(cRep.getRecordId()==null) {
|
||||
LOG.error("The record id is null!!!");
|
||||
throw new Exception("Invalid record id");
|
||||
}
|
||||
break;
|
||||
case WARNING:
|
||||
cRep.setState(STATE.WARN);
|
||||
cRep.setMsg("Project saved with errors");
|
||||
}
|
||||
cRep.setMsg(report.getWarningMessages().toString());
|
||||
break;
|
||||
case ERROR:
|
||||
cRep.setState(STATE.ERROR);
|
||||
cRep.setMsg(report.getErrorMessages().toString());
|
||||
break;
|
||||
|
||||
default:
|
||||
cRep.setState(STATE.UNKNOWN);
|
||||
break;
|
||||
}
|
||||
|
||||
return cRep;
|
||||
} catch (ValidationException e1) {
|
||||
LOG.error("Error on validating data: ", e1);
|
||||
throw new Exception("Error on validating data: " + Serialization.prettyPrint(e1.getReport()));
|
||||
} catch (PublishException e2) {
|
||||
LOG.error("Error on publishing data: ", e2);
|
||||
throw new Exception("Error on publishing data: " + e2.getMessage());
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on commiting data: ", e);
|
||||
throw new Exception(
|
||||
"Error occurred on saving data, try again or contact the support. Error: " + e.getMessage());
|
||||
"Error occurred on saving data. Error: " + e.getMessage());
|
||||
} finally {
|
||||
// if(manager!=null) {
|
||||
// try {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CommitReport implements Serializable {
|
|||
}
|
||||
|
||||
public STATE state = STATE.UNKNOWN;
|
||||
public long recordId;
|
||||
public Long recordId;
|
||||
public String msg;
|
||||
public String report;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class CommitReport implements Serializable {
|
|||
*
|
||||
* @return the record id
|
||||
*/
|
||||
public long getRecordId() {
|
||||
public Long getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue