NIHVIVO-3746 Change DataGetter.getData() so it doesn't require VitroRequest. Modify implementations of DataGetter to conform.
This commit is contained in:
parent
a26f0c2809
commit
3250efd091
10 changed files with 87 additions and 73 deletions
|
@ -31,7 +31,7 @@ public class HomePageController extends FreemarkerHttpServlet {
|
||||||
List<DataGetter> dgList = DataGetterUtils.getDataGettersForPage(vreq, vreq.getDisplayModel(), DisplayVocabulary.HOME_PAGE_URI);
|
List<DataGetter> dgList = DataGetterUtils.getDataGettersForPage(vreq, vreq.getDisplayModel(), DisplayVocabulary.HOME_PAGE_URI);
|
||||||
|
|
||||||
for( DataGetter dg : dgList){
|
for( DataGetter dg : dgList){
|
||||||
Map<String,Object> moreData = dg.getData(getServletContext(),vreq,body);
|
Map<String,Object> moreData = dg.getData(body);
|
||||||
if( moreData != null ){
|
if( moreData != null ){
|
||||||
body.putAll(moreData);
|
body.putAll(moreData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
||||||
//TODO: Change so that instantiation here occurs correctly <-- how should data getter be instantiated
|
//TODO: Change so that instantiation here occurs correctly <-- how should data getter be instantiated
|
||||||
DataGetter pg = DataGetterUtils.dataGetterForURI(vreq, vreq.getDisplayModel(), dataGetterURI);
|
DataGetter pg = DataGetterUtils.dataGetterForURI(vreq, vreq.getDisplayModel(), dataGetterURI);
|
||||||
//TODO: Check template data variable and what that is?
|
//TODO: Check template data variable and what that is?
|
||||||
Map<String, Object> pageData = pg.getData(getServletContext(), vreq, templateData);
|
Map<String, Object> pageData = pg.getData(templateData);
|
||||||
//Map<String, Object> pageInfo = vreq.getWebappDaoFactory().getPageDao().getPage(pageURI);
|
//Map<String, Object> pageInfo = vreq.getWebappDaoFactory().getPageDao().getPage(pageURI);
|
||||||
SelectDataGetterUtils.processAndRetrieveData(vreq, getServletContext(), pageData, className, templateData);
|
SelectDataGetterUtils.processAndRetrieveData(vreq, getServletContext(), pageData, className, templateData);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class PageController extends FreemarkerHttpServlet{
|
||||||
|
|
||||||
//executePageDataGetters( pageUri, vreq, getServletContext(), mapForTemplate );
|
//executePageDataGetters( pageUri, vreq, getServletContext(), mapForTemplate );
|
||||||
//these should all be data getters now
|
//these should all be data getters now
|
||||||
executeDataGetters( pageUri, vreq, getServletContext(), mapForTemplate);
|
executeDataGetters( pageUri, vreq, mapForTemplate);
|
||||||
|
|
||||||
mapForTemplate.putAll( getPageControllerValues( pageUri, vreq, getServletContext(), mapForTemplate));
|
mapForTemplate.putAll( getPageControllerValues( pageUri, vreq, getServletContext(), mapForTemplate));
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ public class PageController extends FreemarkerHttpServlet{
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeDataGetters(String pageUri, VitroRequest vreq, ServletContext context, Map<String, Object> mapForTemplate)
|
private void executeDataGetters(String pageUri, VitroRequest vreq, Map<String, Object> mapForTemplate)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
List<DataGetter> dgList = DataGetterUtils.getDataGettersForPage(vreq, vreq.getDisplayModel(), pageUri);
|
List<DataGetter> dgList = DataGetterUtils.getDataGettersForPage(vreq, vreq.getDisplayModel(), pageUri);
|
||||||
|
|
||||||
for( DataGetter dg : dgList){
|
for( DataGetter dg : dgList){
|
||||||
Map<String,Object> moreData = dg.getData(context,vreq,mapForTemplate);
|
Map<String,Object> moreData = dg.getData(mapForTemplate);
|
||||||
if( moreData != null ){
|
if( moreData != null ){
|
||||||
mapForTemplate.putAll(moreData);
|
mapForTemplate.putAll(moreData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,13 @@ public class FakeApplicationOntologyService {
|
||||||
* Return the template name and DataGetter instances associated with this
|
* Return the template name and DataGetter instances associated with this
|
||||||
* class and this short view context. If none, return null.
|
* class and this short view context. If none, return null.
|
||||||
*/
|
*/
|
||||||
public TemplateAndDataGetters getShortViewProperties(WebappDaoFactory wadf,
|
public TemplateAndDataGetters getShortViewProperties(VitroRequest vreq,
|
||||||
Individual individual, String classUri, String contextName) {
|
Individual individual, String classUri, String contextName) {
|
||||||
if ((BROWSE.name().equals(contextName))
|
if ((BROWSE.name().equals(contextName))
|
||||||
&& (isClassInPeopleClassGroup(wadf, classUri))) {
|
&& (isClassInPeopleClassGroup(vreq.getWebappDaoFactory(),
|
||||||
|
classUri))) {
|
||||||
return new TemplateAndDataGetters("view-browse-people.ftl",
|
return new TemplateAndDataGetters("view-browse-people.ftl",
|
||||||
new FakeVivoPeopleDataGetter(individual.getURI()));
|
new FakeVivoPeopleDataGetter(vreq, individual.getURI()));
|
||||||
}
|
}
|
||||||
// A mockup of Tammy's use case.
|
// A mockup of Tammy's use case.
|
||||||
// if ((SEARCH.name().equals(contextName))
|
// if ((SEARCH.name().equals(contextName))
|
||||||
|
@ -117,8 +118,7 @@ public class FakeApplicationOntologyService {
|
||||||
|
|
||||||
private static class FakeFacultyDataGetter implements DataGetter {
|
private static class FakeFacultyDataGetter implements DataGetter {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context,
|
public Map<String, Object> getData(Map<String, Object> valueMap) {
|
||||||
VitroRequest vreq, Map<String, Object> valueMap) {
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
Map<String, Object> extras = new HashMap<String, Object>();
|
Map<String, Object> extras = new HashMap<String, Object>();
|
||||||
extras.put("departmentName", "Department of Redundancy Department");
|
extras.put("departmentName", "Department of Redundancy Department");
|
||||||
|
@ -156,19 +156,22 @@ public class FakeApplicationOntologyService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String individualUri;
|
private String individualUri;
|
||||||
|
private VitroRequest vreq;
|
||||||
|
private ServletContext ctx;
|
||||||
|
|
||||||
public FakeVivoPeopleDataGetter(String individualUri) {
|
public FakeVivoPeopleDataGetter(VitroRequest vreq, String individualUri) {
|
||||||
super(fakeDisplayModel, "http://FakeVivoPeopleDataGetter");
|
super(vreq, fakeDisplayModel, "http://FakeVivoPeopleDataGetter");
|
||||||
this.individualUri = individualUri;
|
this.individualUri = individualUri;
|
||||||
|
this.vreq = vreq;
|
||||||
|
this.ctx = vreq.getSession().getServletContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context,
|
public Map<String, Object> getData(Map<String, Object> pageData) {
|
||||||
VitroRequest vreq, Map<String, Object> pageData) {
|
|
||||||
Map<String, String[]> parms = new HashMap<String, String[]>();
|
Map<String, String[]> parms = new HashMap<String, String[]>();
|
||||||
parms.put("uri", new String[] { individualUri });
|
parms.put("uri", new String[] { individualUri });
|
||||||
|
|
||||||
return doQuery(parms, getModel(context, vreq, null));
|
return doQuery(parms, getModel(ctx, vreq, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -80,7 +78,7 @@ public class ShortViewServiceImpl implements ShortViewService {
|
||||||
ShortViewContext svContext, VitroRequest vreq) {
|
ShortViewContext svContext, VitroRequest vreq) {
|
||||||
TemplateAndDataGetters tdg = fetchTemplateAndDataGetters(individual,
|
TemplateAndDataGetters tdg = fetchTemplateAndDataGetters(individual,
|
||||||
svContext, vreq);
|
svContext, vreq);
|
||||||
Map<String, Object> gotData = runDataGetters(tdg.getDataGetters(), vreq);
|
Map<String, Object> gotData = runDataGetters(tdg.getDataGetters());
|
||||||
return new TemplateAndSupplementalDataImpl(tdg.getTemplateName(),
|
return new TemplateAndSupplementalDataImpl(tdg.getTemplateName(),
|
||||||
gotData);
|
gotData);
|
||||||
}
|
}
|
||||||
|
@ -103,9 +101,8 @@ public class ShortViewServiceImpl implements ShortViewService {
|
||||||
classUris.addAll(figureMostSpecificClassUris(individual));
|
classUris.addAll(figureMostSpecificClassUris(individual));
|
||||||
|
|
||||||
for (String classUri : classUris) {
|
for (String classUri : classUris) {
|
||||||
TemplateAndDataGetters tdg = faker.getShortViewProperties(
|
TemplateAndDataGetters tdg = faker.getShortViewProperties(vreq,
|
||||||
vreq.getWebappDaoFactory(), individual, classUri,
|
individual, classUri, svContext.name());
|
||||||
svContext.name());
|
|
||||||
if (tdg != null) {
|
if (tdg != null) {
|
||||||
return tdg;
|
return tdg;
|
||||||
}
|
}
|
||||||
|
@ -116,13 +113,10 @@ public class ShortViewServiceImpl implements ShortViewService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build a data map from the combined results of all data getters. */
|
/** Build a data map from the combined results of all data getters. */
|
||||||
private Map<String, Object> runDataGetters(Set<DataGetter> dataGetters,
|
private Map<String, Object> runDataGetters(Set<DataGetter> dataGetters) {
|
||||||
VitroRequest vreq) {
|
|
||||||
ServletContext ctx = vreq.getSession().getServletContext();
|
|
||||||
|
|
||||||
Map<String, Object> gotData = new HashMap<String, Object>();
|
Map<String, Object> gotData = new HashMap<String, Object>();
|
||||||
for (DataGetter dg : dataGetters) {
|
for (DataGetter dg : dataGetters) {
|
||||||
gotData.putAll(dg.getData(ctx, vreq, EMPTY_MAP));
|
gotData.putAll(dg.getData(EMPTY_MAP));
|
||||||
}
|
}
|
||||||
return gotData;
|
return gotData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,28 +34,34 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.Listed
|
||||||
public class BrowseDataGetter extends DataGetterBase implements DataGetter {
|
public class BrowseDataGetter extends DataGetterBase implements DataGetter {
|
||||||
final static Log log = LogFactory.getLog(BrowseDataGetter.class);
|
final static Log log = LogFactory.getLog(BrowseDataGetter.class);
|
||||||
String dataGetterURI;
|
String dataGetterURI;
|
||||||
|
VitroRequest vreq;
|
||||||
|
ServletContext context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* Constructor with display model and data getter URI that will be called by reflection.
|
||||||
*/
|
*/
|
||||||
public BrowseDataGetter(Model displayModel, String dataGetterURI){
|
public BrowseDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
||||||
this.configure(displayModel,dataGetterURI);
|
this.configure(vreq, displayModel,dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this instance based on the URI and display model.
|
* Configure this instance based on the URI and display model.
|
||||||
*/
|
*/
|
||||||
protected void configure(Model displayModel, String dataGetterURI) {
|
protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) {
|
||||||
|
if( vreq == null )
|
||||||
|
throw new IllegalArgumentException("VitroRequest may not be null.");
|
||||||
if( displayModel == null )
|
if( displayModel == null )
|
||||||
throw new IllegalArgumentException("Display Model may not be null.");
|
throw new IllegalArgumentException("Display Model may not be null.");
|
||||||
if( dataGetterURI == null )
|
if( dataGetterURI == null )
|
||||||
throw new IllegalArgumentException("PageUri may not be null.");
|
throw new IllegalArgumentException("PageUri may not be null.");
|
||||||
|
|
||||||
this.dataGetterURI = dataGetterURI;
|
this.vreq = vreq;
|
||||||
|
this.context = vreq.getSession().getServletContext();
|
||||||
|
this.dataGetterURI = dataGetterURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context, VitroRequest vreq, Map<String, Object> pageData) {
|
public Map<String, Object> getData(Map<String, Object> pageData) {
|
||||||
try{
|
try{
|
||||||
Map params = vreq.getParameterMap();
|
Map params = vreq.getParameterMap();
|
||||||
|
|
||||||
|
|
|
@ -32,29 +32,36 @@ public class ClassGroupPageData extends DataGetterBase implements DataGetter{
|
||||||
private static final Log log = LogFactory.getLog(ClassGroupPageData.class);
|
private static final Log log = LogFactory.getLog(ClassGroupPageData.class);
|
||||||
String dataGetterURI;
|
String dataGetterURI;
|
||||||
String classGroupUri;
|
String classGroupUri;
|
||||||
|
VitroRequest vreq;
|
||||||
|
ServletContext context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* Constructor with display model and data getter URI that will be called by reflection.
|
||||||
*/
|
*/
|
||||||
public ClassGroupPageData(Model displayModel, String dataGetterURI){
|
public ClassGroupPageData(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
||||||
this.configure(displayModel,dataGetterURI);
|
this.configure(vreq, displayModel,dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this instance based on the URI and display model.
|
* Configure this instance based on the URI and display model.
|
||||||
*/
|
*/
|
||||||
protected void configure(Model displayModel, String dataGetterURI) {
|
protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) {
|
||||||
|
if( vreq == null )
|
||||||
|
throw new IllegalArgumentException("VitroRequest may not be null.");
|
||||||
if( displayModel == null )
|
if( displayModel == null )
|
||||||
throw new IllegalArgumentException("Display Model may not be null.");
|
throw new IllegalArgumentException("Display Model may not be null.");
|
||||||
if( dataGetterURI == null )
|
if( dataGetterURI == null )
|
||||||
throw new IllegalArgumentException("PageUri may not be null.");
|
throw new IllegalArgumentException("PageUri may not be null.");
|
||||||
|
|
||||||
|
this.vreq = vreq;
|
||||||
|
this.context = vreq.getSession().getServletContext();
|
||||||
this.dataGetterURI = dataGetterURI;
|
this.dataGetterURI = dataGetterURI;
|
||||||
this.classGroupUri = DataGetterUtils.getClassGroupForDataGetter(displayModel, dataGetterURI);
|
this.classGroupUri = DataGetterUtils.getClassGroupForDataGetter(displayModel, dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context, VitroRequest vreq, Map<String, Object> pageData) {
|
public Map<String, Object> getData(Map<String, Object> pageData) {
|
||||||
HashMap<String, Object> data = new HashMap<String,Object>();
|
HashMap<String, Object> data = new HashMap<String,Object>();
|
||||||
data.put("classGroupUri", this.classGroupUri);
|
data.put("classGroupUri", this.classGroupUri);
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,21 @@ package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to get data based on configurations in RDF. These are useful for pages bug not specific to pages.
|
* A class to get data based on configurations in RDF. These are useful for pages bug not specific to pages.
|
||||||
* Consider using this interface when you need data based on RDF configuration.
|
* Consider using this interface when you need data based on RDF configuration.
|
||||||
*
|
*
|
||||||
|
* Instances should be short-lived, and only used on a single HTTP request. The getData method accepts only
|
||||||
|
* a value map, so if stat is required from the request (or the servlet context), the request should be
|
||||||
|
* passed to the constructor.
|
||||||
|
*
|
||||||
|
* Constructors: Objects that implement this interface will be constructed by reflection with the following
|
||||||
|
* constructor signatures in the following order:
|
||||||
|
* DataGetter( VitroRequest vreq, Model displayModel, String dataGetterURI )
|
||||||
|
* DataGetter( Model displayModel, String dataGetterURI )
|
||||||
|
* DataGetter( VitroRequest vreq )
|
||||||
|
* DataGetter()
|
||||||
|
*
|
||||||
* The main difference between this and PageDataGetter is that these are configured not based on page URI
|
* The main difference between this and PageDataGetter is that these are configured not based on page URI
|
||||||
* but on DataGetter URI. This allows a configuration of a DataGetter to be used in multiple situations.
|
* but on DataGetter URI. This allows a configuration of a DataGetter to be used in multiple situations.
|
||||||
* The DataGetter is not passed information about what page it might be associated with.
|
* The DataGetter is not passed information about what page it might be associated with.
|
||||||
|
@ -20,22 +25,18 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
* Using this interface is preferred over PageDataGetter because then the DataGetter can be associated with
|
* Using this interface is preferred over PageDataGetter because then the DataGetter can be associated with
|
||||||
* things other than pages.
|
* things other than pages.
|
||||||
*
|
*
|
||||||
* Constructors: Objects that implement this interface will be constructed by reflection with the following
|
|
||||||
* constructor signatures in the following order:
|
|
||||||
* DataGetter( Model displayModel, String dataGetterURI )
|
|
||||||
* DataGetter()
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface DataGetter {
|
public interface DataGetter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data. Throwing an Exception is acceptable.
|
* Get data. Throwing an Exception is acceptable.
|
||||||
*
|
*
|
||||||
* @param context - servlet context to get state from
|
* @param valueMap
|
||||||
* @param vreq - request to get state from
|
* any values already generated by data getters or the controller.
|
||||||
* @param valueMap - any values already generated by data getters or the controller.
|
* Might be immutable, and should not be modified within the method.
|
||||||
* @return data to add to valueMap. Should not be null.
|
*
|
||||||
*/
|
* @return data to add to valueMap. Might be empty, but should not be null.
|
||||||
Map<String,Object> getData(ServletContext context, VitroRequest vreq, Map<String, Object> valueMap );
|
*/
|
||||||
|
Map<String,Object> getData( Map<String, Object> valueMap );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -17,30 +16,21 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Query;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
import com.hp.hpl.jena.query.QuerySolutionMap;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
|
||||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
||||||
|
|
||||||
|
@ -52,6 +42,8 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateMo
|
||||||
public class IndividualsForClassesDataGetter extends DataGetterBase implements DataGetter{
|
public class IndividualsForClassesDataGetter extends DataGetterBase implements DataGetter{
|
||||||
private static final Log log = LogFactory.getLog(IndividualsForClassesDataGetter.class);
|
private static final Log log = LogFactory.getLog(IndividualsForClassesDataGetter.class);
|
||||||
protected static String restrictClassesTemplateName = null;
|
protected static String restrictClassesTemplateName = null;
|
||||||
|
VitroRequest vreq;
|
||||||
|
ServletContext context;
|
||||||
String dataGetterURI;
|
String dataGetterURI;
|
||||||
String classGroupURI;
|
String classGroupURI;
|
||||||
Map<String, Object> classIntersectionsMap;
|
Map<String, Object> classIntersectionsMap;
|
||||||
|
@ -59,19 +51,23 @@ public class IndividualsForClassesDataGetter extends DataGetterBase implements D
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* Constructor with display model and data getter URI that will be called by reflection.
|
||||||
*/
|
*/
|
||||||
public IndividualsForClassesDataGetter(Model displayModel, String dataGetterURI){
|
public IndividualsForClassesDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
||||||
this.configure(displayModel,dataGetterURI);
|
this.configure(vreq,displayModel,dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this instance based on the URI and display model.
|
* Configure this instance based on the URI and display model.
|
||||||
*/
|
*/
|
||||||
protected void configure(Model displayModel, String dataGetterURI) {
|
protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) {
|
||||||
|
if( vreq == null )
|
||||||
|
throw new IllegalArgumentException("VitroRequest may not be null.");
|
||||||
if( displayModel == null )
|
if( displayModel == null )
|
||||||
throw new IllegalArgumentException("Display Model may not be null.");
|
throw new IllegalArgumentException("Display Model may not be null.");
|
||||||
if( dataGetterURI == null )
|
if( dataGetterURI == null )
|
||||||
throw new IllegalArgumentException("PageUri may not be null.");
|
throw new IllegalArgumentException("PageUri may not be null.");
|
||||||
|
|
||||||
|
this.vreq = vreq;
|
||||||
|
this.context = vreq.getSession().getServletContext();
|
||||||
this.dataGetterURI = dataGetterURI;
|
this.dataGetterURI = dataGetterURI;
|
||||||
this.classGroupURI = DataGetterUtils.getClassGroupForDataGetter(displayModel, dataGetterURI);
|
this.classGroupURI = DataGetterUtils.getClassGroupForDataGetter(displayModel, dataGetterURI);
|
||||||
this.classIntersectionsMap = getClassIntersectionsMap(displayModel);
|
this.classIntersectionsMap = getClassIntersectionsMap(displayModel);
|
||||||
|
@ -122,7 +118,7 @@ public class IndividualsForClassesDataGetter extends DataGetterBase implements D
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context, VitroRequest vreq, Map<String, Object> pageData) {
|
public Map<String, Object> getData(Map<String, Object> pageData) {
|
||||||
this.setTemplateName();
|
this.setTemplateName();
|
||||||
HashMap<String, Object> data = new HashMap<String,Object>();
|
HashMap<String, Object> data = new HashMap<String,Object>();
|
||||||
|
|
||||||
|
|
|
@ -35,30 +35,37 @@ public class SparqlQueryDataGetter extends DataGetterBase implements DataGetter{
|
||||||
String queryText;
|
String queryText;
|
||||||
String saveToVar;
|
String saveToVar;
|
||||||
String modelURI;
|
String modelURI;
|
||||||
|
VitroRequest vreq;
|
||||||
|
ServletContext context;
|
||||||
|
|
||||||
|
|
||||||
final static Log log = LogFactory.getLog(SparqlQueryDataGetter.class);
|
final static Log log = LogFactory.getLog(SparqlQueryDataGetter.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with display model and data getter URI that will be called by reflection.
|
* Constructor with display model and data getter URI that will be called by reflection.
|
||||||
*/
|
*/
|
||||||
public SparqlQueryDataGetter(Model displayModel, String dataGetterURI){
|
public SparqlQueryDataGetter(VitroRequest vreq, Model displayModel, String dataGetterURI){
|
||||||
this.configure(displayModel,dataGetterURI);
|
this.configure(vreq, displayModel,dataGetterURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getData(ServletContext context, VitroRequest vreq, Map<String, Object> pageData) {
|
public Map<String, Object> getData(Map<String, Object> pageData) {
|
||||||
return doQuery( vreq.getParameterMap(), getModel(context, vreq, modelURI));
|
return doQuery( vreq.getParameterMap(), getModel(context, vreq, modelURI));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure this instance based on the URI and display model.
|
* Configure this instance based on the URI and display model.
|
||||||
*/
|
*/
|
||||||
protected void configure(Model displayModel, String dataGetterURI) {
|
protected void configure(VitroRequest vreq, Model displayModel, String dataGetterURI) {
|
||||||
|
if( vreq == null )
|
||||||
|
throw new IllegalArgumentException("VitroRequest may not be null.");
|
||||||
if( displayModel == null )
|
if( displayModel == null )
|
||||||
throw new IllegalArgumentException("Display Model may not be null.");
|
throw new IllegalArgumentException("Display Model may not be null.");
|
||||||
if( dataGetterURI == null )
|
if( dataGetterURI == null )
|
||||||
throw new IllegalArgumentException("PageUri may not be null.");
|
throw new IllegalArgumentException("PageUri may not be null.");
|
||||||
|
|
||||||
|
this.vreq = vreq;
|
||||||
|
this.context = vreq.getSession().getServletContext();
|
||||||
this.dataGetterURI = dataGetterURI;
|
this.dataGetterURI = dataGetterURI;
|
||||||
|
|
||||||
QuerySolutionMap initBindings = new QuerySolutionMap();
|
QuerySolutionMap initBindings = new QuerySolutionMap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue