|
|
|
@ -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<GeoNaFormDataObject> 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<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB();
|
|
|
|
|
List<UploadedImage> immaginiRappresentativeService = null;
|
|
|
|
|
if(imgRaprsLst.size()>0) {
|
|
|
|
|
if (imgRaprsLst.size() > 0) {
|
|
|
|
|
immaginiRappresentativeService = new ArrayList<UploadedImage>(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<GenericDatasetBean> listPfs = listGDB;
|
|
|
|
|
//Managing N:N
|
|
|
|
|
// Managing N:N
|
|
|
|
|
List<LayerConcessione> pianteFineScavo = null;
|
|
|
|
|
if(listPfs.size()>0) {
|
|
|
|
|
if (listPfs.size() > 0) {
|
|
|
|
|
pianteFineScavo = new ArrayList<LayerConcessione>(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<TempFile> 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<TempFile> 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<imgRaprsLst.size(); i++) {
|
|
|
|
|
|
|
|
|
|
// IMMAGINI RAPPRESENTATIVE
|
|
|
|
|
for (int i = 0; i < imgRaprsLst.size(); i++) {
|
|
|
|
|
LOG.debug("\n\n");
|
|
|
|
|
GenericDatasetBean imgRapr = imgRaprsLst.get(i);
|
|
|
|
|
// Building TempFile for Immagini
|
|
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
|
files = serviceUtil.toTemFiles(imgRapr.getFilesUploaded());
|
|
|
|
|
// Upload file to Concessione. The size is always 1 so it is consistent with the 'for' index
|
|
|
|
|
if (files!=null && files.size() > 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<listPfs.size(); i++) {
|
|
|
|
|
|
|
|
|
|
// PIANTE FINE SCAVO
|
|
|
|
|
if (listPfs.size() > 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<Concessione> concessioni = clientMongo.getList();
|
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
LOG.info("Returning: " + concessioni);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest());
|
|
|
|
|
int maxOffset = listOfConcessioni.size();
|
|
|
|
|
List<Concessione> toReturn = new ArrayList<Concessione>();
|
|
|
|
|
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.
|
|
|
|
|