[VIVO-1245] Cleanup Template Model classes
This commit is contained in:
parent
0e37b6a69e
commit
f3b66a9d42
12 changed files with 66 additions and 12 deletions
|
@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -100,7 +101,7 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
|
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
|
||||||
if (inds != null) {
|
if (inds != null) {
|
||||||
for ( Individual ind : inds ) {
|
for ( Individual ind : inds ) {
|
||||||
indsTm.add(new ListedIndividual(ind,vreq));
|
indsTm.add(ListedIndividualBuilder.build(ind,vreq));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body.put("individuals", indsTm);
|
body.put("individuals", indsTm);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -268,7 +269,7 @@ class IndividualResponseBuilder {
|
||||||
private IndividualTemplateModel getIndividualTemplateModel(
|
private IndividualTemplateModel getIndividualTemplateModel(
|
||||||
Individual individual) {
|
Individual individual) {
|
||||||
//individual.sortForDisplay();
|
//individual.sortForDisplay();
|
||||||
return new IndividualTemplateModel(individual, vreq);
|
return IndividualTemplateModelBuilder.build(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateModel wrap(Object obj, BeansWrapper wrapper) throws TemplateModelException {
|
private TemplateModel wrap(Object obj, BeansWrapper wrapper) throws TemplateModelException {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -72,7 +73,7 @@ public class GetRandomSearchIndividualsByVClass extends GetSearchIndividualsByVC
|
||||||
|
|
||||||
Map<String, Object> modelMap = new HashMap<String, Object>();
|
Map<String, Object> modelMap = new HashMap<String, Object>();
|
||||||
modelMap.put("individual",
|
modelMap.put("individual",
|
||||||
new IndividualTemplateModel(individual, vreq));
|
IndividualTemplateModelBuilder.build(individual, vreq));
|
||||||
modelMap.put("vclass", vclassName);
|
modelMap.put("vclass", vclassName);
|
||||||
|
|
||||||
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -80,7 +81,7 @@ public class GetRenderedSearchIndividualsByVClass extends GetSearchIndividualsBy
|
||||||
|
|
||||||
Map<String, Object> modelMap = new HashMap<String, Object>();
|
Map<String, Object> modelMap = new HashMap<String, Object>();
|
||||||
modelMap.put("individual",
|
modelMap.put("individual",
|
||||||
new IndividualTemplateModel(individual, vreq));
|
IndividualTemplateModelBuilder.build(individual, vreq));
|
||||||
modelMap.put("vclass", vclassName);
|
modelMap.put("vclass", vclassName);
|
||||||
|
|
||||||
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -174,7 +175,7 @@ public class BrowseDataGetter extends DataGetterBase implements DataGetter {
|
||||||
|
|
||||||
List<ListedIndividual> tInds = new ArrayList<ListedIndividual>(inds.size());
|
List<ListedIndividual> tInds = new ArrayList<ListedIndividual>(inds.size());
|
||||||
for( Individual ind : inds){
|
for( Individual ind : inds){
|
||||||
tInds.add(new ListedIndividual(ind, vreq));
|
tInds.add(ListedIndividualBuilder.build(ind, vreq));
|
||||||
}
|
}
|
||||||
map.put("individualsInClass", tInds);
|
map.put("individualsInClass", tInds);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -183,7 +184,7 @@ public class SearchIndividualsDataGetter extends DataGetterBase implements DataG
|
||||||
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
|
List<ListedIndividual> indsTm = new ArrayList<ListedIndividual>();
|
||||||
if (inds != null) {
|
if (inds != null) {
|
||||||
for ( Individual ind : inds ) {
|
for ( Individual ind : inds ) {
|
||||||
indsTm.add(new ListedIndividual(ind,vreq));
|
indsTm.add(ListedIndividualBuilder.build(ind,vreq));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body.put("individuals", indsTm);
|
body.put("individuals", indsTm);
|
||||||
|
|
|
@ -12,8 +12,7 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(IndividualTemplateModel.class);
|
private static final Log log = LogFactory.getLog(IndividualTemplateModel.class);
|
||||||
|
|
||||||
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||||
super(individual, vreq);
|
super(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
|
||||||
|
|
||||||
|
public class IndividualTemplateModelBuilder {
|
||||||
|
static IIndividualTemplateModelBuilder customBuilder = null;
|
||||||
|
|
||||||
|
static public IndividualTemplateModel build(Individual individual, VitroRequest vreq) {
|
||||||
|
if (customBuilder != null) {
|
||||||
|
return customBuilder.build(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new IndividualTemplateModel(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void setCustomBuilder(IIndividualTemplateModelBuilder builder) {
|
||||||
|
customBuilder = builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IIndividualTemplateModelBuilder {
|
||||||
|
public IndividualTemplateModel build(Individual individual, VitroRequest vreq);
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@ public abstract class BaseListedIndividual extends BaseTemplateModel {
|
||||||
public static List<ListedIndividual> getIndividualTemplateModels(List<Individual> individuals, VitroRequest vreq) {
|
public static List<ListedIndividual> getIndividualTemplateModels(List<Individual> individuals, VitroRequest vreq) {
|
||||||
List<ListedIndividual> models = new ArrayList<ListedIndividual>(individuals.size());
|
List<ListedIndividual> models = new ArrayList<ListedIndividual>(individuals.size());
|
||||||
for (Individual individual : individuals) {
|
for (Individual individual : individuals) {
|
||||||
models.add(new ListedIndividual(individual, vreq));
|
models.add(ListedIndividualBuilder.build(individual, vreq));
|
||||||
}
|
}
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,7 @@ public class ListedIndividual extends BaseListedIndividual {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ListedIndividual.class);
|
private static final Log log = LogFactory.getLog(ListedIndividual.class);
|
||||||
|
|
||||||
public ListedIndividual(Individual individual, VitroRequest vreq) {
|
ListedIndividual(Individual individual, VitroRequest vreq) {
|
||||||
super(individual, vreq);
|
super(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
|
||||||
|
public class ListedIndividualBuilder {
|
||||||
|
static ILIstedIndividualBuilder customBuilder = null;
|
||||||
|
|
||||||
|
static public ListedIndividual build(Individual individual, VitroRequest vreq) {
|
||||||
|
if (customBuilder != null) {
|
||||||
|
return customBuilder.build(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ListedIndividual(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void setCustomBuilder(ILIstedIndividualBuilder builder) {
|
||||||
|
customBuilder = builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ILIstedIndividualBuilder {
|
||||||
|
public ListedIndividual build(Individual individual, VitroRequest vreq);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import java.util.Map;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -163,7 +164,7 @@ public class BrowseWidget extends Widget {
|
||||||
|
|
||||||
List<ListedIndividual> tInds = new ArrayList<ListedIndividual>(inds.size());
|
List<ListedIndividual> tInds = new ArrayList<ListedIndividual>(inds.size());
|
||||||
for( Individual ind : inds){
|
for( Individual ind : inds){
|
||||||
tInds.add(new ListedIndividual(ind, vreq));
|
tInds.add(ListedIndividualBuilder.build(ind, vreq));
|
||||||
}
|
}
|
||||||
map.put("individualsInClass", tInds);
|
map.put("individualsInClass", tInds);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue