Merge pull request #30 from vivo-project/feature/1245-resolve-duplication
[VIVO-1245] Reduce code duplication and class overwriting in VIVO
This commit is contained in:
commit
4643a2a118
27 changed files with 410 additions and 786 deletions
|
@ -3,17 +3,16 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||
|
@ -25,7 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestA
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestAnalyzer;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestInfo;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.VIVOIndividualTemplateModel;
|
||||
import freemarker.ext.beans.BeansWrapper;
|
||||
import freemarker.template.DefaultObjectWrapper;
|
||||
|
||||
|
@ -67,7 +66,7 @@ public class ExportQrCodeController extends FreemarkerHttpServlet {
|
|||
wrapper.setExposureLevel(BeansWrapper.EXPOSE_SAFE);
|
||||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
body.put("individual", wrapper.wrap(new IndividualTemplateModel(individual, vreq)));
|
||||
body.put("individual", wrapper.wrap(IndividualTemplateModelBuilder.build(individual, vreq)));
|
||||
body.put("qrData", qrData);
|
||||
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
||||
} catch (Throwable e) {
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.controller.ajax;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.Integer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -19,21 +15,13 @@ import org.json.JSONException;
|
|||
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestAnalysisContextImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestAnalyzer;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.individual.IndividualRequestInfo;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
||||
|
||||
|
||||
public class QrCodeDetails extends AbstractAjaxResponder {
|
||||
|
|
|
@ -11,10 +11,10 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.visualization.tools.ToolsRequestHandler;
|
||||
|
||||
public class SiteAdminController extends BaseSiteAdminController {
|
||||
public class VIVOSiteAdminController extends BaseSiteAdminController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(SiteAdminController.class);
|
||||
private static final Log log = LogFactory.getLog(VIVOSiteAdminController.class);
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getSiteMaintenanceUrls(VitroRequest vreq) {
|
|
@ -1,87 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
|
||||
/**
|
||||
* Wrap an Individual in a JSON object for display by the script.
|
||||
*
|
||||
* This overrides the Vitro version so we can have more info in the display.
|
||||
*/
|
||||
public class IndividualJsonWrapper {
|
||||
private static final Log log = LogFactory
|
||||
.getLog(IndividualJsonWrapper.class);
|
||||
|
||||
private static String VCARD_DATA_QUERY = ""
|
||||
+ "PREFIX obo: <http://purl.obolibrary.org/obo/> \n"
|
||||
+ "PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> \n"
|
||||
+ "SELECT DISTINCT ?title \n" + "WHERE { \n"
|
||||
+ " ?subject obo:ARG_2000028 ?vIndividual . \n"
|
||||
+ " ?vIndividual vcard:hasTitle ?vTitle . \n"
|
||||
+ " ?vTitle vcard:title ?title . \n" + "} ";
|
||||
|
||||
static JSONObject packageIndividualAsJson(VitroRequest vreq, Individual ind)
|
||||
throws JSONException {
|
||||
// need an unfiltered dao to get firstnames and lastnames
|
||||
WebappDaoFactory fullWdf = vreq.getUnfilteredWebappDaoFactory();
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("URI", ind.getURI());
|
||||
jo.put("label", ind.getRdfsLabel());
|
||||
jo.put("name", ind.getName());
|
||||
jo.put("thumbUrl", ind.getThumbUrl());
|
||||
jo.put("imageUrl", ind.getImageUrl());
|
||||
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
|
||||
jo.put("mostSpecificTypes", getMostSpecificTypes(ind, fullWdf));
|
||||
jo.put("preferredTitle", findPreferredTitle(vreq, ind));
|
||||
return jo;
|
||||
}
|
||||
|
||||
private static String findPreferredTitle(VitroRequest vreq, Individual ind) {
|
||||
String queryStr = QueryUtils.subUriForQueryVar(VCARD_DATA_QUERY,
|
||||
"subject", ind.getURI());
|
||||
log.debug("queryStr = " + queryStr);
|
||||
String value = "";
|
||||
try {
|
||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
String t = QueryUtils.nodeToString(soln.get("title"));
|
||||
if (StringUtils.isNotBlank(t)) {
|
||||
value = t;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Collection<String> getMostSpecificTypes(
|
||||
Individual individual, WebappDaoFactory wdf) {
|
||||
ObjectPropertyStatementDao opsDao = wdf.getObjectPropertyStatementDao();
|
||||
Map<String, String> mostSpecificTypes = opsDao
|
||||
.getMostSpecificTypesInClassgroupsForIndividual(individual
|
||||
.getURI());
|
||||
return mostSpecificTypes.values();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.JspToGeneratorMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -8,6 +10,9 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
|||
public N3TransitionToV2Mapping(){
|
||||
Map<String,String> map = this;
|
||||
|
||||
map.put("defaultAddMissingIndividualForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVODefaultAddMissingIndividualFormGenerator.class.getName());
|
||||
|
||||
// vivo forms:
|
||||
|
||||
map.put("addAuthorsToInformationResource.jsp",
|
||||
|
@ -15,7 +20,7 @@ public class N3TransitionToV2Mapping extends HashMap<String, String>{
|
|||
map.put("manageWebpagesForIndividual.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator.class.getName());
|
||||
map.put("newIndividualForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.NewIndividualFormGenerator.class.getName());
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVONewIndividualFormGenerator.class.getName());
|
||||
map.put("organizationHasPositionHistory.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.OrganizationHasPositionHistoryGenerator.class.getName());
|
||||
map.put("personHasEducationalTraining.jsp",
|
||||
|
|
|
@ -36,7 +36,7 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
|||
HttpSession session) throws Exception {
|
||||
EditConfigurationVTwo editConfig = super.getEditConfiguration(vreq, session);
|
||||
//If this isn't adding a new individual, then override template/types
|
||||
if(!DefaultAddMissingIndividualFormGenerator.isCreateNewIndividual(vreq, session)) {
|
||||
if(!VIVODefaultAddMissingIndividualFormGenerator.isCreateNewIndividual(vreq, session)) {
|
||||
//return rangetypes in form specific data
|
||||
editConfig.addFormSpecificData("createNewTypes", getCreateNewTypesOptions(vreq));
|
||||
//override templates with ones that will override create new types portion
|
||||
|
|
|
@ -1,547 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.DefaultAddMissingIndividualFormModelPreprocessor;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||
|
||||
/**
|
||||
* Generates the edit configuration for a default property form.
|
||||
*
|
||||
*/
|
||||
public class DefaultAddMissingIndividualFormGenerator implements EditConfigurationGenerator {
|
||||
|
||||
private Log log = LogFactory.getLog(DefaultAddMissingIndividualFormGenerator.class);
|
||||
private boolean isObjectPropForm = false;
|
||||
private String subjectUri = null;
|
||||
private String predicateUri = null;
|
||||
private String objectUri = null;
|
||||
|
||||
private String template = "defaultAddMissingIndividualForm.ftl";
|
||||
private static String createCommand = "create";
|
||||
private static String objectVarName = "newIndividual";
|
||||
private static HashMap<String,String> defaultsForXSDtypes ;
|
||||
static {
|
||||
defaultsForXSDtypes = new HashMap<String,String>();
|
||||
//defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","2001-01-01T12:00:00");
|
||||
defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","#Unparseable datetime defaults to now");
|
||||
}
|
||||
|
||||
//Method which checks whether this particular generator should be employed
|
||||
public static boolean isCreateNewIndividual(VitroRequest vreq, HttpSession session) {
|
||||
String command = vreq.getParameter("cmd");
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
//This method also looks at domain and range uris and so is different than just getting the
|
||||
//object property based on predicate uri alone
|
||||
ObjectProperty objProp = EditConfigurationUtils.getObjectPropertyForPredicate(vreq,
|
||||
predicateUri);
|
||||
if(objProp != null) {
|
||||
return(objProp.getOfferCreateNewOption() &&
|
||||
(
|
||||
(command != null && command.equals(createCommand)) ||
|
||||
objProp.getSelectFromExisting() == false
|
||||
)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
||||
EditConfigurationVTwo editConfiguration = new EditConfigurationVTwo();
|
||||
|
||||
//process subject, predicate, object parameters
|
||||
this.initProcessParameters(vreq, session, editConfiguration);
|
||||
|
||||
//Assumes this is a simple case of subject predicate var
|
||||
editConfiguration.setN3Required(this.generateN3Required(vreq));
|
||||
|
||||
//n3 optional
|
||||
editConfiguration.setN3Optional(this.generateN3Optional(vreq));
|
||||
|
||||
|
||||
editConfiguration.setNewResources(this.generateNewResources(vreq));
|
||||
//In scope
|
||||
this.setUrisAndLiteralsInScope(editConfiguration);
|
||||
|
||||
//on Form
|
||||
this.setUrisAndLiteralsOnForm(editConfiguration, vreq);
|
||||
|
||||
editConfiguration.setFilesOnForm(new ArrayList<String>());
|
||||
|
||||
//Sparql queries
|
||||
this.setSparqlQueries(editConfiguration);
|
||||
|
||||
//set fields
|
||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
||||
|
||||
//form specific data
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
|
||||
//add preprocesoors
|
||||
addPreprocessors(vreq, editConfiguration);
|
||||
|
||||
prepareForUpdate(vreq, session, editConfiguration);
|
||||
|
||||
//Form title and submit label now moved to edit configuration template
|
||||
//TODO: check if edit configuration template correct place to set those or whether
|
||||
//additional methods here should be used and reference instead, e.g. edit configuration template could call
|
||||
//default obj property form.populateTemplate or some such method
|
||||
//Select from existing also set within template itself
|
||||
setTemplate(editConfiguration, vreq);
|
||||
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
|
||||
//edit key now set in the edit request dispatch controller
|
||||
return editConfiguration;
|
||||
}
|
||||
|
||||
private Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||
//Null triggers default namespace
|
||||
newResources.put(objectVarName, null);
|
||||
newResources.put("newVcardInd", null);
|
||||
newResources.put("newVcardName", null);
|
||||
return newResources;
|
||||
}
|
||||
//Need to replace edit key
|
||||
//TODO:Check if we need to recheck forward to create new or assume that is the case since
|
||||
//we're using this generator
|
||||
//In this case we always set a new edit key as the original jsp checked 'isForwardToCreateNew'
|
||||
//which condition would require that an entirely new edit key be created
|
||||
private void setEditKey(HttpSession session, EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
String editKey = EditConfigurationVTwo.newEditKey(session);
|
||||
editConfiguration.setEditKey(editKey);
|
||||
}
|
||||
|
||||
private void setTemplate(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq) {
|
||||
editConfiguration.setTemplate(template);
|
||||
|
||||
}
|
||||
|
||||
//Initialize setup: process parameters
|
||||
//Doesn't look like we need to set up separate processing for data property form
|
||||
private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
String formUrl = EditConfigurationUtils.getFormUrlWithoutContext(vreq);
|
||||
|
||||
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
|
||||
editConfiguration.setFormUrl(formUrl);
|
||||
|
||||
|
||||
editConfiguration.setUrlPatternToReturnTo("/individual");
|
||||
|
||||
editConfiguration.setVarNameForSubject("subject");
|
||||
editConfiguration.setSubjectUri(subjectUri);
|
||||
editConfiguration.setEntityToReturnTo(subjectUri);
|
||||
editConfiguration.setVarNameForPredicate("predicate");
|
||||
editConfiguration.setPredicateUri(predicateUri);
|
||||
|
||||
|
||||
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
|
||||
//pretends this is a data property editing statement and throws an error
|
||||
//"object" : [ "newIndividual" , "${objectUriJson}" , "URI"],
|
||||
if(EditConfigurationUtils.isObjectProperty(predicateUri, vreq)) {
|
||||
//not concerned about remainder, can move into default obj prop form if required
|
||||
this.isObjectPropForm = true;
|
||||
this.initObjectParameters(vreq);
|
||||
this.processObjectPropForm(vreq, editConfiguration);
|
||||
} else {
|
||||
log.error("Add missing individual called for a data property instead of object property");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void initObjectParameters(VitroRequest vreq) {
|
||||
//in case of object property
|
||||
String thisObjectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
if(thisObjectUri != null && !thisObjectUri.isEmpty()) {
|
||||
objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
}
|
||||
//otherwise object uri will stay null - since don't want to set it to empty string
|
||||
}
|
||||
|
||||
//this particular form uses a different var name for object "newIndividual"
|
||||
private void processObjectPropForm(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.setVarNameForObject(objectVarName);
|
||||
//If is replace with new, set Object resource to null
|
||||
if(isReplaceWithNew(vreq)) {
|
||||
editConfiguration.setObject(null);
|
||||
} else {
|
||||
editConfiguration.setObject(objectUri);
|
||||
}
|
||||
//this needs to be set for the editing to be triggered properly, otherwise the 'prepare' method
|
||||
//pretends this is a data property editing statement and throws an error
|
||||
//TODO: Check if null in case no object uri exists but this is still an object property
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Get N3 required
|
||||
//Handles both object and data property
|
||||
private List<String> generateN3Required(VitroRequest vreq) {
|
||||
List<String> n3ForEdit = new ArrayList<String>();
|
||||
n3ForEdit.add(getN3PrefixesAsString() + "\n" + getN3ForName());
|
||||
n3ForEdit.add("?subject ?predicate ?" + objectVarName + " .");
|
||||
n3ForEdit.add(getN3PrefixesAsString() + "\n" + "?" + objectVarName + " rdf:type <" + getRangeClassUri(vreq) + "> . ");
|
||||
return n3ForEdit;
|
||||
}
|
||||
|
||||
private List<String> getN3Prefixes() {
|
||||
List<String> prefixStrings = new ArrayList<String>();
|
||||
prefixStrings.add("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .");
|
||||
prefixStrings.add("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .");
|
||||
prefixStrings.add("@prefix vcard:<http://www.w3.org/2006/vcard/ns#> .");
|
||||
return prefixStrings;
|
||||
}
|
||||
|
||||
private String getN3PrefixesAsString() {
|
||||
String prefixes = StringUtils.join(getN3Prefixes(), "\n");
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
private String getN3ForName() {
|
||||
return "?" + objectVarName + " rdfs:label ?label .";
|
||||
}
|
||||
|
||||
private List<String> generateN3Optional(VitroRequest vreq) {
|
||||
//flag uri and asserted types need to be added here
|
||||
List<String> n3Optional = new ArrayList<String>();
|
||||
n3Optional.add("?" + objectVarName + " ?inverseProp ?subject .");
|
||||
//asserted types string buffer is empty in the original jsp
|
||||
//TODO: Review original comments in jsp to see what could go here
|
||||
//n3Optional.add(getN3AssertedTypes(vreq));
|
||||
n3Optional.add(getN3PrefixesAsString() + "\n" + "?" + objectVarName + " rdf:type <" + getFlagURI(vreq) + "> . ");
|
||||
n3Optional.add(getN3PrefixesAsString()
|
||||
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
||||
+ " ?newVcardInd <http://purl.obolibrary.org/obo/ARG_2000029> ?" + objectVarName + " . \n"
|
||||
+ " ?newVcardInd a vcard:Individual . \n"
|
||||
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
||||
+ " ?newVcardName a vcard:Name . \n"
|
||||
+ " ?newVcardName vcard:givenName ?firstName . \n"
|
||||
+ " ?newVcardName vcard:familyName ?lastName . \n");
|
||||
n3Optional.add(getN3PrefixesAsString()
|
||||
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
||||
+ " ?newVcardInd a vcard:Individual . \n"
|
||||
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
||||
+ " ?newVcardName a vcard:Name . \n"
|
||||
+ " ?newVcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .");
|
||||
return n3Optional;
|
||||
|
||||
}
|
||||
|
||||
private String getFlagURI(VitroRequest vreq) {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
String flagURI = wdf.getVClassDao().getTopConcept().getURI();
|
||||
return flagURI;
|
||||
}
|
||||
private String getN3AssertedTypes(VitroRequest vreq) {
|
||||
return null;
|
||||
}
|
||||
//Set queries
|
||||
private String retrieveQueryForInverse () {
|
||||
String queryForInverse = "PREFIX owl: <http://www.w3.org/2002/07/owl#>"
|
||||
+ " SELECT ?inverse_property "
|
||||
+ " WHERE { ?inverse_property owl:inverseOf ?predicate } ";
|
||||
return queryForInverse;
|
||||
}
|
||||
|
||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration) {
|
||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||
//Add subject uri and predicate turo to uris in scope
|
||||
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||
editConfiguration.setUrisInScope(urisInScope);
|
||||
editConfiguration.setLiteralsInScope(new HashMap<String, List<Literal>>());
|
||||
}
|
||||
|
||||
//n3 should look as follows
|
||||
//?subject ?predicate ?objectVar
|
||||
|
||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("label");
|
||||
literalsOnForm.add("firstName");
|
||||
literalsOnForm.add("middleName");
|
||||
literalsOnForm.add("lastName");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
|
||||
//This is for various items
|
||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration) {
|
||||
//Sparql queries defining retrieval of literals etc.
|
||||
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||
|
||||
Map<String, String> urisInScope = new HashMap<String, String>();
|
||||
urisInScope.put("inverseProp", this.retrieveQueryForInverse());
|
||||
editConfiguration.setSparqlForAdditionalUrisInScope(urisInScope);
|
||||
|
||||
editConfiguration.setSparqlForExistingLiterals(generateSparqlForExistingLiterals());
|
||||
editConfiguration.setSparqlForExistingUris(generateSparqlForExistingUris());
|
||||
}
|
||||
|
||||
|
||||
//Sparql queries
|
||||
|
||||
|
||||
private HashMap<String, String> generateSparqlForExistingUris() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
return map;
|
||||
}
|
||||
|
||||
private HashMap<String, String> generateSparqlForExistingLiterals() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
String query = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";
|
||||
query += "SELECT ?existingName WHERE { ?" + objectVarName + " rdfs:label ?existingName . }";
|
||||
map.put("name", query);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)) {
|
||||
|
||||
//make name field
|
||||
FieldVTwo labelField = new FieldVTwo();
|
||||
labelField.setName("label");
|
||||
|
||||
FieldVTwo firstNameField = new FieldVTwo();
|
||||
firstNameField.setName("firstName");
|
||||
|
||||
FieldVTwo middleNameField = new FieldVTwo();
|
||||
middleNameField.setName("middleName");
|
||||
|
||||
FieldVTwo lastNameField = new FieldVTwo();
|
||||
lastNameField.setName("lastName");
|
||||
|
||||
List<String> validators = new ArrayList<String>();
|
||||
validators.add("nonempty");
|
||||
if(!isPersonType(vreq)) {
|
||||
labelField.setValidators(validators);
|
||||
}
|
||||
if(isPersonType(vreq)) {
|
||||
firstNameField.setValidators(validators);
|
||||
lastNameField.setValidators(validators);
|
||||
}
|
||||
|
||||
fields.put(labelField.getName(), labelField);
|
||||
fields.put(firstNameField.getName(), firstNameField);
|
||||
fields.put(middleNameField.getName(), middleNameField);
|
||||
fields.put(lastNameField.getName(), lastNameField);
|
||||
|
||||
} else {
|
||||
log.error("Is not object property so fields not set");
|
||||
}
|
||||
|
||||
editConfiguration.setFields(fields);
|
||||
}
|
||||
|
||||
private String getRangeClassUri(VitroRequest vreq) {
|
||||
Individual subject = EditConfigurationUtils.getSubjectIndividual(vreq);
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
if( prop.getRangeVClassURI() == null ) {
|
||||
// If property has no explicit range, we will use e.g. owl:Thing.
|
||||
// Typically an allValuesFrom restriction will come into play later.
|
||||
VClass top = wdf.getVClassDao().getTopConcept();
|
||||
prop.setRangeVClassURI(top.getURI());
|
||||
}
|
||||
|
||||
VClass rangeClass = null;
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
if(typeOfNew != null )
|
||||
rangeClass = wdf.getVClassDao().getVClassByURI( typeOfNew );
|
||||
if( rangeClass == null ){
|
||||
rangeClass = wdf.getVClassDao().getVClassByURI(prop.getRangeVClassURI());
|
||||
if( rangeClass == null ) throw new Error ("Cannot find class for range for property. Looking for " + prop.getRangeVClassURI() );
|
||||
}
|
||||
return rangeClass.getURI();
|
||||
}
|
||||
|
||||
private void prepareForUpdate(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
//Here, retrieve model from
|
||||
OntModel model = ModelAccess.on(session.getServletContext()).getOntModel();
|
||||
//if object property
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)){
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
if(!isReplaceWithNew(vreq) &&
|
||||
(isForwardToCreateButEdit(vreq) ||
|
||||
objectIndividual != null)
|
||||
) {
|
||||
editConfiguration.prepareForObjPropUpdate(model);
|
||||
} else {
|
||||
//new object to be created
|
||||
editConfiguration.prepareForNonUpdate( model );
|
||||
}
|
||||
} else {
|
||||
log.error("Data property not object property so update can't be done correctly");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addPreprocessors(VitroRequest vreq, EditConfigurationVTwo editConfiguration) {
|
||||
if(isReplaceWithNew(vreq)) {
|
||||
//String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
//String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
//String objectUri = EditConfigurationUtils.getObjectUri(vreq);
|
||||
editConfiguration.addModelChangePreprocessor(
|
||||
new DefaultAddMissingIndividualFormModelPreprocessor(
|
||||
subjectUri, predicateUri, objectUri));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Command processing
|
||||
private boolean isTypeOfNew(VitroRequest vreq) {
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
return (typeOfNew != null && !typeOfNew.isEmpty());
|
||||
}
|
||||
|
||||
private String getTypeOfNew(VitroRequest vreq) {
|
||||
return vreq.getParameter("typeOfNew");
|
||||
}
|
||||
// The default object proepty form offers the option to create a new item
|
||||
// instead of selecting from existing individuals in the system.
|
||||
// This is where the request to create a new indivdiual is handled.
|
||||
//We don't really need this again b/c we wouldn't be using this generator unless we want
|
||||
//to create a new individual so commenting out for now
|
||||
/*
|
||||
private boolean isForwardToCreateNew(VitroRequest vreq) {
|
||||
String command = vreq.getParameter("cmd");
|
||||
ObjectProperty objectProp = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
if(hasCustomForm(objectProp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isForwardToCreateNew =
|
||||
( objectProp != null && objectProp.getOfferCreateNewOption() )
|
||||
&& ( objectProp.getSelectFromExisting() == false
|
||||
|| "create".equals(command));
|
||||
|
||||
return isForwardToCreateNew;
|
||||
|
||||
}
|
||||
|
||||
private boolean hasCustomForm(ObjectProperty objectProp) {
|
||||
return( objectProp != null &&
|
||||
objectProp.getCustomEntryForm() != null &&
|
||||
!objectProp.getCustomEntryForm().isEmpty());
|
||||
|
||||
}*/
|
||||
|
||||
private boolean isReplaceWithNew(VitroRequest vreq) {
|
||||
ObjectProperty objectProp = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
boolean isEditOfExistingStmt = isEditOfExistingStatement(vreq);
|
||||
String command = vreq.getParameter("cmd");
|
||||
return (isEditOfExistingStmt
|
||||
&& "create".equals(command))
|
||||
&& (objectProp != null)
|
||||
&& (objectProp.getOfferCreateNewOption() == true);
|
||||
}
|
||||
|
||||
private boolean isForwardToCreateButEdit(VitroRequest vreq) {
|
||||
boolean isEditOfExistingStmt = isEditOfExistingStatement(vreq);
|
||||
ObjectProperty objectProp = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
String command = vreq.getParameter("cmd");
|
||||
return (isEditOfExistingStmt
|
||||
&& (! "create".equals(command))
|
||||
&& (objectProp != null)
|
||||
&& (objectProp.getOfferCreateNewOption() == true)
|
||||
&& (objectProp.getSelectFromExisting() == false)
|
||||
);
|
||||
}
|
||||
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
formSpecificData.put("typeName", getTypeName(vreq));
|
||||
//Put in whether or not person type
|
||||
if(isPersonType(vreq)) {
|
||||
//Doing this b/c unsure how freemarker will handle boolean value from JAVA
|
||||
formSpecificData.put("isPersonType", "true");
|
||||
} else {
|
||||
formSpecificData.put("isPersonType", "false");
|
||||
|
||||
}
|
||||
editConfiguration.setFormSpecificData(formSpecificData);
|
||||
}
|
||||
|
||||
private String getTypeName(VitroRequest vreq) {
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
public String getFOAFPersonClassURI() {
|
||||
return "http://xmlns.com/foaf/0.1/Person";
|
||||
}
|
||||
|
||||
public boolean isPersonType(VitroRequest vreq) {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
Boolean isPersonType = Boolean.FALSE;
|
||||
String foafPersonType = getFOAFPersonClassURI();
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
List<String> superTypes = wdf.getVClassDao().getAllSuperClassURIs(typeOfNew);
|
||||
//add the actual type as well so we can add that for the list to be checked
|
||||
superTypes.add(typeOfNew);
|
||||
if( superTypes != null ){
|
||||
for( String typeUri : superTypes){
|
||||
if( foafPersonType.equals(typeUri)) {
|
||||
isPersonType = Boolean.TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPersonType;
|
||||
}
|
||||
|
||||
//Is edit of existing statement only applicable to object properties
|
||||
private boolean isEditOfExistingStatement(VitroRequest vreq) {
|
||||
//TODO: Check if also applicable to data property, currently returning false
|
||||
if(EditConfigurationUtils.isDataProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)) {
|
||||
return false;
|
||||
}
|
||||
Individual object = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
return (object != null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.VIVOIndividualSearchResult;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
||||
/**
|
||||
* Generates the edit configuration for a default property form.
|
||||
*
|
||||
*/
|
||||
public class VIVODefaultAddMissingIndividualFormGenerator extends DefaultAddMissingIndividualFormGenerator {
|
||||
|
||||
private Log log = LogFactory.getLog(VIVODefaultAddMissingIndividualFormGenerator.class);
|
||||
|
||||
protected Map<String, String> generateNewResources(VitroRequest vreq) {
|
||||
Map<String, String> newResources = super.generateNewResources(vreq);
|
||||
newResources.put("newVcardInd", null);
|
||||
newResources.put("newVcardName", null);
|
||||
return newResources;
|
||||
}
|
||||
|
||||
protected List<String> getN3Prefixes() {
|
||||
List<String> prefixStrings = super.getN3Prefixes();
|
||||
prefixStrings.add("@prefix vcard:<http://www.w3.org/2006/vcard/ns#> .");
|
||||
return prefixStrings;
|
||||
}
|
||||
|
||||
private String getN3ForName() {
|
||||
return "?" + objectVarName + " rdfs:label ?label .";
|
||||
}
|
||||
|
||||
protected List<String> generateN3Optional(VitroRequest vreq) {
|
||||
List<String> n3Optional = super.generateN3Optional(vreq);
|
||||
n3Optional.add(getN3PrefixesAsString()
|
||||
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
||||
+ " ?newVcardInd <http://purl.obolibrary.org/obo/ARG_2000029> ?" + objectVarName + " . \n"
|
||||
+ " ?newVcardInd a vcard:Individual . \n"
|
||||
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
||||
+ " ?newVcardName a vcard:Name . \n"
|
||||
+ " ?newVcardName vcard:givenName ?firstName . \n"
|
||||
+ " ?newVcardName vcard:familyName ?lastName . \n");
|
||||
n3Optional.add(getN3PrefixesAsString()
|
||||
+ "?" + objectVarName + "<http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
|
||||
+ " ?newVcardInd a vcard:Individual . \n"
|
||||
+ " ?newVcardInd vcard:hasName ?newVcardName . \n"
|
||||
+ " ?newVcardName a vcard:Name . \n"
|
||||
+ " ?newVcardName <http://vivoweb.org/ontology/core#middleName> ?middleName .");
|
||||
return n3Optional;
|
||||
}
|
||||
|
||||
protected void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("label");
|
||||
literalsOnForm.add("firstName");
|
||||
literalsOnForm.add("middleName");
|
||||
literalsOnForm.add("lastName");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
||||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||
if(EditConfigurationUtils.isObjectProperty(EditConfigurationUtils.getPredicateUri(vreq), vreq)) {
|
||||
|
||||
//make name field
|
||||
FieldVTwo labelField = new FieldVTwo();
|
||||
labelField.setName("label");
|
||||
|
||||
FieldVTwo firstNameField = new FieldVTwo();
|
||||
firstNameField.setName("firstName");
|
||||
|
||||
FieldVTwo middleNameField = new FieldVTwo();
|
||||
middleNameField.setName("middleName");
|
||||
|
||||
FieldVTwo lastNameField = new FieldVTwo();
|
||||
lastNameField.setName("lastName");
|
||||
|
||||
List<String> validators = new ArrayList<String>();
|
||||
validators.add("nonempty");
|
||||
if(!isPersonType(vreq)) {
|
||||
labelField.setValidators(validators);
|
||||
}
|
||||
if(isPersonType(vreq)) {
|
||||
firstNameField.setValidators(validators);
|
||||
lastNameField.setValidators(validators);
|
||||
}
|
||||
|
||||
fields.put(labelField.getName(), labelField);
|
||||
fields.put(firstNameField.getName(), firstNameField);
|
||||
fields.put(middleNameField.getName(), middleNameField);
|
||||
fields.put(lastNameField.getName(), lastNameField);
|
||||
|
||||
} else {
|
||||
log.error("Is not object property so fields not set");
|
||||
}
|
||||
|
||||
editConfiguration.setFields(fields);
|
||||
}
|
||||
|
||||
//Form specific data
|
||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||
formSpecificData.put("typeName", getTypeName(vreq));
|
||||
//Put in whether or not person type
|
||||
if(isPersonType(vreq)) {
|
||||
//Doing this b/c unsure how freemarker will handle boolean value from JAVA
|
||||
formSpecificData.put("isPersonType", "true");
|
||||
} else {
|
||||
formSpecificData.put("isPersonType", "false");
|
||||
|
||||
}
|
||||
editConfiguration.setFormSpecificData(formSpecificData);
|
||||
}
|
||||
|
||||
private String getTypeName(VitroRequest vreq) {
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
VClass type = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(typeOfNew);
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
public String getFOAFPersonClassURI() {
|
||||
return "http://xmlns.com/foaf/0.1/Person";
|
||||
}
|
||||
|
||||
public boolean isPersonType(VitroRequest vreq) {
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
Boolean isPersonType = Boolean.FALSE;
|
||||
String foafPersonType = getFOAFPersonClassURI();
|
||||
String typeOfNew = getTypeOfNew(vreq);
|
||||
List<String> superTypes = wdf.getVClassDao().getAllSuperClassURIs(typeOfNew);
|
||||
//add the actual type as well so we can add that for the list to be checked
|
||||
superTypes.add(typeOfNew);
|
||||
if( superTypes != null ){
|
||||
for( String typeUri : superTypes){
|
||||
if( foafPersonType.equals(typeUri)) {
|
||||
isPersonType = Boolean.TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPersonType;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
|
|||
*This generator selects the actual generator to be employed based on whether the individual is a Person
|
||||
*or another individual. Adding a label for a person relies on first/name last name information i.e. object properties.
|
||||
*/
|
||||
public class ManageLabelsGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||
public class VIVOManageLabelsGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||
public static Log log = LogFactory.getLog(ManageLabelsForIndividualGenerator.class);
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
|
@ -27,7 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
|||
* Generates the edit configuration for a default property form.
|
||||
* ModelChangePreprocessor creates the rdfs:label statement.
|
||||
*/
|
||||
public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||
public class VIVONewIndividualFormGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||
|
||||
@Override
|
||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
|
|
@ -1,25 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/*
|
||||
* This class determines what n3 should be returned for a particular data getter and can be overwritten or extended in VIVO.
|
||||
*/
|
||||
public class ProcessDataGetterN3Map {
|
||||
private static final Log log = LogFactory.getLog(ProcessDataGetterN3Map.class);
|
||||
public static HashMap<String, String> getDataGetterTypeToProcessorMap() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSparqlDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessInternalClassDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSearchIndividualsDataGetterN3");
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils.menuManagement;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter;
|
||||
|
||||
|
||||
/*
|
||||
* This class includes methods that help in selecting a data getter based on
|
||||
* parameters, and VIVO will have its own version or extend this
|
||||
*/
|
||||
public class SelectDataGetterUtils {
|
||||
private static final Log log = LogFactory.getLog(SelectDataGetterUtils.class);
|
||||
|
||||
/**Get data for an existing page and set variables for the template accordingly**/
|
||||
|
||||
|
||||
public static void processAndRetrieveData(VitroRequest vreq, ServletContext context, Map<String, Object> pageData, String dataGetterClass, Map<String, Object> templateData) {
|
||||
//The type of the data getter will show how to process the data from the data getter
|
||||
ProcessDataGetter processor = selectProcessor(dataGetterClass);
|
||||
processor.populateTemplate(vreq, pageData, templateData);
|
||||
}
|
||||
|
||||
//This will be different in VIVO than in VITRO
|
||||
private static ProcessDataGetter selectProcessor(String dataGetterClass) {
|
||||
if(dataGetterClass.equals(ClassGroupPageData.class.getName())) {
|
||||
return new ProcessClassGroup();
|
||||
} else if(dataGetterClass.equals(InternalClassesDataGetter.class.getName())) {
|
||||
return new ProcessInternalClasses();
|
||||
//below should be for vitro specific version
|
||||
//return new ProcessIndividualsForClasses();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**Process parameters from form and select appropriate data getter on this basis **/
|
||||
public static Model createDataGetterModel(VitroRequest vreq, Resource dataGetterResource) {
|
||||
Model dataGetterModel = null;
|
||||
if(dataGetterResource != null) {
|
||||
//If "All selected" then use class group else use individuals for classes
|
||||
dataGetterModel = ModelFactory.createDefaultModel();
|
||||
|
||||
ProcessInternalClasses individualsProcess = new ProcessInternalClasses();
|
||||
|
||||
ProcessClassGroup classGroupProcess = new ProcessClassGroup();
|
||||
if(individualsProcess.useProcessor(vreq)) {
|
||||
dataGetterModel = individualsProcess.processSubmission(vreq, dataGetterResource);
|
||||
} else {
|
||||
dataGetterModel = classGroupProcess.processSubmission(vreq, dataGetterResource);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
log.error("Data getter is null ");
|
||||
}
|
||||
return dataGetterModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -23,18 +23,17 @@ import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
|||
* This class includes methods that help in selecting a data getter based on
|
||||
* parameters, and VIVO will have its own version or extend this
|
||||
*/
|
||||
public class MenuManagementDataUtils {
|
||||
private static final Log log = LogFactory.getLog(MenuManagementDataUtils.class);
|
||||
public class VIVOMenuManagementDataUtils implements MenuManagementDataUtils.IMenuManagementDataUtils {
|
||||
private static final Log log = LogFactory.getLog(VIVOMenuManagementDataUtils.class);
|
||||
|
||||
//Data that is to be returned to template that does not involve data getters
|
||||
//e.g. what are the current class groups, etc.
|
||||
public static void includeRequiredSystemData(ServletContext context, Map<String, Object> templateData) {
|
||||
|
||||
public void includeRequiredSystemData(ServletContext context, Map<String, Object> templateData) {
|
||||
checkInstitutionalInternalClass(context, templateData);
|
||||
}
|
||||
|
||||
//Check whether any classes exist with internal class restrictions
|
||||
private static void checkInstitutionalInternalClass(ServletContext context, Map<String, Object> templateData) {
|
||||
private void checkInstitutionalInternalClass(ServletContext context, Map<String, Object> templateData) {
|
||||
//TODO: replace with more generic ModelContext retrieval method
|
||||
String internalClass = retrieveInternalClass(context);
|
||||
if(internalClass != null) {
|
||||
|
@ -47,7 +46,7 @@ public class MenuManagementDataUtils {
|
|||
|
||||
}
|
||||
|
||||
private static String retrieveInternalClass(ServletContext context) {
|
||||
private String retrieveInternalClass(ServletContext context) {
|
||||
OntModel mainModel = ModelAccess.on(context).getOntModel(TBOX_ASSERTIONS);
|
||||
StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null);
|
||||
if(internalIt.hasNext()) {
|
|
@ -2,32 +2,19 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.visualization.VisualizationFrameworkConstants;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
||||
public class VIVOIndividualTemplateModel extends IndividualTemplateModel {
|
||||
|
||||
private static final Log log = LogFactory.getLog(IndividualTemplateModel.class);
|
||||
private static final Log log = LogFactory.getLog(VIVOIndividualTemplateModel.class);
|
||||
|
||||
private static final String FOAF = "http://xmlns.com/foaf/0.1/";
|
||||
private static final String PERSON_CLASS = FOAF + "Person";
|
||||
|
@ -42,7 +29,7 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
|||
private static final String BASE_VISUALIZATION_URL =
|
||||
UrlBuilder.getUrl(Route.VISUALIZATION_SHORT.path());
|
||||
|
||||
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||
VIVOIndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||
super(individual, vreq);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
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;
|
||||
|
||||
public class VIVOIndividualTemplateModelBuilder implements IndividualTemplateModelBuilder.IIndividualTemplateModelBuilder {
|
||||
@Override
|
||||
public VIVOIndividualTemplateModel build(Individual individual, VitroRequest vreq) {
|
||||
return new VIVOIndividualTemplateModel(individual, vreq);
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
|
||||
public class ListedIndividual extends BaseListedIndividual {
|
||||
private static final Log log = LogFactory.getLog(ListedIndividual.class);
|
||||
public class VIVOListedIndividual extends ListedIndividual {
|
||||
private static final Log log = LogFactory.getLog(VIVOListedIndividual.class);
|
||||
|
||||
private static String VCARD_DATA_QUERY = ""
|
||||
+ "PREFIX obo: <http://purl.obolibrary.org/obo/> \n"
|
||||
|
@ -28,7 +28,7 @@ public class ListedIndividual extends BaseListedIndividual {
|
|||
|
||||
private final String title;
|
||||
|
||||
public ListedIndividual(Individual individual, VitroRequest vreq) {
|
||||
VIVOListedIndividual(Individual individual, VitroRequest vreq) {
|
||||
super(individual, vreq);
|
||||
title = findPreferredTitle();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
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 VIVOListedIndividualBuilder implements ListedIndividualBuilder.ILIstedIndividualBuilder {
|
||||
@Override
|
||||
public ListedIndividual build(Individual individual, VitroRequest vreq) {
|
||||
return new VIVOListedIndividual(individual, vreq);
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
|
||||
public class IndividualSearchResult extends BaseIndividualSearchResult {
|
||||
private static final Log log = LogFactory.getLog(IndividualSearchResult.class);
|
||||
public class VIVOIndividualSearchResult extends IndividualSearchResult {
|
||||
private static final Log log = LogFactory.getLog(VIVOIndividualSearchResult.class);
|
||||
|
||||
private static String VCARD_DATA_QUERY = ""
|
||||
+ "PREFIX obo: <http://purl.obolibrary.org/obo/> \n"
|
||||
|
@ -33,7 +33,7 @@ public class IndividualSearchResult extends BaseIndividualSearchResult {
|
|||
private String email = "";
|
||||
private String title = "";
|
||||
|
||||
public IndividualSearchResult(Individual individual, VitroRequest vreq) {
|
||||
public VIVOIndividualSearchResult(Individual individual, VitroRequest vreq) {
|
||||
super(individual, vreq);
|
||||
log.debug("Called Individual Search Result");
|
||||
findVcardInfo();
|
||||
|
@ -71,4 +71,7 @@ public class IndividualSearchResult extends BaseIndividualSearchResult {
|
|||
return email;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
IndividualSearchResult.registerResultClass(VIVOIndividualSearchResult.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVODefaultAddMissingIndividualFormGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Map;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DataGetterN3Setup implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSparqlDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.InternalClassesDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessInternalClassDataGetterN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
|
||||
map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSearchIndividualsDataGetterN3");
|
||||
|
||||
ProcessDataGetterN3Map.replaceDataGetterMap(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.JspToGeneratorMapping;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVODefaultAddMissingIndividualFormGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.VIVOIndividualSearchResult;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class GeneratorSetup implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
JspToGeneratorMapping.jspsToGenerators.put("defaultAddMissingIndividualForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVODefaultAddMissingIndividualFormGenerator.class.getName());
|
||||
|
||||
JspToGeneratorMapping.jspsToGenerators.put("newIndividualForm.jsp",
|
||||
edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVONewIndividualFormGenerator.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualJsonWrapper;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSONWrapperSetup implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(JSONWrapperSetup.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
IndividualJsonWrapper.setAddJSONFields(new IndividualJsonWrapper.AddJSONFields() {
|
||||
@Override
|
||||
public void add(JSONObject jo, VitroRequest vreq, Individual ind) throws JSONException {
|
||||
jo.put("preferredTitle", findPreferredTitle(vreq, ind));
|
||||
}
|
||||
|
||||
private String VCARD_DATA_QUERY = ""
|
||||
+ "PREFIX obo: <http://purl.obolibrary.org/obo/> \n"
|
||||
+ "PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> \n"
|
||||
+ "SELECT DISTINCT ?title \n" + "WHERE { \n"
|
||||
+ " ?subject obo:ARG_2000028 ?vIndividual . \n"
|
||||
+ " ?vIndividual vcard:hasTitle ?vTitle . \n"
|
||||
+ " ?vTitle vcard:title ?title . \n" + "} ";
|
||||
|
||||
private String findPreferredTitle(VitroRequest vreq, Individual ind) {
|
||||
String queryStr = QueryUtils.subUriForQueryVar(VCARD_DATA_QUERY,
|
||||
"subject", ind.getURI());
|
||||
log.debug("queryStr = " + queryStr);
|
||||
String value = "";
|
||||
try {
|
||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
String t = QueryUtils.nodeToString(soln.get("title"));
|
||||
if (StringUtils.isNotBlank(t)) {
|
||||
value = t;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.MenuManagementDataUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.menuManagement.VIVOMenuManagementDataUtils;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class MenuManagementSetup implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
MenuManagementDataUtils.setImplementation(new VIVOMenuManagementDataUtils());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.searchresult.VIVOIndividualSearchResult;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class SearchResultTemplateModelSetup implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
VIVOIndividualSearchResult.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.vivoweb.webapp.startup;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.VIVOIndividualTemplateModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.VIVOIndividualTemplateModelBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.VIVOListedIndividual;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.VIVOListedIndividualBuilder;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class TemplateModelSetup implements ServletContextListener {
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
IndividualTemplateModelBuilder.setCustomBuilder(new VIVOIndividualTemplateModelBuilder());
|
||||
ListedIndividualBuilder.setCustomBuilder(new VIVOListedIndividualBuilder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
|
||||
}
|
||||
}
|
|
@ -57,6 +57,13 @@ edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup
|
|||
|
||||
edu.cornell.mannlib.vitro.webapp.visualization.setup.VisualizationSetup
|
||||
|
||||
org.vivoweb.webapp.startup.DataGetterN3Setup
|
||||
org.vivoweb.webapp.startup.GeneratorSetup
|
||||
org.vivoweb.webapp.startup.JSONWrapperSetup
|
||||
org.vivoweb.webapp.startup.MenuManagementSetup
|
||||
org.vivoweb.webapp.startup.TemplateModelSetup
|
||||
org.vivoweb.webapp.startup.SearchResultTemplateModelSetup
|
||||
|
||||
edu.ucsf.vitro.opensocial.OpenSocialSmokeTests
|
||||
|
||||
# For multiple language support
|
||||
|
|
|
@ -326,7 +326,7 @@
|
|||
|
||||
<servlet>
|
||||
<servlet-name>SiteAdminController</servlet-name>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.SiteAdminController</servlet-class>
|
||||
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.VIVOSiteAdminController</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>SiteAdminController</servlet-name>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#assign ManageLabelsGenerator = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVOManageLabelsGenerator" />
|
||||
<#assign NewIndividualFormGenerator = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.VIVONewIndividualFormGenerator" />
|
Loading…
Add table
Reference in a new issue