NIHVIVO-1667 Don't display an add link for data properties whose display limit has already been reached.

This commit is contained in:
rjy7 2011-01-14 22:22:44 +00:00
parent 1e2070299d
commit 9ac7796c67
2 changed files with 15 additions and 11 deletions

View file

@ -33,15 +33,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
super(dp, subject, policyHelper); super(dp, subject, policyHelper);
setName(dp.getPublicName()); setName(dp.getPublicName());
// Determine whether a new statement can be added
if (policyHelper != null) {
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
if (policyHelper.isAuthorizedAction(action)) {
addAccess = true;
}
}
// Get the data property statements via a sparql query // Get the data property statements via a sparql query
DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao(); DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
List<Literal> values = dpDao.getDataPropertyValuesForIndividualByProperty(subject, dp); List<Literal> values = dpDao.getDataPropertyValuesForIndividualByProperty(subject, dp);
@ -49,6 +41,17 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
for (Literal value : values) { for (Literal value : values) {
statements.add(new DataPropertyStatementTemplateModel(subjectUri, propertyUri, value, policyHelper)); statements.add(new DataPropertyStatementTemplateModel(subjectUri, propertyUri, value, policyHelper));
} }
// Determine whether a new statement can be added
if (policyHelper != null) {
// If the display limit has already been reached, we can't add a new statement
if ( dp.getDisplayLimit() > statements.size() ) {
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
if (policyHelper.isAuthorizedAction(action)) {
addAccess = true;
}
}
}
} }
/* Access methods for templates */ /* Access methods for templates */

View file

@ -99,8 +99,8 @@ public class GroupedPropertyList extends BaseTemplateModel {
// Build the template data model from the groupList // Build the template data model from the groupList
groups = new ArrayList<PropertyGroupTemplateModel>(propertyGroupList.size()); groups = new ArrayList<PropertyGroupTemplateModel>(propertyGroupList.size());
for (PropertyGroup pg : propertyGroupList) { for (PropertyGroup propertyGroup: propertyGroupList) {
groups.add(new PropertyGroupTemplateModel(vreq, pg, subject, policyHelper)); groups.add(new PropertyGroupTemplateModel(vreq, propertyGroup, subject, policyHelper));
} }
} }
@ -425,5 +425,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
} }
return null; return null;
} }
} }