NIHVIVO-1590 dateTimeValue custom list view finished; dateTimeInterval custom list view in progress.
This commit is contained in:
parent
ea78774a2d
commit
11dd397799
3 changed files with 74 additions and 18 deletions
|
@ -114,7 +114,7 @@ public class FreemarkerConfigurationLoader {
|
|||
|
||||
String dateFormat = "M/d/yyyy";
|
||||
config.setDateFormat(dateFormat);
|
||||
String timeFormat = "hh:mm a";
|
||||
String timeFormat = "h:mm a";
|
||||
config.setTimeFormat(timeFormat);
|
||||
config.setDateTimeFormat(dateFormat + " " + timeFormat);
|
||||
|
||||
|
|
|
@ -256,13 +256,13 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
*/
|
||||
public List<Map<String, String>> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String queryString) {
|
||||
|
||||
log.debug("Object property query string: " + queryString);
|
||||
log.debug("Query string for object property " + propertyUri + ": " + queryString);
|
||||
|
||||
Query query = null;
|
||||
try {
|
||||
query = QueryFactory.create(queryString, Syntax.syntaxARQ);
|
||||
} catch(Throwable th){
|
||||
log.error("could not create SPARQL query for query string " + th.getMessage());
|
||||
log.error("Could not create SPARQL query for query string. " + th.getMessage());
|
||||
log.error(queryString);
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
QueryExecution qexec = QueryExecutionFactory.create(
|
||||
query, dataset, bindings);
|
||||
ResultSet results = qexec.execSelect();
|
||||
|
||||
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.nextSolution();
|
||||
list.add(QueryUtils.querySolutionToStringValueMap(soln));
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Macros and functions for datetime formatting.
|
||||
|
||||
Currently these do more than format the datetime string, they actually select the precision as well. This should change in a future
|
||||
implementation; see NIHVIVO-1567. We want the Java code to apply the precision to the datetime string to pass only the
|
||||
meaningful data to the templates. The templates can format as they like, so these functions/macros would do display formatting
|
||||
but not data extraction.
|
||||
-->
|
||||
<#-- Macros for datetime formatting -->
|
||||
|
||||
<#-- Macro yearInterval
|
||||
|
||||
|
@ -39,15 +33,77 @@
|
|||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#-- Function xsdDateTimeToYear
|
||||
|
||||
Display an XSD datetime string as a year.
|
||||
|
||||
Example: 1983-12-07T17:15:28Z displays as 1983
|
||||
<#macro dateTimeInterval dateTimeStart precisionStart dateTimeEnd precisionEnd endAsRange=true>
|
||||
|
||||
<#if dateTimeStart?has_content>
|
||||
<#local start = formatXsdDateTime(dateTimeStart, precisionStart)>
|
||||
</#if>
|
||||
|
||||
<#if dateTimeEnd?has_content>
|
||||
<#local end = formatXsdDateTime(dateTimeEnd, precisionEnd)>
|
||||
</#if>
|
||||
|
||||
<#local interval>
|
||||
<#if start?? && end??>
|
||||
${start} - ${end}
|
||||
<#elseif start??>
|
||||
${start} -
|
||||
<#elseif end??>
|
||||
<#if endAsRange>- </#if>${end}
|
||||
</#if>
|
||||
</#local>
|
||||
|
||||
<#if interval?has_content>
|
||||
<span class="listDateTime">${interval}</span>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#-- Functions for formatting and applying precision to a datetime
|
||||
|
||||
Currently these do more than format the datetime string, they select the precision as well. This should change in a future
|
||||
implementation; see NIHVIVO-1567. We want the Java code to apply the precision to the datetime string to pass only the
|
||||
meaningful data to the templates. The templates can format as they like, so these functions/macros would do display formatting
|
||||
but not data extraction.
|
||||
-->
|
||||
|
||||
<#function xsdDateTimeToYear datetime>
|
||||
<#return datetime?date("yyyy")?string("yyyy") >
|
||||
<#function toDateTime dateTimeString>
|
||||
<#-- First convert the datetime string to a string format that Freemarker
|
||||
understands, then to a datetime object -->
|
||||
<#return dateTimeString?replace("T", " ")?datetime("yyyy-MM-dd HH:mm:ss")>
|
||||
</#function>
|
||||
|
||||
<#function formatXsdDateTime dateTime precision view="short">
|
||||
|
||||
<#-- Convert to a string format that Freemarker understands,
|
||||
then to a datetime -->
|
||||
<#local dt = toDateTime(dateTime)>
|
||||
|
||||
<#-- Use the precision to determine which portion to display,
|
||||
and the view to determine how to display it. -->
|
||||
<#local format>
|
||||
<#if view == "long">
|
||||
<#if precision == "yearPrecision">yyyy
|
||||
<#elseif precision == "yearMonthPrecision">MMMM yyyy
|
||||
<#elseif precision == "yearMonthDayPrecision">MMMM d, yyyy
|
||||
<#else>MMMM d, yyyy h:mm a
|
||||
</#if>
|
||||
<#else>
|
||||
<#if precision == "yearPrecision">yyyy
|
||||
<#elseif precision == "yearMonthPrecision">M-yyyy
|
||||
<#elseif precision == "yearMonthDayPrecision">M-d-yyyy
|
||||
<#else>M-d-yyyy h:mm a
|
||||
</#if>
|
||||
</#if>
|
||||
</#local>
|
||||
|
||||
<#return dt?string(format)>
|
||||
</#function>
|
||||
|
||||
<#-- Function xsdDateTimeToYear -->
|
||||
|
||||
<#-- get rid of this -->
|
||||
|
||||
<#function xsdDateTimeToYear datetime>
|
||||
<#local format = "yyyy">
|
||||
<#return datetime?date(format)?string(format)>
|
||||
</#function>
|
||||
|
|
Loading…
Add table
Reference in a new issue