diff --git a/languages/example/themes/wilma/i18n/all_es.properties b/languages/example/themes/wilma/i18n/all_es.properties index ff406899..100a8de6 100644 --- a/languages/example/themes/wilma/i18n/all_es.properties +++ b/languages/example/themes/wilma/i18n/all_es.properties @@ -819,6 +819,9 @@ item_capitalized = Artículo telephone_number_for = número de teléfono para telephone_number = Número de Teléfono enter_telephone_number = Por favor, introduzca un valor en el campo Número de teléfono. +fax_number_for = número de fax para +fax_number = Número de Fax +enter_fax_number = Por favor, introduzca un valor en el campo Número de fax. email_address = Dirección de Correo Electrónico email_address_for = dirección de correo electrónico para enter_email_address = Por favor, introduzca un valor en el campo Dirección de Correo Electrónico. diff --git a/productMods/config/listViewConfig-faxNumber.xml b/productMods/config/listViewConfig-faxNumber.xml new file mode 100644 index 00000000..af509c32 --- /dev/null +++ b/productMods/config/listViewConfig-faxNumber.xml @@ -0,0 +1,46 @@ + + + + + + + + PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> + + SELECT DISTINCT ?vcard ?phone + ?number + WHERE { + ?subject ?property ?vcard . + ?vcard vcard:hasTelephone ?phone . + ?phone a vcard:Fax + OPTIONAL { ?phone vcard:telephone ?number } + + } + + + + PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> + CONSTRUCT { + ?subject ?property ?vcard . + ?vcard vcard:hasTelephone ?phone . + ?phone a vcard:Fax . + ?phone ?phoneProperty ?phoneValue + } WHERE { + { + ?subject ?property ?vcard + } UNION { + ?subject ?property ?vcard . + ?vcard vcard:hasTelephone ?phone . + ?phone a vcard:Fax + } UNION { + ?subject ?property ?vcard . + ?vcard vcard:hasTelephone ?phone . + ?phone a vcard:Fax . + ?phone ?phoneProperty ?phoneValue + } + } + + + + edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.MaintainDuplicatesObjectPropertyDataPostProcessor + diff --git a/productMods/config/listViewConfig-telephoneNumber.xml b/productMods/config/listViewConfig-telephoneNumber.xml index 6ab383cb..b1ac2c0c 100644 --- a/productMods/config/listViewConfig-telephoneNumber.xml +++ b/productMods/config/listViewConfig-telephoneNumber.xml @@ -13,7 +13,7 @@ ?subject ?property ?vcard . ?vcard vcard:hasTelephone ?phone OPTIONAL { ?phone vcard:telephone ?number } - + MINUS {?phone a vcard:Fax} } @@ -37,6 +37,6 @@ } - + edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.MaintainDuplicatesObjectPropertyDataPostProcessor diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-telephoneNumber.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-phoneFaxNumber.ftl similarity index 100% rename from productMods/templates/freemarker/body/partials/individual/propStatement-telephoneNumber.ftl rename to productMods/templates/freemarker/body/partials/individual/propStatement-phoneFaxNumber.ftl diff --git a/productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl b/productMods/templates/freemarker/edit/forms/subjectHasMailingAddress.ftl similarity index 100% rename from productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl rename to productMods/templates/freemarker/edit/forms/subjectHasMailingAddress.ftl diff --git a/productMods/templates/freemarker/edit/forms/subjectHasPhoneFaxNumber.ftl b/productMods/templates/freemarker/edit/forms/subjectHasPhoneFaxNumber.ftl new file mode 100644 index 00000000..71a2fb89 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/subjectHasPhoneFaxNumber.ftl @@ -0,0 +1,95 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- this is in request.subject.name --> + +<#-- leaving this edit/add mode code in for reference in case we decide we need it --> + +<#import "lib-vivo-form.ftl" as lvf> + +<#--Retrieve certain edit configuration information--> +<#if editConfiguration.objectUri?has_content> + <#assign editMode = "edit"> +<#else> + <#assign editMode = "add"> + + +<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> + +<#--Retrieve variables needed--> +<#assign telephoneNumberValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "telephoneNumber") /> +<#assign numberType = lvf.getEditConfigLiteralValue(editConfiguration, "numberType") /> + +<#--If edit submission exists, then retrieve validation errors if they exist--> +<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> + <#assign submissionErrors = editSubmission.validationErrors/> + + +<#if numberType?? && numberType == "fax" > + <#assign labelString = "${i18n().fax_number}" /> + <#assign errorString = "${i18n().enter_fax_number}" /> + <#assign titleString = "${i18n().fax_number_for}" /> +<#else> + <#assign labelString = "${i18n().telephone_number}" /> + <#assign errorString = "${i18n().enter_telephone_number}" /> + <#assign titleString = "${i18n().telephone_number_for}" /> + + +<#if editMode == "edit"> + <#assign titleVerb="${i18n().edit_capitalized}"> + <#assign submitButtonText="${titleVerb}" + " ${labelString}"> + <#assign disabledVal="disabled"> +<#else> + <#assign titleVerb="${i18n().create_capitalized}"> + <#assign submitButtonText="${titleVerb}" + " ${labelString}"> + <#assign disabledVal=""/> + + +<#assign requiredHint = " *" /> + +

${titleVerb} ${titleString} ${editConfiguration.subjectName}

+ +<#--Display error messages if any--> +<#if submissionErrors?has_content> + + + +<@lvf.unsupportedBrowser urls.base /> + +
+ +
+ +

+ + +

+ + + +

+ ${i18n().or} + ${i18n().cancel_link} +

+ +

* ${i18n().required_fields}

+ +
+ +
+ +${stylesheets.add('')} +${stylesheets.add('')} +${stylesheets.add('')} + +${scripts.add('', + '', + '', + '')} diff --git a/rdf/display/everytime/PropertyConfig.n3 b/rdf/display/everytime/PropertyConfig.n3 index 56225b97..ee388246 100644 --- a/rdf/display/everytime/PropertyConfig.n3 +++ b/rdf/display/everytime/PropertyConfig.n3 @@ -404,22 +404,82 @@ local:mailingAddressConfig a :ObjectPropertyDisplayConfig ; vitro:displayRankAnnot 80; vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; - vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasMailingAddressGenerator"^^ ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasMailingAddressGenerator"^^ ; :propertyGroup . -local:telephoneContext a :ConfigContext ; - :hasConfiguration local:telephoneConfig ; +local:mailingAddressContext a :ConfigContext ; + :hasConfiguration local:mailingAddressConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedBy . + +local:mailingAddressConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-mailingAddress.xml"^^xsd:string ; + :displayName "mailing address" ; + vitro:displayRankAnnot 80; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasMailingAddressGenerator"^^ ; + :propertyGroup . + +local:personTelephoneContext a :ConfigContext ; + :hasConfiguration local:personTelephoneConfig ; :configContextFor ; :qualifiedByDomain ; :qualifiedBy . -local:telephoneConfig a :ObjectPropertyDisplayConfig ; +local:personTelephoneConfig a :ObjectPropertyDisplayConfig ; :listViewConfigFile "listViewConfig-telephoneNumber.xml"^^xsd:string ; :displayName "phone" ; vitro:displayRankAnnot 60; vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; - vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasTelephoneNumberGenerator"^^ ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasPhoneFaxNumberGenerator"^^ ; + :propertyGroup . + +local:orgTelephoneContext a :ConfigContext ; + :hasConfiguration local:orgTelephoneConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedBy . + +local:orgTelephoneConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-telephoneNumber.xml"^^xsd:string ; + :displayName "phone" ; + vitro:displayRankAnnot 10; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasPhoneFaxNumberGenerator"^^ ; + :propertyGroup . + +local:personFaxContext a :ConfigContext ; + :hasConfiguration local:personFaxConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedBy . + +local:personFaxConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-faxNumber.xml"^^xsd:string ; + :displayName "fax" ; + vitro:displayRankAnnot 60; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasPhoneFaxNumberGenerator"^^ ; + :propertyGroup . + +local:orgFaxContext a :ConfigContext ; + :hasConfiguration local:orgFaxConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedBy . + +local:orgFaxConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-faxNumber.xml"^^xsd:string ; + :displayName "fax" ; + vitro:displayRankAnnot 10; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.SubjectHasPhoneFaxNumberGenerator"^^ ; :propertyGroup . local:additionalEmailContext a :ConfigContext ; @@ -467,6 +527,21 @@ local:webpageConfig a :ObjectPropertyDisplayConfig ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; :propertyGroup . +local:webpageContext a :ConfigContext ; + :hasConfiguration local:webpageConfig ; + :configContextFor ; + :qualifiedByDomain ; + :qualifiedBy . + +local:webpageConfig a :ObjectPropertyDisplayConfig ; + :listViewConfigFile "listViewConfig-webpage.xml"^^xsd:string ; + :displayName "webpage" ; + vitro:displayRankAnnot 40; + vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ; + vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ; + vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageWebpagesForIndividualGenerator"^^ ; + :propertyGroup . + local:fullNameContext a :ConfigContext ; :hasConfiguration local:fullNameConfig ; :configContextFor ; diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasMailingAddressGenerator.java similarity index 93% rename from src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java rename to src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasMailingAddressGenerator.java index bde067ee..5ca52d6d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasMailingAddressGenerator.java @@ -25,9 +25,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; -public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implements +public class SubjectHasMailingAddressGenerator extends VivoBaseGenerator implements EditConfigurationGenerator { - private Log log = LogFactory.getLog(PersonHasMailingAddressGenerator.class); + private Log log = LogFactory.getLog(SubjectHasMailingAddressGenerator.class); @Override public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, @@ -40,9 +40,9 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen initObjectPropForm(conf, vreq); String addressUri = vreq.getParameter("addressUri"); - conf.setTemplate("personHasMailingAddress.ftl"); + conf.setTemplate("subjectHasMailingAddress.ftl"); - conf.setVarNameForSubject("person"); + conf.setVarNameForSubject("subject"); conf.setVarNameForPredicate("predicate"); conf.setVarNameForObject("individualVcard"); @@ -107,9 +107,9 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen /* N3 assertions */ final static String n3ForNewAddress = - "?person ?individualVcard . \n" + + "?subject ?individualVcard . \n" + "?individualVcard a . \n" + - "?individualVcard ?person . \n" + + "?individualVcard ?subject . \n" + "?individualVcard ?address . \n" + "?address a . " ; @@ -133,7 +133,7 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen final static String individualVcardQuery = "SELECT ?individualVcard WHERE { \n" + - "?person ?individualVcard . \n" + + "?subject ?individualVcard . \n" + "}"; final static String streetAddressQuery = diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasPhoneFaxNumberGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasPhoneFaxNumberGenerator.java new file mode 100644 index 00000000..e0506e5e --- /dev/null +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/SubjectHasPhoneFaxNumberGenerator.java @@ -0,0 +1,137 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.lang.StringUtils; + +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 com.hp.hpl.jena.vocabulary.XSD; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions; +import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation; + +public class SubjectHasPhoneFaxNumberGenerator extends VivoBaseGenerator implements + EditConfigurationGenerator { + private Log log = LogFactory.getLog(SubjectHasPhoneFaxNumberGenerator.class); + + @Override + public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, + HttpSession session) throws Exception { + + EditConfigurationVTwo conf = new EditConfigurationVTwo(); + Model model = ModelFactory.createDefaultModel(); + + initBasics(conf, vreq); + initPropertyParameters(vreq, session, conf); + initObjectPropForm(conf, vreq); + String phoneUri = getPhoneUri(vreq); + String rangeUri = getRangeUri(vreq); + Literal numberType = null; + + conf.setTemplate("subjectHasPhoneFaxNumber.ftl"); + + conf.setVarNameForSubject("subject"); + conf.setVarNameForPredicate("predicate"); + conf.setVarNameForObject("individualVcard"); + + if ( rangeUri.equals("http://www.w3.org/2006/vcard/ns#Fax") ) { + conf.setN3Required( Arrays.asList( n3ForNewFaxNumber ) ); + numberType = model.createLiteral("fax"); + } + else { + conf.setN3Required( Arrays.asList( n3ForNewPhoneNumber ) ); + numberType = model.createLiteral("phone"); + } + + conf.setN3Optional( Arrays.asList( telephoneNumberAssertion ) ); + + conf.addNewResource("phone", DEFAULT_NS_FOR_NEW_RESOURCE); + conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE); + + conf.setLiteralsOnForm(Arrays.asList("telephoneNumber" )); + + conf.addSparqlForExistingLiteral("telephoneNumber", telephoneNumberQuery); + conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery); + + conf.addLiteralInScope("numberType", numberType); + + if ( conf.isUpdate() ) { + HashMap> urisInScope = new HashMap>(); + urisInScope.put("phone", Arrays.asList(new String[]{phoneUri})); + conf.addUrisInScope(urisInScope); + } + + conf.addField( new FieldVTwo(). + setName("telephoneNumber") + .setRangeDatatypeUri( XSD.xstring.toString() ). + setValidators( list("nonempty") )); + + conf.addValidator(new AntiXssValidation()); + + prepare(vreq, conf); + return conf; + } + + /* N3 assertions */ + + final static String n3ForNewPhoneNumber = + "?subject ?individualVcard . \n" + + "?individualVcard a . \n" + + "?individualVcard ?subject . \n" + + "?individualVcard ?phone . \n" + + "?phone a . " ; + + final static String n3ForNewFaxNumber = + "?subject ?individualVcard . \n" + + "?individualVcard a . \n" + + "?individualVcard ?subject . \n" + + "?individualVcard ?phone . \n" + + "?phone a . \n " + + "?phone a . " ; + + final static String telephoneNumberAssertion = + "?phone ?telephoneNumber ."; + + /* Queries for editing an existing entry */ + + final static String individualVcardQuery = + "SELECT ?existingIndividualVcard WHERE { \n" + + "?subject ?existingIndividualVcard . \n" + + "}"; + + final static String telephoneNumberQuery = + "SELECT ?existingTelephoneNumber WHERE {\n"+ + "?phone ?existingTelephoneNumber . }"; + + private String getPhoneUri(VitroRequest vreq) { + String phoneUri = vreq.getParameter("phoneUri"); + + return phoneUri; + } + private String getRangeUri(VitroRequest vreq) { + String rangeUri = vreq.getParameter("rangeUri"); + + return rangeUri; + } + +} diff --git a/themes/wilma/i18n/all.properties b/themes/wilma/i18n/all.properties index 8d336220..e5a83f4b 100644 --- a/themes/wilma/i18n/all.properties +++ b/themes/wilma/i18n/all.properties @@ -867,3 +867,6 @@ please_select_type = Please select a type from the drop-down list. preferred_title = Preferred Title preferred_title_for = preferred title for enter_preferred_title = Please enter a value in the Preferred Title field. +fax_number_for = fax number for +fax_number = Fax Number +enter_fax_number = Please enter a value in the Fax Number field.