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"> <#assign editMode = "add">
</#if> </#if>
<#assign newUriSentinel = "" /> <#assign blankSentinel = "" />
<#if editConfigurationConstants?has_content> <#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] /> <#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] />
</#if> </#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 /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed--> <#--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 presentationLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabel") />
<#assign presentationLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabelDisplay") />
<#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") /> <#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") />
<#assign roleLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "roleLabel") /> <#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 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 edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
@ -50,6 +57,12 @@
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#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"> <section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" /> <img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p> <p>
@ -91,7 +104,7 @@
<#if editMode == "edit"> <#if editMode == "edit">
<#list presentationTypeOpts?keys as key> <#list presentationTypeOpts?keys as key>
<#if presentationTypeValue = 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}"> <input type="hidden" id="typeSelectorInput" name="presentationType" acGroupName="presentation" value="${presentationTypeValue}">
</#if> </#if>
</#list> </#list>
@ -109,6 +122,7 @@
<p> <p>
<label for="presentation">### Name ${requiredHint}</label> <label for="presentation">### Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="presentation" acGroupName="presentation" name="presentationLabel" value="${presentationLabelValue}"> <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> </p>
<div class="acSelection" acGroupName="presentation"> <div class="acSelection" acGroupName="presentation">
@ -118,7 +132,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<p><label for="roleLabel">Role in ### ${requiredHint} <span class="hint">(e.g., Moderator, Speaker, Panelist)</span></label> <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}" /> <input size="50" type="text" id="roleLabel" name="roleLabel" value="${roleLabelValue}" />
@ -126,6 +140,7 @@
<p> <p>
<label for="org">Presented At</label> <label for="org">Presented At</label>
<input class="acSelector" size="50" acGroupName="conference" type="text" id="conference" name="conferenceLabel" value="${conferenceLabelValue}" /> <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> </p>
<div class="acSelection" acGroupName="conference"> <div class="acSelection" acGroupName="conference">
<p class="inline"> <p class="inline">
@ -134,7 +149,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<p> <p>
<h4>Years of Participation in ###</h4> <h4>Years of Participation in ###</h4>
@ -183,7 +198,8 @@ var customFormData = {
defaultTypeName: 'presentation', defaultTypeName: 'presentation',
multipleTypeNames: {presentation: 'presentation', conference: 'conference'}, multipleTypeNames: {presentation: 'presentation', conference: 'conference'},
baseHref: '${urls.base}/individual?uri=', baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}' blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
}; };
</script> </script>

View file

@ -23,21 +23,42 @@
<#assign submissionErrors = editSubmission.validationErrors/> <#assign submissionErrors = editSubmission.validationErrors/>
</#if> </#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--> <#--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 publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") />
<#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") /> <#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") />
<#assign pubUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubUri") /> <#assign pubUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubUri") />
<#assign collectionValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collection") /> <#assign collectionValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collection") />
<#assign collectionDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionDisplay") />
<#assign collectionUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionUri") /> <#assign collectionUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionUri") />
<#assign bookValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "book") /> <#assign bookValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "book") />
<#assign bookDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookDisplay") />
<#assign bookUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookUri") /> <#assign bookUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookUri") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") /> <#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") />
<#assign conferenceDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceDisplay") />
<#assign conferenceUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceUri") /> <#assign conferenceUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceUri") />
<#assign eventValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "event") /> <#assign eventValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "event") />
<#assign eventDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventDisplay") />
<#assign eventUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventUri") /> <#assign eventUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventUri") />
<#assign editorValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editor") /> <#assign editorValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editor") />
<#assign editorDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editorDisplay") />
<#assign editorUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editorUri") /> <#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 publisherValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisher") />
<#assign publisherDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherDisplay") />
<#assign publisherUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherUri") /> <#assign publisherUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherUri") />
<#assign localeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "locale") /> <#assign localeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "locale") />
<#assign volumeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "volume") /> <#assign volumeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "volume") />
@ -59,6 +80,26 @@
<h2>${titleVerb}&nbsp;publication entry for ${editConfiguration.subjectName}</h2> <h2>${titleVerb}&nbsp;publication entry for ${editConfiguration.subjectName}</h2>
<#if submissionErrors?has_content> <#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"> <section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" /> <img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p> <p>
@ -114,6 +155,7 @@
<p> <p>
<label for="collection">Published in</label> <label for="collection">Published in</label>
<input class="acSelector" size="50" type="text" id="collection" name="collection" acGroupName="collection" value="${collectionValue}" /> <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> </p>
<div class="acSelection" acGroupName="collection" > <div class="acSelection" acGroupName="collection" >
@ -123,14 +165,15 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Published In: book --> <#-- Published In: book -->
<p> <p>
<label for="book">Published in</label> <label for="book">Published in</label>
<input class="acSelector" size="50" type="text" id="book" name="book" acGroupName="book" value="${bookValue}" /> <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" > <div class="acSelection" acGroupName="book" >
<p class="inline"> <p class="inline">
@ -139,13 +182,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Presented At --> <#-- Presented At -->
<p> <p>
<label for="conference">Presented at</label> <label for="conference">Presented at</label>
<input class="acSelector" size="50" type="text" id="conference" name="conference" acGroupName="conference" value="${conferenceValue}" /> <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> </p>
<div class="acSelection" acGroupName="conference" > <div class="acSelection" acGroupName="conference" >
@ -155,13 +199,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Proceedings of --> <#-- Proceedings of -->
<p> <p>
<label for="event">Proceedings of</label> <label for="event">Proceedings of</label>
<input class="acSelector" size="50" type="text" id="event" name="event" acGroupName="event" value="${eventValue}" /> <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> </p>
<div class="acSelection" acGroupName="event" > <div class="acSelection" acGroupName="event" >
@ -171,14 +216,17 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Editor --> <#-- Editor -->
<p> <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 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> </p>
<div class="acSelection" acGroupName="editor" > <div class="acSelection" acGroupName="editor" >
@ -188,13 +236,14 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Publisher --> <#-- Publisher -->
<p> <p>
<label for="publisher">Publisher</label> <label for="publisher">Publisher</label>
<input class="acSelector" size="50" type="text" id="publisher" name="publisher" acGroupName="publisher" value="${publisherValue}" /> <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> </p>
<div class="acSelection" acGroupName="publisher" > <div class="acSelection" acGroupName="publisher" >
@ -204,7 +253,7 @@
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or <a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a> <a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </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> </div>
<#-- Place of Publication --> <#-- Place of Publication -->
@ -267,13 +316,14 @@
defaultTypeName: 'publication', // used in repair mode to generate button text defaultTypeName: 'publication', // used in repair mode to generate button text
multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'}, multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'},
baseHref: '${urls.base}/individual?uri=', baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}' blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
}; };
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
publicationToPersonUtils.onLoad('${urls.base}/individual?uri=', '${newUriSentinel}'); publicationToPersonUtils.onLoad('${urls.base}/individual?uri=', '${blankSentinel}');
}); });
</script> </script>
</section> </section>

View file

@ -11,6 +11,12 @@ var advisingRelUtils = {
this.initObjectReferences(); this.initObjectReferences();
this.bindEventListeners(); this.bindEventListeners();
$.extend(this, vitro.customFormUtils);
if ( this.findValidationErrors() ) {
this.resetLastNameLabel();
}
}, },
initObjectReferences: function() { initObjectReferences: function() {
@ -80,6 +86,7 @@ var advisingRelUtils = {
} }
}, },
buildAdvisingRelLabel: function() { buildAdvisingRelLabel: function() {
if ( this.advisee.val() != "" ) { if ( this.advisee.val() != "" ) {
this.adRelshiplabel.val(this.subjName + " advising " + this.advisee.val()); this.adRelshiplabel.val(this.subjName + " advising " + this.advisee.val());
@ -90,6 +97,14 @@ var advisingRelUtils = {
else { else {
this.adRelshiplabel.val(this.subjName + " advising relationship"); 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.bindEventListeners();
this.baseHref = href; this.baseHref = href;
this.editMode = mode; this.editMode = mode;
$.extend(this, vitro.customFormUtils);
// in edit mode copy the year awarded to the displayed input element // in edit mode copy the year awarded to the displayed input element
if ( this.editMode == "edit" ) { if ( this.editMode == "edit" ) {
this.hiddenOrgDiv = $('div#hiddenOrgLabel'); this.hiddenOrgDiv = $('div#hiddenOrgLabel');
@ -18,7 +19,6 @@ var awardReceiptUtils = {
} }
} }
this.subjectName = subjectName; this.subjectName = subjectName;
$.extend(this, vitro.customFormUtils);
}, },
initObjectReferences: function() { initObjectReferences: function() {

View file

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

View file

@ -3,24 +3,33 @@
var publicationToPersonUtils = { var publicationToPersonUtils = {
onLoad: function(href, sentinel) { onLoad: function(href, blankSentinel) {
this.initObjectReferences(); this.initObjectReferences();
this.bindEventListeners(); this.bindEventListeners();
this.autoDateLabel.hide(); this.autoDateLabel.hide();
this.baseHref = href; this.baseHref = href;
this.newUriSentinel = sentinel; this.sentinel = blankSentinel;
$.extend(this, vitro.customFormUtils); $.extend(this, vitro.customFormUtils);
this.displayFieldsForType();
if ( this.findValidationErrors() ) {
this.resetLastNameLabel();
}
}, },
initObjectReferences: function() { initObjectReferences: function() {
this.form = $('#addpublicationToPerson'); this.form = $('#addpublicationToPerson');
this.pubTitle = $('input#title');
this.collection = $('#collection'); this.collection = $('#collection');
this.book = $('#book'); this.book = $('#book');
this.presentedAt = $('#conference'); this.presentedAt = $('#conference');
this.proceedingsOf = $('#event'); this.proceedingsOf = $('#event');
this.editor = $('#editor'); this.editor = $('#editor');
this.editorUri = $('#editorUri'); this.editorUri = $('#editorUri');
this.firstName = $('#firstName');
this.lastName = $('#lastName');
this.publisher = $('#publisher'); this.publisher = $('#publisher');
this.locale = $('#locale'); this.locale = $('#locale');
this.volume = $('#volume'); this.volume = $('#volume');
@ -44,10 +53,13 @@ var publicationToPersonUtils = {
} }
}); });
this.pubTitle = $('input#title');
this.pubAcSelection = $('div#pubAcSelection'); this.pubAcSelection = $('div#pubAcSelection');
this.fieldsForNewPub = $('#fieldsForNewPub'); this.fieldsForNewPub = $('#fieldsForNewPub');
this.changeLink = this.pubAcSelection.children('p').children('#changeSelection'); this.changeLink = this.pubAcSelection.children('p').children('#changeSelection');
// may not need this
this.firstName.attr('disabled', '');
}, },
bindEventListeners: function() { bindEventListeners: function() {
@ -76,6 +88,10 @@ var publicationToPersonUtils = {
this.changeLink.click( function() { this.changeLink.click( function() {
publicationToPersonUtils.showFieldsForPub(); publicationToPersonUtils.showFieldsForPub();
}); });
this.form.submit(function() {
publicationToPersonUtils.resolveEditorNames();
});
}, },
@ -90,16 +106,16 @@ var publicationToPersonUtils = {
}, },
resetAcSelection: function(groupName) { 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); this.hideFields($acSelection);
$acSelection.removeClass('userSelected'); $acSelection.removeClass('userSelected');
$acSelection.find("input.acUriReceiver").val(this.newUriSentinel); $acSelection.find("input.acUriReceiver").val(this.sentinel);
$acSelection.find("span").text(''); $acSelection.find("span").text('');
$acSelection.find("a.verifyMatch").attr('href', this.baseHref); $acSelection.find("a.verifyMatch").attr('href', this.baseHref);
}, },
getAcUriReceiverVal: function(groupName) { 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(); 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 // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('collection'); var ckForVal = this.getAcUriReceiverVal('collection');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.collection.parent('p').show(); this.collection.parent('p').show();
} }
this.volume.show(); this.volume.show();
@ -146,10 +162,8 @@ var publicationToPersonUtils = {
// if the user has changed type, ensure that irrelevant fields are cleared // if the user has changed type, ensure that irrelevant fields are cleared
// and reset an acSelection divs // and reset an acSelection divs
if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) { if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) {
alert(this.book.val());
this.book.val(''); this.book.val('');
this.resetAcSelection('book'); this.resetAcSelection('book');
alert(this.book.val());
} }
if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) { if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) {
this.editor.val(''); this.editor.val('');
@ -174,15 +188,15 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('book'); var ckForVal = this.getAcUriReceiverVal('book');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.book.parent('p').show(); this.book.parent('p').show();
} }
ckForVal = this.getAcUriReceiverVal('editor'); ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.editor.parent('p').show(); this.editor.parent('p').show();
} }
ckForVal = this.getAcUriReceiverVal('publisher'); ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.publisher.parent('p').show(); this.publisher.parent('p').show();
} }
@ -214,11 +228,11 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('editor'); var ckForVal = this.getAcUriReceiverVal('editor');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.editor.parent('p').show(); this.editor.parent('p').show();
} }
ckForVal = this.getAcUriReceiverVal('publisher'); ckForVal = this.getAcUriReceiverVal('publisher');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.publisher.parent('p').show(); this.publisher.parent('p').show();
} }
@ -250,11 +264,11 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('collection'); var ckForVal = this.getAcUriReceiverVal('collection');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.collection.parent('p').show(); this.collection.parent('p').show();
} }
ckForVal = this.getAcUriReceiverVal('conference'); ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.presentedAt.parent('p').show(); this.presentedAt.parent('p').show();
} }
@ -289,7 +303,7 @@ var publicationToPersonUtils = {
// if the user has changed type, keep any relevant values and display the // if the user has changed type, keep any relevant values and display the
// acSelection as appropriate // acSelection as appropriate
var ckForVal = this.getAcUriReceiverVal('conference'); var ckForVal = this.getAcUriReceiverVal('conference');
if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { if ( ckForVal == '' || ckForVal == this.sentinel ) {
this.presentedAt.parent('p').show(); 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--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#assign adviseeLabelValue = adviseeLabelDisplayValue /> <#if adviseeLabelDisplayValue?has_content >
<#assign subjAreaLabelValue = subjAreaLabelDisplayValue /> <#assign adviseeLabelValue = adviseeLabelDisplayValue />
</#if>
<#if subjAreaLabelDisplayValue?has_content >
<#assign subjAreaLabelValue = subjAreaLabelDisplayValue />
</#if>
<section id="error-alert" role="alert"> <section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" /> <img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p> <p>
@ -119,7 +124,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<p > <p >
<label for="advisee">Advisee: Last Name ${requiredHint}<span style="padding-left:322px">First Name ${requiredHint}</span></label> <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 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 type="hidden" id="lastName" name="lastName" value="">
<input class="display" type="hidden" acGroupName="advisee" id="adviseeDisplay" name="adviseeLabelDisplay" value="${adviseeLabelDisplayValue}" > <input class="display" type="hidden" acGroupName="advisee" id="adviseeDisplay" name="adviseeLabelDisplay" value="${adviseeLabelDisplayValue}" >
</p> </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--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#assign orgLabelValue = orgLabelDisplayValue /> <#if orgLabelDisplayValue?has_content >
<#assign awardLabelValue = awardLabelDisplayValue /> <#assign orgLabelValue = orgLabelDisplayValue />
</#if>
<#if awardLabelDisplayValue?has_content >
<#assign awardLabelValue = awardLabelDisplayValue />
</#if>
<section id="error-alert" role="alert"> <section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" /> <img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p> <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.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission; 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 @Override
public Map<String, String> validate(EditConfigurationVTwo editConfig, public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) { MultiValueEditSubmission editSub) {
@ -24,25 +32,23 @@ public class PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>(); Map<String,String> errors = new HashMap<String,String>();
List<String> awardUri = urisFromForm.get("existingAward"); List<String> selectedUri = urisFromForm.get(uriReceiver);
if (allListElementsEmpty(awardUri)) {
awardUri = null; // If there's a presentationUri, then we're done. If not, check to see if the label exists.
}
// If there's an awardUri, then we're done. If not, check to see if the label exists.
// If that's null, too, it's an error. // 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; return null;
} }
else { else {
List<String> awardLabel = urisFromForm.get("awardLabel"); List<Literal> specifiedLabel = literalsFromForm.get(labelInput);
if (allListElementsEmpty(awardLabel)) { if (specifiedLabel != null && specifiedLabel.size() > 0) {
awardLabel = null;
}
if (awardLabel != null) {
return null; return null;
} }
else { 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_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 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."; 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 @Override
public Map<String, String> validate(EditConfigurationVTwo editConfig, public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) { MultiValueEditSubmission editSub) {
@ -27,7 +27,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>(); Map<String,String> errors = new HashMap<String,String>();
List<String> adviseeUri = urisFromForm.get("existingAdvisee"); List<String> adviseeUri = urisFromForm.get("existingAdvisee");
if (allListElementsEmpty(adviseeUri)) { if (allListElementsEmpty(adviseeUri) || adviseeUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
adviseeUri = null; adviseeUri = null;
} }
// If there's an adviseeUri, then we're done. The firstName and lastName fields are // 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 { public class PersonHasPublicationValidator implements N3ValidatorVTwo {
private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type."; private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title."; 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 @Override
public Map<String, String> validate(EditConfigurationVTwo editConfig, public Map<String, String> validate(EditConfigurationVTwo editConfig,
@ -29,35 +30,53 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>(); 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. // 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 //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 //Assumption is that only one value for uri, type, or title will be sent back
String pubUri = (String) getFirstElement(pubUriList); String editorUri = (String) getFirstElement(editorUriList);
if (!StringUtils.isEmpty(pubUri)) { if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
editorUri = null;
}
if ( editorUri != null ) {
return null; return null;
} }
List<String> pubTypeList = urisFromForm.get("pubType"); //Expecting only one first name in this case
String pubType = (String) getFirstElement(pubTypeList); //To Do: update logic if multiple first names considered
if ("".equals(pubType)) { Literal firstName = null;
pubType = null; List<Literal> firstNameList = literalsFromForm.get("firstName");
if(firstNameList != null && firstNameList.size() > 0) {
firstName = firstNameList.get(0);
} }
if( firstName != null &&
List<Literal> titleList = literalsFromForm.get("title"); firstName.getLexicalForm() != null &&
Literal title = (Literal) getFirstElement(titleList); "".equals(firstName.getLexicalForm()) )
if (title != null) { firstName = null;
String titleValue = title.getLexicalForm();
if (StringUtils.isEmpty(titleValue)) {
title = 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) { if (firstName == null) {
errors.put("pubType", MISSING_PUB_TYPE_ERROR); errors.put("firstName", MISSING_FIRST_NAME_ERROR);
} }
if (title == null) {
errors.put("title", MISSING_PUB_TITLE_ERROR);
}
return errors.size() != 0 ? errors : null; 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.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo; 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.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.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator { EditConfigurationGenerator {
@ -61,13 +63,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
conf.setVarNameForObject("role"); conf.setVarNameForObject("role");
conf.setN3Required( Arrays.asList( n3ForNewRole, conf.setN3Required( Arrays.asList( n3ForNewRole,
roleLabelAssertion, roleLabelAssertion) );
presTypeAssertion, conf.setN3Optional( Arrays.asList( n3ForNewPresentation, presTypeAssertion, n3ForExistingPresentation, n3ForNewConference, n3ForExistingConference, n3ForStart, n3ForEnd ) );
presLabelAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForConference, n3ForStart, n3ForEnd ) );
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE); 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("role", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", 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 //uris in scope: none
//literals in scope: none //literals in scope: none
conf.setUrisOnform(Arrays.asList("presentation", "conference", "role", "presentationType")); conf.setUrisOnform(Arrays.asList("existingPresentation", "existingConference", "presentationType"));
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "conferenceLabel", "roleLabel")); conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "presentationLabelDisplay", "conferenceLabel", "conferenceLabelDisplay", "roleLabel"));
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery); conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery); conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery); conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
conf.addSparqlForExistingUris("presentation", presentationQuery); conf.addSparqlForExistingUris("existingPresentation", presentationQuery);
conf.addSparqlForExistingUris("conference", conferenceQuery); conf.addSparqlForExistingUris("existingConference", existingConferenceQuery);
conf.addSparqlForExistingUris("presentationType", presentationTypeQuery); conf.addSparqlForExistingUris("presentationType", presentationTypeQuery);
conf.addSparqlForExistingLiteral( conf.addSparqlForExistingLiteral(
"startField-value", existingStartDateQuery); "startField-value", existingStartDateQuery);
@ -99,15 +99,21 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
existingEndPrecisionQuery); existingEndPrecisionQuery);
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("presentation"). setName("existingPresentation").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS). setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(presentationClass) setObjectClassUri(presentationClass)
); );
conf.addField( new FieldVTwo().
setName("presentationLabelDisplay")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("presentationLabel") setName("presentationLabel")
.setRangeDatatypeUri( XSD.xstring.toString() ). .setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("nonempty") ) setValidators( list("datatype:" + XSD.xstring.toString()) )
); );
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
@ -124,7 +130,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
); );
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("conference"). setName("existingConference").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS). setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(conferenceClass) setObjectClassUri(conferenceClass)
); );
@ -134,6 +140,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
setRangeDatatypeUri(XSD.xstring.toString() ) setRangeDatatypeUri(XSD.xstring.toString() )
); );
conf.addField( new FieldVTwo().
setName("conferenceLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() )
);
conf.addField( new FieldVTwo().setName("startField"). conf.addField( new FieldVTwo().setName("startField").
setEditElement( setEditElement(
new DateTimeWithPrecisionVTwo(null, new DateTimeWithPrecisionVTwo(null,
@ -152,7 +163,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField")); conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation()); conf.addValidator(new AntiXssValidation());
conf.addValidator(new AutocompleteRequiredInputValidator("existingPresentation", "presentationLabel"));
prepare(vreq, conf); prepare(vreq, conf);
return conf; return conf;
} }
@ -162,24 +173,33 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
"@prefix core: <" + vivoCore + "> . \n\n" + "@prefix core: <" + vivoCore + "> . \n\n" +
"?person <" + hasRolePred + "> ?role . \n" + "?person <" + hasRolePred + "> ?role . \n" +
"?role a <" + roleClass + "> . \n" + "?role a <" + roleClass + "> . \n" +
"?role <" + roleOfPred + "> ?person . \n" + "?role <" + roleOfPred + "> ?person . ";
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
"?presentation <" + realizedRolePred + "> ?role .";
final static String roleLabelAssertion = final static String roleLabelAssertion =
"?role <" + label + "> ?roleLabel ."; "?role <" + label + "> ?roleLabel .";
final static String presLabelAssertion = final static String n3ForNewPresentation =
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
"?presentation <" + realizedRolePred + "> ?role . \n" +
"?presentation <" + label + "> ?presentationLabel ."; "?presentation <" + label + "> ?presentationLabel .";
final static String n3ForExistingPresentation =
"?role <" + roleRealizedInPred + "> ?existingPresentation . \n" +
"?existingPresentation <" + realizedRolePred + "> ?role . ";
final static String presTypeAssertion = final static String presTypeAssertion =
"?presentation a ?presentationType ."; "?presentation a ?presentationType .";
final static String n3ForConference = final static String n3ForNewConference =
"?conference a <" + conferenceClass + "> . \n" + "?presentation <" + eventWithinPred + "> ?newConference . \n" +
"?conference <" + includesEventPred + "> ?presentation . \n" + "?newConference <" + includesEventPred + "> ?presentation . \n" +
"?presentation <" + eventWithinPred + "> ?conference . \n" + "?newConference a <" + conferenceClass + "> . \n" +
"?conference <" + label + "> ?conferenceLabel ."; "?newConference <" + label + "> ?conferenceLabel .";
final static String n3ForExistingConference =
"?existingConference a <" + conferenceClass + "> . \n" +
"?existingConference <" + includesEventPred + "> ?presentation . \n" +
"?presentation <" + eventWithinPred + "> ?existingConference . ";
final static String n3ForStart = final static String n3ForStart =
"?role <" + roleToInterval + "> ?intervalNode . \n" + "?role <" + roleToInterval + "> ?intervalNode . \n" +
@ -217,7 +237,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
"?role <" + roleRealizedInPred + "> ?existingPresentation . " + "?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }"; "?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
final static String conferenceQuery = final static String existingConferenceQuery =
"SELECT ?existingConference WHERE { \n" + "SELECT ?existingConference WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " + "?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }"; "?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.configuration.validators.AntiXssValidation;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo; 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.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 * 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 // template file
editConfiguration.setTemplate("addPublicationToPerson.ftl"); editConfiguration.setTemplate("addPublicationToPerson.ftl");
// adding person has publication validator // adding person has publication validator
editConfiguration.addValidator(new PersonHasPublicationValidator());
editConfiguration.addValidator(new AntiXssValidation()); editConfiguration.addValidator(new AntiXssValidation());
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("pubUri", "title"));
editConfiguration.addValidator(new PersonHasPublicationValidator());
// Adding additional data, specifically edit mode // Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq); addFormSpecificData(editConfiguration, vreq);
@ -140,29 +142,35 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
/***N3 strings both required and optional***/ /***N3 strings both required and optional***/
private List<String> generateN3Optional() { private List<String> generateN3Optional() {
return list(getN3ForExistingPub(), return list(getN3ForNewCollection(),
getN3ForNewPub(), getN3ForNewBook(),
getN3NewPubNameAssertion(), getN3ForNewConference(),
getN3NewPubTypeAssertion(), getN3ForNewEvent(),
getN3ForCollection(), getN3ForNewEditor(),
getN3ForBook(), getN3ForNewPublisher(),
getN3ForConference(), getN3ForCollection(),
getN3ForEvent(), getN3ForBook(),
getN3ForEditor(), getN3ForConference(),
getN3ForPublisher(), getN3ForEvent(),
getN3ForLocaleAssertion(), getN3ForEditor(),
getN3ForVolumeAssertion(), getN3ForPublisher(),
getN3ForNumberAssertion(), getN3ForLocaleAssertion(),
getN3ForIssueAssertion(), getN3ForVolumeAssertion(),
getN3ForStartPageAssertion(), getN3ForNumberAssertion(),
getN3ForEndPageAssertion(), getN3ForIssueAssertion(),
getN3ForDateTimeAssertion() getN3ForStartPageAssertion(),
getN3ForEndPageAssertion(),
getN3ForDateTimeAssertion()
); );
} }
private List<String> generateN3Required() { private List<String> generateN3Required() {
return list(getAuthorshipN3()); return list(getAuthorshipN3(),
getN3ForNewPub(),
getN3NewPubNameAssertion(),
getN3NewPubTypeAssertion()
);
} }
private String getAuthorshipN3() { 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() { private String getN3ForCollection() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?collectionUri . \n" + "?pubUri vivo:hasPublicationVenue ?collectionUri . \n" +
"?collectionUri a <" + collectionClass + "> . \n" + "?collectionUri vivo:publicationVenueFor ?pubUri . ";
"?collectionUri vivo:publicationVenueFor ?pubUri . \n" + }
"?collectionUri <" + label + "> ?collection .";
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() { private String getN3ForBook() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?bookUri . \n" + "?pubUri vivo:hasPublicationVenue ?bookUri . \n" +
"?bookUri a <" + bookClass + "> . \n" + "?bookUri vivo:publicationVenueFor ?pubUri . ";
"?bookUri vivo:publicationVenueFor ?pubUri . \n " + }
"?bookUri <" + label + "> ?book .";
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() { private String getN3ForConference() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" + "?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" +
"?conferenceUri a <" + conferenceClass + "> . \n" + "?conferenceUri vivo:includesEvent ?pubUri . ";
"?conferenceUri vivo:includesEvent ?pubUri . \n" + }
"?conferenceUri <" + label + "> ?conference .";
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() { private String getN3ForEvent() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:proceedingsOf ?eventUri . \n" + "?pubUri vivo:proceedingsOf ?eventUri . \n" +
"?eventUri a <" + conferenceClass + "> . \n" + "?eventUri vivo:hasProceedings ?pubUri . ";
"?eventUri vivo:hasProceedings ?pubUri . \n" + }
"?eventUri <" + label + "> ?event .";
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() { private String getN3ForEditor() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:editor ?editorUri . \n" + "?pubUri vivo:editor ?editorUri . \n" +
"?editorUri a <" + editorClass + "> . \n" + "?editorUri vivo:editorOf ?pubUri . ";
"?editorUri vivo:editorOf ?pubUri . \n" + }
"?editorUri <" + label + "> ?editor .";
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() { private String getN3ForPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?publisherUri . \n" + "?pubUri vivo:publisher ?publisherUri . \n" +
"?publisherUri a <" + publisherClass + "> . \n" + "?publisherUri vivo:publisherOf ?pubUri . ";
"?publisherUri vivo:publisherOf ?pubUri . \n" +
"?publisherUri <" + label + "> ?publisher .";
} }
private String getN3ForLocaleAssertion() { private String getN3ForLocaleAssertion() {
@ -288,12 +332,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
HashMap<String, String> newResources = new HashMap<String, String>(); HashMap<String, String> newResources = new HashMap<String, String>();
newResources.put("authorshipUri", DEFAULT_NS_TOKEN); newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
newResources.put("pubUri", DEFAULT_NS_TOKEN); newResources.put("pubUri", DEFAULT_NS_TOKEN);
newResources.put("collectionUri", DEFAULT_NS_TOKEN); newResources.put("newCollection", DEFAULT_NS_TOKEN);
newResources.put("bookUri", DEFAULT_NS_TOKEN); newResources.put("newBook", DEFAULT_NS_TOKEN);
newResources.put("conferenceUri", DEFAULT_NS_TOKEN); newResources.put("newConference", DEFAULT_NS_TOKEN);
newResources.put("eventUri", DEFAULT_NS_TOKEN); newResources.put("newEvent", DEFAULT_NS_TOKEN);
newResources.put("editorUri", DEFAULT_NS_TOKEN); newResources.put("newEditor", DEFAULT_NS_TOKEN);
newResources.put("publisherUri", DEFAULT_NS_TOKEN); newResources.put("newPublisher", DEFAULT_NS_TOKEN);
newResources.put("dateTimeNode", DEFAULT_NS_TOKEN); newResources.put("dateTimeNode", DEFAULT_NS_TOKEN);
return newResources; return newResources;
} }
@ -314,7 +358,6 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
List<String> urisOnForm = new ArrayList<String>(); List<String> urisOnForm = new ArrayList<String>();
//add role activity and roleActivityType to uris on form //add role activity and roleActivityType to uris on form
urisOnForm.add("pubUri");
urisOnForm.add("pubType"); urisOnForm.add("pubType");
urisOnForm.add("collectionUri"); urisOnForm.add("collectionUri");
urisOnForm.add("bookUri"); urisOnForm.add("bookUri");
@ -333,12 +376,20 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
literalsOnForm.add("event"); literalsOnForm.add("event");
literalsOnForm.add("editor"); literalsOnForm.add("editor");
literalsOnForm.add("publisher"); 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("locale");
literalsOnForm.add("volume"); literalsOnForm.add("volume");
literalsOnForm.add("number"); literalsOnForm.add("number");
literalsOnForm.add("issue"); literalsOnForm.add("issue");
literalsOnForm.add("startPage"); literalsOnForm.add("startPage");
literalsOnForm.add("endPage"); literalsOnForm.add("endPage");
literalsOnForm.add("firstName");
literalsOnForm.add("lastName");
editConfiguration.setLiteralsOnForm(literalsOnForm); editConfiguration.setLiteralsOnForm(literalsOnForm);
} }
@ -361,16 +412,24 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setPubTypeField(editConfiguration); setPubTypeField(editConfiguration);
setPubUriField(editConfiguration); setPubUriField(editConfiguration);
setCollectionLabelField(editConfiguration); setCollectionLabelField(editConfiguration);
setCollectionDisplayField(editConfiguration);
setCollectionUriField(editConfiguration); setCollectionUriField(editConfiguration);
setBookLabelField(editConfiguration); setBookLabelField(editConfiguration);
setBookDisplayField(editConfiguration);
setBookUriField(editConfiguration); setBookUriField(editConfiguration);
setConferenceLabelField(editConfiguration); setConferenceLabelField(editConfiguration);
setConferenceDisplayField(editConfiguration);
setConferenceUriField(editConfiguration); setConferenceUriField(editConfiguration);
setEventLabelField(editConfiguration); setEventLabelField(editConfiguration);
setEventDisplayField(editConfiguration);
setEventUriField(editConfiguration); setEventUriField(editConfiguration);
setEditorLabelField(editConfiguration); setEditorLabelField(editConfiguration);
setEditorDisplayField(editConfiguration);
setFirstNameField(editConfiguration);
setLastNameField(editConfiguration);
setEditorUriField(editConfiguration); setEditorUriField(editConfiguration);
setPublisherLabelField(editConfiguration); setPublisherLabelField(editConfiguration);
setPublisherDisplayField(editConfiguration);
setPublisherUriField(editConfiguration); setPublisherUriField(editConfiguration);
setLocaleField(editConfiguration); setLocaleField(editConfiguration);
setVolumeField(editConfiguration); setVolumeField(editConfiguration);
@ -393,7 +452,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
setName("pubType"). setName("pubType").
setOptionsType("HARDCODED_LITERALS"). setOptionsType("HARDCODED_LITERALS").
setLiteralOptions(getPublicationTypeLiteralOptions())); setLiteralOptions(getPublicationTypeLiteralOptions()).
setValidators( list("nonempty") ));
} }
private void setPubUriField(EditConfigurationVTwo editConfiguration) { private void setPubUriField(EditConfigurationVTwo editConfiguration) {
@ -410,6 +470,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setRangeDatatypeUri(stringDatatypeUri)); 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) { private void setCollectionUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
setName("collectionUri"). setName("collectionUri").
@ -423,6 +491,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(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) { private void setBookUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
@ -437,6 +513,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(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) { private void setConferenceUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
@ -451,7 +535,31 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(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) { private void setEventUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
setName("eventUri"). setName("eventUri").
@ -465,6 +573,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(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) { private void setEditorUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
@ -479,6 +595,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(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) { private void setPublisherUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). 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;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode; import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils; 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 public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator { EditConfigurationGenerator {
@ -189,7 +189,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField")); conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation()); conf.addValidator(new AntiXssValidation());
conf.addValidator(new PersonHasAwardOrHonorValidator()); conf.addValidator(new AutocompleteRequiredInputValidator("existingAward", "awardLabel"));
prepare(vreq, conf); prepare(vreq, conf);
return conf; return conf;
} }