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

@ -34,14 +34,6 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
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
DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
List<Literal> values = dpDao.getDataPropertyValuesForIndividualByProperty(subject, dp);
@ -49,6 +41,17 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
for (Literal value : values) {
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 */

View file

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