converted objects forms to server objects
This commit is contained in:
parent
28b78c8f04
commit
5a09e88604
|
@ -27,6 +27,8 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="org.eclipse.jst.component.dependency"
|
||||||
|
value="/WEB-INF/lib" />
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
||||||
public enum ConcessioniFormCardTitle {
|
public enum ConcessioniFormCardTitle {
|
||||||
|
|
||||||
INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false),
|
INFORMAZIONI_DI_PROGETTO("Informazioni", "Informazioni di Progetto", 1, false),
|
||||||
RELAZIONI_DI_SCAVO("Relazione di Scavo", "Relazioni di Scavo", 2, false),
|
RELAZIONE_DI_SCAVO("Relazione di Scavo", "Relazione di Scavo", 2, false),
|
||||||
IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true),
|
IMMAGINI_RAPPRESENTATIVE("Immagini Rappresentative", "Immagini Rappresentative", 3, true),
|
||||||
POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false),
|
POSIZIONAMENTO_DELL_AREA_DI_INDAGINE("Posizionamento", "Posizionamento dell'Area di Indagine", 4, false),
|
||||||
PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true);
|
PIANTA_DI_FINE_SCAVO("Pianta di Fine Scavo", "Pianta di Fine Scavo", 5, true);
|
||||||
|
|
|
@ -140,9 +140,9 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
if(theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) {
|
if(theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) {
|
||||||
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
||||||
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), geonaForm);
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(), geonaForm);
|
||||||
}else if(theMetaType.contains(ConcessioniFormCardTitle.RELAZIONI_DI_SCAVO.getKey().toLowerCase())) {
|
}else if(theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
||||||
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONI_DI_SCAVO);
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
||||||
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONI_DI_SCAVO.getOrder(), geonaForm);
|
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);
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
||||||
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), geonaForm);
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(), geonaForm);
|
||||||
|
@ -196,7 +196,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
alert.setClose(false);
|
alert.setClose(false);
|
||||||
modal.add(alert);
|
modal.add(alert);
|
||||||
modal.setCloseVisible(true);
|
modal.setCloseVisible(true);
|
||||||
resetUI();
|
//resetUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -207,9 +207,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
alert.setClose(false);
|
alert.setClose(false);
|
||||||
modal.add(alert);
|
modal.add(alert);
|
||||||
modal.setCloseVisible(true);
|
modal.setCloseVisible(true);
|
||||||
resetUI();
|
//resetUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,6 @@ public class ConvertToServiceModel {
|
||||||
concessione.setAuthors(authors);
|
concessione.setAuthors(authors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
//concessione.setCentroidLat(centroidLat);
|
|
||||||
// concessione.setCentroidLong(centroidLong);
|
|
||||||
|
|
||||||
List<String> contributors = mapFields.get("Contributore");
|
List<String> contributors = mapFields.get("Contributore");
|
||||||
if(contributors!=null) {
|
if(contributors!=null) {
|
||||||
for (String contributor : contributors) {
|
for (String contributor : contributors) {
|
||||||
|
@ -65,10 +60,6 @@ public class ConvertToServiceModel {
|
||||||
//concessione.setCreationTime(Instant.now());
|
//concessione.setCreationTime(Instant.now());
|
||||||
concessione.setCreationUser(user.getUsername());
|
concessione.setCreationUser(user.getUsername());
|
||||||
|
|
||||||
//TODO
|
|
||||||
// concessione.setDataFineScavo(dataFineScavo);
|
|
||||||
// concessione.setDataInizioScavo(dataInizioScavo);
|
|
||||||
|
|
||||||
List<String> dataInizProgettoList = mapFields.get("Data inizio Progetto");
|
List<String> dataInizProgettoList = mapFields.get("Data inizio Progetto");
|
||||||
if(dataInizProgettoList!=null && dataInizProgettoList.size()>0) {
|
if(dataInizProgettoList!=null && dataInizProgettoList.size()>0) {
|
||||||
String inizioProgetto = dataInizProgettoList.get(0);
|
String inizioProgetto = dataInizProgettoList.get(0);
|
||||||
|
@ -103,8 +94,7 @@ public class ConvertToServiceModel {
|
||||||
|
|
||||||
List<String> licenzaLst = mapFields.get("ID Licenza");
|
List<String> licenzaLst = mapFields.get("ID Licenza");
|
||||||
if(licenzaLst!=null && licenzaLst.size()>0) {
|
if(licenzaLst!=null && licenzaLst.size()>0) {
|
||||||
//TODO FABIO
|
concessione.setLicenzaID(licenzaLst.get(0));
|
||||||
//concessione.setLicenza()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> introduzioneLst = mapFields.get("Introduzione");
|
List<String> introduzioneLst = mapFields.get("Introduzione");
|
||||||
|
@ -181,7 +171,6 @@ public class ConvertToServiceModel {
|
||||||
relazioneScavo.setResponsabili(responsabiliLst);
|
relazioneScavo.setResponsabili(responsabiliLst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<String> licenzaIdList = mapFields.get("ID Licenza");
|
List<String> licenzaIdList = mapFields.get("ID Licenza");
|
||||||
if(licenzaIdList!=null && licenzaIdList.size()>0) {
|
if(licenzaIdList!=null && licenzaIdList.size()>0) {
|
||||||
relazioneScavo.setLicenseID(licenzaIdList.get(0));
|
relazioneScavo.setLicenseID(licenzaIdList.get(0));
|
||||||
|
@ -220,6 +209,11 @@ public class ConvertToServiceModel {
|
||||||
uplaodedImage.setResponsabili(responsabileLst);
|
uplaodedImage.setResponsabili(responsabileLst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> licenzaIdList = mapFields.get("ID Licenza");
|
||||||
|
if(licenzaIdList!=null && licenzaIdList.size()>0) {
|
||||||
|
uplaodedImage.setLicenseID(licenzaIdList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
//TODO???
|
//TODO???
|
||||||
List<String> autoreLst = mapFields.get("Autore");
|
List<String> autoreLst = mapFields.get("Autore");
|
||||||
if(autoreLst!=null) {
|
if(autoreLst!=null) {
|
||||||
|
@ -245,7 +239,6 @@ public class ConvertToServiceModel {
|
||||||
layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0));
|
layerConcessione.setValutazioneQualita(valutazioneQualitaLst.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<String> metodoRaccoltaDatiLst = mapFields.get("Metodo di raccolta dei dati");
|
List<String> 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));
|
layerConcessione.setMetodoRaccoltaDati(metodoRaccoltaDatiLst.get(0));
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
package org.gcube.portlets.user.geoportaldataentry.server;
|
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
||||||
|
import org.gcube.application.geoportal.managers.ManagerFactory;
|
||||||
|
import org.gcube.application.geoportal.model.InputStreamDescriptor;
|
||||||
|
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||||
|
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||||
|
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
||||||
|
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||||
|
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.client.GreetingService;
|
import org.gcube.portlets.user.geoportaldataentry.client.GreetingService;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier;
|
|
||||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||||
|
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.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
|
||||||
|
@ -12,47 +28,173 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
* The server side implementation of the RPC service.
|
* The server side implementation of the RPC service.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class GreetingServiceImpl extends RemoteServiceServlet implements
|
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
|
||||||
GreetingService {
|
|
||||||
|
|
||||||
public String greetServer(String input) throws IllegalArgumentException {
|
private static final Logger LOG = LoggerFactory.getLogger(GreetingServiceImpl.class);
|
||||||
// Verify that the input is valid.
|
|
||||||
if (!FieldVerifier.isValidName(input)) {
|
|
||||||
// If the input is not valid, throw an IllegalArgumentException back to
|
|
||||||
// the client.
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Name must be at least 4 characters long");
|
|
||||||
}
|
|
||||||
|
|
||||||
String serverInfo = getServletContext().getServerInfo();
|
@Override
|
||||||
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
|
public String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception {
|
||||||
|
LOG.info("saveGeonaDataForms called");
|
||||||
|
|
||||||
// Escape data from the client to avoid cross-site script vulnerabilities.
|
HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap =
|
||||||
input = escapeHtml(input);
|
new HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>>();
|
||||||
userAgent = escapeHtml(userAgent);
|
|
||||||
|
|
||||||
return "Hello, " + input + "!<br><br>I am running " + serverInfo
|
for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) {
|
||||||
+ ".<br><br>It looks like you are using:<br>" + userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
ConcessioniFormCardTitle theType = geoNaFormDataObject.getTheType();
|
||||||
* Escape an html string. Escaping data received from the client helps to
|
|
||||||
* prevent cross-site script vulnerabilities.
|
|
||||||
*
|
|
||||||
* @param html the html string to escape
|
|
||||||
* @return the escaped string
|
|
||||||
*/
|
|
||||||
private String escapeHtml(String html) {
|
|
||||||
if (html == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return html.replaceAll("&", "&").replaceAll("<", "<").replaceAll(
|
|
||||||
">", ">");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
List<GeoNaFormDataObject> listForm = toMap.get(theType);
|
||||||
public String saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception{
|
if (listForm == null) {
|
||||||
|
listForm = new ArrayList<GeoNaFormDataObject>();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
listForm.add(geoNaFormDataObject);
|
||||||
}
|
toMap.put(theType, listForm);
|
||||||
|
}
|
||||||
|
if(LOG.isDebugEnabled())
|
||||||
|
prettyPrintClientDataEntryMap(toMap);
|
||||||
|
|
||||||
|
LOG.debug("Built map with form data: "+toMap);
|
||||||
|
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
|
||||||
|
//Saving Data
|
||||||
|
//Informazioni di Progetto
|
||||||
|
List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
||||||
|
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null)
|
||||||
|
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getTitle());
|
||||||
|
|
||||||
|
List<GenericDatasetBean> listGDB = list.get(0).getListGDB();
|
||||||
|
GenericDatasetBean idp = listGDB.get(0);
|
||||||
|
LOG.debug("\n\n");
|
||||||
|
LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" building with client obj: "+idp);
|
||||||
|
Concessione concessione = ConvertToServiceModel.toConcessione(idp, user);
|
||||||
|
LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+concessione);
|
||||||
|
//saving into back-end
|
||||||
|
ConcessioneManager manager = ManagerFactory.registerNew(concessione);
|
||||||
|
|
||||||
|
//RELAZIONE_DI_SCAVO
|
||||||
|
list = toMap.get(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
||||||
|
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null)
|
||||||
|
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getTitle());
|
||||||
|
|
||||||
|
listGDB = list.get(0).getListGDB();
|
||||||
|
GenericDatasetBean rds = listGDB.get(0);
|
||||||
|
LOG.debug("\n\n");
|
||||||
|
LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO+" building with client obj: "+rds);
|
||||||
|
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(rds);
|
||||||
|
LOG.debug("Built "+ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO+" as server obj: "+relazioneDiScavo);
|
||||||
|
//Should be only one
|
||||||
|
for (FileUploaded fileUploaded : rds.getFilesUploaded()) {
|
||||||
|
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
||||||
|
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
||||||
|
//saving into back-end
|
||||||
|
manager.setRelazioneScavo(relazioneDiScavo, isd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//IMMAGINI_RAPPRESENTATIVE
|
||||||
|
list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
||||||
|
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null)
|
||||||
|
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle());
|
||||||
|
|
||||||
|
List<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB();
|
||||||
|
for (GenericDatasetBean imgRapr : imgRaprsLst) {
|
||||||
|
LOG.debug("\n\n");
|
||||||
|
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);
|
||||||
|
for (FileUploaded fileUploaded : imgRapr.getFilesUploaded()) {
|
||||||
|
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+img);
|
||||||
|
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
||||||
|
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
||||||
|
//saving into back-end
|
||||||
|
manager.addImmagineRappresentativa(img,isd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//POSIZIONAMENTO_DELL_AREA_DI_INDAGINE
|
||||||
|
list = toMap.get(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE);
|
||||||
|
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null)
|
||||||
|
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getTitle());
|
||||||
|
|
||||||
|
listGDB = list.get(0).getListGDB();
|
||||||
|
GenericDatasetBean pad = listGDB.get(0);
|
||||||
|
LOG.debug("\n\n");
|
||||||
|
LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" building with client obj: "+pad);
|
||||||
|
LayerConcessione layerPad = ConvertToServiceModel.toLayerConcessione(pad);
|
||||||
|
LOG.debug("Built "+ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE+" as server obj: "+layerPad);
|
||||||
|
for (FileUploaded fileUploaded : pad.getFilesUploaded()) {
|
||||||
|
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPad);
|
||||||
|
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
||||||
|
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
||||||
|
//saving into back-end
|
||||||
|
manager.setPosizionamento(layerPad, isd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//PIANTA_DI_FINE_SCAVO
|
||||||
|
list = toMap.get(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO);
|
||||||
|
if(list==null || list.isEmpty() || list.get(0)==null || list.get(0).getListGDB()==null)
|
||||||
|
throw new Exception("Error: no data found for "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle());
|
||||||
|
|
||||||
|
listGDB = list.get(0).getListGDB();
|
||||||
|
GenericDatasetBean pfs = listGDB.get(0);
|
||||||
|
LOG.debug("\n\n");
|
||||||
|
LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" building with client obj: "+pfs);
|
||||||
|
LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs);
|
||||||
|
LOG.debug("Built "+ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO+" as server obj: "+layerPfs);
|
||||||
|
for (FileUploaded fileUploaded : pfs.getFilesUploaded()) {
|
||||||
|
LOG.debug("Adding uploaded file: "+fileUploaded.getFileName() + " to "+layerPfs);
|
||||||
|
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
||||||
|
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
||||||
|
//saving into back-end
|
||||||
|
manager.addPiantaFineScavo(layerPfs, isd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//If true -> data are published into the SDI
|
||||||
|
Boolean publish=false;
|
||||||
|
|
||||||
|
/*Chiedo al manager di salvare il progetto, causando :
|
||||||
|
*scrittura sul WS
|
||||||
|
*pubblicazione sull'SDI (boolean publish)
|
||||||
|
*scrittura sul DB di applicazione sia dei meta che dei vari link */
|
||||||
|
// Concessione registered=manager.commit(publish);
|
||||||
|
//
|
||||||
|
// LOG.info("Registered: "+registered);
|
||||||
|
// String link = null;
|
||||||
|
// try {
|
||||||
|
// link = ((WorkspaceContent)registered.getRelazioneScavo().getActualContent().get(0)).getLink();
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// // TODO: handle exception
|
||||||
|
// }
|
||||||
|
|
||||||
|
String link = "toTest";
|
||||||
|
|
||||||
|
if(link!=null)
|
||||||
|
return "Project saved successfully";
|
||||||
|
else
|
||||||
|
return "Project saved with errors";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void prettyPrintClientDataEntryMap(HashMap<ConcessioniFormCardTitle, List<GeoNaFormDataObject>> toMap) {
|
||||||
|
|
||||||
|
for (ConcessioniFormCardTitle theType : toMap.keySet()) {
|
||||||
|
LOG.debug("\n\n"+theType);
|
||||||
|
List<GeoNaFormDataObject> list = toMap.get(theType);
|
||||||
|
for (GeoNaFormDataObject geoNaFormDataObject : list) {
|
||||||
|
LOG.debug("\t has "+geoNaFormDataObject.getListGDB().size() +" data bean/s");
|
||||||
|
int i = 0;
|
||||||
|
for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) {
|
||||||
|
LOG.debug("\t "+ ++i +") "+GenericDatasetBean.class.getSimpleName()+" entries:");
|
||||||
|
Map<String, List<String>> map = gbd.getFormDataEntryFields();
|
||||||
|
for (String keyEntry : map.keySet()) {
|
||||||
|
LOG.debug("\t "+keyEntry + ": "+map.get(keyEntry));
|
||||||
|
}
|
||||||
|
for (FileUploaded fup : gbd.getFilesUploaded()) {
|
||||||
|
LOG.debug("\t "+fup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.gcube.common.portal.PortalContext;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Auto-generated Javadoc
|
||||||
|
/**
|
||||||
|
* The Class SessionUtil.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 20, 2020
|
||||||
|
*/
|
||||||
|
public class SessionUtil {
|
||||||
|
|
||||||
|
/** The log. */
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is into portal.
|
||||||
|
*
|
||||||
|
* @return true, if is into portal
|
||||||
|
*/
|
||||||
|
public static boolean isIntoPortal() {
|
||||||
|
try {
|
||||||
|
UserLocalServiceUtil.getService();
|
||||||
|
return true;
|
||||||
|
}catch (Exception ex) {
|
||||||
|
LOG.debug("Development Mode ON");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the current user by using the portal manager.
|
||||||
|
*
|
||||||
|
* @param request the request
|
||||||
|
* @return a GcubeUser object
|
||||||
|
*/
|
||||||
|
public static GCubeUser getCurrentUser(HttpServletRequest request){
|
||||||
|
|
||||||
|
if(request == null)
|
||||||
|
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||||
|
|
||||||
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
|
GCubeUser user = pContext.getCurrentUser(request);
|
||||||
|
LOG.debug("Returning user " + user);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the current scope by using the portal manager.
|
||||||
|
*
|
||||||
|
* @param request the request
|
||||||
|
* @param setInThread the set in thread
|
||||||
|
* @return a GcubeUser object
|
||||||
|
*/
|
||||||
|
public static String getCurrentContext(HttpServletRequest request, boolean setInThread){
|
||||||
|
|
||||||
|
if(request == null)
|
||||||
|
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||||
|
|
||||||
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
|
String context = pContext.getCurrentScope(request);
|
||||||
|
LOG.debug("Returning context " + context);
|
||||||
|
|
||||||
|
if(context != null && setInThread)
|
||||||
|
ScopeProvider.instance.set(context);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the group given the scope.
|
||||||
|
*
|
||||||
|
* @param scope the scope
|
||||||
|
* @return the group from scope
|
||||||
|
* @throws UserManagementSystemException the user management system exception
|
||||||
|
* @throws GroupRetrievalFault the group retrieval fault
|
||||||
|
*/
|
||||||
|
public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault{
|
||||||
|
|
||||||
|
if(scope == null || scope.isEmpty())
|
||||||
|
throw new IllegalArgumentException("Scope is missing here!!");
|
||||||
|
|
||||||
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
|
||||||
|
return gm.getGroup(groupId);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue