Updates for debugging and some refactoring
This commit is contained in:
parent
c2f61655a2
commit
31196ff024
2 changed files with 79 additions and 59 deletions
|
@ -201,11 +201,12 @@ public class JsonServlet extends VitroHttpServlet {
|
|||
try{
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
VClass vclass=null;
|
||||
|
||||
log.info("Retrieving solr individuals by vclasses");
|
||||
// Could have multiple vclass ids sent in
|
||||
String[] vitroClassIdStr = vreq.getParameterValues("vclassId");
|
||||
if ( vitroClassIdStr != null && vitroClassIdStr.length > 0){
|
||||
for(String vclassId: vitroClassIdStr) {
|
||||
log.info("Using VClass " + vclassId);
|
||||
vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vclassId);
|
||||
if (vclass == null) {
|
||||
log.debug("Couldn't retrieve vclass ");
|
||||
|
@ -254,6 +255,7 @@ public class JsonServlet extends VitroHttpServlet {
|
|||
|
||||
//Including version for Solr query for Vclass Intersections
|
||||
private static Map<String,Object> getSolrVClassIntersectionResults(List<String> vclassURIs, VitroRequest vreq, ServletContext context){
|
||||
log.info("Retrieving Solr intersection results for " + vclassURIs.toString());
|
||||
String alpha = IndividualListController.getAlphaParameter(vreq);
|
||||
int page = IndividualListController.getPageParameter(vreq);
|
||||
Map<String,Object> map = null;
|
||||
|
|
|
@ -37,20 +37,33 @@ public class IndividualsForClassesDataGetter implements PageDataGetter{
|
|||
//This is the old technique of getting class intersections
|
||||
Map<String, List<String>> classIntersectionsMap = vreq.getWebappDaoFactory().getPageDao().getClassesAndRestrictionsForPage(pageUri);
|
||||
|
||||
|
||||
//Use Individual List Controller to get all the individuals and related data
|
||||
List<Individual> inds = new ArrayList<Individual>();
|
||||
try{
|
||||
List<String> classes = classIntersectionsMap.get("classes");
|
||||
List<String> restrictClasses = classIntersectionsMap.get("restrictClasses");
|
||||
//Get vclass group
|
||||
//Anonymous vclass group
|
||||
log.debug("Retrieving classes for " + classes.toString() + " and restricting by " + restrictClasses.toString());
|
||||
processClassesAndRestrictions(vreq, context, data, classes, restrictClasses);
|
||||
//Also add data service url
|
||||
//Hardcoding for now, need a more dynamic way of doing this
|
||||
data.put("dataServiceUrlIndividualsByVClass", this.getDataServiceUrl());
|
||||
} catch(Exception ex) {
|
||||
log.error("An error occurred retrieving Vclass Intersection individuals", ex);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
protected void processClassesAndRestrictions(VitroRequest vreq, ServletContext context,
|
||||
HashMap<String, Object> data, List<String> classes, List<String> restrictClasses ) {
|
||||
processClassesForDisplay(context, data, classes);
|
||||
processRestrictionClasses(vreq, context, data, restrictClasses);
|
||||
}
|
||||
|
||||
private void processClassesForDisplay(ServletContext context, HashMap<String, Object> data, List<String> classes) {
|
||||
VClassGroup classesGroup = new VClassGroup();
|
||||
classesGroup.setURI("displayClasses");
|
||||
VClassGroup restrictClassesGroup = new VClassGroup();
|
||||
restrictClassesGroup.setURI("restrictClasses");
|
||||
|
||||
List<VClass> vClasses = new ArrayList<VClass>();
|
||||
List<VClass> restrictVClasses = new ArrayList<VClass>();
|
||||
|
||||
VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(context);
|
||||
for(String classUri: classes) {
|
||||
//VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
||||
|
@ -67,15 +80,25 @@ public class IndividualsForClassesDataGetter implements PageDataGetter{
|
|||
}
|
||||
}
|
||||
classesGroup.setVitroClassList(vClasses);
|
||||
//What is individual count? Total?
|
||||
//classesGroup.setIndividualCount(vClasses.size());
|
||||
//Set vclass group
|
||||
data.put("vClassGroup", classesGroup);
|
||||
}
|
||||
|
||||
private void processRestrictionClasses(VitroRequest vreq, ServletContext context,
|
||||
HashMap<String, Object> data, List<String> restrictClasses) {
|
||||
try {
|
||||
VClassGroup restrictClassesGroup = new VClassGroup();
|
||||
restrictClassesGroup.setURI("restrictClasses");
|
||||
|
||||
List<VClass> restrictVClasses = new ArrayList<VClass>();
|
||||
|
||||
List<String> urlEncodedRestrictClasses = new ArrayList<String>();
|
||||
if(restrictClasses.size() > 0) {
|
||||
//classes for restriction are not displayed so don't need to include their class individual counts
|
||||
for(String restrictClassUri: restrictClasses) {
|
||||
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(restrictClassUri);
|
||||
if(vclass != null) {
|
||||
log.debug("Found restrict class and adding to list " + restrictClassUri);
|
||||
restrictVClasses.add(vclass);
|
||||
} else {
|
||||
log.error("Error occurred, vclass does not exist for this uri " + restrictClassUri);
|
||||
|
@ -97,14 +120,9 @@ public class IndividualsForClassesDataGetter implements PageDataGetter{
|
|||
data.put("restrictVClasses", restrictVClasses);
|
||||
//not sure if this is useful
|
||||
data.put("restrictVClassGroup", restrictClassesGroup);
|
||||
//Also add data service url
|
||||
//Hardcoding for now, need a more dynamic way of doing this
|
||||
data.put("dataServiceUrlIndividualsByVClass", this.getDataServiceUrl());
|
||||
} catch(Exception ex) {
|
||||
log.error("An error occurred retrieving Vclass Intersection individuals", ex);
|
||||
log.error("An error occurred in processing restriction classes ", ex);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static VClassGroupTemplateModel getClassGroup(String classGroupUri, ServletContext context, VitroRequest vreq){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue