added a method
This commit is contained in:
parent
a134c87b6d
commit
5fbb0fa8a7
|
@ -3,27 +3,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-1.3.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-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"/>
|
||||
<dependent-module archiveName="geoportal-data-common-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -33,14 +42,17 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
|
|
@ -100,7 +100,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// 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)
|
||||
|
@ -129,7 +128,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// Setting Relazione
|
||||
concessioneNew.setRelazioneScavo(relazioneDiScavo);
|
||||
|
||||
|
||||
// IMMAGINI_RAPPRESENTATIVE
|
||||
list = toMap.get(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
||||
if (list == null || list.isEmpty() || list.get(0) == null || list.get(0).getListGDB() == null)
|
||||
|
@ -142,7 +140,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
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);
|
||||
|
@ -214,12 +213,14 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// Building TempFile for ABSTRACT DELLA RELAZIONE DI SCAVO
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
List<TempFile> ardsFiles = serviceUtil.toTemFiles(ards.getFilesUploaded());
|
||||
//TODO MUST BE UNIFIED WITH RELAZIONE OPPURE BISOGNA PREVEDERE UN ABSTRACT_RELAZIONE???
|
||||
// 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
|
||||
|
@ -230,7 +231,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// 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
|
||||
|
@ -240,12 +242,15 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// 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
|
||||
// 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -257,9 +262,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// Upload file to Concessione
|
||||
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
|
||||
|
@ -272,9 +279,11 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// 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);
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -330,8 +339,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
} 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 {
|
||||
|
@ -400,19 +408,37 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
// @Override
|
||||
public void getListConcessioni(Integer startIdx, Integer limit) throws Exception {
|
||||
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();
|
||||
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);
|
||||
//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.
|
||||
*
|
||||
|
|
|
@ -3,8 +3,14 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -29,6 +35,7 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
*/
|
||||
public class SessionUtil {
|
||||
|
||||
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI";
|
||||
/** The log. */
|
||||
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
|
@ -111,4 +118,36 @@ public class SessionUtil {
|
|||
return gm.getGroup(groupId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of concessioni.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @return the list of concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
|
||||
List<Concessione> result = new ArrayList<Concessione>();
|
||||
|
||||
if (listOfConcessioni == null) {
|
||||
LOG.info("Loading list of concessione from client mongo");
|
||||
SessionUtil.getCurrentContext(httpServletRequest, true);
|
||||
ServiceUtil serviceUtil = new ServiceUtil();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
Iterable<Concessione> concessioni = clientMongo.getList();
|
||||
if (concessioni != null) {
|
||||
for (Concessione conc : concessioni) {
|
||||
result.add(conc);
|
||||
}
|
||||
}
|
||||
LOG.debug("Got list of concessione from client mongo: "+result);
|
||||
session.setAttribute(LIST_OF_CONCESSIONI, result);
|
||||
LOG.info("Saved in session list of concessione from client mongo with size: "+result.size());
|
||||
}
|
||||
LOG.info("returning list of concessioni with size: "+result.size());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue