work on VIVO-60 application ontology for property/class combinations

This commit is contained in:
brianjlowe 2013-05-22 16:28:11 -04:00
parent d65d4109fa
commit 7760fdf6af
5 changed files with 24 additions and 6 deletions

View file

@ -114,9 +114,11 @@ public class DisplayByRolePermission extends Permission {
ObjectPropertyStatement stmt = action.getObjectPropertyStatement(); ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
String subjectUri = stmt.getSubjectURI(); String subjectUri = stmt.getSubjectURI();
String predicateUri = stmt.getPropertyURI(); String predicateUri = stmt.getPropertyURI();
String rangeUri = (stmt.getProperty() == null) ? null
: stmt.getProperty().getRangeVClassURI();
String objectUri = stmt.getObjectURI(); String objectUri = stmt.getObjectURI();
return canDisplayResource(subjectUri) return canDisplayResource(subjectUri)
&& canDisplayPredicate(predicateUri) && canDisplayPredicate(predicateUri, rangeUri)
&& canDisplayResource(objectUri); && canDisplayResource(objectUri);
} }
@ -126,8 +128,12 @@ public class DisplayByRolePermission extends Permission {
} }
private boolean canDisplayPredicate(String predicateUri) { private boolean canDisplayPredicate(String predicateUri) {
return canDisplayPredicate(predicateUri, null);
}
private boolean canDisplayPredicate(String predicateUri, String rangeUri) {
return PropertyRestrictionPolicyHelper.getBean(ctx) return PropertyRestrictionPolicyHelper.getBean(ctx)
.canDisplayPredicate(predicateUri, this.roleLevel); .canDisplayPredicate(predicateUri, rangeUri, this.roleLevel);
} }
@Override @Override

View file

@ -258,16 +258,22 @@ public class PropertyRestrictionPolicyHelper {
return true; return true;
} }
public boolean canDisplayPredicate(String predicateUri, RoleLevel userRole) {
return canDisplayPredicate(predicateUri, null, userRole);
}
/** /**
* If display of a predicate is restricted, the user's role must be at least * If display of a predicate is restricted, the user's role must be at least
* as high as the restriction level. * as high as the restriction level.
*/ */
public boolean canDisplayPredicate(String predicateUri, RoleLevel userRole) { public boolean canDisplayPredicate(String predicateUri, String rangeUri, RoleLevel userRole) {
if (predicateUri == null) { if (predicateUri == null) {
log.debug("can't display predicate: predicateUri was null"); log.debug("can't display predicate: predicateUri was null");
return false; return false;
} }
// TODO insert combo logic here
RoleLevel displayThreshold = displayThresholdMap.get(predicateUri); RoleLevel displayThreshold = displayThresholdMap.get(predicateUri);
if (isAuthorized(userRole, displayThreshold)) { if (isAuthorized(userRole, displayThreshold)) {
log.debug("can display predicate: '" + predicateUri log.debug("can display predicate: '" + predicateUri

View file

@ -105,6 +105,10 @@ class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements Objec
for (Map<String, String> map : data) { for (Map<String, String> map : data) {
String objectUri = map.get(objectKey); String objectUri = map.get(objectKey);
ObjectPropertyStatement statement = new ObjectPropertyStatementImpl(subjectUri, propertyUri, objectUri); ObjectPropertyStatement statement = new ObjectPropertyStatementImpl(subjectUri, propertyUri, objectUri);
ObjectProperty op = new ObjectProperty();
op.setURI(propertyUri);
op.setRangeVClassURI(rangeUri);
statement.setProperty(op);
stmtsToData.put(statement, map); stmtsToData.put(statement, map);
} }

View file

@ -297,7 +297,9 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
QuerySolutionMap initialBindings = new QuerySolutionMap(); QuerySolutionMap initialBindings = new QuerySolutionMap();
initialBindings.add("subject", ResourceFactory.createResource(subjectUri)); initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
initialBindings.add("property", ResourceFactory.createResource(propertyUri)); initialBindings.add("property", ResourceFactory.createResource(propertyUri));
initialBindings.add("objectType", ResourceFactory.createResource(rangeUri)); if (rangeUri != null) {
initialBindings.add("objectType", ResourceFactory.createResource(rangeUri));
}
// 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>>();

View file

@ -55,7 +55,7 @@ public class ApplicationConfigurationOntologyUtils {
"}"; "}";
for (ObjectProperty op : propList) { for (ObjectProperty op : propList) {
log.info("Checking " + op.getURI() + " for additional properties"); log.debug("Checking " + op.getURI() + " for additional properties");
String queryStr = propQuery.replaceAll("\\?property", "<" + op.getURI() + ">"); String queryStr = propQuery.replaceAll("\\?property", "<" + op.getURI() + ">");
log.debug(queryStr); log.debug(queryStr);
Query q = QueryFactory.create(queryStr); Query q = QueryFactory.create(queryStr);