Changes to individual templates and associated queries
This commit is contained in:
parent
d220c7e9af
commit
ac624c0bc3
16 changed files with 110 additions and 90 deletions
|
@ -50,7 +50,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(FreemarkerHttpServlet.class);
|
private static final Log log = LogFactory.getLog(FreemarkerHttpServlet.class);
|
||||||
|
|
||||||
|
|
||||||
public static final String PAGE_TEMPLATE_TYPE = "page";
|
public static final String PAGE_TEMPLATE_TYPE = "page";
|
||||||
public static final String BODY_TEMPLATE_TYPE = "body";
|
public static final String BODY_TEMPLATE_TYPE = "body";
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class VitroVocabulary {
|
||||||
public static final String OWL_ONTOLOGY = OWL+"Ontology";
|
public static final String OWL_ONTOLOGY = OWL+"Ontology";
|
||||||
public static final String OWL_THING = OWL+"Thing";
|
public static final String OWL_THING = OWL+"Thing";
|
||||||
|
|
||||||
|
public static final String AFN = "http://jena.hpl.hp.com/ARQ/function#";
|
||||||
|
|
||||||
public static final String label = vitroURI + "label";
|
public static final String label = vitroURI + "label";
|
||||||
|
|
||||||
// an OWL DL-compatible surrogate for rdf:value for use with boxing idiom
|
// an OWL DL-compatible surrogate for rdf:value for use with boxing idiom
|
||||||
|
|
|
@ -82,11 +82,11 @@ public class HiddenFromDisplayBelowRoleLevelFilter extends VitroFiltersImpl {
|
||||||
private class RoleFilter<E extends ResourceBean> extends UnaryFunctor<E,Boolean>{
|
private class RoleFilter<E extends ResourceBean> extends UnaryFunctor<E,Boolean>{
|
||||||
@Override
|
@Override
|
||||||
public Boolean fn(E resource) {
|
public Boolean fn(E resource) {
|
||||||
log.debug("checking hidden status for \"" + resource.getURI() + "\"");
|
|
||||||
try{
|
try{
|
||||||
if( resource == null )
|
if( resource == null )
|
||||||
return canViewOddItems();
|
return canViewOddItems();
|
||||||
else
|
else
|
||||||
|
log.debug("checking hidden status for \"" + resource.getURI() + "\"");
|
||||||
return sameLevelOrHigher( resource.getHiddenFromDisplayBelowRoleLevel() );
|
return sameLevelOrHigher( resource.getHiddenFromDisplayBelowRoleLevel() );
|
||||||
}catch(RuntimeException th){
|
}catch(RuntimeException th){
|
||||||
log.warn("Error checking hidden status for " + resource, th);
|
log.warn("Error checking hidden status for " + resource, th);
|
||||||
|
|
|
@ -24,11 +24,8 @@ import com.hp.hpl.jena.ontology.ProfileException;
|
||||||
import com.hp.hpl.jena.ontology.Restriction;
|
import com.hp.hpl.jena.ontology.Restriction;
|
||||||
import com.hp.hpl.jena.ontology.SomeValuesFromRestriction;
|
import com.hp.hpl.jena.ontology.SomeValuesFromRestriction;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
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.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Property;
|
import com.hp.hpl.jena.rdf.model.Property;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
@ -46,7 +43,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||||
|
@ -86,21 +82,21 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
}
|
}
|
||||||
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
|
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
|
||||||
}
|
}
|
||||||
protected static final String dataPropertyQueryString =
|
protected static final String DATA_PROPERTY_QUERY_STRING =
|
||||||
PREFIXES + "\n" +
|
prefixes + "\n" +
|
||||||
"SELECT DISTINCT ?property WHERE { \n" +
|
"SELECT DISTINCT ?property WHERE { \n" +
|
||||||
" GRAPH ?g1 { ?subject ?property ?object } \n" +
|
" GRAPH ?g1 { ?subject ?property ?object } \n" +
|
||||||
" GRAPH ?g2 { ?property rdf:type owl:DatatypeProperty } \n" +
|
" GRAPH ?g2 { ?property rdf:type owl:DatatypeProperty } \n" +
|
||||||
propertyFilters +
|
propertyFilters +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
static protected Query dataPropertyQuery;
|
protected static Query dataPropertyQuery;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
dataPropertyQuery = QueryFactory.create(dataPropertyQueryString);
|
dataPropertyQuery = QueryFactory.create(DATA_PROPERTY_QUERY_STRING);
|
||||||
} catch(Throwable th){
|
} catch(Throwable th){
|
||||||
log.error("could not create SPARQL query for dataPropertyQueryString " + th.getMessage());
|
log.error("could not create SPARQL query for DATA_PROPERTY_QUERY_STRING " + th.getMessage());
|
||||||
log.error(dataPropertyQueryString);
|
log.error(DATA_PROPERTY_QUERY_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,8 +742,8 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
* into the new one in a future release.
|
* into the new one in a future release.
|
||||||
*/
|
*/
|
||||||
public List<DataProperty> getDataPropertyList(String subjectUri) {
|
public List<DataProperty> getDataPropertyList(String subjectUri) {
|
||||||
log.debug("dataPropertyQueryString:\n" + dataPropertyQueryString);
|
log.debug("Data property query string:\n" + DATA_PROPERTY_QUERY_STRING);
|
||||||
log.debug("dataPropertyQuery:\n" + dataPropertyQuery);
|
log.debug("Data property query:\n" + dataPropertyQuery);
|
||||||
ResultSet results = getPropertyQueryResults(subjectUri, dataPropertyQuery);
|
ResultSet results = getPropertyQueryResults(subjectUri, dataPropertyQuery);
|
||||||
List<DataProperty> properties = new ArrayList<DataProperty>();
|
List<DataProperty> properties = new ArrayList<DataProperty>();
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
|
|
||||||
private DatasetWrapperFactory dwf;
|
private DatasetWrapperFactory dwf;
|
||||||
|
|
||||||
protected static final String dataPropertyValueQueryString =
|
protected static final String DATA_PROPERTY_VALUE_QUERY_STRING =
|
||||||
"SELECT ?value WHERE { \n" +
|
"SELECT ?value WHERE { \n" +
|
||||||
" GRAPH ?g {\n" +
|
" GRAPH ?g {\n" +
|
||||||
" ?subject ?property ?value . \n" +
|
" ?subject ?property ?value . \n" +
|
||||||
|
@ -52,10 +52,10 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
static protected Query dataPropertyValueQuery;
|
static protected Query dataPropertyValueQuery;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
dataPropertyValueQuery = QueryFactory.create(dataPropertyValueQueryString);
|
dataPropertyValueQuery = QueryFactory.create(DATA_PROPERTY_VALUE_QUERY_STRING);
|
||||||
} catch(Throwable th){
|
} catch(Throwable th){
|
||||||
log.error("could not create SPARQL query for dataPropertyQueryString " + th.getMessage());
|
log.error("could not create SPARQL query for DATA_PROPERTY_VALUE_QUERY_STRING " + th.getMessage());
|
||||||
log.error(dataPropertyValueQueryString);
|
log.error(DATA_PROPERTY_VALUE_QUERY_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,12 +320,12 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Literal> getDataPropertyValuesForIndividualByProperty(String subjectUri, String propertyUri) {
|
public List<Literal> getDataPropertyValuesForIndividualByProperty(String subjectUri, String propertyUri) {
|
||||||
log.debug("dataPropertyValueQueryString:\n" + dataPropertyValueQueryString);
|
log.debug("Data property value query string:\n" + DATA_PROPERTY_VALUE_QUERY_STRING);
|
||||||
log.debug("dataPropertyValueQuery:\n" + dataPropertyValueQuery);
|
log.debug("Data property value:\n" + dataPropertyValueQuery);
|
||||||
|
|
||||||
QuerySolutionMap bindings = new QuerySolutionMap();
|
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
bindings.add("subject", ResourceFactory.createResource(subjectUri));
|
initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
|
||||||
bindings.add("property", ResourceFactory.createResource(propertyUri));
|
initialBindings.add("property", ResourceFactory.createResource(propertyUri));
|
||||||
|
|
||||||
// Run the SPARQL query to get the properties
|
// Run the SPARQL query to get the properties
|
||||||
List<Literal> values = new ArrayList<Literal>();
|
List<Literal> values = new ArrayList<Literal>();
|
||||||
|
@ -334,7 +334,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(
|
QueryExecution qexec = QueryExecutionFactory.create(
|
||||||
dataPropertyValueQuery, dataset, bindings);
|
dataPropertyValueQuery, dataset, initialBindings);
|
||||||
ResultSet results = qexec.execSelect();
|
ResultSet results = qexec.execSelect();
|
||||||
|
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
|
|
|
@ -54,12 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||||
public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao {
|
public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao {
|
||||||
private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName());
|
private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName());
|
||||||
|
|
||||||
/* This may be the intent behind JenaBaseDao.NONUSER_NAMESPACES, but that
|
|
||||||
* value does not contain all of these namespaces.
|
|
||||||
*/
|
|
||||||
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
||||||
//"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#",
|
|
||||||
//"http://vitro.mannlib.cornell.edu/ns/vitro/public#",
|
|
||||||
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
||||||
"http://www.w3.org/2000/01/rdf-schema#",
|
"http://www.w3.org/2000/01/rdf-schema#",
|
||||||
"http://www.w3.org/2002/07/owl#"
|
"http://www.w3.org/2002/07/owl#"
|
||||||
|
@ -75,43 +70,43 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
namespaceFilters.add("(afn:namespace(?property) != \"" + s + "\")");
|
namespaceFilters.add("(afn:namespace(?property) != \"" + s + "\")");
|
||||||
}
|
}
|
||||||
// A hack to include the vitro:primaryLink and vitro:additionalLink properties in the list
|
// A hack to include the vitro:primaryLink and vitro:additionalLink properties in the list
|
||||||
namespaceFilters.add("( ?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#primaryLink> ||" +
|
namespaceFilters.add("( ?property = vitro:primaryLink ||" +
|
||||||
"?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#additionalLink> ||" +
|
"?property = vitro:additionalLink ||" +
|
||||||
"afn:namespace(?property) != \"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#\" )");
|
"afn:namespace(?property) != \"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#\" )");
|
||||||
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
|
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final String objectPropertyQueryString =
|
protected static final String OBJECT_PROPERTY_QUERY_STRING =
|
||||||
PREFIXES + "\n" +
|
prefixes + "\n" +
|
||||||
"SELECT DISTINCT ?property WHERE { \n" +
|
"SELECT DISTINCT ?property WHERE { \n" +
|
||||||
" GRAPH ?g1 { ?subject ?property ?object } \n" +
|
" GRAPH ?g1 { ?subject ?property ?object } \n" +
|
||||||
" GRAPH ?g2 { ?property rdf:type owl:ObjectProperty } \n" +
|
" GRAPH ?g2 { ?property rdf:type owl:ObjectProperty } \n" +
|
||||||
propertyFilters +
|
propertyFilters +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
static protected Query objectPropertyQuery;
|
protected static Query objectPropertyQuery;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
objectPropertyQuery = QueryFactory.create(objectPropertyQueryString);
|
objectPropertyQuery = QueryFactory.create(OBJECT_PROPERTY_QUERY_STRING);
|
||||||
} catch(Throwable th){
|
} catch(Throwable th){
|
||||||
log.error("could not create SPARQL query for objectPropertyQueryString " + th.getMessage());
|
log.error("could not create SPARQL query for OBJECT_PROPERTY_QUERY_STRING " + th.getMessage());
|
||||||
log.error(objectPropertyQueryString);
|
log.error(OBJECT_PROPERTY_QUERY_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected String listViewConfigFileQueryString =
|
protected static final String LIST_VIEW_CONFIG_FILE_QUERY_STRING =
|
||||||
"PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>" +
|
"PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>" +
|
||||||
"SELECT ?property ?filename WHERE { \n" +
|
"SELECT ?property ?filename WHERE { \n" +
|
||||||
" ?property display:listViewConfigFile ?filename . \n" +
|
" ?property display:listViewConfigFile ?filename . \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
static protected Query listViewConfigFileQuery;
|
protected static Query listViewConfigFileQuery;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
listViewConfigFileQuery = QueryFactory.create(listViewConfigFileQueryString);
|
listViewConfigFileQuery = QueryFactory.create(LIST_VIEW_CONFIG_FILE_QUERY_STRING);
|
||||||
} catch(Throwable th){
|
} catch(Throwable th){
|
||||||
log.error("could not create SPARQL query for listViewConfigFileQueryString " + th.getMessage());
|
log.error("could not create SPARQL query for LIST_VIEW_CONFIG_FILE_QUERY_STRING " + th.getMessage());
|
||||||
log.error(listViewConfigFileQueryString);
|
log.error(LIST_VIEW_CONFIG_FILE_QUERY_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,8 +883,8 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
* into the new one in a future release.
|
* into the new one in a future release.
|
||||||
*/
|
*/
|
||||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
|
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
|
||||||
log.debug("objectPropertyQueryString:\n" + objectPropertyQueryString);
|
log.debug("Object property query string:\n" + OBJECT_PROPERTY_QUERY_STRING);
|
||||||
log.debug("objectPropertyQuery:\n" + objectPropertyQuery);
|
log.debug("Object property query:\n" + objectPropertyQuery);
|
||||||
ResultSet results = getPropertyQueryResults(subjectUri, objectPropertyQuery);
|
ResultSet results = getPropertyQueryResults(subjectUri, objectPropertyQuery);
|
||||||
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
|
|
|
@ -268,9 +268,11 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QuerySolutionMap bindings = new QuerySolutionMap();
|
// RY One oddity here is that SDB adds the bound variables to the query select terms,
|
||||||
bindings.add("subject", ResourceFactory.createResource(subjectUri));
|
// even if they're not included in the query.
|
||||||
bindings.add("property", ResourceFactory.createResource(propertyUri));
|
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
|
initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
|
||||||
|
initialBindings.add("property", ResourceFactory.createResource(propertyUri));
|
||||||
|
|
||||||
// Run the SPARQL query to get the properties
|
// Run the SPARQL query to get the properties
|
||||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
||||||
|
@ -280,7 +282,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
try {
|
try {
|
||||||
|
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(
|
QueryExecution qexec = QueryExecutionFactory.create(
|
||||||
query, dataset, bindings);
|
query, dataset, initialBindings);
|
||||||
ResultSet results = qexec.execSelect();
|
ResultSet results = qexec.execSelect();
|
||||||
|
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -19,7 +20,6 @@ import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
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.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.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
@ -36,17 +36,29 @@ import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||||
|
|
||||||
public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(PropertyDaoJena.class.getName());
|
protected static final Log log = LogFactory.getLog(PropertyDaoJena.class.getName());
|
||||||
|
|
||||||
protected static final String PREFIXES =
|
private static final Map<String, String> NAMESPACES = new HashMap<String, String>() {{
|
||||||
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
|
put("afn", VitroVocabulary.AFN);
|
||||||
//"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
put("owl", VitroVocabulary.OWL);
|
||||||
"PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
|
put("rdf", VitroVocabulary.RDF);
|
||||||
"PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>";
|
put("rdfs", VitroVocabulary.RDFS);
|
||||||
|
put("vitro", VitroVocabulary.vitroURI);
|
||||||
|
put("vitroPublic", VitroVocabulary.VITRO_PUBLIC);
|
||||||
|
}};
|
||||||
|
|
||||||
|
protected static String prefixes = "";
|
||||||
|
static {
|
||||||
|
for (String key : NAMESPACES.keySet()) {
|
||||||
|
prefixes += "PREFIX " + key + ": <" + NAMESPACES.get(key) + ">\n";
|
||||||
|
}
|
||||||
|
log.debug("Query prefixes: " + prefixes);
|
||||||
|
}
|
||||||
|
|
||||||
protected DatasetWrapperFactory dwf;
|
protected DatasetWrapperFactory dwf;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,9 @@ public class QueryUtils {
|
||||||
Iterator<String> varNames = soln.varNames();
|
Iterator<String> varNames = soln.varNames();
|
||||||
while(varNames.hasNext()){
|
while(varNames.hasNext()){
|
||||||
String varName = varNames.next();
|
String varName = varNames.next();
|
||||||
map.put(varName, nodeToObject( soln.get(varName)));
|
Object value = nodeToObject( soln.get(varName));
|
||||||
|
log.debug("Adding " + varName + " : " + value + " to query solution data.");
|
||||||
|
map.put(varName, value);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +44,9 @@ public class QueryUtils {
|
||||||
Iterator<String> varNames = soln.varNames();
|
Iterator<String> varNames = soln.varNames();
|
||||||
while(varNames.hasNext()){
|
while(varNames.hasNext()){
|
||||||
String varName = varNames.next();
|
String varName = varNames.next();
|
||||||
map.put(varName, nodeToString( soln.get(varName)));
|
String value = nodeToString( soln.get(varName));
|
||||||
|
log.debug("Adding " + varName + " : " + value + " to query solution data.");
|
||||||
|
map.put(varName, value);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,11 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* This method handles the special case where we are creating a DataPropertyStatementTemplateModel outside the GroupedPropertyList.
|
* This method handles the special case where we are creating a DataPropertyStatementTemplateModel outside the GroupedPropertyList.
|
||||||
* Specifically, it allows rdfs:label to be treated like a data property statement and thus have editing links. It could potentially
|
* Specifically, it allows rdfs:label to be treated like a data property statement and thus have editing links. It is not possible
|
||||||
* be used for other properties outside the property list as well.
|
* to handle rdfs:label like vitro links and vitroPublic image, because it is not possible to construct a DataProperty from
|
||||||
|
* rdfs:label.
|
||||||
*/
|
*/
|
||||||
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
|
||||||
super(subjectUri, propertyUri, policyHelper);
|
super(subjectUri, propertyUri, policyHelper);
|
||||||
|
|
|
@ -172,6 +172,10 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
return loginStatusBean.isLoggedInAtLeast(LoginStatusBean.EDITOR);
|
return loginStatusBean.isLoggedInAtLeast(LoginStatusBean.EDITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* rdfs:label needs special treatment, because it is not possible to construct a
|
||||||
|
* DataProperty from it. It cannot be handled the way the vitro links and vitro public image
|
||||||
|
* are handled like ordinary ObjectProperty instances.
|
||||||
|
*/
|
||||||
public DataPropertyStatementTemplateModel getNameStatement() {
|
public DataPropertyStatementTemplateModel getNameStatement() {
|
||||||
String propertyUri = VitroVocabulary.LABEL; // rdfs:label
|
String propertyUri = VitroVocabulary.LABEL; // rdfs:label
|
||||||
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
|
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(getUri(), propertyUri, vreq, policyHelper);
|
||||||
|
|
|
@ -27,6 +27,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
|
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
|
||||||
propertyUri = property.getURI();
|
propertyUri = property.getURI();
|
||||||
localName = property.getLocalName();
|
localName = property.getLocalName();
|
||||||
|
log.debug("Local name for property " + propertyUri + ": " + localName);
|
||||||
|
|
||||||
// Do in subclass constructor. The label has not been set on the property, and the
|
// Do in subclass constructor. The label has not been set on the property, and the
|
||||||
// means of getting the label differs between object and data properties.
|
// means of getting the label differs between object and data properties.
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
<section id="individual-intro" class="vcard" role="region">
|
<section id="individual-intro" class="vcard" role="region">
|
||||||
|
|
||||||
<#-- Image -->
|
<#-- Image -->
|
||||||
<@p.imageLinks individual propertyGroups editable />
|
<@p.imageLinks individual propertyGroups namespaces editable />
|
||||||
|
|
||||||
|
|
||||||
<section id="individual-info" role="region">
|
<section id="individual-info" role="region">
|
||||||
<#if individual.showAdminPanel>
|
<#if individual.showAdminPanel>
|
||||||
|
@ -20,9 +19,7 @@
|
||||||
<#else>
|
<#else>
|
||||||
<h1 class="fn">
|
<h1 class="fn">
|
||||||
<#-- Label -->
|
<#-- Label -->
|
||||||
<#assign label = individual.nameStatement>
|
<@p.label individual editable />
|
||||||
${label.value}
|
|
||||||
<#-- <@p.editingLinks label label editable /> -->
|
|
||||||
|
|
||||||
<#-- Moniker -->
|
<#-- Moniker -->
|
||||||
<#if individual.moniker?has_content>
|
<#if individual.moniker?has_content>
|
||||||
|
@ -47,7 +44,7 @@
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<#-- Links -->
|
<#-- Links -->
|
||||||
<@p.vitroLinks propertyGroups editable />
|
<@p.vitroLinks propertyGroups namespaces editable />
|
||||||
|
|
||||||
<#if individualProductExtension??>
|
<#if individualProductExtension??>
|
||||||
${individualProductExtension}
|
${individualProductExtension}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
<#-- Default individual profile page template -->
|
<#-- Default individual profile page template -->
|
||||||
|
|
||||||
<#include "individual-setup.ftl">
|
<#include "individual-setup.ftl">
|
||||||
|
|
||||||
<#include "individual-vitro.ftl">
|
<#include "individual-vitro.ftl">
|
|
@ -88,23 +88,22 @@ name will be used as the label. -->
|
||||||
|
|
||||||
Note that this macro has a side-effect in the calls to propertyGroups.getPropertyAndRemoveFromList().
|
Note that this macro has a side-effect in the calls to propertyGroups.getPropertyAndRemoveFromList().
|
||||||
-->
|
-->
|
||||||
<#macro vitroLinks propertyGroups showEditLinks linkListClass="individual-urls">
|
<#macro vitroLinks propertyGroups namespaces editable linkListClass="individual-urls">
|
||||||
<#local vitroNs = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#">
|
<#local primaryLink = propertyGroups.getPropertyAndRemoveFromList("${namespaces.vitro}primaryLink")!>
|
||||||
<#local primaryLink = propertyGroups.getPropertyAndRemoveFromList("${vitroNs}primaryLink")!>
|
<#local additionalLinks = propertyGroups.getPropertyAndRemoveFromList("${namespaces.vitro}additionalLink")!>
|
||||||
<#local additionalLinks = propertyGroups.getPropertyAndRemoveFromList("${vitroNs}additionalLink")!>
|
|
||||||
|
|
||||||
<#if (primaryLink?has_content || additionalLinks?has_content)> <#-- true when the property is in the list, even if not populated (when editing) -->
|
<#if (primaryLink?has_content || additionalLinks?has_content)> <#-- true when the property is in the list, even if not populated (when editing) -->
|
||||||
<nav role="navigation">
|
<nav role="navigation">
|
||||||
<@addLinkWithLabel primaryLink showEditLinks "Primary Web Page" />
|
<@addLinkWithLabel primaryLink editable "Primary Web Page" />
|
||||||
<#if primaryLink.statements?has_content> <#-- if there are any statements -->
|
<#if primaryLink.statements?has_content> <#-- if there are any statements -->
|
||||||
<ul class="${linkListClass}" id="links-primary" role="list">
|
<ul class="${linkListClass}" id="links-primary" role="list">
|
||||||
<@objectPropertyList primaryLink primaryLink.statements primaryLink.template showEditLinks />
|
<@objectPropertyList primaryLink primaryLink.statements primaryLink.template editable />
|
||||||
</ul>
|
</ul>
|
||||||
</#if>
|
</#if>
|
||||||
<@addLinkWithLabel additionalLinks showEditLinks "Additional Web Pages" />
|
<@addLinkWithLabel additionalLinks editable "Additional Web Pages" />
|
||||||
<#if additionalLinks.statements?has_content> <#-- if there are any statements -->
|
<#if additionalLinks.statements?has_content> <#-- if there are any statements -->
|
||||||
<ul class="${linkListClass}" id="links-additional" role="list">
|
<ul class="${linkListClass}" id="links-additional" role="list">
|
||||||
<@objectPropertyList additionalLinks additionalLinks.statements additionalLinks.template showEditLinks />
|
<@objectPropertyList additionalLinks additionalLinks.statements additionalLinks.template editable />
|
||||||
</ul>
|
</ul>
|
||||||
</#if>
|
</#if>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -112,18 +111,25 @@ name will be used as the label. -->
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#-- Main image links -->
|
<#-- Main image links -->
|
||||||
<#macro imageLinks individual propertyGroups showEditLinks placeholderImage="">
|
<#macro imageLinks individual propertyGroups namespaces editable placeholderImage="">
|
||||||
<#assign mainImage = propertyGroups.getPropertyAndRemoveFromList("${namespaces.vitroPublic}mainImage")!>
|
<#local mainImage = propertyGroups.getPropertyAndRemoveFromList("${namespaces.vitroPublic}mainImage")!>
|
||||||
<#assign thumbUrl = individual.thumbUrl!>
|
<#local thumbUrl = individual.thumbUrl!>
|
||||||
<#-- Don't assume that if the mainImage property is populated, there is a thumbnail image (though that is the general case).
|
<#-- Don't assume that if the mainImage property is populated, there is a thumbnail image (though that is the general case).
|
||||||
If there's a mainImage statement but no thumbnail image, treat it as if there is no image. -->
|
If there's a mainImage statement but no thumbnail image, treat it as if there is no image. -->
|
||||||
<#if (mainImage.statements)?has_content && thumbUrl?has_content>
|
<#if (mainImage.statements)?has_content && thumbUrl?has_content>
|
||||||
<div class="thumb-links"><@p.editingLinks mainImage mainImage.statements[0] showEditLinks /></div>
|
|
||||||
<a href="${individual.imageUrl}"><img class="individual-photo" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="160" /></a>
|
<a href="${individual.imageUrl}"><img class="individual-photo" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="160" /></a>
|
||||||
|
<@p.editingLinks mainImage mainImage.statements[0] editable />
|
||||||
<#else>
|
<#else>
|
||||||
<@p.addLinkWithLabel mainImage showEditLinks "Photo" />
|
<@p.addLinkWithLabel mainImage editable "Photo" />
|
||||||
<#if placeholderImage?has_content>
|
<#if placeholderImage?has_content>
|
||||||
<img class="individual-photo" src="${placeholderImage}" title = "no image" alt="placeholder image" width="160" />
|
<img class="individual-photo" src="${placeholderImage}" title = "no image" alt="placeholder image" width="160" />
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
<#-- Label -->
|
||||||
|
<#macro label individual editable>
|
||||||
|
<#local label = individual.nameStatement>
|
||||||
|
${label.value}
|
||||||
|
<#-- ><@p.editingLinks "label" label editable /> -->
|
||||||
|
</#macro>
|
Loading…
Add table
Reference in a new issue