VIVO-904: the display limit annotation on data and faux properties now determines when the more... link is employed for one of these properties. Regular object properties will have a default limit of 5. Also, the add statement link is no longer suppressed when the display limit is reached.

This commit is contained in:
Tim Worrall 2015-02-09 15:54:11 -05:00
parent ed9b82258d
commit b21cd24489
4 changed files with 35 additions and 6 deletions

View file

@ -65,6 +65,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
private String objectKey; private String objectKey;
private String queryString; private String queryString;
private Set<String> constructQueries; private Set<String> constructQueries;
private int displayLimit;
DataPropertyTemplateModel(DataProperty dp, Individual subject, VitroRequest vreq, DataPropertyTemplateModel(DataProperty dp, Individual subject, VitroRequest vreq,
boolean editing, List<DataProperty> populatedDataPropertyList) { boolean editing, List<DataProperty> populatedDataPropertyList) {
@ -82,7 +83,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
constructQueries = getConstructQueries(); constructQueries = getConstructQueries();
statements = new ArrayList<DataPropertyStatementTemplateModel>(); statements = new ArrayList<DataPropertyStatementTemplateModel>();
displayLimit = dp.getDisplayLimit();
// If the property is populated, get the data property statements via a sparql query // If the property is populated, get the data property statements via a sparql query
if (populatedDataPropertyList.contains(dp)) { if (populatedDataPropertyList.contains(dp)) {
log.debug("Getting data for populated data property " + getUri()); log.debug("Getting data for populated data property " + getUri());
@ -108,14 +109,22 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
return; return;
} }
// If the display limit has already been reached, we can't add a new statement. /* If the display limit has already been reached, we can't add a new statement.
// NB This appears to be a misuse of a value called "display limit". Note that it's NB This appears to be a misuse of a value called "display limit". Note that it's
// not used to limit display, either, so should be renamed. not used to limit display, either, so should be renamed.
int displayLimit = dp.getDisplayLimit(); int displayLimit = dp.getDisplayLimit();
// Display limit of -1 (default value for new property) means no display limit Display limit of -1 (default value for new property) means no display limit
if ( displayLimit >= 0 && statements.size() >= displayLimit ) { if ( displayLimit >= 0 && statements.size() >= displayLimit ) {
return; return;
} }
*/
// Rewriting the above per jc55. If the data property is functional, there should only
// be 1 statement. The Display Limit is for determining how many statements to display
// before a "more..." link is used to hide statements exceeding the display limit. tlw72
boolean functional = dp.getFunctional();
if ( functional && statements.size() >= 1 ) {
return;
}
// Determine whether a new statement can be added // Determine whether a new statement can be added
RequestedAction action = new AddDataPropertyStatement( RequestedAction action = new AddDataPropertyStatement(
@ -147,6 +156,11 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
return Route.DATA_PROPERTY_EDIT; return Route.DATA_PROPERTY_EDIT;
} }
@Override
public int getDisplayLimit() {
return displayLimit;
}
public ConfigError checkQuery(String queryString) { public ConfigError checkQuery(String queryString) {
if (StringUtils.isBlank(queryString)) { if (StringUtils.isBlank(queryString)) {
return ConfigError.NO_SELECT_QUERY; return ConfigError.NO_SELECT_QUERY;
@ -192,6 +206,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
return getTemplateName(); return getTemplateName();
} }
/* Template methods */ /* Template methods */
public DataPropertyStatementTemplateModel first() { public DataPropertyStatementTemplateModel first() {

View file

@ -41,6 +41,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
private String name; private String name;
private FauxProperty fauxProperty; private FauxProperty fauxProperty;
private int displayLimit;
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq, String name) { PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq, String name) {
this.vreq = vreq; this.vreq = vreq;
@ -49,11 +50,13 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
propertyUri = property.getURI(); propertyUri = property.getURI();
localName = property.getLocalName(); localName = property.getLocalName();
this.name = name; this.name = name;
this.displayLimit = displayLimit;
addUrl = ""; addUrl = "";
fauxProperty = isFauxProperty(property); fauxProperty = isFauxProperty(property);
if (fauxProperty != null) { if (fauxProperty != null) {
this.name = fauxProperty.getDisplayName(); this.name = fauxProperty.getDisplayName();
this.displayLimit = fauxProperty.getDisplayLimit();
} }
setVerboseDisplayValues(property); setVerboseDisplayValues(property);
@ -142,6 +145,10 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
return name; return name;
} }
public int getDisplayLimit() {
return displayLimit;
}
public String getLocalName() { public String getLocalName() {
return localName; return localName;
} }

View file

@ -68,3 +68,6 @@ li.selectedGroupTab {
li.groupTabSpacer { li.groupTabSpacer {
float:left;border-bottom: 1px solid #DFE6E5;background-color:#fff;width:3px;height:37px float:left;border-bottom: 1px solid #DFE6E5;background-color:#fff;width:3px;height:37px
} }
div.additionalItems {
margin-top: 0 !important;
}

View file

@ -42,7 +42,11 @@
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> </h3> <h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> </h3>
</#if> </#if>
<#-- List the statements for each property --> <#-- List the statements for each property -->
<ul class="property-list" role="list" id="${property.localName}-${rangeClass}-List"> <#assign limit = property.getDisplayLimit()!5 />
<#if limit == -1 || limit == 0 >
<#assign limit = 5 />
</#if>
<ul class="property-list" role="list" id="${property.localName}-${rangeClass}-List" displayLimit="${limit}">
<#-- data property --> <#-- data property -->
<#if property.type == "data"> <#if property.type == "data">
<@p.dataPropertyList property editable /> <@p.dataPropertyList property editable />