Integrated with timeline config
This commit is contained in:
parent
fec3f26c0a
commit
62dc1bad6c
|
@ -161,9 +161,6 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.gcube.application.geoportal.common.model.document.identification.Iden
|
|||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
|
@ -97,6 +98,8 @@ import com.jayway.jsonpath.Option;
|
|||
@SuppressWarnings("serial")
|
||||
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
|
||||
|
||||
private static final String TIMELINE_CONFIG_TJT_DOCUMENT = "tjt_document";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
|
||||
|
||||
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
||||
|
@ -986,7 +989,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LOG.info("Trying to get project for id " + profileID);
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
UseCaseDescriptor ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
|
||||
|
||||
UseCaseDescriptor ucd = SessionUtil.getUCDForId(this.getThreadLocalRequest(), profileID);
|
||||
|
||||
if (ucd == null) {
|
||||
ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
|
||||
SessionUtil.setUCDForId(this.getThreadLocalRequest(), profileID, ucd);
|
||||
}
|
||||
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
|
@ -1173,6 +1183,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
ProjectDV projectDV = new ProjectDV();
|
||||
|
||||
try {
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
|
||||
useCaseDescriptors().build().query(request).forEachRemaining(u -> {
|
||||
try {
|
||||
LOG.debug("UCD for id" + u.getId() + " returend name: " + u.getName());
|
||||
|
@ -1197,7 +1209,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LOG.warn("Error on getting minimalProjectDV of projectID: ", e);
|
||||
}
|
||||
|
||||
LOG.debug("minimalProjectDV returning: "+projectDV);
|
||||
LOG.debug("minimalProjectDV returning: " + projectDV);
|
||||
return projectDV;
|
||||
}
|
||||
|
||||
|
@ -1211,7 +1223,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
private GeoJSON spatialReference(String profileID, String projectID) {
|
||||
LOG.trace("spatialReference for profileID: " + profileID + ", projectID: " + projectID + "called");
|
||||
try {
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
List<IdentificationReference> listIR = projects(profileID).build().getById(projectID)
|
||||
.getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType());
|
||||
if (listIR != null && !listIR.isEmpty()) {
|
||||
|
@ -1241,13 +1253,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(limit);
|
||||
|
||||
try {
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
|
||||
try {
|
||||
Iterator<Entry<String, Object>> entrySetsIt = theProject.getTheDocument().entrySet().iterator();
|
||||
int i = 0;
|
||||
while (entrySetsIt.hasNext()) {
|
||||
if (i+1 > limit)
|
||||
if (i + 1 > limit)
|
||||
break;
|
||||
|
||||
Entry<String, Object> entry = entrySetsIt.next();
|
||||
|
@ -1259,29 +1274,24 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
throw e;
|
||||
}
|
||||
|
||||
/*QueryRequest request = new QueryRequest();
|
||||
request.setFilter(Document.parse("{\"" + Project.ID + "\" : " + "{\"$eq\" : \"" + projectID + "\"}}"));
|
||||
request.setProjection(Document.parse("{\"" + Project.THE_DOCUMENT + "\" : " + "1}"));
|
||||
// should be one
|
||||
projects(profileID).build().query(request).forEachRemaining(p -> {
|
||||
try {
|
||||
Iterator<Entry<String, Object>> entrySetsIt = p.getTheDocument().entrySet().iterator();
|
||||
int i = 0;
|
||||
while (entrySetsIt.hasNext()) {
|
||||
if (i > limit)
|
||||
break;
|
||||
/*
|
||||
* QueryRequest request = new QueryRequest();
|
||||
* request.setFilter(Document.parse("{\"" + Project.ID + "\" : " +
|
||||
* "{\"$eq\" : \"" + projectID + "\"}}"));
|
||||
* request.setProjection(Document.parse("{\"" + Project.THE_DOCUMENT + "\" : " +
|
||||
* "1}")); // should be one
|
||||
* projects(profileID).build().query(request).forEachRemaining(p -> { try {
|
||||
* Iterator<Entry<String, Object>> entrySetsIt =
|
||||
* p.getTheDocument().entrySet().iterator(); int i = 0; while
|
||||
* (entrySetsIt.hasNext()) { if (i > limit) break;
|
||||
*
|
||||
* Entry<String, Object> entry = entrySetsIt.next();
|
||||
* documentAsMap.put(entry.getKey(), entry.getValue()); i++; }
|
||||
*
|
||||
* } catch (Exception e) { throw e; } });
|
||||
*/
|
||||
|
||||
Entry<String, Object> entry = entrySetsIt.next();
|
||||
documentAsMap.put(entry.getKey(), entry.getValue());
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
});*/
|
||||
|
||||
LOG.debug("getEntrySetsDocumentForProjectID returning map: "+documentAsMap);
|
||||
LOG.debug("getEntrySetsDocumentForProjectID returning map: " + documentAsMap);
|
||||
return documentAsMap;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -1301,11 +1311,39 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
try {
|
||||
LOG.info("Trying to getRelationshipsForTimeline for id " + profileID);
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
List<String> listJSON = new ArrayList<String>();
|
||||
String template = null;
|
||||
try {
|
||||
|
||||
template = SessionUtil.getJSONTimelineTemplate(this.getThreadLocalRequest(), profileID);
|
||||
|
||||
try {
|
||||
String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
||||
+ "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
||||
|
||||
if (template == null) {
|
||||
|
||||
List<HandlerDeclaration> timelineHandlers = useCaseDescriptors().build().getById(profileID)
|
||||
.getHandlersByType(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType());
|
||||
|
||||
if (timelineHandlers != null && timelineHandlers.size() > 0) {
|
||||
HandlerDeclaration handler = timelineHandlers.get(0); // only one expected
|
||||
Document config = handler.getConfiguration();
|
||||
LinkedHashMap<String, Object> tjtDoc = (LinkedHashMap<String, Object>) config
|
||||
.get(TIMELINE_CONFIG_TJT_DOCUMENT);
|
||||
template = new Document(tjtDoc).toJson();
|
||||
LOG.info(TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
||||
SessionUtil.setJSONTimelineTemplate(this.getThreadLocalRequest(), profileID, template);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType()
|
||||
+ " not found!!! Timeline cannot be available");
|
||||
}
|
||||
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
||||
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
||||
|
||||
if (template != null) {
|
||||
|
||||
JSONObject sourceJsonTemplate = new JSONObject(template);
|
||||
com.jayway.jsonpath.Configuration conf = com.jayway.jsonpath.Configuration.defaultConfiguration();
|
||||
|
@ -1320,8 +1358,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
// Adding the input document
|
||||
DocumentContext targetDoc = JsonPath.using(conf2).parse(theProject.getTheDocument().toJson());
|
||||
|
||||
JSONObject targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate, profileID, projectID,
|
||||
null);
|
||||
JSONObject targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate, profileID,
|
||||
projectID, null);
|
||||
|
||||
targetJsonObject.put("selected", "from here");
|
||||
String theJSONResult = targetJsonObject.toString();
|
||||
|
@ -1335,8 +1373,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
theProject = GeoportalClientCaller.projects().getProjectByID(relationship.getTargetUCD(),
|
||||
relationship.getTargetID());
|
||||
targetDoc = JsonPath.using(conf2).parse(theProject.getTheDocument().toJson());
|
||||
targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate, relationship.getTargetUCD(),
|
||||
relationship.getTargetID(), relationship.getRelationshipName());
|
||||
targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate,
|
||||
relationship.getTargetUCD(), relationship.getTargetID(),
|
||||
relationship.getRelationshipName());
|
||||
theJSONResult = targetJsonObject.toString();
|
||||
listJSON.add(theJSONResult);
|
||||
|
||||
|
@ -1354,6 +1393,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LOG.debug("Finally list of jsonObject " + listJSON);
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Error occurred on reading relatioships for id: " + projectID;
|
||||
LOG.error(erroMsg, e);
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
|
@ -43,6 +44,8 @@ public class SessionUtil {
|
|||
|
||||
private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
|
||||
private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS";
|
||||
private static final String TIMELINE_JSON_TEMPLATE = "TIMELINE_JSON_TEMPLATE";
|
||||
private static final String USE_CASE_DESCRIPTOR = "USE_CASE_DESCRIPTOR";
|
||||
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI_DATA_VIEWER";
|
||||
private static final String GNA_DATAVIEWER_CONFIG_PROFILE = "GNA_DATAVIEWER_CONFIG_PROFILE";
|
||||
|
||||
|
@ -206,6 +209,55 @@ public class SessionUtil {
|
|||
return lstBML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JSON timeline template.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param profileID the profile ID
|
||||
* @return the JSON timeline template
|
||||
*/
|
||||
public static String getJSONTimelineTemplate(HttpServletRequest httpServletRequest, String profileID) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
return (String) session.getAttribute(TIMELINE_JSON_TEMPLATE + profileID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JSON timeline template.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param profileID the profile ID
|
||||
* @param jsonTimelineTemplate the json timeline template
|
||||
*/
|
||||
public static void setJSONTimelineTemplate(HttpServletRequest httpServletRequest, String profileID,
|
||||
String jsonTimelineTemplate) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute(TIMELINE_JSON_TEMPLATE + profileID, jsonTimelineTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UCD for id.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param profileID the profile ID
|
||||
* @return the UCD for id
|
||||
*/
|
||||
public static UseCaseDescriptor getUCDForId(HttpServletRequest httpServletRequest, String profileID) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
return (UseCaseDescriptor) session.getAttribute(USE_CASE_DESCRIPTOR + profileID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the UCD for id.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param profileID the profile ID
|
||||
* @param ucd the ucd
|
||||
*/
|
||||
public static void setUCDForId(HttpServletRequest httpServletRequest, String profileID, UseCaseDescriptor ucd) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute(USE_CASE_DESCRIPTOR + profileID, ucd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of concessioni.
|
||||
*
|
||||
|
@ -220,35 +272,31 @@ public class SessionUtil {
|
|||
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
|
||||
throw new Exception("getListConcessioni must be revisited!!!!");
|
||||
/*
|
||||
// setting null to force reloading from service
|
||||
if (reloadFromService)
|
||||
listOfConcessioni = null;
|
||||
|
||||
if (listOfConcessioni == null) {
|
||||
listOfConcessioni = new ArrayList<Concessione>();
|
||||
LOG.info("Loading list of concessione from client mongo");
|
||||
SessionUtil.getCurrentContext(httpServletRequest, true);
|
||||
MongoServiceCommon serviceUtil = new MongoServiceCommon();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
if (concessioni != null) {
|
||||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
}
|
||||
}
|
||||
// LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni);
|
||||
session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
|
||||
LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size());
|
||||
|
||||
} else
|
||||
LOG.info("list of concessioni presents in session, using it");
|
||||
|
||||
LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
|
||||
return listOfConcessioni;
|
||||
|
||||
* // setting null to force reloading from service if (reloadFromService)
|
||||
* listOfConcessioni = null;
|
||||
*
|
||||
* if (listOfConcessioni == null) { listOfConcessioni = new
|
||||
* ArrayList<Concessione>();
|
||||
* LOG.info("Loading list of concessione from client mongo");
|
||||
* SessionUtil.getCurrentContext(httpServletRequest, true); MongoServiceCommon
|
||||
* serviceUtil = new MongoServiceCommon(); MongoConcessioni clientMongo =
|
||||
* serviceUtil.getInstanceMongoConcessioni();
|
||||
*
|
||||
* Iterator<Concessione> concessioni = clientMongo.getList(); if (concessioni !=
|
||||
* null) { while (concessioni.hasNext()) { Concessione concessione =
|
||||
* (Concessione) concessioni.next(); listOfConcessioni.add(concessione);
|
||||
*
|
||||
* } } // LOG.debug("Got list of concessioni from client mongo: " +
|
||||
* listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI,
|
||||
* listOfConcessioni);
|
||||
* LOG.info("Saved in session list of concessioni from client mongo with size: "
|
||||
* + listOfConcessioni.size());
|
||||
*
|
||||
* } else LOG.info("list of concessioni presents in session, using it");
|
||||
*
|
||||
* LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
|
||||
* return listOfConcessioni;
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -275,7 +323,6 @@ public class SessionUtil {
|
|||
session.setAttribute(GNA_DATAVIEWER_CONFIG_PROFILE, gNADVConfigProfile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the total document for profile ID.
|
||||
*
|
||||
|
@ -302,4 +349,5 @@ public class SessionUtil {
|
|||
session.setAttribute(COUNT_DOCS_FOR_PROFILE_ID + theProfileID, countForProfileId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue