NIHVIVO-1336 Finished custom list view for core:educationalTraining property
This commit is contained in:
parent
f170c94a68
commit
8c0124819c
8 changed files with 51 additions and 10 deletions
|
@ -37,6 +37,13 @@ public class TestController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
body.put("title", "Freemarker Test");
|
body.put("title", "Freemarker Test");
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
Date now = cal.getTime();
|
||||||
|
body.put("now", now);
|
||||||
|
// In template: ${now?date}, ${now?datetime}, ${now?time}
|
||||||
|
|
||||||
|
body.put("datetime", "1983-12-07T17:15:28Z");
|
||||||
|
|
||||||
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
|
@ -22,6 +25,8 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
|
||||||
public class QueryUtils {
|
public class QueryUtils {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(QueryUtils.class);
|
||||||
|
|
||||||
protected static Map<String,Object> querySolutionToObjectValueMap( QuerySolution soln){
|
protected static Map<String,Object> querySolutionToObjectValueMap( QuerySolution soln){
|
||||||
Map<String,Object> map = new HashMap<String,Object>();
|
Map<String,Object> map = new HashMap<String,Object>();
|
||||||
Iterator<String> varNames = soln.varNames();
|
Iterator<String> varNames = soln.varNames();
|
||||||
|
|
|
@ -86,11 +86,13 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
private static final String NODE_NAME_TEMPLATE = "template";
|
private static final String NODE_NAME_TEMPLATE = "template";
|
||||||
private static final String NODE_NAME_COLLATION_TARGET = "collation-target";
|
private static final String NODE_NAME_COLLATION_TARGET = "collation-target";
|
||||||
private static final String NODE_NAME_POSTPROCESSOR = "postprocessor";
|
private static final String NODE_NAME_POSTPROCESSOR = "postprocessor";
|
||||||
|
private static final String NODE_NAME_EDIT_OBJECT = "edit-object";
|
||||||
|
|
||||||
private String queryString;
|
private String queryString;
|
||||||
private String templateName;
|
private String templateName;
|
||||||
private String collationTarget;
|
private String collationTarget;
|
||||||
private String postprocessor;
|
private String postprocessor;
|
||||||
|
private String editObject;
|
||||||
|
|
||||||
PropertyListConfig(ObjectProperty op, WebappDaoFactory wdf) throws Exception {
|
PropertyListConfig(ObjectProperty op, WebappDaoFactory wdf) throws Exception {
|
||||||
|
|
||||||
|
@ -121,6 +123,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
// Optional values
|
// Optional values
|
||||||
collationTarget = getConfigValue(doc, NODE_NAME_COLLATION_TARGET);
|
collationTarget = getConfigValue(doc, NODE_NAME_COLLATION_TARGET);
|
||||||
postprocessor = getConfigValue(doc, NODE_NAME_POSTPROCESSOR);
|
postprocessor = getConfigValue(doc, NODE_NAME_POSTPROCESSOR);
|
||||||
|
editObject = getConfigValue(doc, NODE_NAME_EDIT_OBJECT);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error processing config file " + configFilePath + " for object property " + op.getURI(), e);
|
log.error("Error processing config file " + configFilePath + " for object property " + op.getURI(), e);
|
||||||
// What should we do here?
|
// What should we do here?
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
<collation-target>object</collation-target>
|
<collation-target>object</collation-target>
|
||||||
|
|
||||||
|
<edit-object>object</edit-object>
|
||||||
|
|
||||||
<postprocessor>edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DefaultObjectPropertyDataPostprocessor</postprocessor>
|
<postprocessor>edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DefaultObjectPropertyDataPostprocessor</postprocessor>
|
||||||
|
|
||||||
<template>propStatement-default.ftl</template>
|
<template>propStatement-default.ftl</template>
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
|
<@widget name="test" />
|
||||||
|
|
||||||
<h3>Dates</h3>
|
<h3>Dates</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>${now?datetime}</li>
|
<li>Current date & time: ${now?datetime}</li>
|
||||||
<li>${now?date}</li>
|
<li>Current date: ${now?date}</li>
|
||||||
<li>${now?time}</li>
|
<li>Current time: ${now?time}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Apples</h3>
|
<h3>Apples</h3>
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
<#-- FreeMarker test cases -->
|
<#-- FreeMarker test cases -->
|
||||||
|
|
||||||
|
<#import "lib-datetime.ftl" as dt>
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
<@widget name="test" />
|
<p>Current date & time: ${now?datetime}</p>
|
||||||
|
<p>Current date: ${now?date}</p>
|
||||||
|
<p>Current datetime: ${now?time}</p>
|
||||||
|
|
||||||
${stylesheets.add("/css/testfrombody.css")}
|
|
||||||
${scripts.add("/js/jstest.js")}
|
|
||||||
|
|
||||||
${bodyClass}
|
<p>${dt.xsdDateTimeToYear(datetime)}</p>
|
||||||
|
|
||||||
<ul><@list.firstLastList><li>apples</li><li>bananas</li></@list.firstLastList></ul>
|
|
20
webapp/web/templates/freemarker/lib/lib-datetime.ftl
Normal file
20
webapp/web/templates/freemarker/lib/lib-datetime.ftl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<#-- $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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<#-- Function xsdDateTimeToYear
|
||||||
|
|
||||||
|
Display an XSD datetime string as a year.
|
||||||
|
|
||||||
|
Example: 1983-12-07T17:15:28Z displays as 1983
|
||||||
|
-->
|
||||||
|
|
||||||
|
<#function xsdDateTimeToYear datetime>
|
||||||
|
<#return datetime?date("yyyy")?string("yyyy") >
|
||||||
|
</#function>
|
|
@ -1,5 +1,7 @@
|
||||||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Macros for generating html lists -->
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
Macro: firstLastList
|
Macro: firstLastList
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue