Working on dateTime with precision NIHVIVO-295
This commit is contained in:
parent
6d06c76e05
commit
c94d82e6e2
11 changed files with 773 additions and 19 deletions
|
@ -3,14 +3,17 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
|
|
||||||
public class HomePageController extends FreemarkerHttpServlet {
|
public class HomePageController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
@ -22,7 +25,11 @@ public class HomePageController extends FreemarkerHttpServlet {
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
|
VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache( getServletContext() );
|
||||||
|
List<VClassGroup> vClassGroups = vcgc.getGroups(vreq.getPortalId());
|
||||||
|
body.put("vClassGroups", vClassGroups);
|
||||||
|
|
||||||
// Add home page data to body here
|
// Add home page data to body here
|
||||||
return new TemplateResponseValues(BODY_TEMPLATE, body);
|
return new TemplateResponseValues(BODY_TEMPLATE, body);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class DisplayVocabulary {
|
||||||
public static final String PAGE_TYPE = NS + "Page";
|
public static final String PAGE_TYPE = NS + "Page";
|
||||||
public static final String HOME_PAGE_TYPE = NS + "HomePage";
|
public static final String HOME_PAGE_TYPE = NS + "HomePage";
|
||||||
public static final String CLASSGROUP_PAGE_TYPE = NS + "ClassGroupPage";
|
public static final String CLASSGROUP_PAGE_TYPE = NS + "ClassGroupPage";
|
||||||
|
|
||||||
/* Object Properties */
|
/* Object Properties */
|
||||||
public static final String FOR_CLASSGROUP = NS + "forClassGroup";
|
public static final String FOR_CLASSGROUP = NS + "forClassGroup";
|
||||||
|
|
||||||
|
|
|
@ -296,4 +296,31 @@ public class VitroVocabulary {
|
||||||
public static final String IND_MAIN_IMAGE = VITRO_PUBLIC + "mainImage";
|
public static final String IND_MAIN_IMAGE = VITRO_PUBLIC + "mainImage";
|
||||||
public static final String IND_IMAGE = VITRO_PUBLIC + "image";
|
public static final String IND_IMAGE = VITRO_PUBLIC + "image";
|
||||||
|
|
||||||
|
// =============== Date Time with Precision vocabulary ===============
|
||||||
|
private static final String DATETIME_NS = "http://vivoweb.org/ontology/core#";
|
||||||
|
|
||||||
|
protected static final String[] PRECISIONS = {
|
||||||
|
DATETIME_NS+"NoPrecision",
|
||||||
|
DATETIME_NS+"YearPrecision",
|
||||||
|
DATETIME_NS+"YearMonthPrecision",
|
||||||
|
DATETIME_NS+"YearMonthDayPrecision",
|
||||||
|
DATETIME_NS+"YearMonthDayHourPrecision",
|
||||||
|
DATETIME_NS+"YearMonthDayHourMinutePrecision",
|
||||||
|
DATETIME_NS+"YearMonthDayTimePrecision"};
|
||||||
|
|
||||||
|
public enum Precision {
|
||||||
|
NONE(PRECISIONS[0]),
|
||||||
|
YEAR(PRECISIONS[1]),
|
||||||
|
MONTH(PRECISIONS[2]),
|
||||||
|
DAY(PRECISIONS[3]),
|
||||||
|
HOUR(PRECISIONS[4]),
|
||||||
|
MINUTE(PRECISIONS[5]),
|
||||||
|
SECOND(PRECISIONS[6]);
|
||||||
|
|
||||||
|
private final String URI;
|
||||||
|
Precision(String uri){
|
||||||
|
URI=uri;
|
||||||
|
}
|
||||||
|
public String uri(){return URI;}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,468 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.edit.elements;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
|
||||||
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is intended to work in conjunction with a template to create the HTML for a
|
||||||
|
* datetime with precision and to convert he submitted parameters into
|
||||||
|
* varname -> Literal and varname -> URI maps.
|
||||||
|
*
|
||||||
|
* This requires two variables to be defined:
|
||||||
|
* ${fieldname}.precision - URI of datetime precision
|
||||||
|
* ${fieldname}.value - DateTime literal
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DateTimeWithPrecision extends BaseEditElement {
|
||||||
|
|
||||||
|
String fieldName;
|
||||||
|
VitroVocabulary.Precision requiredMinimumPrecision;
|
||||||
|
|
||||||
|
|
||||||
|
VitroVocabulary.Precision DEFAULT_MIN_PRECISION = VitroVocabulary.Precision.DAY;
|
||||||
|
VitroVocabulary.Precision[] precisions = VitroVocabulary.Precision.values();
|
||||||
|
|
||||||
|
public DateTimeWithPrecision(Field field) {
|
||||||
|
super(field);
|
||||||
|
fieldName = field.getName();
|
||||||
|
requiredMinimumPrecision = DEFAULT_MIN_PRECISION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTimeWithPrecision(Field field, VitroVocabulary.Precision requiredMinimumPrecision){
|
||||||
|
this(field);
|
||||||
|
if( requiredMinimumPrecision != null )
|
||||||
|
this.requiredMinimumPrecision = requiredMinimumPrecision;
|
||||||
|
else
|
||||||
|
requiredMinimumPrecision = DEFAULT_MIN_PRECISION;
|
||||||
|
}
|
||||||
|
|
||||||
|
//it would be nice to have only the version of the constructor that takes the enum
|
||||||
|
//but this is to quickly get the JSP configuration working.
|
||||||
|
public DateTimeWithPrecision(Field field, String precisionURI){
|
||||||
|
this(field);
|
||||||
|
for( VitroVocabulary.Precision precision : VitroVocabulary.Precision.values()){
|
||||||
|
if( precision.uri().equals(precisionURI))
|
||||||
|
this.requiredMinimumPrecision = precision;
|
||||||
|
}
|
||||||
|
if( this.requiredMinimumPrecision == null )
|
||||||
|
throw new IllegalArgumentException(precisionURI +" is not a valid precision, see VitroVocabulary.Precision");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(DateTimeWithPrecision.class);
|
||||||
|
protected String TEMPATE_NAME = "DateTimeWithPrecision.ftl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String draw(String fieldName, EditConfiguration editConfig,
|
||||||
|
EditSubmission editSub, Configuration fmConfig) {
|
||||||
|
Map map = getMapForTemplate( editConfig, editSub);
|
||||||
|
map.putAll( FreemarkerHttpServlet.getDirectives());
|
||||||
|
return merge( fmConfig, TEMPATE_NAME, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This produces a map for use in the template.
|
||||||
|
*/
|
||||||
|
private Map getMapForTemplate(EditConfiguration editConfig, EditSubmission editSub) {
|
||||||
|
Map<String,Object>map = new HashMap<String,Object>();
|
||||||
|
|
||||||
|
map.put("fieldName", fieldName);
|
||||||
|
|
||||||
|
DateTime value = getTimeValue(editConfig,editSub);
|
||||||
|
map.put("year", Integer.toString(value.getYear()));
|
||||||
|
map.put("month", Integer.toString(value.getMonthOfYear()));
|
||||||
|
map.put("day", Integer.toString(value.getDayOfMonth()) );
|
||||||
|
map.put("hour", Integer.toString(value.getHourOfDay()) );
|
||||||
|
map.put("minute", Integer.toString(value.getMinuteOfHour()) );
|
||||||
|
map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
|
||||||
|
|
||||||
|
map.put("precision", getPrecision(editConfig,editSub));
|
||||||
|
map.put("requiredMinimumPrecision", requiredMinimumPrecision.uri());
|
||||||
|
|
||||||
|
addPrecisionConstants(map);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds precisionURIs for use by the templates */
|
||||||
|
private void addPrecisionConstants(Map<String,Object> map){
|
||||||
|
Map<String,Object> constants = new HashMap<String,Object>();
|
||||||
|
for( VitroVocabulary.Precision pc: VitroVocabulary.Precision.values()){
|
||||||
|
constants.put(pc.name().toLowerCase(),pc.uri());
|
||||||
|
}
|
||||||
|
map.put("precisions", constants);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the currently set precision
|
||||||
|
*/
|
||||||
|
private String getPrecision(EditConfiguration editConfig, EditSubmission editSub) {
|
||||||
|
String precisionURI = editConfig.getUrisInScope().get( getPrecisionVariableName() );
|
||||||
|
if( precisionURI == null ){
|
||||||
|
//maybe we need a way to specify a default value?
|
||||||
|
return VitroVocabulary.Precision.DAY.uri();
|
||||||
|
}else{
|
||||||
|
return precisionURI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DateTime getTimeValue(EditConfiguration editConfig, EditSubmission editSub) {
|
||||||
|
Literal dtValue = editConfig.getLiteralsInScope().get( getValueVariableName() );
|
||||||
|
if( dtValue == null ){
|
||||||
|
//maybe we need a way to specify a default value?
|
||||||
|
return new DateTime();
|
||||||
|
}else{
|
||||||
|
return new DateTime( dtValue.getLexicalForm() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the literals for a submitted form from the queryParmeters.
|
||||||
|
* It will only be called if getValidationErrors() doesn't return any errors.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Literal> getLiterals(String fieldName,
|
||||||
|
EditConfiguration editConfig, Map<String, String[]> queryParameters) {
|
||||||
|
Map<String,Literal> literalMap = new HashMap<String,Literal>();
|
||||||
|
|
||||||
|
Literal datetime =getDateTime( queryParameters);
|
||||||
|
literalMap.put(fieldName+".value", datetime);
|
||||||
|
|
||||||
|
return literalMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Literal getDateTime( Map<String, String[]> queryParameters ) {
|
||||||
|
Integer year = parseToInt(fieldName+".year", queryParameters);
|
||||||
|
Integer month = parseToInt(fieldName+".month", queryParameters);
|
||||||
|
if( month == null || month == 0 )
|
||||||
|
month = 1;
|
||||||
|
Integer day = parseToInt(fieldName+".day", queryParameters);
|
||||||
|
if( day == null || day == 0 )
|
||||||
|
day = 1;
|
||||||
|
Integer hour = parseToInt(fieldName+".hour", queryParameters);
|
||||||
|
if( hour == null )
|
||||||
|
hour = 0;
|
||||||
|
Integer minute = parseToInt(fieldName+".minute", queryParameters);
|
||||||
|
if( minute == null )
|
||||||
|
minute = 0;
|
||||||
|
Integer second = parseToInt(fieldName+".second", queryParameters);
|
||||||
|
if( second == null )
|
||||||
|
second = 0;
|
||||||
|
int mills = 0;
|
||||||
|
|
||||||
|
|
||||||
|
DateTime value = new DateTime(
|
||||||
|
year.intValue(),month.intValue(),day.intValue(),
|
||||||
|
hour.intValue(),minute.intValue(),second.intValue(),mills);
|
||||||
|
|
||||||
|
Date dValue = value.toDate();
|
||||||
|
|
||||||
|
/*This isn't doing what I want it to do. It is recording the correct instance of timeb
|
||||||
|
* but it is recording it with the timezone UTC/zulu */
|
||||||
|
//return ResourceFactory.createTypedLiteral(ISODateTimeFormat.dateTimeNoMillis().print(value),XSDDatatype.XSDdateTime);
|
||||||
|
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(value.toDate());
|
||||||
|
|
||||||
|
Model m = ModelFactory.createDefaultModel();
|
||||||
|
Literal lit = m.createTypedLiteral( c );
|
||||||
|
return lit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the URIs for a submitted form from the queryParmeters.
|
||||||
|
* It will only be called if getValidationErrors() doesn't return any errors.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getURIs(String fieldName,
|
||||||
|
EditConfiguration editConfig, Map<String, String[]> queryParameters) {
|
||||||
|
String precisionUri;
|
||||||
|
try {
|
||||||
|
precisionUri = getSubmittedPrecision( queryParameters);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("getURIS() should only be called on input that passed getValidationErrors()");
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
Map<String,String> uriMap = new HashMap<String,String>();
|
||||||
|
uriMap.put(fieldName+".precision", precisionUri);
|
||||||
|
return uriMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precision is based on the values returned by the form. Throws an exception with
|
||||||
|
* the error message if the queryParameters cannot make a valid date/precision because
|
||||||
|
* there are values missing.
|
||||||
|
*/
|
||||||
|
protected String getSubmittedPrecision(Map<String, String[]> queryParameters) throws Exception {
|
||||||
|
|
||||||
|
Integer year = parseToInt(fieldName+".year",queryParameters);
|
||||||
|
Integer month = parseToInt(fieldName+".month",queryParameters);
|
||||||
|
Integer day = parseToInt(fieldName+".day",queryParameters);
|
||||||
|
Integer hour = parseToInt(fieldName+".hour",queryParameters);
|
||||||
|
Integer minute = parseToInt(fieldName+".minute",queryParameters);
|
||||||
|
Integer second = parseToInt(fieldName+".second",queryParameters);
|
||||||
|
Integer[] values = { year, month, day, hour, minute, second };
|
||||||
|
|
||||||
|
/* find the most significant date field that is null. */
|
||||||
|
int indexOfFirstNull= -1;
|
||||||
|
for(int i=0; i < values.length ; i++){
|
||||||
|
if( values[i] == null ){
|
||||||
|
indexOfFirstNull = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if they all had values then we have seconds precision */
|
||||||
|
if( indexOfFirstNull == -1 )
|
||||||
|
return VitroVocabulary.Precision.SECOND.uri();
|
||||||
|
|
||||||
|
|
||||||
|
/* check that there are no values after the most significant null field
|
||||||
|
* that are non-null. */
|
||||||
|
boolean nonNullAfterFirstNull=false;
|
||||||
|
for(int i=0; i < values.length ; i++){
|
||||||
|
if( i > indexOfFirstNull && values[i] != null ){
|
||||||
|
nonNullAfterFirstNull = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( nonNullAfterFirstNull )
|
||||||
|
throw new Exception("cannot determine precision, there were filledout values after the first un-filledout value, ");
|
||||||
|
else{
|
||||||
|
return precisions[ indexOfFirstNull ].uri();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getValidationMessages(String fieldName,
|
||||||
|
EditConfiguration editConfig, Map<String, String[]> queryParameters) {
|
||||||
|
Map<String,String> errorMsgMap = new HashMap<String,String>();
|
||||||
|
|
||||||
|
//check that any parameters we got are single values
|
||||||
|
String[] names = {"year","month","day","hour","minute","second", "precision"};
|
||||||
|
for( String name:names){
|
||||||
|
if ( !hasNoneOrSingle(fieldName+"."+name, queryParameters))
|
||||||
|
errorMsgMap.put(fieldName+"."+name, "must have only one value for " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
try{
|
||||||
|
precisionURI = getSubmittedPrecision( queryParameters);
|
||||||
|
}catch(Exception ex){
|
||||||
|
errorMsgMap.put(fieldName,ex.getMessage());
|
||||||
|
return errorMsgMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorMsgMap.putAll(checkDate( precisionURI, queryParameters) );
|
||||||
|
|
||||||
|
return errorMsgMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks for invalid date times.
|
||||||
|
*/
|
||||||
|
final static String NON_INTEGER_YEAR = "must enter a valid year";
|
||||||
|
final static String NON_INTEGER_MONTH = "must enter a valid month";
|
||||||
|
final static String NON_INTEGER_DAY = "must enter a valid day";
|
||||||
|
final static String NON_INTEGER_HOUR = "must enter a valid hour";
|
||||||
|
final static String NON_INTEGER_MINUTE = "must enter a valid minute";
|
||||||
|
final static String NON_INTEGER_SECOND = "must enter a valid second";
|
||||||
|
|
||||||
|
private Map<String,String> checkDate( String precisionURI, Map<String, String[]> qp){
|
||||||
|
if( precisionURI == null )
|
||||||
|
return Collections.emptyMap();
|
||||||
|
|
||||||
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
|
Integer year,month,day,hour,minute,second;
|
||||||
|
|
||||||
|
//just check if the values for the precision parse to integers
|
||||||
|
if( precisionURI.equals(VitroVocabulary.Precision.YEAR.uri() ) ){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
}else if( precisionURI.equals( VitroVocabulary.Precision.MONTH.uri() )){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
if( ! canParseToNumber(fieldName+".month" ,qp))
|
||||||
|
errors.put(fieldName+".month", NON_INTEGER_MONTH);
|
||||||
|
}else if( precisionURI.equals( VitroVocabulary.Precision.DAY.uri() )){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
if( ! canParseToNumber(fieldName+".month" ,qp))
|
||||||
|
errors.put(fieldName+".month", NON_INTEGER_MONTH);
|
||||||
|
if( ! canParseToNumber(fieldName+".day" ,qp))
|
||||||
|
errors.put(fieldName+".day", NON_INTEGER_DAY);
|
||||||
|
}else if( precisionURI.equals( VitroVocabulary.Precision.HOUR.uri() )){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
if( ! canParseToNumber(fieldName+".month" ,qp))
|
||||||
|
errors.put(fieldName+".month", NON_INTEGER_MONTH);
|
||||||
|
if( ! canParseToNumber(fieldName+".day" ,qp))
|
||||||
|
errors.put(fieldName+".day", NON_INTEGER_DAY);
|
||||||
|
if( ! canParseToNumber(fieldName+".hour" ,qp))
|
||||||
|
errors.put(fieldName+".hour", NON_INTEGER_HOUR);
|
||||||
|
}else if( precisionURI.equals( VitroVocabulary.Precision.MINUTE.uri() )){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
if( ! canParseToNumber(fieldName+".month" ,qp))
|
||||||
|
errors.put(fieldName+".month", NON_INTEGER_MONTH);
|
||||||
|
if( ! canParseToNumber(fieldName+".day" ,qp))
|
||||||
|
errors.put(fieldName+".day", NON_INTEGER_DAY);
|
||||||
|
if( ! canParseToNumber(fieldName+".hour" ,qp))
|
||||||
|
errors.put(fieldName+".hour", NON_INTEGER_HOUR);
|
||||||
|
if( ! canParseToNumber(fieldName+".minute" ,qp))
|
||||||
|
errors.put(fieldName+".minute", NON_INTEGER_HOUR);
|
||||||
|
}else if( precisionURI.equals( VitroVocabulary.Precision.SECOND.uri() )){
|
||||||
|
if( ! canParseToNumber(fieldName+".year" ,qp))
|
||||||
|
errors.put(fieldName+".year", NON_INTEGER_YEAR);
|
||||||
|
if( ! canParseToNumber(fieldName+".month" ,qp))
|
||||||
|
errors.put(fieldName+".month", NON_INTEGER_MONTH);
|
||||||
|
if( ! canParseToNumber(fieldName+".day" ,qp))
|
||||||
|
errors.put(fieldName+".day", NON_INTEGER_DAY);
|
||||||
|
if( ! canParseToNumber(fieldName+".hour" ,qp))
|
||||||
|
errors.put(fieldName+".hour", NON_INTEGER_HOUR);
|
||||||
|
if( ! canParseToNumber(fieldName+".minute" ,qp))
|
||||||
|
errors.put(fieldName+".minute", NON_INTEGER_HOUR);
|
||||||
|
if( ! canParseToNumber(fieldName+".second" ,qp))
|
||||||
|
errors.put(fieldName+".second", NON_INTEGER_SECOND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if we can make a valid date with these integers
|
||||||
|
year = parseToInt(fieldName+".year", qp);
|
||||||
|
if( year == null )
|
||||||
|
year = 1999;
|
||||||
|
month= parseToInt(fieldName+".month", qp);
|
||||||
|
if(month == null )
|
||||||
|
month = 1;
|
||||||
|
day = parseToInt(fieldName+".day", qp);
|
||||||
|
if( day == null )
|
||||||
|
day = 1;
|
||||||
|
hour = parseToInt(fieldName+".hour", qp);
|
||||||
|
if( hour == null )
|
||||||
|
hour = 0;
|
||||||
|
minute = parseToInt(fieldName+".minute",qp);
|
||||||
|
if( minute == null )
|
||||||
|
minute = 0;
|
||||||
|
second = parseToInt(fieldName+".second", qp);
|
||||||
|
if( second == null )
|
||||||
|
second = 0;
|
||||||
|
|
||||||
|
DateTime dateTime = new DateTime();
|
||||||
|
try{
|
||||||
|
dateTime.withYear(year);
|
||||||
|
}catch(IllegalArgumentException iae){
|
||||||
|
errors.put(fieldName+".year", iae.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
dateTime.withMonthOfYear(month);
|
||||||
|
}catch(IllegalArgumentException iae){
|
||||||
|
errors.put(fieldName+".month", iae.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
dateTime.withDayOfMonth(day);
|
||||||
|
}catch(IllegalArgumentException iae){
|
||||||
|
errors.put(fieldName+".day", iae.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
dateTime.withHourOfDay(hour);
|
||||||
|
}catch(IllegalArgumentException iae){
|
||||||
|
errors.put(fieldName+".hour", iae.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
dateTime.withSecondOfMinute(second);
|
||||||
|
}catch(IllegalArgumentException iae){
|
||||||
|
errors.put(fieldName+".second", iae.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean fieldMatchesPattern( String fieldName, Map<String,String[]>queryParameters, Pattern pattern){
|
||||||
|
String[] varg = queryParameters.get(fieldName);
|
||||||
|
if( varg == null || varg.length != 1 || varg[0] == null)
|
||||||
|
return false;
|
||||||
|
String value = varg[0];
|
||||||
|
Matcher match = pattern.matcher(value);
|
||||||
|
return match.matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean emptyOrBlank(String key,Map<String, String[]> queryParameters){
|
||||||
|
String[] vt = queryParameters.get(key);
|
||||||
|
return ( vt == null || vt.length ==0 || vt[0] == null || vt[0].length() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canParseToNumber(String key,Map<String, String[]> queryParameters){
|
||||||
|
Integer out = null;
|
||||||
|
try{
|
||||||
|
String[] vt = queryParameters.get(key);
|
||||||
|
if( vt == null || vt.length ==0 || vt[0] == null)
|
||||||
|
return false;
|
||||||
|
else{
|
||||||
|
out = Integer.parseInt(vt[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}catch(IndexOutOfBoundsException iex){
|
||||||
|
out = null;
|
||||||
|
}catch(NumberFormatException nfe){
|
||||||
|
out = null;
|
||||||
|
}catch(NullPointerException npe){
|
||||||
|
out = null;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Integer parseToInt(String key,Map<String, String[]> queryParameters){
|
||||||
|
Integer out = null;
|
||||||
|
try{
|
||||||
|
String[] vt = queryParameters.get(key);
|
||||||
|
if( vt == null || vt.length ==0 || vt[0] == null)
|
||||||
|
out = null;
|
||||||
|
else
|
||||||
|
out = Integer.parseInt(vt[0]);
|
||||||
|
}catch(IndexOutOfBoundsException iex){
|
||||||
|
out = null;
|
||||||
|
}catch(NumberFormatException nfe){
|
||||||
|
out = null;
|
||||||
|
}catch(NullPointerException npe){
|
||||||
|
out = null;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VitroVocabulary.Precision getRequiredMinimumPrecision() {
|
||||||
|
return requiredMinimumPrecision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredMinimumPrecision(
|
||||||
|
VitroVocabulary.Precision requiredMinimumPrecision) {
|
||||||
|
this.requiredMinimumPrecision = requiredMinimumPrecision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValueVariableName(){ return fieldName + ".value" ; }
|
||||||
|
public String getPrecisionVariableName(){ return fieldName + ".precision" ; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ public interface EditElement {
|
||||||
*/
|
*/
|
||||||
public String draw(String fieldName, EditConfiguration editConfig, EditSubmission editSub, Configuration fmConfig);
|
public String draw(String fieldName, EditConfiguration editConfig, EditSubmission editSub, Configuration fmConfig);
|
||||||
|
|
||||||
/**
|
/* in the future, we may need to get existing values */
|
||||||
* We may need a method to get existing URIs and Literals for use in building retraction statements?
|
/*
|
||||||
*/
|
public Map<String,Literal> getExistingLiterals(???)
|
||||||
// public Map<String,Literal> getExistingLiterals(?);
|
public Map<String,String> getExistingURIs(???);
|
||||||
// public Map<String,Literal> getExistingURIs(?);
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class Field {
|
||||||
* Property for special edit element.
|
* Property for special edit element.
|
||||||
*/
|
*/
|
||||||
private EditElement editElement=null;;
|
private EditElement editElement=null;;
|
||||||
|
|
||||||
/* *********************** Constructors ************************** */
|
/* *********************** Constructors ************************** */
|
||||||
|
|
||||||
public Field(String config, String varName) {
|
public Field(String config, String varName) {
|
||||||
|
@ -163,7 +163,7 @@ public class Field {
|
||||||
setLiteralOptions(obj.getJSONArray("literalOptions"));
|
setLiteralOptions(obj.getJSONArray("literalOptions"));
|
||||||
setAssertions(EditConfiguration.JsonArrayToStringList(obj.getJSONArray("assertions")));
|
setAssertions(EditConfiguration.JsonArrayToStringList(obj.getJSONArray("assertions")));
|
||||||
|
|
||||||
setEditElement( obj, fieldName);
|
setEditElement( obj, fieldName);
|
||||||
|
|
||||||
//check for odd parameters
|
//check for odd parameters
|
||||||
JSONArray names = obj.names();
|
JSONArray names = obj.names();
|
||||||
|
@ -179,7 +179,10 @@ public class Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEditElement(EditElement editElement){
|
||||||
|
this.editElement = editElement;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A field may specify a class for additional features.
|
* A field may specify a class for additional features.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
|
||||||
*
|
*
|
||||||
* @author bdc34
|
* @author bdc34
|
||||||
*
|
*
|
||||||
*@deprecated Use LuceneIndexFactory instead
|
* @ deprecated Use LuceneIndexFactory instead
|
||||||
*/
|
*/
|
||||||
public interface Searcher {
|
public interface Searcher {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
*
|
*
|
||||||
* @author bdc34
|
* @author bdc34
|
||||||
*
|
*
|
||||||
* @deprecated there is no replacement
|
* @ deprecated there is no replacement
|
||||||
*/
|
*/
|
||||||
public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
|
public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
|
||||||
|
|
||||||
|
|
|
@ -385,10 +385,7 @@ public class InputElementFormattingTag extends TagSupport {
|
||||||
|
|
||||||
public int doStartTag() {
|
public int doStartTag() {
|
||||||
try {
|
try {
|
||||||
/* first check for blank or missing type and id values */
|
|
||||||
if (getType()==null || getType().equals("")){
|
|
||||||
log.error("Error in doStartTag: input element type is blank or not specified.");
|
|
||||||
}
|
|
||||||
if (getId()==null || getId().equals("")){
|
if (getId()==null || getId().equals("")){
|
||||||
log.error("Error in doStartTag: input element id is blank or not specified.");
|
log.error("Error in doStartTag: input element id is blank or not specified.");
|
||||||
}
|
}
|
||||||
|
@ -440,6 +437,11 @@ public class InputElementFormattingTag extends TagSupport {
|
||||||
// return SKIP_BODY;
|
// return SKIP_BODY;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if ((getType()==null || getType().equals("")) && field.getEditElement() == null ){
|
||||||
|
log.error("Error in doStartTag: input element type is blank or not specified.");
|
||||||
|
}
|
||||||
|
|
||||||
// set ProhibitedFromSearch object so picklist doesn't show
|
// set ProhibitedFromSearch object so picklist doesn't show
|
||||||
// individuals from classes that should be hidden from list views
|
// individuals from classes that should be hidden from list views
|
||||||
OntModel displayOntModel =
|
OntModel displayOntModel =
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.edit.elements;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
|
||||||
|
import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
|
||||||
|
|
||||||
|
|
||||||
|
public class DateTimeWithPrecisionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionSecondsValidationTest() throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
queryParameters.put(FIELDNAME+".month", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".day", new String[]{"01"});
|
||||||
|
queryParameters.put(FIELDNAME+".hour", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".minute", new String[]{"00"});
|
||||||
|
queryParameters.put(FIELDNAME+".second", new String[]{"00"});
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
//Assert.assertEquals(dtwp.PRECISIONS[6], precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.SECOND.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionMinutesValidationTest() throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
queryParameters.put(FIELDNAME+".month", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".day", new String[]{"01"});
|
||||||
|
queryParameters.put(FIELDNAME+".hour", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".minute", new String[]{"00"});
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.MINUTE.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionHourssValidationTest() throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
queryParameters.put(FIELDNAME+".month", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".day", new String[]{"01"});
|
||||||
|
queryParameters.put(FIELDNAME+".hour", new String[]{"12"});
|
||||||
|
//no minutes
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.HOUR.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionDaysValidationTest() throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
queryParameters.put(FIELDNAME+".month", new String[]{"12"});
|
||||||
|
queryParameters.put(FIELDNAME+".day", new String[]{"01"});
|
||||||
|
//no hours
|
||||||
|
//no minutes
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.DAY.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionMonthsValidationTest()throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
queryParameters.put(FIELDNAME+".month", new String[]{"12"});
|
||||||
|
//no days
|
||||||
|
//no hours
|
||||||
|
//no minutes
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.MONTH.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void precisionYearValidationTest() throws Exception{
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
//no months
|
||||||
|
//no days
|
||||||
|
//no hours
|
||||||
|
//no minutes
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
String precisionURI = null;
|
||||||
|
precisionURI = dtwp.getSubmittedPrecision( queryParameters);
|
||||||
|
|
||||||
|
Assert.assertNotNull(precisionURI);
|
||||||
|
Assert.assertEquals(VitroVocabulary.Precision.YEAR.uri(), precisionURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDateLiteralTest(){
|
||||||
|
String FIELDNAME = "testfield";
|
||||||
|
Field field = new Field();
|
||||||
|
field.setName(FIELDNAME);
|
||||||
|
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
|
||||||
|
|
||||||
|
Map<String,String[]> queryParameters = new HashMap<String, String[]>();
|
||||||
|
queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
|
||||||
|
//no months
|
||||||
|
//no days
|
||||||
|
//no hours
|
||||||
|
//no minutes
|
||||||
|
//no seconds
|
||||||
|
|
||||||
|
EditConfiguration editConfig=null;
|
||||||
|
Map<String,String> validationMsgs = dtwp.getValidationMessages("testfield", editConfig, queryParameters);
|
||||||
|
Assert.assertNotNull(validationMsgs);
|
||||||
|
Assert.assertTrue(validationMsgs.size() == 0 );
|
||||||
|
|
||||||
|
Literal date = dtwp.getDateTime( queryParameters);
|
||||||
|
Assert.assertNotNull(date);
|
||||||
|
Assert.assertEquals( XSDDatatype.XSDdateTime.getURI() ,date.getDatatypeURI() );
|
||||||
|
|
||||||
|
DateTime result = new DateTime( date.getLexicalForm() );
|
||||||
|
DateTime expected = new DateTime(1999,1,1,0,0,0,0);
|
||||||
|
Assert.assertEquals(expected, result);
|
||||||
|
|
||||||
|
Object obj = date.getValue();
|
||||||
|
Assert.assertNotNull(obj);
|
||||||
|
Assert.assertEquals(XSDDateTime.class, obj.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -29,6 +29,34 @@ This is a test file for the DateTimeWithPrecision EditElement.
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
<v:jsonset var="queryForInverse" >
|
||||||
|
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
||||||
|
SELECT ?inverse_property
|
||||||
|
WHERE {
|
||||||
|
?inverse_property owl:inverseOf ?predicate
|
||||||
|
}
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="sparqlForDxPrecision" >
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
SELECT ?dtX.precision WHERE {
|
||||||
|
?subject ?predicate ?object .
|
||||||
|
?object <core:hasDateTimeValue> ?dtX.
|
||||||
|
?dtX <rdf:type> <core:DateTimeValue> .
|
||||||
|
?dtX <core:dateTimePrecision> ?dtX.precision .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="sparqlForDxValue" >
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
SELECT ?dtX.value WHERE {
|
||||||
|
?subject ?predicate ?object .
|
||||||
|
?object <core:hasDateTimeValue> ?dtX.
|
||||||
|
?dtX <rdf:type> <core:DateTimeValue> .
|
||||||
|
?dtX <core:dateTime> ?dtX.value .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForEdit" >
|
<v:jsonset var="n3ForEdit" >
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||||
|
@ -64,13 +92,14 @@ This is a test file for the DateTimeWithPrecision EditElement.
|
||||||
"filesOnForm" : [ ],
|
"filesOnForm" : [ ],
|
||||||
"sparqlForLiterals" : { },
|
"sparqlForLiterals" : { },
|
||||||
"sparqlForUris" : { },
|
"sparqlForUris" : { },
|
||||||
"sparqlForExistingLiterals" : { },
|
"sparqlForExistingLiterals" : { "dtX.value": "${sparqlForDxValue}" },
|
||||||
"sparqlForExistingUris" : { },
|
"sparqlForExistingUris" : { "dtX.precision": "${sparqlForDxPrecision}" },
|
||||||
"fields" : {
|
"fields" : {
|
||||||
"dtX" : {
|
"dtX" : {
|
||||||
"newResource" : "true",
|
"newResource" : "true",
|
||||||
"validators" : [ ],
|
"validators" : [ ],
|
||||||
"optionsType" : "edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision",
|
"optionsType" : "edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision",
|
||||||
|
"editElement" : "edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision",
|
||||||
"literalOptions" : [ ],
|
"literalOptions" : [ ],
|
||||||
"predicateUri" : "",
|
"predicateUri" : "",
|
||||||
"objectClassUri" : "",
|
"objectClassUri" : "",
|
||||||
|
@ -107,7 +136,7 @@ This is a test file for the DateTimeWithPrecision EditElement.
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
<v:input id="dtX" />
|
<v:input id="dtX" type="what" />
|
||||||
<v:input type="submit" id="submit" value="submit" cancel="true"/>
|
<v:input type="submit" id="submit" value="submit" cancel="true"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue