VIVO-341: new custom form et all for preferred title

This commit is contained in:
tworrall 2013-10-10 14:51:18 -04:00
parent 55d59190e5
commit 0f3a4653ab
9 changed files with 278 additions and 6 deletions

View file

@ -846,3 +846,6 @@ remove_editor_link = desconecte la conexión de editor
add_an_editor = Agregar uno Editor add_an_editor = Agregar uno Editor
add_editor = Agregar Editor add_editor = Agregar Editor
please_select_type = Por favor Seleccione un tipo de la lista desplegable. please_select_type = Por favor Seleccione un tipo de la lista desplegable.
preferred_title = Título Preferido
preferred_title_for = título preferido para
enter_preferred_title = Por favor, introduzca un valor en el campo Preferred Title.

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- See guidelines in vitro/doc/list_view_configuration_guidelines.txt -->
<list-view-config>
<query-select>
PREFIX vcard: &lt;http://www.w3.org/2006/vcard/ns#&gt;
SELECT DISTINCT ?vcard
?title
?preferredTitle
WHERE {
?subject ?property ?vcard .
?vcard vcard:hasTitle ?title
OPTIONAL { ?title vcard:title ?preferredTitle }
}
</query-select>
<query-construct>
PREFIX vcard: &lt;http://www.w3.org/2006/vcard/ns#&gt;
CONSTRUCT {
?subject ?property ?vcard .
?vcard vcard:hasTitle ?title .
?title ?titleProperty ?titleValue
} WHERE {
{
?subject ?property ?vcard
} UNION {
?subject ?property ?vcard .
?vcard vcard:hasTitle ?title
} UNION {
?subject ?property ?vcard .
?vcard vcard:hasTitle ?title .
?title ?titleProperty ?titleValue
}
}
</query-construct>
<template>propStatement-preferredTitle.ftl</template>
<postprocessor>edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.MaintainDuplicatesObjectPropertyDataPostProcessor</postprocessor>
</list-view-config>

View file

@ -0,0 +1,17 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--
This template must be self-contained and not rely on other variables set for the individual page, because it
is also used to generate the property statement during a deletion.
-->
<@showPreferredTitle statement />
<#-- Use a macro to keep variable assignments local; otherwise the values carry over to the
next statement -->
<#macro showPreferredTitle statement>
<#if statement.number?has_content>
${statement.preferredTitle}
</#if>
</#macro>

View file

@ -0,0 +1,86 @@
<#-- $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">
</#if>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign preferredTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "preferredTitle") />
<#--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>
<#if editMode == "edit">
<#assign titleVerb="${i18n().edit_capitalized}">
<#assign submitButtonText="${titleVerb}" + " ${i18n().preferred_title}">
<#assign disabledVal="disabled">
<#else>
<#assign titleVerb="${i18n().create_capitalized}">
<#assign submitButtonText="${titleVerb}" + " ${i18n().preferred_title}">
<#assign disabledVal=""/>
</#if>
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
<h2>${titleVerb}&nbsp;${i18n().preferred_title_for} ${editConfiguration.subjectName}</h2>
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="${i18n().error_alert_icon}" />
<p>
<#--Checking if any required fields are empty-->
<#if lvf.submissionErrorExists(editSubmission, "preferredTitle")>
${i18n().enter_preferred_title}<br />
</#if>
</p>
</section>
</#if>
<@lvf.unsupportedBrowser urls.base />
<section id="personHasTelephoneNumber" role="region">
<form id="personHasTelephoneNumber" class="customForm noIE67" action="${submitUrl}" role="add/edit phone">
<p>
<label for="preferredTitle">${i18n().preferred_title} ${requiredHint}</label>
<input size="25" type="text" id="preferredTitle" name="preferredTitle" value="${preferredTitleValue}" />
</p>
<input type="hidden" id="editKey" name="editKey" value="${editKey}"/>
<p class="submit">
<input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> ${i18n().or} </span>
<a class="cancel" href="${cancelUrl}" title="${i18n().cancel_title}">${i18n().cancel_link}</a>
</p>
<p id="requiredLegend" class="requiredHint">* ${i18n().required_fields}</p>
</form>
</section>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>')}

View file

@ -35,7 +35,7 @@
<#assign requiredHint = "<span class='requiredHint'> *</span>" /> <#assign requiredHint = "<span class='requiredHint'> *</span>" />
<h2>${titleVerb}&nbsp;${i18n().mailing_address_for} ${editConfiguration.subjectName}</h2> <h2>${titleVerb}&nbsp;${i18n().telephone_number_for} ${editConfiguration.subjectName}</h2>
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>

View file

@ -482,6 +482,21 @@ local:fullNameConfig a :ObjectPropertyDisplayConfig ;
vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddFullNameToPersonGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ; vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddFullNameToPersonGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ;
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupaddress> . :propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupaddress> .
local:preferredTitleContext a :ConfigContext ;
:hasConfiguration local:preferredTitleConfig ;
:configContextFor <http://purl.obolibrary.org/obo/ARG_2000028> ;
:qualifiedByDomain <http://xmlns.com/foaf/0.1/Person> ;
:qualifiedBy <http://www.w3.org/2006/vcard/ns#Title> .
local:preferredTitleConfig a :ObjectPropertyDisplayConfig ;
:listViewConfigFile "listViewConfig-preferredTitle.xml"^^xsd:string ;
:displayName "preferred title" ;
vitro:displayRankAnnot 8;
vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ;
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
vitro:customEntryFormAnnot "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.PersonHasPreferredTitleGenerator"^^<http://www.w3.org/2001/XMLSchema#string> ;
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupaddress> .
### properties using default editing form ## ### properties using default editing form ##
local:eventWithinContext a :ConfigContext ; local:eventWithinContext a :ConfigContext ;

View file

@ -0,0 +1,105 @@
/* $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 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 PersonHasPreferredTitleGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
private Log log = LogFactory.getLog(PersonHasPreferredTitleGenerator.class);
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
HttpSession session) throws Exception {
EditConfigurationVTwo conf = new EditConfigurationVTwo();
initBasics(conf, vreq);
initPropertyParameters(vreq, session, conf);
initObjectPropForm(conf, vreq);
String titleUri = getTitleUri(vreq);
conf.setTemplate("personHasPreferredTitle.ftl");
conf.setVarNameForSubject("person");
conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("individualVcard");
conf.setN3Required( Arrays.asList( n3ForNewPhone ) );
conf.setN3Optional( Arrays.asList( preferredTitleAssertion ) );
conf.addNewResource("title", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("individualVcard", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.setLiteralsOnForm(Arrays.asList("preferredTitle" ));
conf.addSparqlForExistingLiteral("preferredTitle", preferredTitleQuery);
conf.addSparqlForAdditionalUrisInScope("individualVcard", individualVcardQuery);
if ( conf.isUpdate() ) {
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
urisInScope.put("title", Arrays.asList(new String[]{titleUri}));
conf.addUrisInScope(urisInScope);
}
conf.addField( new FieldVTwo().
setName("preferredTitle")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("nonempty") ));
conf.addValidator(new AntiXssValidation());
prepare(vreq, conf);
return conf;
}
/* N3 assertions */
final static String n3ForNewPhone =
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?person . \n" +
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasTitle> ?title . \n" +
"?title a <http://www.w3.org/2006/vcard/ns#Title> . " ;
final static String preferredTitleAssertion =
"?title <http://www.w3.org/2006/vcard/ns#title> ?preferredTitle .";
/* Queries for editing an existing entry */
final static String individualVcardQuery =
"SELECT ?existingIndividualVcard WHERE { \n" +
"?person <http://purl.obolibrary.org/obo/ARG_2000028> ?existingIndividualVcard . \n" +
"}";
final static String preferredTitleQuery =
"SELECT ?existingPreferredTitle WHERE {\n"+
"?title <http://www.w3.org/2006/vcard/ns#title> ?existingPreferredTitle . }";
private String getTitleUri(VitroRequest vreq) {
String titleUri = vreq.getParameter("titleUri");
return titleUri;
}
}

View file

@ -864,3 +864,6 @@ remove_editor_link = remove editor link
add_an_editor = Add an Editor add_an_editor = Add an Editor
add_editor = Add Editor add_editor = Add Editor
please_select_type = Please select a type from the drop-down list. 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.

View file

@ -67,12 +67,12 @@
<span class="fn"><@p.label individual editable labelCount localesCount/></span> <span class="fn"><@p.label individual editable labelCount localesCount/></span>
<#-- Display preferredTitle if it exists; otherwise mostSpecificTypes --> <#-- Display preferredTitle if it exists; otherwise mostSpecificTypes -->
<#assign title = propertyGroups.pullProperty("${core}preferredTitle")!> <#assign title = propertyGroups.pullProperty("http://purl.obolibrary.org/obo/ARG_2000028","http://www.w3.org/2006/vcard/ns#Title")!>
<#if title?has_content> <#-- true when the property is in the list, even if not populated (when editing) --> <#if title?has_content> <#-- true when the property is in the list, even if not populated (when editing) -->
<@p.addLinkWithLabel title editable /> <@p.addLinkWithLabel title editable />
<#list title.statements as statement> <#list title.statements as statement>
<span class="display-title">${statement.value}</span> <span class="display-title">${statement.preferredTitle}</span>
<@p.editingLinks "${title.name}" "" statement editable /> <@p.editingLinks "${title.localName}" "${title.name}" statement editable />
</#list> </#list>
</#if> </#if>
<#-- If preferredTitle is unpopulated, display mostSpecificTypes --> <#-- If preferredTitle is unpopulated, display mostSpecificTypes -->