Added template model methods to get first value of data properties and first statement of data props and uncollated object props. Improved efficiency of moniker/preferred title code in person template. Added order by statement to default list view queries so order is not random.

This commit is contained in:
rjy7 2011-02-07 15:52:51 +00:00
parent ec5283795f
commit e028e17010
4 changed files with 16 additions and 3 deletions

View file

@ -84,4 +84,13 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
return statements; return statements;
} }
public DataPropertyStatementTemplateModel getFirst() {
return ( (statements == null || statements.isEmpty()) ) ? null : statements.get(0);
}
public String getFirstValue() {
DataPropertyStatementTemplateModel first = getFirst();
return first == null ? null : first.getValue();
}
} }

View file

@ -65,4 +65,8 @@ public class UncollatedObjectPropertyTemplateModel extends ObjectPropertyTemplat
public boolean isCollatedBySubclass() { public boolean isCollatedBySubclass() {
return false; return false;
} }
public ObjectPropertyStatementTemplateModel getFirst() {
return ( (statements == null || statements.isEmpty()) ) ? null : statements.get(0);
}
} }

View file

@ -14,7 +14,7 @@
?subject ?property ?object ?subject ?property ?object
OPTIONAL { ?object rdfs:label ?name } OPTIONAL { ?object rdfs:label ?name }
OPTIONAL { ?object vitro:moniker ?moniker } OPTIONAL { ?object vitro:moniker ?moniker }
} } ORDER BY ?name ?object
</query-base> </query-base>
<query-collated> <query-collated>
@ -28,7 +28,7 @@
OPTIONAL { ?object rdfs:label ?name } OPTIONAL { ?object rdfs:label ?name }
OPTIONAL { ?object vitro:moniker ?moniker } OPTIONAL { ?object vitro:moniker ?moniker }
FILTER ( afn:namespace(?subclass) != "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" ) FILTER ( afn:namespace(?subclass) != "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" )
} ORDER BY ?subclass } ORDER BY ?subclass ?name ?object
</query-collated> </query-collated>
<query-construct> <query-construct>

View file

@ -180,7 +180,7 @@ name will be used as the label. -->
If there's a mainImage statement but no thumbnail image, treat it as if there is no image. --> If there's a mainImage statement but no thumbnail image, treat it as if there is no image. -->
<#if (mainImage.statements)?has_content && thumbUrl?has_content> <#if (mainImage.statements)?has_content && thumbUrl?has_content>
<a href="${individual.imageUrl}"><img class="individual-photo" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="160" /></a> <a href="${individual.imageUrl}"><img class="individual-photo" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="160" /></a>
<@p.editingLinks "${mainImage.localName}" mainImage.statements[0] editable /> <@p.editingLinks "${mainImage.localName}" mainImage.first editable />
<#else> <#else>
<#local imageLabel><@p.addLinkWithLabel mainImage editable "Photo" /></#local> <#local imageLabel><@p.addLinkWithLabel mainImage editable "Photo" /></#local>
${imageLabel} ${imageLabel}