VIVO-921: some additional validation work as well as dislaying an indicator when a data property has been ingested in an invalid format.
This commit is contained in:
parent
ced99d7703
commit
a32ee20a40
7 changed files with 199 additions and 43 deletions
|
@ -887,3 +887,13 @@ faux_property_by_base = Faux propiedades por base propriedad
|
||||||
faux_property_alpha = Faux propiedades en orden alfabético
|
faux_property_alpha = Faux propiedades en orden alfabético
|
||||||
|
|
||||||
no_class_restrictions=No hay clases con una restricción de esta propiedad.
|
no_class_restrictions=No hay clases con una restricción de esta propiedad.
|
||||||
|
|
||||||
|
invalid_format=Formato inválido
|
||||||
|
four_digit_year=Entrada invalida. Por favor, introduzca un año de 4 dígitos.
|
||||||
|
year_numeric=Entrada invalida. El Año debe ser numérico.
|
||||||
|
year_month_day=Entrada invalida. Por favor, introduzca un año, mes y día.
|
||||||
|
minimum_ymd=Entrada invalida. Introduzca por lo menos un año, mes y día.
|
||||||
|
minimum_hour=Entrada invalida. Especifique por lo menos una hora.
|
||||||
|
year_month=Entrada invalida. Por favor ingrese un Año y Mes.
|
||||||
|
decimal_only=Entrada invalida. Se permite un punto decimal, pero miles separadores no son.
|
||||||
|
whole_number=Entrada invalida. Por favor, introduzca un número entero sin punto decimal o miles separadores.
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
private DataPropertyListConfig config;
|
private DataPropertyListConfig config;
|
||||||
private String objectKey;
|
private String objectKey;
|
||||||
private String queryString;
|
private String queryString;
|
||||||
|
private String rangeDatatypeURI;
|
||||||
private Set<String> constructQueries;
|
private Set<String> constructQueries;
|
||||||
private int displayLimit;
|
private int displayLimit;
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
|
|
||||||
statements = new ArrayList<DataPropertyStatementTemplateModel>();
|
statements = new ArrayList<DataPropertyStatementTemplateModel>();
|
||||||
displayLimit = dp.getDisplayLimit();
|
displayLimit = dp.getDisplayLimit();
|
||||||
|
rangeDatatypeURI = dp.getRangeDatatypeURI();
|
||||||
// If the property is populated, get the data property statements via a sparql query
|
// If the property is populated, get the data property statements via a sparql query
|
||||||
if (populatedDataPropertyList.contains(dp)) {
|
if (populatedDataPropertyList.contains(dp)) {
|
||||||
log.debug("Getting data for populated data property " + getUri());
|
log.debug("Getting data for populated data property " + getUri());
|
||||||
|
@ -161,6 +163,11 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
return displayLimit;
|
return displayLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
public String getRangeDatatypeURI() {
|
||||||
|
return rangeDatatypeURI;
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigError checkQuery(String queryString) {
|
public ConfigError checkQuery(String queryString) {
|
||||||
if (StringUtils.isBlank(queryString)) {
|
if (StringUtils.isBlank(queryString)) {
|
||||||
return ConfigError.NO_SELECT_QUERY;
|
return ConfigError.NO_SELECT_QUERY;
|
||||||
|
|
|
@ -296,3 +296,7 @@ ol.tinyMCENumeric li {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
}
|
}
|
||||||
|
img.invalidFormat {
|
||||||
|
padding-left:8px;
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
|
@ -900,3 +900,13 @@ faux_property_by_base = faux properties by base property
|
||||||
faux_property_alpha = faux properties alphabetically
|
faux_property_alpha = faux properties alphabetically
|
||||||
|
|
||||||
no_class_restrictions=There are no classes with a restriction on this property.
|
no_class_restrictions=There are no classes with a restriction on this property.
|
||||||
|
|
||||||
|
invalid_format=Invalid format
|
||||||
|
four_digit_year=Invalid entry. Please enter a 4-digit Year.
|
||||||
|
year_numeric=Invalid entry. The Year must be numeric.
|
||||||
|
year_month_day=Invalid entry. Please enter a Year, Month and Day.
|
||||||
|
minimum_ymd=Invalid entry. Please enter at least a Year, Month and Day.
|
||||||
|
minimum_hour=Invalid entry. Please specify at least an Hour.
|
||||||
|
year_month=Invalid entry. Please enter a Year and Month.
|
||||||
|
decimal_only=Invalid entry. A decimal point is allowed, but thousands-separators are not.
|
||||||
|
whole_number=Invalid entry. Enter a whole number with no decimal point or thousands-separators.
|
||||||
|
|
|
@ -6,10 +6,14 @@
|
||||||
is also used to generate the property statement during a deletion.
|
is also used to generate the property statement during a deletion.
|
||||||
-->
|
-->
|
||||||
<#import "lib-datetime.ftl" as dt>
|
<#import "lib-datetime.ftl" as dt>
|
||||||
<@showStatement statement />
|
<#if property.rangeDatatypeURI?? && property.rangeDatatypeURI?contains("#")>
|
||||||
|
<#assign datatype = property.rangeDatatypeURI?substring(property.rangeDatatypeURI?last_index_of("#")+1) />
|
||||||
|
</#if>
|
||||||
|
<@showStatement statement datatype />
|
||||||
|
|
||||||
<#macro showStatement statement>
|
<#macro showStatement statement datatype>
|
||||||
<#assign theValue = statement.value />
|
<#assign theValue = statement.value />
|
||||||
|
|
||||||
<#if theValue?contains("<ul>") >
|
<#if theValue?contains("<ul>") >
|
||||||
<#assign theValue = theValue?replace("<ul>","<ul class='tinyMCEDisc'>") />
|
<#assign theValue = theValue?replace("<ul>","<ul class='tinyMCEDisc'>") />
|
||||||
</#if>
|
</#if>
|
||||||
|
@ -23,7 +27,11 @@
|
||||||
<#assign theValue = theValue + "T00:00:00" />
|
<#assign theValue = theValue + "T00:00:00" />
|
||||||
${dt.formatXsdDateTimeLong(theValue, "yearMonthDayPrecision")}
|
${dt.formatXsdDateTimeLong(theValue, "yearMonthDayPrecision")}
|
||||||
<#elseif theValue?matches("^([0-9]{4})-((0[1-9])|(1[0-2]))-((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])")>
|
<#elseif theValue?matches("^([0-9]{4})-((0[1-9])|(1[0-2]))-((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])")>
|
||||||
|
<#if theValue?contains("T00:00:00") >
|
||||||
|
${dt.formatXsdDateTimeLong(theValue, "yearMonthDayPrecision")}
|
||||||
|
<#else>
|
||||||
${dt.formatXsdDateTimeLong(theValue, "yearMonthDayTimePrecision")}
|
${dt.formatXsdDateTimeLong(theValue, "yearMonthDayTimePrecision")}
|
||||||
|
</#if>
|
||||||
<#elseif theValue?matches("^([0-9]{4})-(0[1-9]|1[012])")>
|
<#elseif theValue?matches("^([0-9]{4})-(0[1-9]|1[012])")>
|
||||||
<#assign theValue = theValue + "-01T00:00:00" />
|
<#assign theValue = theValue + "-01T00:00:00" />
|
||||||
${dt.formatXsdDateTimeLong(theValue, "yearMonthPrecision")}
|
${dt.formatXsdDateTimeLong(theValue, "yearMonthPrecision")}
|
||||||
|
@ -31,6 +39,56 @@
|
||||||
<#assign theValue = "2000" + theValue?substring(1) + "-01T00:00:00" />
|
<#assign theValue = "2000" + theValue?substring(1) + "-01T00:00:00" />
|
||||||
${dt.formatXsdDateTimeLong(theValue, "monthPrecision")}
|
${dt.formatXsdDateTimeLong(theValue, "monthPrecision")}
|
||||||
<#else>
|
<#else>
|
||||||
${theValue}
|
${theValue} <@validateFormat theValue datatype/>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
<#macro validateFormat value datatype >
|
||||||
|
<#if datatype?? >
|
||||||
|
<#switch datatype>
|
||||||
|
<#case "date">
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt="${i18n().invalid_format}" title=" ${i18n().invalid_format}"> <#-- validated above -->
|
||||||
|
<#break>
|
||||||
|
<#case "dateTime">
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}"> <#-- validated above -->
|
||||||
|
<#break>
|
||||||
|
<#case "time">
|
||||||
|
<#if !value?matches("(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#case "gYear">
|
||||||
|
<#if !value?matches("^\\d{4}") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#case "gMonth">
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}"> <#-- validated above -->
|
||||||
|
<#break>
|
||||||
|
<#case "gYearMonth">
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}"> <#-- validated above -->
|
||||||
|
<#break>
|
||||||
|
<#case "float">
|
||||||
|
<#if !value?matches("^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?.") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#case "integer">
|
||||||
|
<#if !value?matches("^-?\\d+$") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#case "int">
|
||||||
|
<#if !value?matches("^-?\\d+$") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#case "boolean">
|
||||||
|
<#if !value?matches("false") && !value?matches("true") >
|
||||||
|
<img class="invalidFormat" src="${urls.base}/images/iconAlert.png" width="18" alt=" ${i18n().invalid_format}" title=" ${i18n().invalid_format}">
|
||||||
|
</#if>
|
||||||
|
<#break>
|
||||||
|
<#default>
|
||||||
|
</#switch>
|
||||||
|
</#if>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,17 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var datatype = "${datatype!}";
|
var datatype = "${datatype!}";
|
||||||
|
|
||||||
|
var i18nStrings = {
|
||||||
|
four_digit_year: '${i18n().four_digit_year}',
|
||||||
|
year_numeric: '${i18n().year_numeric}',
|
||||||
|
year_month_day: '${i18n().year_month_day}',
|
||||||
|
minimum_ymd: '${i18n().minimum_ymd}',
|
||||||
|
minimum_hour: '${i18n().minimum_hour}',
|
||||||
|
year_month: '${i18n().year_month}',
|
||||||
|
decimal_only: '${i18n().decimal_only}',
|
||||||
|
whole_number: '${i18n().whole_number}'
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<#include "defaultFormScripts.ftl">
|
<#include "defaultFormScripts.ftl">
|
||||||
|
|
|
@ -17,6 +17,7 @@ var defaultDataPropertyUtils = {
|
||||||
this.textArea = $('textarea.useTinyMce');
|
this.textArea = $('textarea.useTinyMce');
|
||||||
|
|
||||||
$.extend(this, datatype);
|
$.extend(this, datatype);
|
||||||
|
$.extend(this, i18nStrings);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -42,35 +43,59 @@ var defaultDataPropertyUtils = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defaultDataPropertyUtils.createLiteralValue();
|
return defaultDataPropertyUtils.createAndValidateLiteralValue();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
createLiteralValue: function() {
|
createAndValidateLiteralValue: function() {
|
||||||
var theType = datatype.substring(datatype.lastIndexOf("#") + 1);
|
var theType = datatype.substring(datatype.lastIndexOf("#") + 1);
|
||||||
var temp = "";
|
var temp = "";
|
||||||
|
if ( $('#literal').attr("type") == "hidden" ) {
|
||||||
|
if ( $('#dateTimeField-year').length ) {
|
||||||
|
if ( $('#dateTimeField-year').val().length < 4 ) {
|
||||||
|
alert(defaultDataPropertyUtils.four_digit_year);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var reg = /^\d+$/;
|
||||||
|
if ( !reg.test($('#dateTimeField-year').val()) ) {
|
||||||
|
alert(defaultDataPropertyUtils.year_numeric);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (theType) {
|
switch (theType) {
|
||||||
case 'date':
|
case 'date':
|
||||||
temp = $('#dateTimeField-year').val() + "-"
|
temp = $('#dateTimeField-year').val() + "-"
|
||||||
+ $('#dateTimeField-month').val() + "-"
|
+ $('#dateTimeField-month').val() + "-"
|
||||||
+ $('#dateTimeField-day').val();
|
+ $('#dateTimeField-day').val();
|
||||||
|
if ( temp.indexOf("-") == 0 || temp.lastIndexOf("-") == (temp.length - 1) || temp.indexOf("--") > 0 ) {
|
||||||
|
alert(defaultDataPropertyUtils.year_month_day);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$('#literal').val(temp);
|
$('#literal').val(temp);
|
||||||
break;
|
break;
|
||||||
case 'dateTime':
|
case 'dateTime':
|
||||||
temp = $('#dateTimeField-year').val() + "-"
|
temp = $('#dateTimeField-year').val() + "-"
|
||||||
+ $('#dateTimeField-month').val() + "-"
|
+ $('#dateTimeField-month').val() + "-"
|
||||||
+ $('#dateTimeField-day').val() + "T"
|
+ $('#dateTimeField-day').val() + "T"
|
||||||
+ $('#dateTimeField-hour').val() + ":"
|
+ ($('#dateTimeField-hour').val().length == 0 ? "00" : $('#dateTimeField-hour').val()) + ":"
|
||||||
+ $('#dateTimeField-minute').val() + ":"
|
+ ($('#dateTimeField-minute').val().length == 0 ? "00" : $('#dateTimeField-minute').val()) + ":"
|
||||||
+ $('#dateTimeField-second').val();
|
+ ($('#dateTimeField-second').val().length == 0 ? "00" : $('#dateTimeField-second').val());
|
||||||
|
if ( temp.indexOf("-") == 0 || temp.indexOf("-T") > 0 || temp.indexOf("--") > 0 ) {
|
||||||
|
alert(defaultDataPropertyUtils.minimum_ymd);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$('#literal').val(temp);
|
$('#literal').val(temp);
|
||||||
break;
|
break;
|
||||||
case 'time':
|
case 'time':
|
||||||
temp = $('#dateTimeField-hour').val() + ":"
|
temp = $('#dateTimeField-hour').val() + ":"
|
||||||
+ $('#dateTimeField-minute').val() + ":"
|
+ ($('#dateTimeField-minute').val().length == 0 ? "00" : $('#dateTimeField-minute').val()) + ":"
|
||||||
+ $('#dateTimeField-second').val();
|
+ ($('#dateTimeField-second').val().length == 0 ? "00" : $('#dateTimeField-second').val());
|
||||||
|
if ( temp.indexOf(":") == 0 ) {
|
||||||
|
alert(defaultDataPropertyUtils.minimum_hour);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$('#literal').val(temp);
|
$('#literal').val(temp);
|
||||||
break;
|
break;
|
||||||
case 'gYear':
|
case 'gYear':
|
||||||
|
@ -78,13 +103,44 @@ var defaultDataPropertyUtils = {
|
||||||
break;
|
break;
|
||||||
case 'gYearMonth':
|
case 'gYearMonth':
|
||||||
temp = $('#dateTimeField-year').val() + "-" + $('#dateTimeField-month').val();
|
temp = $('#dateTimeField-year').val() + "-" + $('#dateTimeField-month').val();
|
||||||
|
if ( temp.indexOf("-") == 0 || temp.lastIndexOf("-") == (temp.length - 1) ) {
|
||||||
|
alert(defaultDataPropertyUtils.year_month);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$('#literal').val(temp);
|
$('#literal').val(temp);
|
||||||
break;
|
break;
|
||||||
case 'gMonth':
|
case 'gMonth':
|
||||||
|
if ( $('#dateTimeField-month').val().length == 2 ) {
|
||||||
temp = "--" + $('#dateTimeField-month').val()
|
temp = "--" + $('#dateTimeField-month').val()
|
||||||
$('input#literal').val(temp);
|
$('input#literal').val(temp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if ( $('#literal').attr("type") == "text" ) {
|
||||||
|
switch (theType) {
|
||||||
|
case 'float':
|
||||||
|
if ( $('#literal').val().indexOf(",") > -1 ) {
|
||||||
|
alert(defaultDataPropertyUtils.decimal_only);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$('#literal').val($('#literal').val().replace(",",""));
|
||||||
|
break;
|
||||||
|
case 'integer':
|
||||||
|
if ( $('#literal').val().indexOf(".") > -1 || $('#literal').val().indexOf(",") > 0 ) {
|
||||||
|
alert(defaultDataPropertyUtils.whole_number);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'int':
|
||||||
|
if ( $('#literal').val().indexOf(".") > -1 || $('#literal').val().indexOf(",") > 0 ) {
|
||||||
|
alert(defaultDataPropertyUtils.whole_number);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
parseLiteralValue: function() {
|
parseLiteralValue: function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue