custom form changes to support editable autocomplete fields; new validator classes

This commit is contained in:
tworrall 2012-04-04 14:01:41 +00:00
parent 6695832257
commit 5e13309e8a
14 changed files with 462 additions and 157 deletions

View file

@ -13,20 +13,27 @@
<#assign editMode = "add">
</#if>
<#assign newUriSentinel = "" />
<#if editConfigurationConstants?has_content>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] />
<#assign blankSentinel = "" />
<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")>
<#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] />
</#if>
<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete.
Set this flag on the input acUriReceiver where you would like this behavior to occur. -->
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign presentationValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentation") />
<#assign presentationValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingPresentation") />
<#assign presentationLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabel") />
<#assign presentationLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabelDisplay") />
<#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") />
<#assign roleLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "roleLabel") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingConference") />
<#assign conferenceLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceLabel") />
<#assign conferenceLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceLabelDisplay") />
<#--If edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
@ -50,6 +57,12 @@
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#if conferenceLabelDisplayValue?has_content >
<#assign conferenceLabelValue = conferenceLabelDisplayValue />
</#if>
<#if presentationLabelDisplayValue?has_content >
<#assign presentationLabelValue = presentationLabelDisplayValue />
</#if>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
@ -91,7 +104,7 @@
<#if editMode == "edit">
<#list presentationTypeOpts?keys as key>
<#if presentationTypeValue = key >
<span class="readOnly" id="typeSelectorSpan">${presentationTypeOpts[key]}</span>
<span class="readOnly" id="typeSelectorSpan"><#if presentationTypeOpts[key] == "Other">Presentation<#else>${presentationTypeOpts[key]}</#if></span>
<input type="hidden" id="typeSelectorInput" name="presentationType" acGroupName="presentation" value="${presentationTypeValue}">
</#if>
</#list>
@ -109,6 +122,7 @@
<p>
<label for="presentation">### Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="presentation" acGroupName="presentation" name="presentationLabel" value="${presentationLabelValue}">
<input class="display" type="hidden" id="presentationDisplay" acGroupName="presentation" name="presentationLabelDisplay" value="${presentationLabelDisplayValue}">
</p>
<div class="acSelection" acGroupName="presentation">
@ -118,7 +132,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="presentationUri" name="presentation" value="${presentationValue}" />
<input class="acUriReceiver" type="hidden" id="presentationUri" name="existingPresentation" value="${presentationValue}" ${flagClearLabelForExisting}="true" />
</div>
<p><label for="roleLabel">Role in ### ${requiredHint} <span class="hint">(e.g., Moderator, Speaker, Panelist)</span></label>
<input size="50" type="text" id="roleLabel" name="roleLabel" value="${roleLabelValue}" />
@ -126,6 +140,7 @@
<p>
<label for="org">Presented At</label>
<input class="acSelector" size="50" acGroupName="conference" type="text" id="conference" name="conferenceLabel" value="${conferenceLabelValue}" />
<input class="display" acGroupName="conference" type="hidden" id="conferenceDisplay" name="conferenceLabelDisplay" value="${conferenceLabelDisplayValue}" />
</p>
<div class="acSelection" acGroupName="conference">
<p class="inline">
@ -134,7 +149,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="conferenceUri" name="conference" value="${conferenceValue}" />
<input class="acUriReceiver" type="hidden" id="conferenceUri" name="existingConference" value="${conferenceValue}" ${flagClearLabelForExisting}="true" />
</div>
<p>
<h4>Years of Participation in ###</h4>
@ -183,7 +198,8 @@ var customFormData = {
defaultTypeName: 'presentation',
multipleTypeNames: {presentation: 'presentation', conference: 'conference'},
baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
};
</script>

View file

@ -23,21 +23,42 @@
<#assign submissionErrors = editSubmission.validationErrors/>
</#if>
<#--The blank sentinel indicates what value should be put in a URI when no autocomplete result has been selected.
If the blank value is non-null or non-empty, n3 editing for an existing object will remove the original relationship
if nothing is selected for that object-->
<#assign blankSentinel = "" />
<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")>
<#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] />
</#if>
<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete.
Set this flag on the input acUriReceiver where you would like this behavior to occur. -->
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
<#--In case of submission error, may already have publication type or title - although latter not likely, but storing values to be on safe side-->
<#assign publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") />
<#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") />
<#assign pubUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubUri") />
<#assign collectionValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collection") />
<#assign collectionDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionDisplay") />
<#assign collectionUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionUri") />
<#assign bookValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "book") />
<#assign bookDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookDisplay") />
<#assign bookUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookUri") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") />
<#assign conferenceDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceDisplay") />
<#assign conferenceUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceUri") />
<#assign eventValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "event") />
<#assign eventDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventDisplay") />
<#assign eventUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventUri") />
<#assign editorValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editor") />
<#assign editorDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editorDisplay") />
<#assign editorUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editorUri") />
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName") />
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName") />
<#assign publisherValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisher") />
<#assign publisherDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherDisplay") />
<#assign publisherUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherUri") />
<#assign localeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "locale") />
<#assign volumeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "volume") />
@ -59,6 +80,26 @@
<h2>${titleVerb}&nbsp;publication entry for ${editConfiguration.subjectName}</h2>
<#if submissionErrors?has_content>
<#if collectionDisplayValue?has_content >
<#assign collectionValue = collectionDisplayValue />
</#if>
<#if bookDisplayValue?has_content >
<#assign bookValue = bookDisplayValue />
</#if>
<#if conferenceDisplayValue?has_content >
<#assign conferenceValue = conferenceDisplayValue />
</#if>
<#if eventDisplayValue?has_content >
<#assign eventValue = eventDisplayValue />
</#if>
<#if editorDisplayValue?has_content >
<#assign editorValue = editorDisplayValue />
</#if>
<#if publisherDisplayValue?has_content >
<#assign publisherValue = publisherDisplayValue />
</#if>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
@ -114,6 +155,7 @@
<p>
<label for="collection">Published in</label>
<input class="acSelector" size="50" type="text" id="collection" name="collection" acGroupName="collection" value="${collectionValue}" />
<input class="display" type="hidden" id="collectionDisplay" name="collectionDisplay" acGroupName="collection" value="${collectionDisplayValue}" />
</p>
<div class="acSelection" acGroupName="collection" >
@ -123,14 +165,15 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="collectionUri" name="collectionUri" value="${collectionUriValue}" />
<input class="acUriReceiver" type="hidden" id="collectionUri" name="collectionUri" value="${collectionUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Published In: book -->
<p>
<label for="book">Published in</label>
<input class="acSelector" size="50" type="text" id="book" name="book" acGroupName="book" value="${bookValue}" />
</p>
<input class="display" type="hidden" id="bookDisplay" name="bookDisplay" acGroupName="book" value="${bookDisplayValue}" />
</p>
<div class="acSelection" acGroupName="book" >
<p class="inline">
@ -139,13 +182,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="bookUri" name="bookUri" value="${bookUriValue}" />
<input class="acUriReceiver" type="hidden" id="bookUri" name="bookUri" value="${bookUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Presented At -->
<p>
<label for="conference">Presented at</label>
<input class="acSelector" size="50" type="text" id="conference" name="conference" acGroupName="conference" value="${conferenceValue}" />
<input class="display" type="hidden" id="conferenceDisplay" name="conferenceDisplay" acGroupName="conference" value="${conferenceDisplayValue}" />
</p>
<div class="acSelection" acGroupName="conference" >
@ -155,13 +199,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="conferenceUri" name="conferenceUri" value="${conferenceUriValue}" />
<input class="acUriReceiver" type="hidden" id="conferenceUri" name="conferenceUri" value="${conferenceUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Proceedings of -->
<p>
<label for="event">Proceedings of</label>
<input class="acSelector" size="50" type="text" id="event" name="event" acGroupName="event" value="${eventValue}" />
<input class="display" type="hidden" id="eventDisplay" name="eventDisplay" acGroupName="event" value="${eventDisplayValue}" />
</p>
<div class="acSelection" acGroupName="event" >
@ -171,14 +216,17 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="eventUri" name="eventUri" value="${eventUriValue}" />
<input class="acUriReceiver" type="hidden" id="eventUri" name="eventUri" value="${eventUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Editor -->
<p>
<label for="editor">Editor</label>
<label for="editor">Editor: Last Name<span style="padding-left:322px">First Name ${requiredHint}</span></label>
<input class="acSelector" size="50" type="text" id="editor" name="editor" acGroupName="editor" value="${editorValue}" />
<input size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" ><br />
<input type="hidden" id="lastName" name="lastName" value="">
<input class="display" type="hidden" id="editorDisplay" name="editorDisplay" acGroupName="editor" value="${editorDisplayValue}" />
</p>
<div class="acSelection" acGroupName="editor" >
@ -188,13 +236,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="editorUri" name="editorUri" value="${editorUriValue}" />
<input class="acUriReceiver" type="hidden" id="editorUri" name="editorUri" value="${editorUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Publisher -->
<p>
<label for="publisher">Publisher</label>
<input class="acSelector" size="50" type="text" id="publisher" name="publisher" acGroupName="publisher" value="${publisherValue}" />
<input class="display" type="hidden" id="publisherDisplay" name="publisherDisplay" acGroupName="publisher" value="${publisherDisplayValue}" />
</p>
<div class="acSelection" acGroupName="publisher" >
@ -204,7 +253,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="publisherUri" name="publisherUri" value="${publisherUriValue}" />
<input class="acUriReceiver" type="hidden" id="publisherUri" name="publisherUri" value="${publisherUriValue}" ${flagClearLabelForExisting}="true" />
</div>
<#-- Place of Publication -->
@ -267,13 +316,14 @@
defaultTypeName: 'publication', // used in repair mode to generate button text
multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'},
baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
};
</script>
<script type="text/javascript">
$(document).ready(function(){
publicationToPersonUtils.onLoad('${urls.base}/individual?uri=', '${newUriSentinel}');
publicationToPersonUtils.onLoad('${urls.base}/individual?uri=', '${blankSentinel}');
});
</script>
</section>

View file

@ -11,6 +11,12 @@ var advisingRelUtils = {
this.initObjectReferences();
this.bindEventListeners();
$.extend(this, vitro.customFormUtils);
if ( this.findValidationErrors() ) {
this.resetLastNameLabel();
}
},
initObjectReferences: function() {
@ -80,6 +86,7 @@ var advisingRelUtils = {
}
},
buildAdvisingRelLabel: function() {
if ( this.advisee.val() != "" ) {
this.adRelshiplabel.val(this.subjName + " advising " + this.advisee.val());
@ -90,6 +97,14 @@ var advisingRelUtils = {
else {
this.adRelshiplabel.val(this.subjName + " advising relationship");
}
},
resetLastNameLabel: function() {
var indx = this.advisee.val().indexOf(", ");
if ( indx != -1 ) {
var temp = this.advisee.val().substr(0,indx);
this.advisee.val(temp);
}
}
}

View file

@ -8,6 +8,7 @@ var awardReceiptUtils = {
this.bindEventListeners();
this.baseHref = href;
this.editMode = mode;
$.extend(this, vitro.customFormUtils);
// in edit mode copy the year awarded to the displayed input element
if ( this.editMode == "edit" ) {
this.hiddenOrgDiv = $('div#hiddenOrgLabel');
@ -18,7 +19,6 @@ var awardReceiptUtils = {
}
}
this.subjectName = subjectName;
$.extend(this, vitro.customFormUtils);
},
initObjectReferences: function() {

View file

@ -76,8 +76,6 @@ var customForm = {
this.acTypes = new Object();
}
// forms with multi ac fields will have this defined in customFormData
// this is helpful when the type to display is not a single word, like "Subject Area"
this.hasMultipleTypeNames = false;
@ -209,7 +207,7 @@ var customForm = {
var $acSelection = customForm.acSelections[$(this).attr('acGroupName')];
var uri = $acSelection.find('input.acUriReceiver').val(),
label = $(this).val();
if (uri) {
if (uri && uri != ">SUBMITTED VALUE WAS BLANK<") {
customForm.showAutocompleteSelection(label, uri, $(this));
}
});
@ -278,6 +276,7 @@ var customForm = {
}
});
}
customForm.deleteAcHelpText();
});
},

View file

@ -3,24 +3,33 @@
var publicationToPersonUtils = {
onLoad: function(href, sentinel) {
onLoad: function(href, blankSentinel) {
this.initObjectReferences();
this.bindEventListeners();
this.autoDateLabel.hide();
this.baseHref = href;
this.newUriSentinel = sentinel;
this.sentinel = blankSentinel;
$.extend(this, vitro.customFormUtils);
this.displayFieldsForType();
if ( this.findValidationErrors() ) {
this.resetLastNameLabel();
}
},
initObjectReferences: function() {
this.form = $('#addpublicationToPerson');
this.pubTitle = $('input#title');
this.collection = $('#collection');
this.book = $('#book');
this.presentedAt = $('#conference');
this.proceedingsOf = $('#event');
this.editor = $('#editor');
this.editorUri = $('#editorUri');
this.firstName = $('#firstName');
this.lastName = $('#lastName');
this.publisher = $('#publisher');
this.locale = $('#locale');
this.volume = $('#volume');
@ -44,10 +53,13 @@ var publicationToPersonUtils = {
}
});
this.pubTitle = $('input#title');
this.pubAcSelection = $('div#pubAcSelection');
this.fieldsForNewPub = $('#fieldsForNewPub');
this.changeLink = this.pubAcSelection.children('p').children('#changeSelection');
// may not need this
this.firstName.attr('disabled', '');
},
bindEventListeners: function() {
@ -76,6 +88,10 @@ var publicationToPersonUtils = {
this.changeLink.click( function() {
publicationToPersonUtils.showFieldsForPub();
});
this.form.submit(function() {
publicationToPersonUtils.resolveEditorNames();
});
},
@ -90,16 +106,16 @@ var publicationToPersonUtils = {
},
resetAcSelection: function(groupName) {
var $acSelection = this.form.find('div.acSelection').attr('acGroupName', groupName);
var $acSelection = this.form.find("div.acSelection[acGroupName='" + groupName + "']");
this.hideFields($acSelection);
$acSelection.removeClass('userSelected');
$acSelection.find("input.acUriReceiver").val(this.newUriSentinel);
$acSelection.find("input.acUriReceiver").val(this.sentinel);
$acSelection.find("span").text('');
$acSelection.find("a.verifyMatch").attr('href', this.baseHref);
},
getAcUriReceiverVal: function(groupName) {
var $collectionDiv = this.form.find('div.acSelection').attr('acGroupName', groupName);
var $collectionDiv = this.form.find("div.acSelection[acGroupName='" + groupName + "']");
return $collectionDiv.find('input#'+ groupName + 'Uri').val();
},
@ -131,7 +147,7 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('collection');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.collection.parent('p').show();
}
this.volume.show();
@ -146,10 +162,8 @@ var publicationToPersonUtils = {
// if the user has changed type, ensure that irrelevant fields are cleared
// and reset an acSelection divs
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
alert(this.book.val());
this.book.val('');
this.resetAcSelection('book');
alert(this.book.val());
}
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val('');
@ -174,15 +188,15 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('book');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.book.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.editor.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.publisher.parent('p').show();
}
@ -214,11 +228,11 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.editor.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.publisher.parent('p').show();
}
@ -250,11 +264,11 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('collection');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.collection.parent('p').show();
}
ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.presentedAt.parent('p').show();
}
@ -289,7 +303,7 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the
// acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) {
if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.presentedAt.parent('p').show();
}
@ -358,6 +372,38 @@ var publicationToPersonUtils = {
}
},
resolveEditorNames: function() {
var firstName,
lastName,
name;
// If editorUri contains the sentinel value, we need to process the name fields
// otherwise, disable them so they are not submitted
if ( this.editorUri.val() == this.sentinel ) {
firstName = this.firstName.val();
lastName = this.editor.val();
name = lastName;
if (firstName) {
name += ', ' + firstName;
}
this.editor.val(name);
this.lastName.val(lastName);
}
else {
this.firstName.attr('disabled', 'disabled');
this.lastName.attr('disabled', 'disabled');
}
},
resetLastNameLabel: function() {
var indx = this.editor.val().indexOf(", ");
if ( indx != -1 ) {
var temp = this.editor.val().substr(0,indx);
this.editor.val(temp);
}
}
}

View file

@ -60,8 +60,13 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#assign adviseeLabelValue = adviseeLabelDisplayValue />
<#assign subjAreaLabelValue = subjAreaLabelDisplayValue />
<#if adviseeLabelDisplayValue?has_content >
<#assign adviseeLabelValue = adviseeLabelDisplayValue />
</#if>
<#if subjAreaLabelDisplayValue?has_content >
<#assign subjAreaLabelValue = subjAreaLabelDisplayValue />
</#if>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
@ -119,7 +124,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<p >
<label for="advisee">Advisee: Last Name ${requiredHint}<span style="padding-left:322px">First Name ${requiredHint}</span></label>
<input class="acSelector" size="50" type="text" acGroupName="advisee" id="advisee" name="adviseeLabel" value="${adviseeLabelValue}" >
<input size="30" type="text" id="firstName" name="firstName" value="" ><br />
<input size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" ><br />
<input type="hidden" id="lastName" name="lastName" value="">
<input class="display" type="hidden" acGroupName="advisee" id="adviseeDisplay" name="adviseeLabelDisplay" value="${adviseeLabelDisplayValue}" >
</p>

View file

@ -61,8 +61,13 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#assign orgLabelValue = orgLabelDisplayValue />
<#assign awardLabelValue = awardLabelDisplayValue />
<#if orgLabelDisplayValue?has_content >
<#assign orgLabelValue = orgLabelDisplayValue />
</#if>
<#if awardLabelDisplayValue?has_content >
<#assign awardLabelValue = awardLabelDisplayValue />
</#if>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>

View file

@ -12,10 +12,18 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
public class PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
public class AutocompleteRequiredInputValidator implements N3ValidatorVTwo {
private static String MISSING_AWARD_LABEL_ERROR = "You must select an existing award or type the name of a new award.";
;
private static String MISSING_LABEL_ERROR = "Please select an existing value or enter a new value in the Name field.";
private String uriReceiver;
private String labelInput;
public AutocompleteRequiredInputValidator(String uriReceiver, String labelInput) {
this.uriReceiver = uriReceiver;
this.labelInput = labelInput;
}
@Override
public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) {
@ -24,25 +32,23 @@ public class PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>();
List<String> awardUri = urisFromForm.get("existingAward");
if (allListElementsEmpty(awardUri)) {
awardUri = null;
}
// If there's an awardUri, then we're done. If not, check to see if the label exists.
List<String> selectedUri = urisFromForm.get(uriReceiver);
// If there's a presentationUri, then we're done. If not, check to see if the label exists.
// If that's null, too, it's an error.
if (awardUri != null) {
if (allListElementsEmpty(selectedUri) || selectedUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
selectedUri = null;
}
if (selectedUri != null) {
return null;
}
else {
List<String> awardLabel = urisFromForm.get("awardLabel");
if (allListElementsEmpty(awardLabel)) {
awardLabel = null;
}
if (awardLabel != null) {
List<Literal> specifiedLabel = literalsFromForm.get(labelInput);
if (specifiedLabel != null && specifiedLabel.size() > 0) {
return null;
}
else {
errors.put("awardLabel", MISSING_AWARD_LABEL_ERROR);
errors.put(labelInput, MISSING_LABEL_ERROR);
}
}

View file

@ -17,7 +17,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
;
@Override
public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) {
@ -27,7 +27,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>();
List<String> adviseeUri = urisFromForm.get("existingAdvisee");
if (allListElementsEmpty(adviseeUri)) {
if (allListElementsEmpty(adviseeUri) || adviseeUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
adviseeUri = null;
}
// If there's an adviseeUri, then we're done. The firstName and lastName fields are

View file

@ -16,8 +16,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
public class PersonHasPublicationValidator implements N3ValidatorVTwo {
private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type.";
private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title.";
private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
@Override
public Map<String, String> validate(EditConfigurationVTwo editConfig,
@ -29,35 +30,53 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>();
// If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted.
List<String> pubUriList = urisFromForm.get("pubUri");
List<String> editorUriList = urisFromForm.get("editorUri");
//This method will return null if the list is null or empty, otherwise returns first element
//Assumption is that only one value for uri, type, or title will be sent back
String pubUri = (String) getFirstElement(pubUriList);
if (!StringUtils.isEmpty(pubUri)) {
String editorUri = (String) getFirstElement(editorUriList);
if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
editorUri = null;
}
if ( editorUri != null ) {
return null;
}
List<String> pubTypeList = urisFromForm.get("pubType");
String pubType = (String) getFirstElement(pubTypeList);
if ("".equals(pubType)) {
pubType = null;
//Expecting only one first name in this case
//To Do: update logic if multiple first names considered
Literal firstName = null;
List<Literal> firstNameList = literalsFromForm.get("firstName");
if(firstNameList != null && firstNameList.size() > 0) {
firstName = firstNameList.get(0);
}
List<Literal> titleList = literalsFromForm.get("title");
Literal title = (Literal) getFirstElement(titleList);
if (title != null) {
String titleValue = title.getLexicalForm();
if (StringUtils.isEmpty(titleValue)) {
title = null;
if( firstName != null &&
firstName.getLexicalForm() != null &&
"".equals(firstName.getLexicalForm()) )
firstName = null;
List<Literal> lastNameList = literalsFromForm.get("lastName");
Literal lastName = null;
if(lastNameList != null && lastNameList.size() > 0) {
lastName = lastNameList.get(0);
}
String lastNameValue = "";
if (lastName != null) {
lastNameValue = lastName.getLexicalForm();
if( "".equals(lastNameValue) ) {
lastName = null;
}
}
if (lastName == null) {
errors.put("lastName", MISSING_LAST_NAME_ERROR);
// Don't reject space in the last name: de Vries, etc.
} else if (lastNameValue.contains(",")) {
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
}
if (pubType == null) {
errors.put("pubType", MISSING_PUB_TYPE_ERROR);
}
if (title == null) {
errors.put("title", MISSING_PUB_TITLE_ERROR);
}
if (firstName == null) {
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
}
return errors.size() != 0 ? errors : null;
}

View file

@ -19,8 +19,10 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisio
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
@ -61,13 +63,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
conf.setVarNameForObject("role");
conf.setN3Required( Arrays.asList( n3ForNewRole,
roleLabelAssertion,
presTypeAssertion,
presLabelAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForConference, n3ForStart, n3ForEnd ) );
roleLabelAssertion) );
conf.setN3Optional( Arrays.asList( n3ForNewPresentation, presTypeAssertion, n3ForExistingPresentation, n3ForNewConference, n3ForExistingConference, n3ForStart, n3ForEnd ) );
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newConference", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("role", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -76,14 +76,14 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
//uris in scope: none
//literals in scope: none
conf.setUrisOnform(Arrays.asList("presentation", "conference", "role", "presentationType"));
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "conferenceLabel", "roleLabel"));
conf.setUrisOnform(Arrays.asList("existingPresentation", "existingConference", "presentationType"));
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "presentationLabelDisplay", "conferenceLabel", "conferenceLabelDisplay", "roleLabel"));
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
conf.addSparqlForExistingUris("presentation", presentationQuery);
conf.addSparqlForExistingUris("conference", conferenceQuery);
conf.addSparqlForExistingUris("existingPresentation", presentationQuery);
conf.addSparqlForExistingUris("existingConference", existingConferenceQuery);
conf.addSparqlForExistingUris("presentationType", presentationTypeQuery);
conf.addSparqlForExistingLiteral(
"startField-value", existingStartDateQuery);
@ -99,15 +99,21 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
existingEndPrecisionQuery);
conf.addField( new FieldVTwo().
setName("presentation").
setName("existingPresentation").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(presentationClass)
);
conf.addField( new FieldVTwo().
setName("presentationLabelDisplay")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("presentationLabel")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("nonempty") )
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
@ -124,7 +130,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
);
conf.addField( new FieldVTwo().
setName("conference").
setName("existingConference").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(conferenceClass)
);
@ -134,6 +140,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
setRangeDatatypeUri(XSD.xstring.toString() )
);
conf.addField( new FieldVTwo().
setName("conferenceLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() )
);
conf.addField( new FieldVTwo().setName("startField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
@ -152,7 +163,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation());
conf.addValidator(new AutocompleteRequiredInputValidator("existingPresentation", "presentationLabel"));
prepare(vreq, conf);
return conf;
}
@ -162,24 +173,33 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
"@prefix core: <" + vivoCore + "> . \n\n" +
"?person <" + hasRolePred + "> ?role . \n" +
"?role a <" + roleClass + "> . \n" +
"?role <" + roleOfPred + "> ?person . \n" +
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
"?presentation <" + realizedRolePred + "> ?role .";
"?role <" + roleOfPred + "> ?person . ";
final static String roleLabelAssertion =
"?role <" + label + "> ?roleLabel .";
final static String presLabelAssertion =
final static String n3ForNewPresentation =
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
"?presentation <" + realizedRolePred + "> ?role . \n" +
"?presentation <" + label + "> ?presentationLabel .";
final static String n3ForExistingPresentation =
"?role <" + roleRealizedInPred + "> ?existingPresentation . \n" +
"?existingPresentation <" + realizedRolePred + "> ?role . ";
final static String presTypeAssertion =
"?presentation a ?presentationType .";
final static String n3ForConference =
"?conference a <" + conferenceClass + "> . \n" +
"?conference <" + includesEventPred + "> ?presentation . \n" +
"?presentation <" + eventWithinPred + "> ?conference . \n" +
"?conference <" + label + "> ?conferenceLabel .";
final static String n3ForNewConference =
"?presentation <" + eventWithinPred + "> ?newConference . \n" +
"?newConference <" + includesEventPred + "> ?presentation . \n" +
"?newConference a <" + conferenceClass + "> . \n" +
"?newConference <" + label + "> ?conferenceLabel .";
final static String n3ForExistingConference =
"?existingConference a <" + conferenceClass + "> . \n" +
"?existingConference <" + includesEventPred + "> ?presentation . \n" +
"?presentation <" + eventWithinPred + "> ?existingConference . ";
final static String n3ForStart =
"?role <" + roleToInterval + "> ?intervalNode . \n" +
@ -217,7 +237,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
final static String conferenceQuery =
final static String existingConferenceQuery =
"SELECT ?existingConference WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }";

View file

@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
/**
* On an add/new, this will show a form, on an edit/update this will skip to the
@ -112,8 +113,9 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
// template file
editConfiguration.setTemplate("addPublicationToPerson.ftl");
// adding person has publication validator
editConfiguration.addValidator(new PersonHasPublicationValidator());
editConfiguration.addValidator(new AntiXssValidation());
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("pubUri", "title"));
editConfiguration.addValidator(new PersonHasPublicationValidator());
// Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq);
@ -140,29 +142,35 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
/***N3 strings both required and optional***/
private List<String> generateN3Optional() {
return list(getN3ForExistingPub(),
getN3ForNewPub(),
getN3NewPubNameAssertion(),
getN3NewPubTypeAssertion(),
getN3ForCollection(),
getN3ForBook(),
getN3ForConference(),
getN3ForEvent(),
getN3ForEditor(),
getN3ForPublisher(),
getN3ForLocaleAssertion(),
getN3ForVolumeAssertion(),
getN3ForNumberAssertion(),
getN3ForIssueAssertion(),
getN3ForStartPageAssertion(),
getN3ForEndPageAssertion(),
getN3ForDateTimeAssertion()
return list(getN3ForNewCollection(),
getN3ForNewBook(),
getN3ForNewConference(),
getN3ForNewEvent(),
getN3ForNewEditor(),
getN3ForNewPublisher(),
getN3ForCollection(),
getN3ForBook(),
getN3ForConference(),
getN3ForEvent(),
getN3ForEditor(),
getN3ForPublisher(),
getN3ForLocaleAssertion(),
getN3ForVolumeAssertion(),
getN3ForNumberAssertion(),
getN3ForIssueAssertion(),
getN3ForStartPageAssertion(),
getN3ForEndPageAssertion(),
getN3ForDateTimeAssertion()
);
}
private List<String> generateN3Required() {
return list(getAuthorshipN3());
return list(getAuthorshipN3(),
getN3ForNewPub(),
getN3NewPubNameAssertion(),
getN3NewPubTypeAssertion()
);
}
private String getAuthorshipN3() {
@ -195,52 +203,88 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
}
private String getN3ForNewCollection() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?newCollection . \n" +
"?newCollection a <" + collectionClass + "> . \n" +
"?newCollection vivo:publicationVenueFor ?pubUri . \n" +
"?newCollection <" + label + "> ?collection .";
}
private String getN3ForCollection() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?collectionUri . \n" +
"?collectionUri a <" + collectionClass + "> . \n" +
"?collectionUri vivo:publicationVenueFor ?pubUri . \n" +
"?collectionUri <" + label + "> ?collection .";
"?collectionUri vivo:publicationVenueFor ?pubUri . ";
}
private String getN3ForNewBook() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?newBook . \n" +
"?newBook a <" + bookClass + "> . \n" +
"?newBook vivo:publicationVenueFor ?pubUri . \n " +
"?newBook <" + label + "> ?book .";
}
private String getN3ForBook() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?bookUri . \n" +
"?bookUri a <" + bookClass + "> . \n" +
"?bookUri vivo:publicationVenueFor ?pubUri . \n " +
"?bookUri <" + label + "> ?book .";
"?bookUri vivo:publicationVenueFor ?pubUri . ";
}
private String getN3ForNewConference() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + presentedAtPred + "> ?newConference . \n" +
"?newConference a <" + conferenceClass + "> . \n" +
"?newConference vivo:includesEvent ?pubUri . \n" +
"?newConference <" + label + "> ?conference .";
}
private String getN3ForConference() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" +
"?conferenceUri a <" + conferenceClass + "> . \n" +
"?conferenceUri vivo:includesEvent ?pubUri . \n" +
"?conferenceUri <" + label + "> ?conference .";
"?conferenceUri vivo:includesEvent ?pubUri . ";
}
private String getN3ForNewEvent() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:proceedingsOf ?newEvent . \n" +
"?newEvent a <" + conferenceClass + "> . \n" +
"?newEvent vivo:hasProceedings ?pubUri . \n" +
"?newEvent <" + label + "> ?event .";
}
private String getN3ForEvent() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:proceedingsOf ?eventUri . \n" +
"?eventUri a <" + conferenceClass + "> . \n" +
"?eventUri vivo:hasProceedings ?pubUri . \n" +
"?eventUri <" + label + "> ?event .";
"?eventUri vivo:hasProceedings ?pubUri . ";
}
private String getN3ForNewEditor() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:editor ?newEditor . \n" +
"?newEditor a <" + editorClass + "> . \n" +
"?newEditor vivo:editorOf ?pubUri . \n" +
"?newEditor <" + label + "> ?editor .";
}
private String getN3ForEditor() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:editor ?editorUri . \n" +
"?editorUri a <" + editorClass + "> . \n" +
"?editorUri vivo:editorOf ?pubUri . \n" +
"?editorUri <" + label + "> ?editor .";
"?editorUri vivo:editorOf ?pubUri . ";
}
private String getN3ForNewPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?newPublisher . \n" +
"?newPublisher a <" + publisherClass + "> . \n" +
"?newPublisher vivo:publisherOf ?pubUri . \n" +
"?newPublisher <" + label + "> ?publisher .";
}
private String getN3ForPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?publisherUri . \n" +
"?publisherUri a <" + publisherClass + "> . \n" +
"?publisherUri vivo:publisherOf ?pubUri . \n" +
"?publisherUri <" + label + "> ?publisher .";
"?publisherUri vivo:publisherOf ?pubUri . ";
}
private String getN3ForLocaleAssertion() {
@ -288,12 +332,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
HashMap<String, String> newResources = new HashMap<String, String>();
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
newResources.put("pubUri", DEFAULT_NS_TOKEN);
newResources.put("collectionUri", DEFAULT_NS_TOKEN);
newResources.put("bookUri", DEFAULT_NS_TOKEN);
newResources.put("conferenceUri", DEFAULT_NS_TOKEN);
newResources.put("eventUri", DEFAULT_NS_TOKEN);
newResources.put("editorUri", DEFAULT_NS_TOKEN);
newResources.put("publisherUri", DEFAULT_NS_TOKEN);
newResources.put("newCollection", DEFAULT_NS_TOKEN);
newResources.put("newBook", DEFAULT_NS_TOKEN);
newResources.put("newConference", DEFAULT_NS_TOKEN);
newResources.put("newEvent", DEFAULT_NS_TOKEN);
newResources.put("newEditor", DEFAULT_NS_TOKEN);
newResources.put("newPublisher", DEFAULT_NS_TOKEN);
newResources.put("dateTimeNode", DEFAULT_NS_TOKEN);
return newResources;
}
@ -314,7 +358,6 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
List<String> urisOnForm = new ArrayList<String>();
//add role activity and roleActivityType to uris on form
urisOnForm.add("pubUri");
urisOnForm.add("pubType");
urisOnForm.add("collectionUri");
urisOnForm.add("bookUri");
@ -333,12 +376,20 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
literalsOnForm.add("event");
literalsOnForm.add("editor");
literalsOnForm.add("publisher");
literalsOnForm.add("collectionDisplay");
literalsOnForm.add("bookDisplay");
literalsOnForm.add("conferenceDisplay");
literalsOnForm.add("eventDisplay");
literalsOnForm.add("editorDisplay");
literalsOnForm.add("publisherDisplay");
literalsOnForm.add("locale");
literalsOnForm.add("volume");
literalsOnForm.add("number");
literalsOnForm.add("issue");
literalsOnForm.add("startPage");
literalsOnForm.add("endPage");
literalsOnForm.add("firstName");
literalsOnForm.add("lastName");
editConfiguration.setLiteralsOnForm(literalsOnForm);
}
@ -361,16 +412,24 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setPubTypeField(editConfiguration);
setPubUriField(editConfiguration);
setCollectionLabelField(editConfiguration);
setCollectionDisplayField(editConfiguration);
setCollectionUriField(editConfiguration);
setBookLabelField(editConfiguration);
setBookDisplayField(editConfiguration);
setBookUriField(editConfiguration);
setConferenceLabelField(editConfiguration);
setConferenceDisplayField(editConfiguration);
setConferenceUriField(editConfiguration);
setEventLabelField(editConfiguration);
setEventDisplayField(editConfiguration);
setEventUriField(editConfiguration);
setEditorLabelField(editConfiguration);
setEditorDisplayField(editConfiguration);
setFirstNameField(editConfiguration);
setLastNameField(editConfiguration);
setEditorUriField(editConfiguration);
setPublisherLabelField(editConfiguration);
setPublisherDisplayField(editConfiguration);
setPublisherUriField(editConfiguration);
setLocaleField(editConfiguration);
setVolumeField(editConfiguration);
@ -393,7 +452,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
editConfiguration.addField(new FieldVTwo().
setName("pubType").
setOptionsType("HARDCODED_LITERALS").
setLiteralOptions(getPublicationTypeLiteralOptions()));
setLiteralOptions(getPublicationTypeLiteralOptions()).
setValidators( list("nonempty") ));
}
private void setPubUriField(EditConfigurationVTwo editConfiguration) {
@ -410,6 +470,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setRangeDatatypeUri(stringDatatypeUri));
}
private void setCollectionDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("collectionDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setCollectionUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("collectionUri").
@ -423,6 +491,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setBookDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("bookDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setBookUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
@ -437,6 +513,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setConferenceDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("conferenceDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setConferenceUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
@ -451,7 +535,31 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEventDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("eventDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setFirstNameField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("firstName").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setLastNameField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("lastName").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEventUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("eventUri").
@ -465,6 +573,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEditorDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("editorDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEditorUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
@ -479,6 +595,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setPublisherDisplayField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("publisherDisplay").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setPublisherUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().

View file

@ -22,7 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasAwardOrHonorValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
@ -189,7 +189,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation());
conf.addValidator(new PersonHasAwardOrHonorValidator());
conf.addValidator(new AutocompleteRequiredInputValidator("existingAward", "awardLabel"));
prepare(vreq, conf);
return conf;
}