Feature_20435 #3
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/geoportal-data-entry-app-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/geoportal-data-entry-app-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -35,5 +35,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/geoportal-data-entry-app-1.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
jarsExcludedFromWebInfLib=
|
jarsExcludedFromWebInfLib=
|
||||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.2.0-SNAPSHOT
|
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.3.0-SNAPSHOT
|
||||||
warSrcDir=src/main/webapp
|
warSrcDir=src/main/webapp
|
||||||
warSrcDirIsOutput=false
|
warSrcDirIsOutput=false
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
<wb-module deploy-name="geoportal-data-entry-app-1.0.0-SNAPSHOT">
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-module deploy-name="geoportal-data-entry-app-1.3.0-SNAPSHOT">
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
|
||||||
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
|
||||||
</wb-module>
|
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
</wb-module>
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<faceted-project>
|
<faceted-project>
|
||||||
<installed facet="jst.web" version="2.3"/>
|
<installed facet="jst.web" version="3.0"/>
|
||||||
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
|
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
|
||||||
<installed facet="java" version="1.7"/>
|
<installed facet="java" version="1.7"/>
|
||||||
<installed facet="jst.jaxrs" version="1.1"/>
|
<installed facet="jst.jaxrs" version="1.1"/>
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
All notable changes to this project will be documented in this file.
|
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).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [v1.3.0-SNAPSHOT] - 2021-07-22
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
[#20435] Client integration with MongoConcessioni
|
||||||
|
Moved to maven-portal-bom 3.6.3
|
||||||
|
|
||||||
|
|
||||||
## [v1.2.0] - 2020-12-18
|
## [v1.2.0] - 2020-12-18
|
||||||
|
|
||||||
|
|
12
pom.xml
12
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>geoportal-data-entry-app</artifactId>
|
<artifactId>geoportal-data-entry-app</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
<name>GeoPortal Data Entry App</name>
|
<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>
|
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
<artifactId>maven-portal-bom</artifactId>
|
||||||
<version>3.6.0</version>
|
<version>3.6.3-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -122,8 +122,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.application</groupId>
|
<groupId>org.gcube.application</groupId>
|
||||||
<artifactId>geoportal-logic</artifactId>
|
<artifactId>geoportal-client</artifactId>
|
||||||
<version>[1.0.8, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -227,6 +227,10 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>${maven.compiler.source}</source>
|
||||||
|
<target>${maven.compiler.target}</target>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- SA Plugin -->
|
<!-- SA Plugin -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -8,11 +8,11 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportal.model.AccessPolicy;
|
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.managers.ManagerFactory;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||||
import org.gcube.application.geoportal.model.InputStreamDescriptor;
|
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||||
import org.gcube.application.geoportal.model.Record;
|
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
||||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest;
|
||||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||||
import org.gcube.application.geoportal.model.report.PublicationReport;
|
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||||
|
@ -60,7 +59,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) {
|
for (GeoNaFormDataObject geoNaFormDataObject : listGeonaFormObjects) {
|
||||||
|
|
||||||
ConcessioniFormCardTitle theType = geoNaFormDataObject.getTheType();
|
ConcessioniFormCardTitle theType = geoNaFormDataObject.getTheType();
|
||||||
|
|
||||||
List<GeoNaFormDataObject> listForm = toMap.get(theType);
|
List<GeoNaFormDataObject> listForm = toMap.get(theType);
|
||||||
if (listForm == null) {
|
if (listForm == null) {
|
||||||
listForm = new ArrayList<GeoNaFormDataObject>();
|
listForm = new ArrayList<GeoNaFormDataObject>();
|
||||||
|
@ -73,13 +71,18 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
prettyPrintClientDataEntryMap(toMap);
|
prettyPrintClientDataEntryMap(toMap);
|
||||||
|
|
||||||
LOG.debug("Built map with form data: " + toMap);
|
LOG.debug("Built map with form data: " + toMap);
|
||||||
|
|
||||||
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
|
||||||
ConcessioneManager manager;
|
Concessione concessioneNew;
|
||||||
|
String mongoId = null;
|
||||||
|
ServiceUtil serviceUtil = new ServiceUtil();
|
||||||
|
MongoConcessioni clientMongo = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
|
clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||||
|
|
||||||
// Saving Data
|
// Saving Data
|
||||||
// Informazioni di Progetto
|
// Informazioni di Progetto
|
||||||
List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
List<GeoNaFormDataObject> list = toMap.get(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
||||||
|
@ -93,11 +96,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp);
|
LOG.debug(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " building with client obj: " + idp);
|
||||||
Concessione concessione = ConvertToServiceModel.toConcessione(idp, user);
|
Concessione concessione = ConvertToServiceModel.toConcessione(idp, user);
|
||||||
LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione);
|
LOG.debug("Built " + ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO + " as server obj: " + concessione);
|
||||||
|
|
||||||
// saving into back-end
|
|
||||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
||||||
manager = ManagerFactory.registerNew(concessione);
|
|
||||||
|
|
||||||
|
//Register New Concessione
|
||||||
|
concessioneNew=clientMongo.createNew(concessione);
|
||||||
|
|
||||||
|
|
||||||
// ABSTRACT_RELAZIONE_DI_SCAVO
|
// ABSTRACT_RELAZIONE_DI_SCAVO
|
||||||
list = toMap.get(ConcessioniFormCardTitle.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)
|
if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
|
||||||
|
@ -122,13 +125,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds);
|
LOG.debug(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " building with client obj: " + rds);
|
||||||
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds);
|
RelazioneScavo relazioneDiScavo = ConvertToServiceModel.toRelazioneScavo(abstractRelazioneDiScavo, rds);
|
||||||
LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo);
|
LOG.debug("Built " + ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO + " as server obj: " + relazioneDiScavo);
|
||||||
// Should be only one
|
|
||||||
for (FileUploaded fileUploaded : rds.getFilesUploaded()) {
|
//Setting Relazione
|
||||||
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
concessioneNew.setRelazioneScavo(relazioneDiScavo);
|
||||||
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
|
||||||
// saving into back-end
|
|
||||||
manager.setRelazioneScavo(relazioneDiScavo, isd);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IMMAGINI_RAPPRESENTATIVE
|
// IMMAGINI_RAPPRESENTATIVE
|
||||||
list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
||||||
|
@ -137,20 +137,23 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
"Error: no data found for " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle());
|
"Error: no data found for " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getTitle());
|
||||||
|
|
||||||
List<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB();
|
List<GenericDatasetBean> imgRaprsLst = list.get(0).getListGDB();
|
||||||
for (GenericDatasetBean imgRapr : imgRaprsLst) {
|
List<UploadedImage> immaginiRappresentativeService = null;
|
||||||
LOG.debug("\n\n");
|
if(imgRaprsLst.size()>0) {
|
||||||
LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + imgRapr);
|
immaginiRappresentativeService = new ArrayList<UploadedImage>(imgRaprsLst.size());
|
||||||
UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr);
|
for (GenericDatasetBean imgRapr : imgRaprsLst) {
|
||||||
LOG.debug("Built " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img);
|
LOG.debug("\n\n");
|
||||||
for (FileUploaded fileUploaded : imgRapr.getFilesUploaded()) {
|
LOG.debug(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " building with client obj: " + imgRapr);
|
||||||
LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + img);
|
UploadedImage img = ConvertToServiceModel.toImmaginiRappresentative(imgRapr);
|
||||||
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
LOG.debug("Built " + ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE + " as server obj: " + img);
|
||||||
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
immaginiRappresentativeService.add(img);
|
||||||
// saving into back-end
|
|
||||||
manager.addImmagineRappresentativa(img, isd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setting Immagini Rappresentative
|
||||||
|
if(immaginiRappresentativeService!=null) {
|
||||||
|
concessioneNew.setImmaginiRappresentative(immaginiRappresentativeService);
|
||||||
|
}
|
||||||
|
|
||||||
// POSIZIONAMENTO_DELL_AREA_DI_INDAGINE
|
// POSIZIONAMENTO_DELL_AREA_DI_INDAGINE
|
||||||
list = toMap.get(ConcessioniFormCardTitle.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)
|
if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
|
||||||
|
@ -159,18 +162,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
|
|
||||||
listGDB = list.get(0).getListGDB();
|
listGDB = list.get(0).getListGDB();
|
||||||
GenericDatasetBean pad = listGDB.get(0);
|
GenericDatasetBean pad = listGDB.get(0);
|
||||||
LOG.debug("\n\n");
|
LayerConcessione layerPad = null;
|
||||||
LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: "
|
if(pad!=null) {
|
||||||
+ pad);
|
LOG.debug("\n\n");
|
||||||
LayerConcessione layerPad = ConvertToServiceModel.toLayerConcessione(pad);
|
LOG.debug(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " building with client obj: "
|
||||||
LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: "
|
+ pad);
|
||||||
+ layerPad);
|
layerPad = ConvertToServiceModel.toLayerConcessione(pad);
|
||||||
for (FileUploaded fileUploaded : pad.getFilesUploaded()) {
|
LOG.debug("Built " + ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE + " as server obj: "
|
||||||
LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPad);
|
+ layerPad);
|
||||||
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
}
|
||||||
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
|
||||||
// saving into back-end
|
//Setting Posizionamento Di Scavo
|
||||||
manager.setPosizionamento(layerPad, isd);
|
if(layerPad!=null) {
|
||||||
|
concessioneNew.setPosizionamentoScavo(layerPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PIANTA_DI_FINE_SCAVO
|
// PIANTA_DI_FINE_SCAVO
|
||||||
|
@ -180,20 +184,91 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
"Error: no data found for " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle());
|
"Error: no data found for " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getTitle());
|
||||||
|
|
||||||
listGDB = list.get(0).getListGDB();
|
listGDB = list.get(0).getListGDB();
|
||||||
|
List<GenericDatasetBean> listPfs = listGDB;
|
||||||
//Managing N:N
|
//Managing N:N
|
||||||
for (GenericDatasetBean pfs : listGDB) {
|
List<LayerConcessione> pianteFineScavo = null;
|
||||||
LOG.debug("\n\n");
|
if(listPfs.size()>0) {
|
||||||
LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs);
|
pianteFineScavo = new ArrayList<LayerConcessione>(listPfs.size());
|
||||||
LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs);
|
for (GenericDatasetBean pfs : listPfs) {
|
||||||
LOG.debug("Built " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs);
|
LOG.debug("\n\n");
|
||||||
for (FileUploaded fileUploaded : pfs.getFilesUploaded()) {
|
LOG.debug(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " building with client obj: " + pfs);
|
||||||
LOG.debug("Adding uploaded file: " + fileUploaded.getFileName() + " to " + layerPfs);
|
LayerConcessione layerPfs = ConvertToServiceModel.toLayerConcessione(pfs);
|
||||||
FileInputStream fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
LOG.debug("Built " + ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO + " as server obj: " + layerPfs);
|
||||||
InputStreamDescriptor isd = new InputStreamDescriptor(fis, fileUploaded.getFileName());
|
pianteFineScavo.add(layerPfs);
|
||||||
// saving into back-end
|
|
||||||
manager.addPiantaFineScavo(layerPfs, isd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setting Piante fine Scavo
|
||||||
|
if(pianteFineScavo!=null) {
|
||||||
|
concessioneNew.setPianteFineScavo(pianteFineScavo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Registering Meta
|
||||||
|
clientMongo.replace(concessioneNew);
|
||||||
|
mongoId = concessioneNew.getMongo_id();
|
||||||
|
LOG.info("Registered the meta. Called mongo.replace for: "+concessioneNew);
|
||||||
|
|
||||||
|
//UPLOADING FILES
|
||||||
|
LOG.info("Now uploading the files...");
|
||||||
|
// Building TempFile for Relazione
|
||||||
|
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) {
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
// saving into back-end
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
// saving into back-end
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
// saving into back-end
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on converting form data: ", e);
|
LOG.error("Error on converting form data: ", e);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -201,44 +276,46 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// If true -> data are published into the SDI
|
|
||||||
Boolean publish = true;
|
|
||||||
PublicationReport report = manager.commitSafely(publish);
|
|
||||||
LOG.info("PublicationReport: " + report);
|
|
||||||
Record registered = report.getTheRecord();
|
|
||||||
|
|
||||||
// String link = "toTest";
|
|
||||||
CommitReport cRep = new CommitReport();
|
|
||||||
|
|
||||||
if(registered!=null)
|
Concessione concessione;
|
||||||
cRep.setRecordId(registered.getId());
|
if(clientMongo!=null && mongoId!=null) {
|
||||||
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
cRep.setReport(report.prettyPrint());
|
concessione = clientMongo.publish(mongoId);
|
||||||
|
//server report
|
||||||
switch (report.getStatus()) {
|
ValidationReport report = concessione.getReport();
|
||||||
case PASSED:
|
LOG.info("ValidationReport: " + report);
|
||||||
cRep.setState(STATE.OK);
|
//to client
|
||||||
if(cRep.getRecordId()==null) {
|
CommitReport cRep = new CommitReport();
|
||||||
LOG.error("The record id is null!!!");
|
cRep.setRecordId(concessione.getId());
|
||||||
throw new Exception("Invalid record 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");
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case WARNING:
|
return cRep;
|
||||||
cRep.setState(STATE.WARN);
|
}else
|
||||||
cRep.setMsg(report.getWarningMessages().toString());
|
throw new Exception("MongoId or Client not found");
|
||||||
break;
|
|
||||||
case ERROR:
|
|
||||||
cRep.setState(STATE.ERROR);
|
|
||||||
cRep.setMsg(report.getErrorMessages().toString());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
cRep.setState(STATE.UNKNOWN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cRep;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on commiting data: ", e);
|
LOG.error("Error on commiting data: ", e);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -301,6 +378,28 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
LOG.info("Returning: " + item);
|
LOG.info("Returning: " + item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the links for.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param recordType the record type
|
||||||
|
* @return the links for
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
//@Override
|
||||||
|
public void getListConcessioni(Integer startIdx, Integer limit) 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pretty print client data entry map.
|
* Pretty print client data entry map.
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||||
|
|
||||||
|
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||||
|
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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the instance mongo concessioni.
|
||||||
|
*
|
||||||
|
* @return the instance mongo concessioni
|
||||||
|
*/
|
||||||
|
public MongoConcessioni getInstanceMongoConcessioni() {
|
||||||
|
return mongoConcessioni().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the temp file on storage.
|
||||||
|
*
|
||||||
|
* @param is the is
|
||||||
|
* @param fileName the file name
|
||||||
|
* @return the temp file
|
||||||
|
*/
|
||||||
|
public TempFile createTempFileOnStorage(InputStream is, String fileName) {
|
||||||
|
LOG.debug("createTempFileOnStorage called");
|
||||||
|
StorageUtils storage = new StorageUtils();
|
||||||
|
TempFile toUpload = null;
|
||||||
|
try {
|
||||||
|
LOG.info("calling putOntoStorage the stream with the fileName: " + fileName);
|
||||||
|
toUpload = storage.putOntoStorage(is, fileName);
|
||||||
|
} catch (RemoteBackendException | FileNotFoundException e) {
|
||||||
|
LOG.error("Error when uploading stream on Storage: ", e);
|
||||||
|
}
|
||||||
|
return toUpload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To tem files.
|
||||||
|
*
|
||||||
|
* @param listFileUploaded the list file uploaded
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public List<TempFile> toTemFiles(List<FileUploaded> listFileUploaded) {
|
||||||
|
LOG.debug("toTemFiles called");
|
||||||
|
if (listFileUploaded == null || listFileUploaded.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Building TempFile
|
||||||
|
List<TempFile> files = new ArrayList<TempFile>(listFileUploaded.size());
|
||||||
|
for (FileUploaded fileUploaded : listFileUploaded) {
|
||||||
|
FileInputStream fis;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(fileUploaded.getTempSystemPath());
|
||||||
|
// Creating TempFile
|
||||||
|
TempFile storageTempFile = createTempFileOnStorage(fis, fileUploaded.getFileName());
|
||||||
|
files.add(storageTempFile);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
LOG.error("Error on loading temp file with path: " + fileUploaded.getTempSystemPath(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To JSON.
|
||||||
|
*
|
||||||
|
* @param <T> the generic type
|
||||||
|
* @param report the report
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public String toJSON(Object theObj) {
|
||||||
|
LOG.debug("toJSON called");
|
||||||
|
try {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.geoportaldataentry.server;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
@ -67,20 +68,27 @@ public class SessionUtil {
|
||||||
* Retrieve the current scope by using the portal manager.
|
* Retrieve the current scope by using the portal manager.
|
||||||
*
|
*
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param setInThread the set in thread
|
* @param setContextsInThread set the scope and the security token into current thread
|
||||||
* @return a GcubeUser object
|
* @return a GcubeUser object
|
||||||
*/
|
*/
|
||||||
public static String getCurrentContext(HttpServletRequest request, boolean setInThread){
|
public static String getCurrentContext(HttpServletRequest request, boolean setContextsInThread){
|
||||||
|
|
||||||
if(request == null)
|
if(request == null)
|
||||||
throw new IllegalArgumentException("HttpServletRequest is null!");
|
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||||
|
|
||||||
PortalContext pContext = PortalContext.getConfiguration();
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
String context = pContext.getCurrentScope(request);
|
String context = pContext.getCurrentScope(request);
|
||||||
LOG.debug("Returning context " + context);
|
|
||||||
|
if(setContextsInThread) {
|
||||||
if(context != null && setInThread)
|
GCubeUser user = getCurrentUser(request);
|
||||||
ScopeProvider.instance.set(context);
|
String token = pContext.getCurrentUserToken(context, user.getUsername());
|
||||||
|
|
||||||
|
if(context!=null)
|
||||||
|
ScopeProvider.instance.set(context);
|
||||||
|
|
||||||
|
if(token!=null)
|
||||||
|
SecurityTokenProvider.instance.set(token);
|
||||||
|
}
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue