work on VIVO-60 application ontology code for class/property combination configuration
This commit is contained in:
parent
3ce6a224a3
commit
b26922242a
14 changed files with 195 additions and 58 deletions
|
@ -8,6 +8,7 @@ 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.Model;
|
||||
|
||||
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
||||
import edu.cornell.mannlib.vedit.listener.ChangeListener;
|
||||
|
@ -92,8 +93,9 @@ public class PropertyRestrictionListener implements ChangeListener {
|
|||
|
||||
private void createAndSetBean() {
|
||||
OntModel model = ModelAccess.on(ctx).getJenaOntModel();
|
||||
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
|
||||
PropertyRestrictionPolicyHelper bean = PropertyRestrictionPolicyHelper
|
||||
.createBean(model);
|
||||
.createBean(model, displayModel);
|
||||
PropertyRestrictionPolicyHelper.setBean(ctx, bean);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,13 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
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.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
@ -97,7 +104,10 @@ public class PropertyRestrictionPolicyHelper {
|
|||
* Initialize the bean with the standard prohibitions and exceptions, and
|
||||
* with the thresholds obtained from the model.
|
||||
*/
|
||||
public static PropertyRestrictionPolicyHelper createBean(OntModel model) {
|
||||
public static PropertyRestrictionPolicyHelper createBean(OntModel model,
|
||||
Model displayModel) {
|
||||
|
||||
|
||||
Map<String, RoleLevel> displayThresholdMap = new HashMap<String, RoleLevel>();
|
||||
Map<String, RoleLevel> modifyThresholdMap = new HashMap<String, RoleLevel>();
|
||||
|
||||
|
@ -112,7 +122,7 @@ public class PropertyRestrictionPolicyHelper {
|
|||
|
||||
PropertyRestrictionPolicyHelper bean = new PropertyRestrictionPolicyHelper(
|
||||
PROHIBITED_NAMESPACES, PERMITTED_EXCEPTIONS,
|
||||
displayThresholdMap, modifyThresholdMap);
|
||||
displayThresholdMap, modifyThresholdMap, displayModel);
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
@ -172,6 +182,8 @@ public class PropertyRestrictionPolicyHelper {
|
|||
* the threshold role.
|
||||
*/
|
||||
private final Map<String, RoleLevel> modifyThresholdMap;
|
||||
|
||||
private final Model displayModel;
|
||||
|
||||
/**
|
||||
* Store unmodifiable versions of the inputs.
|
||||
|
@ -183,11 +195,13 @@ public class PropertyRestrictionPolicyHelper {
|
|||
Collection<String> modifyProhibitedNamespaces,
|
||||
Collection<String> modifyExceptionsAllowedUris,
|
||||
Map<String, RoleLevel> displayThresholdMap,
|
||||
Map<String, RoleLevel> modifyThresholdMap) {
|
||||
Map<String, RoleLevel> modifyThresholdMap,
|
||||
Model displayModel) {
|
||||
this.modifyProhibitedNamespaces = unmodifiable(modifyProhibitedNamespaces);
|
||||
this.modifyExceptionsAllowedUris = unmodifiable(modifyExceptionsAllowedUris);
|
||||
this.displayThresholdMap = unmodifiable(displayThresholdMap);
|
||||
this.modifyThresholdMap = unmodifiable(modifyThresholdMap);
|
||||
this.displayModel = displayModel;
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("prohibited: " + this.modifyProhibitedNamespaces);
|
||||
|
@ -271,10 +285,19 @@ public class PropertyRestrictionPolicyHelper {
|
|||
log.debug("can't display predicate: predicateUri was null");
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO insert combo logic here
|
||||
|
||||
RoleLevel displayThreshold = displayThresholdMap.get(predicateUri);
|
||||
RoleLevel displayThreshold = RoleLevel.NOBODY;
|
||||
if (rangeUri == null) {
|
||||
displayThreshold = displayThresholdMap.get(predicateUri);
|
||||
} else {
|
||||
log.debug("Getting display threshold for " + predicateUri + " " + rangeUri);
|
||||
displayThreshold = getDisplayThreshold(predicateUri, rangeUri);
|
||||
if (displayThreshold == null) {
|
||||
displayThreshold = displayThresholdMap.get(predicateUri);
|
||||
}
|
||||
log.debug(displayThreshold);
|
||||
}
|
||||
|
||||
if (isAuthorized(userRole, displayThreshold)) {
|
||||
log.debug("can display predicate: '" + predicateUri
|
||||
+ "', userRole=" + userRole + ", thresholdRole="
|
||||
|
@ -286,7 +309,45 @@ public class PropertyRestrictionPolicyHelper {
|
|||
+ userRole + ", thresholdRole=" + displayThreshold);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the role level threshold for displaying a predicate with a particular
|
||||
* object class
|
||||
* @param predicateUri
|
||||
* @param rangeUri
|
||||
* @return RoleLevel threshold
|
||||
*/
|
||||
private RoleLevel getDisplayThreshold(String predicateUri, String rangeUri) {
|
||||
String query = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||
"SELECT ?level WHERE { \n" +
|
||||
// " ?p rdfs:subPropertyOf ?property . \n" +
|
||||
" ?context config:configContextFor ?p . \n" +
|
||||
" ?context config:qualifiedBy ?range . \n" +
|
||||
" ?context config:hasConfiguration ?configuration . \n" +
|
||||
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?level \n" +
|
||||
"}";
|
||||
Query q = QueryFactory.create(query);
|
||||
QueryExecution qe = QueryExecutionFactory.create(q, displayModel);
|
||||
try {
|
||||
ResultSet rs = qe.execSelect();
|
||||
if (!rs.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
while(rs.hasNext()) {
|
||||
QuerySolution qsoln = rs.nextSolution();
|
||||
Resource levelRes = qsoln.getResource("level");
|
||||
if (levelRes != null) {
|
||||
return RoleLevel.getRoleByUri(levelRes.getURI());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
qe.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A predicate cannot be modified if its namespace is in the prohibited list
|
||||
* (some exceptions are allowed).
|
||||
|
@ -356,9 +417,14 @@ public class PropertyRestrictionPolicyHelper {
|
|||
throw new NullPointerException(
|
||||
"jenaOntModel has not been initialized.");
|
||||
}
|
||||
|
||||
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
|
||||
if (displayModel == null) {
|
||||
throw new NullPointerException(
|
||||
"display model has not been initialized.");
|
||||
}
|
||||
|
||||
PropertyRestrictionPolicyHelper bean = PropertyRestrictionPolicyHelper
|
||||
.createBean(model);
|
||||
.createBean(model, displayModel);
|
||||
PropertyRestrictionPolicyHelper.setBean(ctx, bean);
|
||||
} catch (Exception e) {
|
||||
ss.fatal(this, "could not set up PropertyRestrictionPolicyHelper", e);
|
||||
|
|
|
@ -15,6 +15,8 @@ import java.util.Map;
|
|||
|
||||
import net.sf.jga.algorithms.Filter;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -29,7 +31,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
|
||||
/**
|
||||
* A Individual object that will delegate to an inner Individual
|
||||
|
@ -42,6 +43,8 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
|||
public class IndividualFiltering implements Individual {
|
||||
private final Individual _innerIndividual;
|
||||
private final VitroFilters _filters;
|
||||
|
||||
private static final Log log = LogFactory.getLog(IndividualFiltering.class);
|
||||
|
||||
public IndividualFiltering(Individual individual, VitroFilters filters) {
|
||||
super();
|
||||
|
@ -143,10 +146,18 @@ public class IndividualFiltering implements Individual {
|
|||
// I'd rather filter on the actual ObjectPropertyStatements here, but
|
||||
// Individual.getPopulatedObjectPropertyList doesn't actually populate
|
||||
// the ObjectProperty with statements. - jblake
|
||||
|
||||
// bjl23: disabling this filtering because the individual statements are
|
||||
// filtered later, and we need to allow for the possibility that a particular
|
||||
// predicate + range class combination is allowed even if the predicate is
|
||||
// hidden on its own.
|
||||
|
||||
// Will revisit filtering at this level if it turns out to be truly necessary.
|
||||
|
||||
List<ObjectProperty> outOProps = new ArrayList<ObjectProperty>();
|
||||
List<ObjectProperty> oProps = _innerIndividual.getPopulatedObjectPropertyList();
|
||||
for (ObjectProperty op: oProps) {
|
||||
if (_filters.getObjectPropertyStatementFilter().fn(
|
||||
if (true || _filters.getObjectPropertyStatementFilter().fn(
|
||||
new ObjectPropertyStatementImpl(this._innerIndividual.getURI(), op.getURI(), SOME_LITERAL))) {
|
||||
outOProps.add(op);
|
||||
}
|
||||
|
|
|
@ -231,12 +231,6 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private String stripItalics(String in) {
|
||||
String out = in.replaceAll("\\<i\\>","");
|
||||
out = out.replaceAll("\\<\\/i\\>","");
|
||||
return out;
|
||||
}
|
||||
|
||||
public List getAllObjectProperties() {
|
||||
getOntModel().enterCriticalSection(Lock.READ);
|
||||
|
@ -800,7 +794,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
PREFIXES + "\n" +
|
||||
"SELECT DISTINCT ?property WHERE { \n" +
|
||||
" ?subject ?property ?object . \n" +
|
||||
" ?property a owl:ObjectProperty . \n" +
|
||||
// " ?property a owl:ObjectProperty . \n" +
|
||||
" FILTER ( \n" +
|
||||
" isURI(?object) && \n" +
|
||||
PROPERTY_FILTERS + "\n" +
|
||||
|
@ -846,11 +840,19 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
|
||||
protected static final String LIST_VIEW_CONFIG_FILE_QUERY_STRING =
|
||||
"PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>" +
|
||||
"SELECT ?property ?filename WHERE { \n" +
|
||||
" ?property display:listViewConfigFile ?filename . \n" +
|
||||
"PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> \n" +
|
||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||
"SELECT ?property ?range ?filename WHERE { \n" +
|
||||
" { ?property display:listViewConfigFile ?filename \n" +
|
||||
" } UNION { \n" +
|
||||
" ?lv config:listViewConfigFile ?filename . \n " +
|
||||
" ?configuration config:hasListView ?lv . " +
|
||||
" ?context config:hasConfiguration ?configuration . \n" +
|
||||
" ?context config:configContextFor ?property . \n" +
|
||||
" ?context config:qualifiedBy ?range . \n" +
|
||||
" } \n" +
|
||||
"}";
|
||||
|
||||
|
||||
protected static Query listViewConfigFileQuery = null;
|
||||
static {
|
||||
try {
|
||||
|
@ -879,6 +881,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.next();
|
||||
String propertyUri = soln.getResource("property").getURI();
|
||||
RDFNode rangeNode = soln.get("range");
|
||||
String rangeUri = (rangeNode != null)
|
||||
? ((Resource) rangeNode).getURI()
|
||||
: OWL.Thing.getURI();
|
||||
ObjectProperty prop = getObjectPropertyByURI(propertyUri);
|
||||
if (prop == null) {
|
||||
//This is a warning only if this property is the one for which we're searching
|
||||
|
@ -889,7 +895,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
} else {
|
||||
String filename = soln.getLiteral("filename").getLexicalForm();
|
||||
customListViewConfigFileMap.put(new Pair<ObjectProperty, String>(prop, OWL.Thing.getURI()), filename);
|
||||
customListViewConfigFileMap.put(new Pair<ObjectProperty, String>(prop, rangeUri), filename);
|
||||
}
|
||||
}
|
||||
qexec.close();
|
||||
|
|
|
@ -53,6 +53,10 @@ public class EditConfigurationUtils {
|
|||
return vreq.getParameter("objectUri");
|
||||
}
|
||||
|
||||
public static String getRangeUri(VitroRequest vreq) {
|
||||
return vreq.getParameter("rangeUri");
|
||||
}
|
||||
|
||||
//get individual
|
||||
|
||||
public static Individual getSubjectIndividual(VitroRequest vreq) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
@ -15,22 +14,25 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
|
||||
public class IndividualsViaObjectPropetyOptions implements FieldOptions {
|
||||
|
||||
private static final Log log = LogFactory.getLog(IndividualsViaObjectPropetyOptions.class);
|
||||
|
||||
private static final String LEFT_BLANK = "";
|
||||
private String subjectUri;
|
||||
private String predicateUri;
|
||||
private String rangeUri;
|
||||
private String objectUri;
|
||||
|
||||
private String defaultOptionLabel;
|
||||
|
||||
public IndividualsViaObjectPropetyOptions(String subjectUri,
|
||||
String predicateUri, String objectUri) throws Exception {
|
||||
String predicateUri, String rangeUri, String objectUri) throws Exception {
|
||||
super();
|
||||
|
||||
if (subjectUri == null || subjectUri.equals("")) {
|
||||
|
@ -42,8 +44,14 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
|
|||
|
||||
this.subjectUri = subjectUri;
|
||||
this.predicateUri = predicateUri;
|
||||
this.rangeUri = rangeUri;
|
||||
this.objectUri = objectUri;
|
||||
}
|
||||
|
||||
public IndividualsViaObjectPropetyOptions(String subjectUri,
|
||||
String predicateUri, String objectUri) throws Exception {
|
||||
this (subjectUri, predicateUri, null, objectUri);
|
||||
}
|
||||
|
||||
public IndividualsViaObjectPropetyOptions setDefaultOptionLabel(String label){
|
||||
this.defaultOptionLabel = label;
|
||||
|
@ -65,21 +73,9 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
|
|||
}
|
||||
|
||||
Individual subject = wDaoFact.getIndividualDao().getIndividualByURI(subjectUri);
|
||||
ObjectProperty objProp = wDaoFact.getObjectPropertyDao().getObjectPropertyByURI(predicateUri);
|
||||
|
||||
//get all vclasses applicable to the individual subject
|
||||
List<VClass> subjectVClasses = subject.getVClasses();
|
||||
//using hashset to prevent duplicates
|
||||
HashSet<String> vclassesURIs = new HashSet<String>();
|
||||
//Get the range vclasses applicable for the property and each vclass for the subject
|
||||
for(VClass subjectVClass: subjectVClasses) {
|
||||
List<VClass> vclasses = wDaoFact.getVClassDao().getVClassesForProperty(subjectVClass.getURI(), predicateUri);
|
||||
//add range vclass to hash
|
||||
if(vclasses != null) {
|
||||
for(VClass v: vclasses) {
|
||||
vclassesURIs.add(v.getURI());
|
||||
}
|
||||
}
|
||||
}
|
||||
HashSet<String> vclassesURIs = getApplicableVClassURIs(subject, wDaoFact);
|
||||
|
||||
if (vclassesURIs.size() == 0) {
|
||||
return optionsMap;
|
||||
|
@ -114,6 +110,33 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
|
|||
return optionsMap;
|
||||
}
|
||||
|
||||
private HashSet<String> getApplicableVClassURIs(Individual subject, WebappDaoFactory wDaoFact) {
|
||||
HashSet<String> vclassesURIs = new HashSet<String>();
|
||||
if (rangeUri != null) {
|
||||
log.debug("individualsViaObjectProperty using rangeUri " + rangeUri);
|
||||
vclassesURIs.add(rangeUri);
|
||||
return vclassesURIs;
|
||||
}
|
||||
|
||||
log.debug("individualsViaObjectProperty not using any rangeUri");
|
||||
|
||||
List<VClass> subjectVClasses = subject.getVClasses();
|
||||
|
||||
//using hashset to prevent duplicates
|
||||
|
||||
//Get the range vclasses applicable for the property and each vclass for the subject
|
||||
for(VClass subjectVClass: subjectVClasses) {
|
||||
List<VClass> vclasses = wDaoFact.getVClassDao().getVClassesForProperty(subjectVClass.getURI(), predicateUri);
|
||||
//add range vclass to hash
|
||||
if(vclasses != null) {
|
||||
for(VClass v: vclasses) {
|
||||
vclassesURIs.add(v.getURI());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vclassesURIs;
|
||||
}
|
||||
|
||||
// copied from OptionsForPropertyTag.java in the thought that class may be deprecated
|
||||
private static List<Individual> removeIndividualsAlreadyInRange(List<Individual> individuals,
|
||||
|
|
|
@ -100,10 +100,15 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
}
|
||||
|
||||
protected List<String> getRangeTypes(VitroRequest vreq) {
|
||||
WebappDaoFactory wDaoFact = vreq.getWebappDaoFactory();
|
||||
List<String> types = new ArrayList<String>();
|
||||
Individual subject = EditConfigurationUtils.getSubjectIndividual(vreq);
|
||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
WebappDaoFactory wDaoFact = vreq.getWebappDaoFactory();
|
||||
List<String> types = new ArrayList<String>();
|
||||
String rangeUri = EditConfigurationUtils.getRangeUri(vreq);
|
||||
if (rangeUri != null) {
|
||||
types.add(rangeUri);
|
||||
return types;
|
||||
}
|
||||
//Get all vclasses applicable to subject
|
||||
List<VClass> vClasses = subject.getVClasses();
|
||||
HashSet<String> typesHash = new HashSet<String>();
|
||||
|
@ -180,7 +185,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
this.setSparqlQueries(editConfiguration);
|
||||
|
||||
//set fields
|
||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq), EditConfigurationUtils.getRangeUri(vreq));
|
||||
|
||||
// No need to put in session here b/c put in session within edit request dispatch controller instead
|
||||
//placing in session depends on having edit key which is handled in edit request dispatch controller
|
||||
|
@ -350,7 +355,11 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
return map;
|
||||
}
|
||||
|
||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) throws Exception {
|
||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) throws Exception {
|
||||
setFields(editConfiguration, vreq, predicateUri, null);
|
||||
}
|
||||
|
||||
protected void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri, String rangeUri) throws Exception {
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName("objectVar");
|
||||
|
||||
|
@ -361,7 +370,8 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
|
|||
if( ! doAutoComplete ){
|
||||
field.setOptions( new IndividualsViaObjectPropetyOptions(
|
||||
subjectUri,
|
||||
predicateUri,
|
||||
predicateUri,
|
||||
rangeUri,
|
||||
objectUri));
|
||||
}else{
|
||||
field.setOptions(null);
|
||||
|
|
|
@ -199,6 +199,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
String editConfGeneratorName = null;
|
||||
|
||||
String predicateUri = getPredicateUri(vreq);
|
||||
String rangeUri = EditConfigurationUtils.getRangeUri(vreq);
|
||||
|
||||
// *** handle the case where the form is specified as a request parameter ***
|
||||
String formParam = getFormParam(vreq);
|
||||
|
@ -215,7 +216,9 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
|||
// *** check for a predicate URI in the request
|
||||
}else if( predicateUri != null && !predicateUri.isEmpty() ){
|
||||
Property prop = getProperty( predicateUri, vreq);
|
||||
if( prop != null && prop.getCustomEntryForm() != null ){
|
||||
if (prop != null && rangeUri != null) {
|
||||
// get the custom form out of the application ontology data
|
||||
} else if( prop != null && prop.getCustomEntryForm() != null ){
|
||||
//there is a custom form, great! let's use it.
|
||||
editConfGeneratorName = prop.getCustomEntryForm();
|
||||
|
||||
|
|
|
@ -44,14 +44,15 @@ public class ApplicationConfigurationOntologyUtils {
|
|||
Model union = ModelFactory.createUnion(displayModel, tboxModel);
|
||||
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||
"SELECT ?range ?label ?listView ?group WHERE { \n" +
|
||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||
"SELECT ?range ?label ?group ?customForm WHERE { \n" +
|
||||
" ?p rdfs:subPropertyOf ?property . \n" +
|
||||
" ?context config:configContextFor ?p . \n" +
|
||||
" ?context config:qualifiedBy ?range . \n" +
|
||||
" ?context config:hasConfiguration ?configuration . \n" +
|
||||
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
||||
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
||||
" OPTIONAL { ?configuration config:hasListView ?lv . ?lv config:listViewConfigFile ?listView } \n" +
|
||||
" OPTIONAL { ?configuration vitro:customEntryFormAnnot ?customForm } \n" +
|
||||
"}";
|
||||
|
||||
for (ObjectProperty op : propList) {
|
||||
|
@ -85,11 +86,11 @@ public class ApplicationConfigurationOntologyUtils {
|
|||
} else {
|
||||
newProp.setDomainPublic(op.getDomainPublic());
|
||||
}
|
||||
Literal listViewLit = qsoln.getLiteral("listView");
|
||||
if (listViewLit != null) {
|
||||
// TODO where do we get the list views from?
|
||||
Literal customFormLit = qsoln.getLiteral("customForm");
|
||||
if (customFormLit != null) {
|
||||
newProp.setCustomEntryForm(customFormLit.getLexicalForm());
|
||||
} else {
|
||||
// newProp.set
|
||||
newProp.setCustomEntryForm(op.getCustomEntryForm());
|
||||
}
|
||||
additionalProps.add(newProp);
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
|
||||
//Also used above and can be used in object auto complete form
|
||||
public String getObjectPropertyNameForDisplay() {
|
||||
// TODO modify this to get prop/class combo
|
||||
String propertyTitle = null;
|
||||
Individual objectIndividual = EditConfigurationUtils.getObjectIndividual(vreq);
|
||||
ObjectProperty prop = EditConfigurationUtils.getObjectProperty(vreq);
|
||||
|
@ -546,7 +547,6 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
|
||||
HashMap<String,String> types = new HashMap<String, String>();
|
||||
for( VClass vclass : vclasses ){
|
||||
|
||||
String name = null;
|
||||
if( vclass.getPickListName() != null && vclass.getPickListName().length() > 0){
|
||||
name = vclass.getPickListName();
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
" properties due to application configuration ontology");
|
||||
}
|
||||
|
||||
populatedObjectPropertyList.addAll(additions);
|
||||
populatedObjectPropertyList.addAll(additions);
|
||||
|
||||
propertyList.addAll(populatedObjectPropertyList);
|
||||
|
||||
|
|
|
@ -122,12 +122,20 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
return;
|
||||
}
|
||||
|
||||
String rangeUri = (property instanceof ObjectProperty)
|
||||
? ((ObjectProperty) property).getRangeVClassURI()
|
||||
: "data";
|
||||
|
||||
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||
addUrl = getImageUploadUrl(subjectUri, "add");
|
||||
} else {
|
||||
ParamMap params = new ParamMap(
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri);
|
||||
"predicateUri", propertyUri);
|
||||
|
||||
if (rangeUri != null) {
|
||||
params.put("rangeUri", rangeUri);
|
||||
}
|
||||
|
||||
params.putAll(UrlBuilder.getModelParams(vreq));
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
|
|||
bean = new PropertyRestrictionPolicyHelper(
|
||||
Arrays.asList(PROHIBITED_NAMESPACES),
|
||||
Arrays.asList(PERMITTED_EXCEPTIONS), displayLevels,
|
||||
modifyLevels);
|
||||
modifyLevels, ModelFactory.createDefaultModel());
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -8,6 +8,9 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
|
||||
|
@ -57,7 +60,7 @@ public class PropertyRestrictionPolicyHelperStub extends
|
|||
Map<String, RoleLevel> displayThresholds,
|
||||
Map<String, RoleLevel> modifyThresholds) {
|
||||
super(modifyRestrictedNamespaces, modifyPermittedExceptions,
|
||||
displayThresholds, modifyThresholds);
|
||||
displayThresholds, modifyThresholds, ModelFactory.createDefaultModel());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue