From 4e216e9360c63e10813645ce1cb26e4376ce70f5 Mon Sep 17 00:00:00 2001 From: tworrall Date: Mon, 9 Dec 2013 16:18:02 -0500 Subject: [PATCH 1/4] related to VIVO-628, there was no validation on the datetimeinterval form when no years are specified --- webapp/languages/es_GO/i18n/all_es_GO.properties | 2 ++ .../n3editing/VTwo/DateTimeIntervalValidationVTwo.java | 7 +++++-- webapp/web/i18n/all.properties | 4 +++- .../freemarker/edit/forms/dateTimeIntervalForm.ftl | 5 ++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/webapp/languages/es_GO/i18n/all_es_GO.properties b/webapp/languages/es_GO/i18n/all_es_GO.properties index 5544aafb0..6e9016109 100644 --- a/webapp/languages/es_GO/i18n/all_es_GO.properties +++ b/webapp/languages/es_GO/i18n/all_es_GO.properties @@ -862,3 +862,5 @@ view_labels_capitalized = Ver etiquetas view_labels_for = Ver Etiquetas de select_an_existing_document = Seleccione un documento existente + +datetime_year_required = Intervalos de fecha / hora deben empezar por un año. Ingrese una Fecha de inicio, un fin de año o los dos. \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java index aa3ca0ed6..65f5f420e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java @@ -63,8 +63,11 @@ public class DateTimeIntervalValidationVTwo implements N3ValidatorVTwo { // errors.put(startFieldName, "If there is an end date, there should be a start date"); // return errors; // } - - + // We need to ensure that the user has entered a start year or end year -- tlw72 + if ( literalListIsNull(formStartYear) && literalListIsNull(formStartYear) ) { + errors.put(startFieldName, "Date/time intervals must begin with a year. Please enter a start year or an end year."); + return errors; + } //Assuming form start year and form end year are working in conjunction with multiple values int index; if (!literalListIsNull(formStartYear) && !literalListIsNull(formEndYear)) { diff --git a/webapp/web/i18n/all.properties b/webapp/web/i18n/all.properties index 818c27c4a..0fce78764 100644 --- a/webapp/web/i18n/all.properties +++ b/webapp/web/i18n/all.properties @@ -875,4 +875,6 @@ selection_in_process = Your selection is being processed. view_labels_capitalized = View Labels view_labels_for = View Labels for -select_an_existing_document = Select an existing document \ No newline at end of file +select_an_existing_document = Select an existing document + +datetime_year_required = Date/time intervals must begin with a year. Enter either a Start Year, an End Year or both. \ No newline at end of file diff --git a/webapp/web/templates/freemarker/edit/forms/dateTimeIntervalForm.ftl b/webapp/web/templates/freemarker/edit/forms/dateTimeIntervalForm.ftl index c7139c5c6..f61c42b61 100644 --- a/webapp/web/templates/freemarker/edit/forms/dateTimeIntervalForm.ftl +++ b/webapp/web/templates/freemarker/edit/forms/dateTimeIntervalForm.ftl @@ -58,7 +58,7 @@ <#if htmlForElements?keys?seq_contains("endField")> ${i18n().end_capitalized}  ${htmlForElements["endField"]} - + *${i18n().datetime_year_required}

@@ -69,8 +69,7 @@

-${stylesheets.add('', - '')} +${stylesheets.add('')} ${scripts.add('', '')} \ No newline at end of file From 12395c00d068487640151d9ade0eb7c81c72e3fd Mon Sep 17 00:00:00 2001 From: j2blake Date: Mon, 9 Dec 2013 16:52:26 -0500 Subject: [PATCH 2/4] VIVO-636 update the language files --- webapp/languages/es_GO/i18n/all_es_GO.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webapp/languages/es_GO/i18n/all_es_GO.properties b/webapp/languages/es_GO/i18n/all_es_GO.properties index 5544aafb0..af31e7b66 100644 --- a/webapp/languages/es_GO/i18n/all_es_GO.properties +++ b/webapp/languages/es_GO/i18n/all_es_GO.properties @@ -685,6 +685,7 @@ select_existing_collaborator = Seleccione un colaborador existente para {0} selected = Seleccionado change_selection = cambiar la selección there_are_no_entries_for_selection = No hay entradas en el sistema desde el cual elegir. +the_range_class_does_not_exist= La clase de rango de esta propiedad no existe en el sistema. editing_prohibited = Esta propiedad no está configurado actualmente para prohibir la edición. confirm_entry_deletion_from = ¿Está seguro de que desea eliminar la siguiente entrada del @@ -740,6 +741,7 @@ custom_template_containing_content = Plantilla personalizada que contiene todo e a_menu_page = Esta es una página de menú menu_item_name = Menu Nombre del artículo if_blank_page_title_used = Si se deja en blanco, se utilizará el título de la página. +multiple_content_default_template_error = Con varios tipos de contenido , debe especificar una plantilla personalizada . label = etiqueta no_classes_to_select = No hay clases en el sistema desde el cual elegir. From 772cde59e50c2e675b7783f51cf97e1b55272a48 Mon Sep 17 00:00:00 2001 From: tworrall Date: Mon, 9 Dec 2013 16:59:03 -0500 Subject: [PATCH 3/4] additional datetimeinterval validation tweaking --- .../VTwo/DateTimeIntervalValidationVTwo.java | 19 ++++++++++++++++--- .../DateTimeIntervalFormGenerator.java | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java index 65f5f420e..ae87a397c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/VTwo/DateTimeIntervalValidationVTwo.java @@ -27,6 +27,7 @@ public class DateTimeIntervalValidationVTwo implements N3ValidatorVTwo { private String startFieldName; private String endFieldName; + private String templateName; private String startValueName; private String endValueName; @@ -43,6 +44,16 @@ public class DateTimeIntervalValidationVTwo implements N3ValidatorVTwo { endPrecisionName = endFieldName + "-precision"; } + public DateTimeIntervalValidationVTwo(String startFieldName, String endFieldName, String template){ + this.templateName = template; + this.startFieldName = startFieldName; + this.endFieldName = endFieldName; + startValueName = startFieldName + "-value"; + endValueName = endFieldName + "-value"; + startPrecisionName = startFieldName + "-precision"; + endPrecisionName = endFieldName + "-precision"; + } + public Map validate(EditConfigurationVTwo editConfig, MultiValueEditSubmission editSub) { Map> existingLiterals = editConfig.getLiteralsInScope(); @@ -64,9 +75,11 @@ public class DateTimeIntervalValidationVTwo implements N3ValidatorVTwo { // return errors; // } // We need to ensure that the user has entered a start year or end year -- tlw72 - if ( literalListIsNull(formStartYear) && literalListIsNull(formStartYear) ) { - errors.put(startFieldName, "Date/time intervals must begin with a year. Please enter a start year or an end year."); - return errors; + if ( templateName != null && templateName.equals("dateTimeIntervalForm.ftl")) { + if ( literalListIsNull(formStartYear) && literalListIsNull(formEndYear) ) { + errors.put(startFieldName, "Date/time intervals must begin with a year. Please enter a start year, an end year or both."); + return errors; + } } //Assuming form start year and form end year are working in conjunction with multiple values int index; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java index 22c8fcb5c..7daa9743c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/DateTimeIntervalFormGenerator.java @@ -92,7 +92,7 @@ public class DateTimeIntervalFormGenerator extends conf.addField(startField); conf.addField(endField); //Need to add validators - conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField")); + conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField","dateTimeIntervalForm.ftl")); //Adding additional data, specifically edit mode addFormSpecificData(conf, vreq); } From 566119f5108533ed8c709b59fd52eb17cd0d88cd Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Tue, 10 Dec 2013 11:25:22 -0500 Subject: [PATCH 4/4] VIVO 625 updating method to enable range uri from possible property to be used instead of blank node broken in populated property so correct range class uri is used --- .../templatemodels/individual/GroupedPropertyList.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java index 8235202a6..866ea5404 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java @@ -20,6 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; @@ -292,6 +293,14 @@ public class GroupedPropertyList extends BaseTemplateModel { } else if (op.getRangeVClassURI() == null) { return (piOp.getRangeVClassURI() != null); } else { + //Check and see if the range vclass exists for the possible piOp and populated op properties, + //because for populated properties, if the range class is a union, + //blank nodes will be broken and the code should instead use the existing or piOp range class uri + VClass piOpRangeClass = wadf.getVClassDao().getVClassByURI(piOp.getRangeVClassURI()); + VClass opRangeClass = wadf.getVClassDao().getVClassByURI(op.getRangeVClassURI()); + //if the possible range class exists but the populated one does not, then return true to allow the possible + //class to be utilized + if(piOpRangeClass != null && opRangeClass == null) return true; return (wadf.getVClassDao().isSubClassOf( piOp.getRangeVClassURI(), op.getRangeVClassURI())); }