working on freemarker custom forms

This commit is contained in:
bdc34 2010-11-17 17:43:56 +00:00
parent 239e5db4b0
commit 488f71b1c8
6 changed files with 403 additions and 187 deletions

View file

@ -321,6 +321,15 @@
<url-pattern>/SearchIndex</url-pattern> <url-pattern>/SearchIndex</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet>
<servlet-name>N3EditFormController</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.freemarker.N3EditFormController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>N3EditFormController</servlet-name>
<url-pattern>/N3EditForm</url-pattern>
</servlet-mapping>
<!-- This is the new navigation controller. It is not ready for the 1.1 release <!-- This is the new navigation controller. It is not ready for the 1.1 release
see http://issues.library.cornell.edu/browse/NIHVIVO-597 see http://issues.library.cornell.edu/browse/NIHVIVO-597
<servlet> <servlet>

View file

@ -68,6 +68,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
%> %>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" /> <c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" /> <c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" /> <c:set var="label" value="${rdfs}label" />
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" /> <c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
@ -75,13 +76,17 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
<%-- Define predicates used in n3 assertions and sparql queries --%> <%-- Define predicates used in n3 assertions and sparql queries --%>
<c:set var="majorFieldPred" value="${vivoCore}majorField" /> <c:set var="majorFieldPred" value="${vivoCore}majorField" />
<c:set var="yearPred" value="${vivoCore}year" />
<c:set var="deptPred" value="${vivoCore}departmentOrSchool" /> <c:set var="deptPred" value="${vivoCore}departmentOrSchool" />
<c:set var="infoPred" value="${vivoCore}supplementalInformation" /> <c:set var="infoPred" value="${vivoCore}supplementalInformation" />
<c:set var="degreeEarned" value="${vivoCore}degreeEarned" /> <c:set var="degreeEarned" value="${vivoCore}degreeEarned" />
<c:set var="degreeOutcomeOf" value="${vivoCore}degreeOutcomeOf" /> <c:set var="degreeOutcomeOf" value="${vivoCore}degreeOutcomeOf" />
<c:set var="orgGrantingDegree" value="${vivoCore}organizationGrantingDegree" /> <c:set var="orgGrantingDegree" value="${vivoCore}organizationGrantingDegree" />
<c:set var="hasDateTimeValue" value="${vivoCore}hasDateTimeValue"/>
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="edToDateTime" value="${vivoCore}dateTimeInterval"/>
<%-- For new datetime handling in ontology - v1.2 <%-- For new datetime handling in ontology - v1.2
<c:set var="dateTimeValue" value="${vivoCore}DateTimeValue" /> <c:set var="dateTimeValue" value="${vivoCore}DateTimeValue" />
<c:set var="hasDateTimeValue" value="${vivoCore}dateTimeValue" /> <c:set var="hasDateTimeValue" value="${vivoCore}dateTimeValue" />
@ -120,8 +125,11 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
?edTraining <${majorFieldPred}> ?majorField . ?edTraining <${majorFieldPred}> ?majorField .
</v:jsonset> </v:jsonset>
<v:jsonset var="yearAssertion" > <v:jsonset var="dateTimeAssertions">
?edTraining <${yearPred}> ?year . ?edTraining <${edToDateTime}> ?dateTimeNode .
?dateTimeNode <${type}> <${dateTimeValueType}> .
?dateTimeNode <${hasDateTimeValue}> ?dateTime.value .
?dateTimeNode <${dateTimePrecision}> ?dateTime.precision .
</v:jsonset> </v:jsonset>
<v:jsonset var="deptAssertion" > <v:jsonset var="deptAssertion" >
@ -178,11 +186,6 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
?edTraining <${majorFieldPred}> ?existingMajorField . } ?edTraining <${majorFieldPred}> ?existingMajorField . }
</v:jsonset> </v:jsonset>
<v:jsonset var="yearQuery" >
SELECT ?existingYear WHERE {
?edTraining <${yearPred}> ?existingYear . }
</v:jsonset>
<v:jsonset var="deptQuery" > <v:jsonset var="deptQuery" >
SELECT ?existingDept WHERE { SELECT ?existingDept WHERE {
?edTraining <${deptPred}> ?existingDept . } ?edTraining <${deptPred}> ?existingDept . }
@ -207,25 +210,25 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
"predicate" : ["predicate", "${predicateUriJson}" ], "predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["edTraining", "${objectUriJson}", "URI" ], "object" : ["edTraining", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewEdTraining}", "${majorFieldAssertion}", "${orgLabelAssertion}", "${orgTypeAssertion}" ], "n3required" : [ "${n3ForNewEdTraining}", "${majorFieldAssertion}", "${orgLabelAssertion}", "${orgTypeAssertion}", "${dateTimeAssertions}" ],
"n3optional" : [ "${n3ForEdTrainingToOrg}", "n3optional" : [ "${n3ForEdTrainingToOrg}",
"${degreeAssertion}", "${deptAssertion}", "${infoAssertion}", "${yearAssertion}" ], "${degreeAssertion}", "${deptAssertion}", "${infoAssertion}" ],
"newResources" : { "edTraining" : "${defaultNamespace}", "newResources" : { "edTraining" : "${defaultNamespace}",
"org" : "${defaultNamespace}" }, "org" : "${defaultNamespace}" ,
"dateTimeNode" : "${defaultNamespace}" },
"urisInScope" : { }, "urisInScope" : { },
"literalsInScope": { }, "literalsInScope": { },
"urisOnForm" : [ "org", "orgType", "degree" ], "urisOnForm" : [ "org", "orgType", "degree" ],
"literalsOnForm" : [ "orgLabel", "majorField", "year", "dept", "info" ], "literalsOnForm" : [ "orgLabel", "majorField", "dept", "info" ],
"filesOnForm" : [ ], "filesOnForm" : [ ],
"sparqlForLiterals" : { }, "sparqlForLiterals" : { },
"sparqlForUris" : { }, "sparqlForUris" : { },
"sparqlForExistingLiterals" : { "sparqlForExistingLiterals" : {
"orgLabel" : "${orgLabelQuery}", "orgLabel" : "${orgLabelQuery}",
"majorField" : "${majorFieldQuery}", "majorField" : "${majorFieldQuery}",
"year" : "${yearQuery}",
"dept" : "${deptQuery}", "dept" : "${deptQuery}",
"info" : "${infoQuery}" "info" : "${infoQuery}"
}, },
@ -257,17 +260,18 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
"rangeLang" : "", "rangeLang" : "",
"assertions" : [ "${majorFieldAssertion}" ] "assertions" : [ "${majorFieldAssertion}" ]
}, },
"year" : { "dateTime" : {
"newResource" : "false", "editElement" : "edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision",
"validators" : [ "datatype:${gYearDatatypeUriJson}" ], "newResource" : "true",
"optionsType" : "UNDEFINED", "validators" : [ ],
"literalOptions" : [ ], "optionsType" : "UNDEFINED",
"predicateUri" : "", "literalOptions" : [ ],
"objectClassUri" : "", "predicateUri" : "",
"rangeDatatypeUri" : "${gYearDatatypeUriJson}", "objectClassUri" : "",
"rangeLang" : "", "rangeDatatypeUri" : "",
"assertions" : ["${yearAssertion}"] "rangeLang" : "",
}, "assertions" : [ "${dateTimeAssertions}" ]
},
"org" : { "org" : {
"newResource" : "false", "newResource" : "false",
"validators" : [ ], "validators" : [ ],
@ -343,26 +347,14 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
editConfig.prepareForNonUpdate(model); editConfig.prepareForNonUpdate(model);
} }
editConfig.setTemplate("personHasEducationalTraining.ftl");
editConfig.setSubmitToUrl("/edit/processRdfForm2.jsp");
String subjectName = ((Individual) request.getAttribute("subject")).getName(); String subjectName = ((Individual) request.getAttribute("subject")).getName();
%> %>
<c:set var="subjectName" value="<%= subjectName %>" /> <c:set var="subjectName" value="<%= subjectName %>" />
<%
if (objectUri != null) { // editing existing entry
%>
<c:set var="editMode" value="edit" />
<c:set var="titleVerb" value="Edit" />
<c:set var="title" value="Edit educational background entry for ${subjectName}" />
<c:set var="submitButtonText" value="Edit Educational Training" />
<c:set var="disabledVal" value="disabled" />
<%
} else { // adding new entry
%>
<c:set var="editMode" value="add" />
<c:set var="titleVerb" value="Create" />
<c:set var="submitButtonText" value="Educational Training" />
<c:set var="disabledVal" value="" />
<% }
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(), List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(), JavaScript.CUSTOM_FORM_UTILS.path(),
@ -377,8 +369,14 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
request.setAttribute("customCss", customCss); request.setAttribute("customCss", customCss);
%> %>
<jsp:forward page="/N3EditForm"/>
<%--
<jsp:include page="${postForm}"/>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" /> <c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
@ -390,21 +388,19 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
<v:input type="text" label="Major Field of Degree ${requiredHint}" id="majorField" size="30" /> <v:input type="text" label="Major Field of Degree ${requiredHint}" id="majorField" size="30" />
<v:input type="text" label="Year ${yearHint}" id="year" size="4" /> <v:input id="dateTime" />
<p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p> <p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p>
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p> <p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
returning from a validation error, we retain the values. --%>
<c:if test="${editMode == 'edit'}"> <c:if test="${editMode == 'edit'}">
<v:input type="hidden" id="orgType" /> <v:input type="hidden" id="orgType" />
<v:input type="hidden" id="orgLabel" /> <v:input type="hidden" id="orgLabel" />
</c:if> </c:if>
<div class="acSelection"> <div class="acSelection">
<%-- RY maybe make this a label and input field. See what looks best. --%>
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p> <p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
<v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript --> <v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
</div> </div>
@ -430,4 +426,4 @@ var customFormData = {
}; };
</script> </script>
<jsp:include page="${postForm}"/> --%>

View file

@ -0,0 +1,101 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- this is in request.subject.name -->
<#assign subjectName = "Bogus, Al">
<#-- where is the context path suppose to come from? -->
<#assign contextPath = "/vivo">
<#assign editMode="edit">
<#assign editMode=editConfig.object!"add">
<#if editMode == "edit">
<#assign titleVerb="Edit">
<#assign title="Edit educational background entry for subjectName" />
<#assign submitButtonText="Edit Educational Training">
<#assign disabledVal="disabled">
<#else>
<#assign titleVerb="Create">
<#assign submitButtonText="Educational Training">
<#assign disabledVal=""/>
</#if>
<#assign requiredHint="<span class='requiredHint'> *</span>"/>
<div class="form">
<h2>${titleVerb}&nbsp;educational training entry for ${subjectName}</h2>
<form class="${editMode}" action="${contextPath}${editConfig.submitToUrl}" >
<div class="entry">
<label for="degreeUri">Degree</label>
<select name="degreeUri" id="degreeUri" >
<option value="" selected="selected">Select one</option>
<@widget name="SelectList" fieldName="degree" />
</select>
</div>
<label for="majorField">Major Field of Degree ${requiredHint}</label>
<input type="text" id="majorField" name="majorField" size="30" />
<@widget name="editElement" name="dateTime" />
<div class="relatedIndividual">
<div class="existing">
<label for="org">Organization Granting Degree ${requiredHint}</label>
<select id="org" name="org">
<@widget name="SelectList" fieldName="org" />
</select>
<span class="existingOrNew">or</span>
</div>
<div class="addNewLink">
If your organization is not listed, please <a href="#">add a new organization</a>.
</div>
<div class="new">
<h6>Add a New Organization</h6>
<label for="newOrgName">Organization Name <span class='requiredHint'> *</span></label>
<input size="30" type="text" id="newOrgName" name="newOrgName" value="" />
<label for="newOrgType">Select Organization Type <span class='requiredHint'> *</span></label>
<select id="newOrgType" name="newOrgType">
<option value="" selected="selected">Select one</option>
<@widget name="SelectList" fieldName="orgType" />
</select>
</div>
</div>
<div class="entry">
<label for="dept">Department or School Name within the Organization</label>
<input size="50" type="text" id="dept" name="dept" value="" />
<label for="info">Supplemental Information</label>
<input size="50" type="text" id="info" name="info" value="" />
<p>e.g., <em>Postdoctoral training</em> or <em>Transferred</em></p>
</div>
<p class="submit">
<input name="editKey" type="hidden" value="${editConfig.editKey}" />
<input type="submit" id="submit" value="${submitButtonText}"/>
<#assign cancelParams = "editKey=${editConfig.editKey}&cancel=true" >
<span class="or">or</span><a class="cancel" href="${contextPath}/edit/postEditCleanUp.jsp?${cancelParams?url}" title="Cancel">Cancel</a>
</p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<#assign acUrl="/autocomplete?tokenize=true&stem=true" >
<script type="text/javascript">
var customFormData = {
acUrl: '${acUrl?url}',
editMode: '${editMode}',
submitButtonTextType: 'compound',
defaultTypeName: 'organization'
};
</script>
</div>

View file

@ -1,6 +1,12 @@
<#-- $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$ -->
${fieldName}<br/> <#--
This is the placeholder template for the dateTime with precision input element.
The UI team should replace any or all of the text in this file.
-->
<div>
${fieldName}
<br/> <br/>
year: <input name="${fieldName}.year" type="text" value="${year}"/> <br/> year: <input name="${fieldName}.year" type="text" value="${year}"/> <br/>
month: <input name="${fieldName}.month" type="text" value="${month}"/> <br/> month: <input name="${fieldName}.month" type="text" value="${month}"/> <br/>
@ -8,4 +14,4 @@ day: <input name="${fieldName}.day" type="text" value="${day}"/> <br/>
hour: <input name="${fieldName}.hour" type="text" value="${hour}"/> <br/> hour: <input name="${fieldName}.hour" type="text" value="${hour}"/> <br/>
minute: <input name=${fieldName}.minute" type="text" value="${minute}"/> <br/> minute: <input name=${fieldName}.minute" type="text" value="${minute}"/> <br/>
second: <input name=${fieldName}.second" type="text" value="${second}"/> <br/> second: <input name=${fieldName}.second" type="text" value="${second}"/> <br/>
<br/> </div>

View file

@ -7,45 +7,71 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
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 com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; 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.EditConfiguration;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
import freemarker.template.Configuration; import freemarker.template.Configuration;
/** /**
* This is intended to work in conjunction with a tempalte to create the HTML for a * 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 * datetime with precision and to convert he submitted parameters into
* varname -> Literal and varname -> URI maps. * varname -> Literal and varname -> URI maps.
*/ */
public class DateTimeWithPrecision extends BaseEditElement { public class DateTimeWithPrecision extends BaseEditElement {
String fieldName;
public DateTimeWithPrecision(Field field) {
super(field);
fieldName = field.getName();
}
private static final Log log = LogFactory.getLog(DateTimeWithPrecision.class); private static final Log log = LogFactory.getLog(DateTimeWithPrecision.class);
private String TEMPATE_NAME = "DateTimeWithPrecision.ftl"; protected String TEMPATE_NAME = "DateTimeWithPrecision.ftl";
protected String[] PRECISIONS = { protected static final String vivoCore = "http://vivoweb.org/ontology/core#";
"http://bogus.com/precision/none", protected static final String[] PRECISIONS = {
"http://bogus.com/precision/year", vivoCore+"NoPrecision",
"http://bogus.com/precision/month", vivoCore+"YearPrecision",
"http://bogus.com/precision/day", vivoCore+"YearMonthPrecision",
"http://bogus.com/precision/hour", vivoCore+"YearMonthDayPrecision",
"http://bogus.com/precision/minute", vivoCore+"YearMonthDayHourPrecision",
"http://bogus.com/precision/second" }; vivoCore+"YearMonthDayHourMinutePrecision",
vivoCore+"YearMonthDayTimePrecision"};
protected 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;}
}
@Override @Override
public String draw(String fieldName, EditConfiguration editConfig, public String draw(String fieldName, EditConfiguration editConfig,
EditSubmission editSub, Configuration fmConfig) { EditSubmission editSub, Configuration fmConfig) {
Map map = getMapForTemplate(fieldName, editConfig, editSub); Map map = getMapForTemplate( editConfig, editSub);
map.putAll( FreemarkerHttpServlet.getDirectives()); map.putAll( FreemarkerHttpServlet.getDirectives());
return merge( fmConfig, TEMPATE_NAME, map); return merge( fmConfig, TEMPATE_NAME, map);
} }
@ -53,12 +79,12 @@ public class DateTimeWithPrecision extends BaseEditElement {
/** /**
* This produces a map for use in the template. * This produces a map for use in the template.
*/ */
private Map getMapForTemplate(String fieldName, EditConfiguration editConfig, EditSubmission editSub) { private Map getMapForTemplate(EditConfiguration editConfig, EditSubmission editSub) {
Map<String,Object>map = new HashMap<String,Object>(); Map<String,Object>map = new HashMap<String,Object>();
map.put("fieldName", fieldName); map.put("fieldName", fieldName);
DateTime value = getTimeValue(fieldName,editConfig,editSub); DateTime value = getTimeValue(editConfig,editSub);
map.put("year", Integer.toString(value.getYear())); map.put("year", Integer.toString(value.getYear()));
map.put("month", Integer.toString(value.getMonthOfYear())); map.put("month", Integer.toString(value.getMonthOfYear()));
map.put("day", Integer.toString(value.getDayOfMonth()) ); map.put("day", Integer.toString(value.getDayOfMonth()) );
@ -66,7 +92,7 @@ public class DateTimeWithPrecision extends BaseEditElement {
map.put("minute", Integer.toString(value.getMinuteOfHour()) ); map.put("minute", Integer.toString(value.getMinuteOfHour()) );
map.put("second", Integer.toString(value.getSecondOfMinute() )) ; map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
map.put("precision", getPrecision(fieldName,editConfig,editSub)); map.put("precision", getPrecision(editConfig,editSub));
//maybe we should put in empty validation errors to show what they would be? //maybe we should put in empty validation errors to show what they would be?
//ex: map.put("year.error",""); //ex: map.put("year.error","");
@ -75,14 +101,12 @@ public class DateTimeWithPrecision extends BaseEditElement {
} }
private String getPrecision(String fieldName, private String getPrecision(EditConfiguration editConfig, EditSubmission editSub) {
EditConfiguration editConfig, EditSubmission editSub) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return "http://bogus.precision.uri.com/bogus"; return "http://bogus.precision.uri.com/bogus";
} }
private DateTime getTimeValue(String fieldName, EditConfiguration editConfig, private DateTime getTimeValue(EditConfiguration editConfig, EditSubmission editSub) {
EditSubmission editSub) {
return new DateTime(); return new DateTime();
} }
@ -95,14 +119,13 @@ public class DateTimeWithPrecision extends BaseEditElement {
EditConfiguration editConfig, Map<String, String[]> queryParameters) { EditConfiguration editConfig, Map<String, String[]> queryParameters) {
Map<String,Literal> literalMap = new HashMap<String,Literal>(); Map<String,Literal> literalMap = new HashMap<String,Literal>();
Literal datetime =getDateTime( fieldName, queryParameters); Literal datetime =getDateTime( queryParameters);
literalMap.put(fieldName+".value", datetime); literalMap.put(fieldName+".value", datetime);
return literalMap; return literalMap;
} }
protected Literal getDateTime(String fieldName, protected Literal getDateTime( Map<String, String[]> queryParameters ) {
Map<String, String[]> queryParameters) {
Integer year = parseToInt(fieldName+".year", queryParameters); Integer year = parseToInt(fieldName+".year", queryParameters);
Integer month = parseToInt(fieldName+".month", queryParameters); Integer month = parseToInt(fieldName+".month", queryParameters);
if( month == null || month == 0 ) if( month == null || month == 0 )
@ -149,7 +172,7 @@ public class DateTimeWithPrecision extends BaseEditElement {
EditConfiguration editConfig, Map<String, String[]> queryParameters) { EditConfiguration editConfig, Map<String, String[]> queryParameters) {
String precisionUri; String precisionUri;
try { try {
precisionUri = getSubmittedPrecision( fieldName, queryParameters); precisionUri = getSubmittedPrecision( queryParameters);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
log.error("getURIS() should only be called on input that passed getValidationErrors()"); log.error("getURIS() should only be called on input that passed getValidationErrors()");
@ -165,8 +188,7 @@ public class DateTimeWithPrecision extends BaseEditElement {
* the error message if the queryParameters cannot make a valid date/precision because * the error message if the queryParameters cannot make a valid date/precision because
* there are values missing. * there are values missing.
*/ */
protected String getSubmittedPrecision(String fieldName, protected String getSubmittedPrecision(Map<String, String[]> queryParameters) throws Exception {
Map<String, String[]> queryParameters) throws Exception {
Integer year = parseToInt(fieldName+".year",queryParameters); Integer year = parseToInt(fieldName+".year",queryParameters);
Integer month = parseToInt(fieldName+".month",queryParameters); Integer month = parseToInt(fieldName+".month",queryParameters);
@ -219,34 +241,175 @@ public class DateTimeWithPrecision extends BaseEditElement {
errorMsgMap.put(fieldName+"."+name, "must have only one value for " + name); errorMsgMap.put(fieldName+"."+name, "must have only one value for " + name);
} }
errorMsgMap.putAll(checkDate( fieldName, queryParameters) ); String precisionURI = null;
try{
precisionURI = getSubmittedPrecision( queryParameters);
}catch(Exception ex){
errorMsgMap.put(fieldName,ex.getMessage());
return errorMsgMap;
}
errorMsgMap.putAll(checkDate( precisionURI, queryParameters) );
return errorMsgMap; return errorMsgMap;
} }
/** /**
* This checks for invalid date times like "2010-02-31" or "2010-02-01T99:99:99". * This checks for invalid date times.
*/ */
private Map<String,String> checkDate(String fieldName, Map<String, String[]> queryParameters){ final static String NON_INTEGER_YEAR = "must enter a valid year";
//TODO final static String NON_INTEGER_MONTH = "must enter a valid month";
//see EditSubmission.getDateTime() for an example of checking for valid dates. 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";
// Integer year,month,day,hour,minute,second; private Map<String,String> checkDate( String precisionURI, Map<String, String[]> qp){
// if( precisionURI == null )
// year = parseToInt(fieldName+".year", queryParameters); return Collections.emptyMap();
// month= parseToInt(fieldName+".month", queryParameters);
// day = parseToInt(fieldName+".day", queryParameters);
// hour = parseToInt(fieldName+".hour", queryParameters);
// minute = parseToInt(fieldName+".minute",queryParameters);
// second = parseToInt(fieldName+".second", queryParameters);
//
// DateTime dateTime = new DateTime();
// DateTimeFormatter fmt = ISODateTimeFormat.dateParser();
//
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( Precision.YEAR.uri() ) ){
if( ! canParseToNumber(fieldName+".year" ,qp))
errors.put(fieldName+".year", NON_INTEGER_YEAR);
}else if( precisionURI.equals( 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( 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( 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( 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( 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){ private Integer parseToInt(String key,Map<String, String[]> queryParameters){
Integer out = null; Integer out = null;
try{ try{
@ -265,78 +428,6 @@ public class DateTimeWithPrecision extends BaseEditElement {
return out; return out;
} }
//
// /**
// * Create the var->value map for the datetimeprec.ftl template.
// */
// private Map<String, Object> getDateTimePrecMap(String fieldName,
// EditConfiguration editConfig, EditSubmission editSub) {
// Date dateFromLit = null;
// String dateStrFromLit = null;
//
// if( editSub != null && editSub.getLiteralsFromForm() != null && editSub.getLiteralsFromForm().get(fieldName) != null ){
// log.debug("found the field " + fieldName + " in the EditSubmission");
// Literal date = editSub.getLiteralsFromForm().get(fieldName);
// Object valueFromLiteral = date.getValue();
// if( valueFromLiteral != null && valueFromLiteral instanceof Date){
// dateFromLit = (Date)valueFromLiteral;
// log.debug("found literal in submission of type Date for field " + fieldName);
// }else if( valueFromLiteral != null && valueFromLiteral instanceof String){
// dateStrFromLit = (String) valueFromLiteral;
// log.debug("found literal in submission of type String for field " + fieldName);
// } else if ( valueFromLiteral != null && valueFromLiteral instanceof XSDDateTime) {
// dateStrFromLit = date.getLexicalForm();
// log.debug("found existing literal of type XSDDateTime for field " + fieldName);
// } else {
// log.error("found a value from the submsission but it was not a String or Date.");
// }
// }else if( editConfig != null && editConfig.getLiteralsInScope() != null && editConfig.getLiteralsInScope().containsKey(fieldName)){
// log.debug( "No EditSubmission found for the field " + fieldName + ", trying to get an existing value");
// Literal date = editConfig.getLiteralsInScope().get(fieldName);
// Object valueFromLiteral = date.getValue();
// if( valueFromLiteral != null && valueFromLiteral instanceof Date){
// dateFromLit = (Date)valueFromLiteral;
// log.debug("found existing literal of type Date for field " + fieldName);
// }else if( valueFromLiteral != null && valueFromLiteral instanceof String){
// dateStrFromLit = (String) valueFromLiteral;
// log.debug("found exisitng literal of type String for field " + fieldName);
// } else if ( valueFromLiteral != null && valueFromLiteral instanceof XSDDateTime) {
// dateStrFromLit = date.getLexicalForm();
// log.debug("found existing literal of type XSDDateTime for field " + fieldName);
// } else {
// log.error("found an existing value from the editConfig but it was not a String or Date:");
// log.error(valueFromLiteral.getClass().getName());
// }
// }else{
// log.debug("no value found for field " + fieldName + " in the submission or config, try to get default value");
// Field field = editConfig.getField(fieldName);
// List<List<String>> options = field.getLiteralOptions();
// if( options.size() >=1 && options.get(0) != null &&
// options.get(0).size() >= 1 && options.get(0).get(0) != null){
// dateStrFromLit = options.get(0).get(0);
// }else{
// log.debug("no default found for field " + fieldName);
// }
// }
//
// DateTime dt = null;
// if( dateStrFromLit != null){
// try {
// /* See:
// * http://joda-time.sourceforge.net/api-release/org/joda/time/format/ISODateTimeFormat.html#dateParser()
// * for date format information*/
// DateTimeFormatter dtFmt = ISODateTimeFormat.dateParser();
// dt = new DateTime( dtFmt.parseDateTime( dateStrFromLit ));
// } catch (Exception e) {
// log.warn("Could not convert '" + dateStrFromLit +"' to DateTime.",e);
// dt = null;
// }
// }else if (dateFromLit != null){
//
// }
//
} }

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.edit.elements; package edu.cornell.mannlib.vitro.webapp.edit.elements;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,17 +12,19 @@ import org.junit.Test;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.datatypes.xsd.XSDDateTime; import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
public class DateTimeWithPrecisionTest extends DateTimeWithPrecision { public class DateTimeWithPrecisionTest {
@Test @Test
public void precisionSecondsValidationTest() throws Exception{ public void precisionSecondsValidationTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -38,7 +39,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[6], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[6], precisionURI);
@ -47,7 +48,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void precisionMinutesValidationTest() throws Exception{ public void precisionMinutesValidationTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -63,7 +66,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[5], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[5], precisionURI);
@ -72,7 +75,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void precisionHourssValidationTest() throws Exception{ public void precisionHourssValidationTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -88,7 +93,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[4], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[4], precisionURI);
@ -97,7 +102,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void precisionDaysValidationTest() throws Exception{ public void precisionDaysValidationTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -113,7 +120,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[3], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[3], precisionURI);
@ -122,7 +129,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void precisionMonthsValidationTest()throws Exception{ public void precisionMonthsValidationTest()throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -138,7 +147,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[2], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[2], precisionURI);
@ -147,7 +156,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void precisionYearValidationTest() throws Exception{ public void precisionYearValidationTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -163,7 +174,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null; String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision(FIELDNAME, queryParameters); precisionURI = dtwp.getSubmittedPrecision( queryParameters);
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(dtwp.PRECISIONS[1], precisionURI); Assert.assertEquals(dtwp.PRECISIONS[1], precisionURI);
@ -172,7 +183,9 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
@Test @Test
public void getDateLiteralTest(){ public void getDateLiteralTest(){
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(); Field field = new Field();
field.setName(FIELDNAME);
DateTimeWithPrecision dtwp = new DateTimeWithPrecision(field);
Map<String,String[]> queryParameters = new HashMap<String, String[]>(); Map<String,String[]> queryParameters = new HashMap<String, String[]>();
queryParameters.put(FIELDNAME+".year", new String[]{"1999" }); queryParameters.put(FIELDNAME+".year", new String[]{"1999" });
@ -187,7 +200,7 @@ public class DateTimeWithPrecisionTest extends DateTimeWithPrecision {
Assert.assertNotNull(validationMsgs); Assert.assertNotNull(validationMsgs);
Assert.assertTrue(validationMsgs.size() == 0 ); Assert.assertTrue(validationMsgs.size() == 0 );
Literal date = dtwp.getDateTime(FIELDNAME, queryParameters); Literal date = dtwp.getDateTime( queryParameters);
Assert.assertNotNull(date); Assert.assertNotNull(date);
Assert.assertEquals( XSDDatatype.XSDdateTime.getURI() ,date.getDatatypeURI() ); Assert.assertEquals( XSDDatatype.XSDdateTime.getURI() ,date.getDatatypeURI() );