NIHVIVO-3709: updates to support editable autocomplete fields

This commit is contained in:
tworrall 2012-04-06 19:04:25 +00:00
parent 5e13309e8a
commit 028d367461
18 changed files with 519 additions and 187 deletions

View file

@ -17,6 +17,19 @@
<#assign disabledVal = "disabled=\"disabled\"" /> <#assign disabledVal = "disabled=\"disabled\"" />
</#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" />
<#--the heading and submit button label depend on the predicate uri--> <#--the heading and submit button label depend on the predicate uri-->
<#assign formHeading = "investigator entry for "/> <#assign formHeading = "investigator entry for "/>
@ -43,11 +56,10 @@
<#--Get selected activity type value if it exists, this is alternative to below--> <#--Get selected activity type value if it exists, this is alternative to below-->
<#assign grantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/> <#assign grantLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/>
<#--Get existing grant label value--> <#assign grantLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabelDisplay")/>
<#assign existingGrantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrantLabel")/>
<#--Get existing grant value--> <#--Get existing grant value-->
<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grant")/> <#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrant")/>
<#assign requiredHint = "<span class='requiredHint'> *</span>" /> <#assign requiredHint = "<span class='requiredHint'> *</span>" />
@ -62,6 +74,10 @@
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#if grantLabelDisplayValue?has_content >
<#assign grantLabelValue = grantLabelDisplayValue />
</#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>
@ -100,10 +116,19 @@
<p> <p>
<label for="grant">Grant Name ${requiredHint}</label> <label for="grant">Grant Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="grant" acGroupName="grant" name="grantLabel" value="${grantLabel}" /> <input class="acSelector" size="50" type="text" id="grant" acGroupName="grant" name="grantLabel" value="${grantLabelValue}" />
<input class="display" type="hidden" id="grantDisplay" acGroupName="grant" name="grantLabelDisplay" value="${grantLabelDisplayValue}">
</p> </p>
<@lvf.acSelection urls.base "grant" "grant" "grant" existingGrantValue "Selected Grant"/> <div class="acSelection" acGroupName="grant" id="grantAcSelection">
<p class="inline">
<label>Selected Grant:</label>
<span class="acSelectionInfo"></span>
<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="grantUri" name="existingGrant" value="${existingGrantValue}" ${flagClearLabelForExisting}="true" />
</div>
<h4>Years of Participation in Grant</h4> <h4>Years of Participation in Grant</h4>
<#if htmlForElements?keys?seq_contains("startField")> <#if htmlForElements?keys?seq_contains("startField")>
@ -137,8 +162,10 @@ var customFormData = {
acTypes: {grant: 'http://vivoweb.org/ontology/core#Grant'}, acTypes: {grant: 'http://vivoweb.org/ontology/core#Grant'},
editMode: '${editMode}', editMode: '${editMode}',
typeName: 'Grant', typeName: 'Grant',
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
}; blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
};
</script> </script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}

View file

@ -26,7 +26,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed--> <#--Retrieve variables needed-->
<#assign presentationValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingPresentation") /> <#assign existingPresentationValue = 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 presentationLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabelDisplay") />
<#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") /> <#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") />
@ -132,7 +132,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<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="existingPresentation" value="${presentationValue}" ${flagClearLabelForExisting}="true" /> <input class="acUriReceiver" type="hidden" id="presentationUri" name="existingPresentation" value="${existingPresentationValue}" ${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}" />

View file

@ -104,10 +104,13 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<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>
<#--below shows examples of both printing out all error messages and checking the error message for a specific field--> <#--below shows examples of both printing out all error messages and checking the error message for a specific field-->
<#if lvf.submissionErrorExists(editSubmission, "title")>
Please select an existing publication in the Title field or enter a new one.<br />
<#else>
<#list submissionErrors?keys as errorFieldName> <#list submissionErrors?keys as errorFieldName>
${submissionErrors[errorFieldName]} <br/> ${submissionErrors[errorFieldName]} <br/>
</#list> </#list>
</#if>
</p> </p>
</section> </section>
</#if> </#if>
@ -222,7 +225,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#-- Editor --> <#-- Editor -->
<p> <p>
<label for="editor">Editor: Last Name<span style="padding-left:322px">First Name ${requiredHint}</span></label> <label class="editor" for="editor">Editor: Last Name<span style="padding-left:338px">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 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="">

View file

@ -493,6 +493,7 @@ var customForm = {
this.resetAcSelection($acSelectionObj); this.resetAcSelection($acSelectionObj);
if ( clearAcSelectorVal == true ) { if ( clearAcSelectorVal == true ) {
$acSelector.val(''); $acSelector.val('');
$("input.display[acGroupName='" + $acSelectionObj.attr('acGroupName') + "']").val("");
} }
customForm.addAcHelpText($acSelector); customForm.addAcHelpText($acSelector);

View file

@ -381,7 +381,11 @@ var publicationToPersonUtils = {
// If editorUri contains the sentinel value, we need to process the name fields // If editorUri contains the sentinel value, we need to process the name fields
// otherwise, disable them so they are not submitted // otherwise, disable them so they are not submitted
if ( this.editorUri.val() == this.sentinel ) { if (this.editor.parent('p').is(':visible') ) {
if ( this.editor.val().indexOf('Select an existing') != -1 ) {
this.editor.val('');
}
if ( this.editorUri.val() == '' || this.editorUri.val() == this.sentinel ) {
firstName = this.firstName.val(); firstName = this.firstName.val();
lastName = this.editor.val(); lastName = this.editor.val();
name = lastName; name = lastName;
@ -392,12 +396,20 @@ var publicationToPersonUtils = {
this.lastName.val(lastName); this.lastName.val(lastName);
} }
else { else {
this.firstName.attr('disabled', 'disabled'); this.disableNameFields();
this.lastName.attr('disabled', 'disabled'); }
}
else {
this.disableNameFields();
} }
}, },
disableNameFields: function() {
this.firstName.attr('disabled', 'disabled');
this.lastName.attr('disabled', 'disabled');
},
resetLastNameLabel: function() { resetLastNameLabel: function() {
var indx = this.editor.val().indexOf(", "); var indx = this.editor.val().indexOf(", ");
if ( indx != -1 ) { if ( indx != -1 ) {

View file

@ -23,10 +23,22 @@
<#assign requiredHint = "<span class='requiredHint'> *</span>" /> <#assign requiredHint = "<span class='requiredHint'> *</span>" />
<#assign yearHint = "<span class='hint'>(YYYY)</span>" /> <#assign yearHint = "<span class='hint'>(YYYY)</span>" />
<#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 positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle") /> <#assign positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle") />
<#assign positionTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionType") /> <#assign positionTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionType") />
<#assign personValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "person") /> <#assign existingPersonValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingPerson") />
<#assign personLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "personLabel") /> <#assign personLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "personLabel") />
<#assign personLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "personLabelDisplay") />
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName") />
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName") />
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
<#assign submissionErrors = editSubmission.validationErrors/> <#assign submissionErrors = editSubmission.validationErrors/>
@ -35,6 +47,9 @@
<h2>${titleVerb}&nbsp;position history entry for ${editConfiguration.subjectName}</h2> <h2>${titleVerb}&nbsp;position history entry for ${editConfiguration.subjectName}</h2>
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#if personLabelDisplayValue?has_content >
<#assign personLabelValue = personLabelDisplayValue />
</#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>
@ -62,6 +77,8 @@
<#else> <#else>
${submissionErrors[errorFieldName]} ${submissionErrors[errorFieldName]}
</#if> </#if>
<#else>
${submissionErrors[errorFieldName]}
</#if><br /> </#if><br />
</#list> </#list>
</p> </p>
@ -93,8 +110,11 @@
</#if> </#if>
</select> </select>
<p> <p>
<label for="relatedIndLabel">Person ${requiredHint}</label> <label for="relatedIndLabel">Person: Last Name ${requiredHint}<span style="padding-left:322px">First Name ${requiredHint}</span></label>
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="personLabel" acGroupName="person" value="${personLabelValue}" > <input class="acSelector" size="50" type="text" id="person" name="personLabel" acGroupName="person" value="${personLabelValue}" >
<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="person" id="personDisplay" name="personLabelDisplay" value="${personLabelDisplayValue}" >
</p> </p>
<div class="acSelection" acGroupName="person"> <div class="acSelection" acGroupName="person">
@ -104,7 +124,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="personUri" name="person" value="${personValue}" /> <input class="acUriReceiver" type="hidden" id="personUri" name="existingPerson" value="${existingPersonValue}" ${flagClearLabelForExisting}="true" />
</div> </div>
<br /> <br />
@ -139,11 +159,19 @@
acTypes: {person: 'http://xmlns.com/foaf/0.1/Person'}, acTypes: {person: 'http://xmlns.com/foaf/0.1/Person'},
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'person', defaultTypeName: 'person',
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
}; };
</script> </script>
</section> </section>
<script type="text/javascript">
$(document).ready(function(){
orgHasPositionUtils.onLoad('${blankSentinel}');
});
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
@ -153,6 +181,7 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarke
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>', '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/orgHasPositionUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -25,7 +25,6 @@ if nothing is selected for that object-->
Set this flag on the input acUriReceiver where you would like this behavior to occur. --> Set this flag on the input acUriReceiver where you would like this behavior to occur. -->
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" /> <#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed--> <#--Retrieve variables needed-->

View file

@ -14,14 +14,27 @@
<#assign editMode = editConfiguration.pageData.editMode /> <#assign editMode = editConfiguration.pageData.editMode />
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--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" />
<#--Retrieve variables needed--> <#--Retrieve variables needed-->
<#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/> <#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/>
<#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel") /> <#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel") />
<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay") />
<#assign deptValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "dept") /> <#assign deptValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "dept") />
<#assign infoValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "info") /> <#assign infoValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "info") />
<#assign majorFieldValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "majorField") /> <#assign majorFieldValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "majorField") />
<#assign degreeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "degree") /> <#assign degreeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "degree") />
<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "org") /> <#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingOrg") />
<#assign trainingTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "trainingType")/> <#assign trainingTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "trainingType")/>
<#--If edit submission exists, then retrieve validation errors if they exist--> <#--If edit submission exists, then retrieve validation errors if they exist-->
@ -47,6 +60,9 @@
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#if orgLabelDisplayValue?has_content >
<#assign orgLabelValue = orgLabelDisplayValue />
</#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>
@ -121,9 +137,18 @@
<p> <p>
<label for="relatedIndLabel">### Name ${requiredHint}</label> <label for="relatedIndLabel">### Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="orgLabel" acGroupName="org" value="${orgLabelValue}" /> <input class="acSelector" size="50" type="text" id="relatedIndLabel" name="orgLabel" acGroupName="org" value="${orgLabelValue}" />
<input class="display" type="hidden" id="orgDisplay" acGroupName="org" name="orgLabelDisplay" value="${orgLabelDisplayValue}">
</p> </p>
<@lvf.acSelection urls.base "org" "org" "org" existingOrgValue/> <div class="acSelection" acGroupName="org">
<p class="inline">
<label>Selected Organization:</label>
<span class="acSelectionInfo"></span>
<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="orgUri" name="existingOrg" value="${existingOrgValue}" ${flagClearLabelForExisting}="true" />
</div>
<label for="positionType">Type of Educational Training ${requiredHint}</label> <label for="positionType">Type of Educational Training ${requiredHint}</label>
<#assign trainingTypeOpts = editConfiguration.pageData.trainingType /> <#assign trainingTypeOpts = editConfiguration.pageData.trainingType />
@ -157,7 +182,7 @@
<p> <p>
<label for="info">Supplemental Information <label for="info">Supplemental Information
<span class="hint">&nbsp;(e.g., Postdoctoral training or Transferred)</span> <span class="hint">&nbsp;(e.g., Thesis title, Transfer info, etc.)</span>
</label> </label>
<input size="60" type="text" id="info" name="info" value="${infoValue}" /> <input size="60" type="text" id="info" name="info" value="${infoValue}" />
@ -192,7 +217,9 @@ var customFormData = {
acUrl: '${urls.base}/autocomplete?tokenize=true&stem=true', acUrl: '${urls.base}/autocomplete?tokenize=true&stem=true',
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'organization', defaultTypeName: 'organization',
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
}; };
</script> </script>

View file

@ -8,12 +8,22 @@
<#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#assign editMode = editConfiguration.pageData.editMode /> <#assign editMode = editConfiguration.pageData.editMode />
<#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" />
<#--Get existing value for specific data literals and uris--> <#--Get existing value for specific data literals and uris-->
<#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/> <#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/>
<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingOrg")/>
<#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel")/> <#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel")/>
<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay")/>
<#assign positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle")/> <#assign positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle")/>
<#assign positionTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionType")/> <#assign positionTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionType")/>
<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "org")/>
<#--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>
@ -38,6 +48,9 @@
<#--Display error messages if any--> <#--Display error messages if any-->
<#if submissionErrors?has_content> <#if submissionErrors?has_content>
<#if orgLabelDisplayValue?has_content >
<#assign orgLabelValue = orgLabelDisplayValue />
</#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>
@ -106,8 +119,17 @@
<p> <p>
<label for="relatedIndLabel">### Name ${requiredHint}</label> <label for="relatedIndLabel">### Name ${requiredHint}</label>
<input type="text" name="orgLabel" id="orgLabel" acGroupName="org" size="50" class="acSelector" value="${orgLabelValue}" > <input type="text" name="orgLabel" id="orgLabel" acGroupName="org" size="50" class="acSelector" value="${orgLabelValue}" >
<input class="display" type="hidden" id="orgDisplay" acGroupName="org" name="orgLabelDisplay" value="${orgLabelDisplayValue}">
</p> </p>
<@lvf.acSelection urls.base "org" "org" "org" existingOrgValue /> <div class="acSelection" acGroupName="org">
<p class="inline">
<label>Selected Organization:</label>
<span class="acSelectionInfo"></span>
<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="orgUri" name="existingOrg" value="${existingOrgValue}" ${flagClearLabelForExisting}="true" />
</div>
<label for="positionTitle">Position Title ${requiredHint}</label> <label for="positionTitle">Position Title ${requiredHint}</label>
<input size="30" type="text" id="positionTitle" name="positionTitle" value="${positionTitleValue}" role="input" /> <input size="30" type="text" id="positionTitle" name="positionTitle" value="${positionTitleValue}" role="input" />
@ -155,8 +177,10 @@ var customFormData = {
acUrl: '${urls.base}/autocomplete?tokenize=true', acUrl: '${urls.base}/autocomplete?tokenize=true',
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'organization', // used in repair mode, to generate button text and org name field label defaultTypeName: 'organization', // used in repair mode, to generate button text and org name field label
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri=',
}; blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'
};
</script> </script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}

View file

@ -0,0 +1,95 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.hp.hpl.jena.rdf.model.Literal;
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 OrganizationHasPositionValidator 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) {
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
Map<String,String> errors = new HashMap<String,String>();
List<String> personUri = urisFromForm.get("existingPerson");
if (allListElementsEmpty(personUri) || personUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
personUri = null;
}
// If there's an adviseeUri, then we're done. The firstName and lastName fields are
// disabled and so don't get submitted.
if (personUri != null) {
return 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);
}
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 (firstName == null) {
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
}
return errors.size() != 0 ? errors : null;
}
private boolean allListElementsEmpty(List<String> checkList) {
if(checkList == null)
return true;
if(checkList.isEmpty()) {
return true;
}
boolean allEmpty = true;
for(String s: checkList) {
if(s.length() != 0){
allEmpty = false;
break;
}
}
return allEmpty;
}
}

View file

@ -7,6 +7,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
@ -16,6 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
public class PersonHasPublicationValidator implements N3ValidatorVTwo { public class PersonHasPublicationValidator implements N3ValidatorVTwo {
private Log log = LogFactory.getLog(PersonHasPublicationValidator.class);
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.";
@ -29,31 +33,21 @@ 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. // The Editor field is optional for all publication subclasses. Validation is only necessary if the user only enters a
List<String> editorUriList = urisFromForm.get("editorUri"); // last name or only enters a first name
//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 editorUri = (String) getFirstElement(editorUriList);
if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
editorUri = null;
}
if ( editorUri != null ) {
return null;
}
//Expecting only one first name in this case //Expecting only one first name in this case
//To Do: update logic if multiple first names considered //To Do: update logic if multiple first names considered
Literal firstName = null;
List<Literal> firstNameList = literalsFromForm.get("firstName"); List<Literal> firstNameList = literalsFromForm.get("firstName");
Literal firstName = null;
if(firstNameList != null && firstNameList.size() > 0) { if(firstNameList != null && firstNameList.size() > 0) {
firstName = firstNameList.get(0); firstName = firstNameList.get(0);
} }
if( firstName != null && if ( firstName != null &&
firstName.getLexicalForm() != null && firstName.getLexicalForm() != null &&
"".equals(firstName.getLexicalForm()) ) "".equals(firstName.getLexicalForm()) )
firstName = null; firstName = null;
List<Literal> lastNameList = literalsFromForm.get("lastName"); List<Literal> lastNameList = literalsFromForm.get("lastName");
Literal lastName = null; Literal lastName = null;
if(lastNameList != null && lastNameList.size() > 0) { if(lastNameList != null && lastNameList.size() > 0) {
@ -67,15 +61,18 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
} }
} }
if (lastName == null) { if ( lastName == null && firstName != null ) {
errors.put("lastName", MISSING_LAST_NAME_ERROR); errors.put("lastName", MISSING_LAST_NAME_ERROR);
// Don't reject space in the last name: de Vries, etc. // Don't reject space in the last name: de Vries, etc.
} else if (lastNameValue.contains(",")) { }
else if ( firstName == null && lastName != null) {
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
}
else if (lastNameValue.contains(",")) {
errors.put("lastName", MALFORMED_LAST_NAME_ERROR); errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
} }
else {
if (firstName == null) { return null;
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
} }
return errors.size() != 0 ? errors : null; return errors.size() != 0 ? errors : null;

View file

@ -34,6 +34,8 @@ 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.AutocompleteRequiredInputValidator;
/** /**
* Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole * Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole
and hasPrincipalInvestigatorRole. and hasPrincipalInvestigatorRole.
@ -109,7 +111,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
//Add validators //Add validators
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") ); editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
editConfiguration.addValidator(new AntiXssValidation()); editConfiguration.addValidator(new AntiXssValidation());
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingGrant","grantLabel"));
//no preprocessors required here //no preprocessors required here
//Adding additional data, specifically edit mode //Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq); addFormSpecificData(editConfiguration, vreq);
@ -183,8 +185,10 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
private List<String> generateN3Optional(VitroRequest vreq) { private List<String> generateN3Optional(VitroRequest vreq) {
List<String> n3Optional = new ArrayList<String>(); List<String> n3Optional = new ArrayList<String>();
//n3 for grant label //n3 for new grant
n3Optional.add(getN3ForGrantLabel(vreq)); n3Optional.add(getN3ForNewGrant(vreq));
//n3 for existing grant
n3Optional.add(getN3ForExistingGrant(vreq));
//n3 for inverse //n3 for inverse
n3Optional.add("?role ?inverseRolePredicate ?person ."); n3Optional.add("?role ?inverseRolePredicate ?person .");
//N3ForStart //N3ForStart
@ -198,15 +202,23 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
String editString = getPrefixesString(); String editString = getPrefixesString();
editString += "?person ?rolePredicate ?role ."; editString += "?person ?rolePredicate ?role .";
editString += "?role a <" + getRoleType(vreq) + "> ."; editString += "?role a <" + getRoleType(vreq) + "> .";
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
editString += "?grant a core:Grant ;" +
"<" + getGrantToRolePredicate(vreq) + "> ?role .";
return editString; return editString;
} }
public String getN3ForGrantLabel(VitroRequest vreq) { public String getN3ForNewGrant(VitroRequest vreq) {
return "?grant <" + RDFS.label.getURI() + "> ?grantLabel ."; String editString = getPrefixesString();
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
editString += "?grant a core:Grant . ";
editString += "?grant <" + getGrantToRolePredicate(vreq) + "> ?role .";
editString += "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
return editString;
}
public String getN3ForExistingGrant(VitroRequest vreq) {
String editString = getPrefixesString();
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?existingGrant . ";
editString += "?existingGrant <" + getGrantToRolePredicate(vreq) + "> ?role .";
return editString;
} }
//Method b/c used in two locations, n3 optional and n3 assertions //Method b/c used in two locations, n3 optional and n3 assertions
@ -249,9 +261,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
return newResources; return newResources;
} }
/* /*
* Set URIS and Literals In Scope and on form and supporting methods * Set URIS and Literals In Scope and on form and supporting methods
*/ */
@ -295,10 +304,11 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
List<String> literalsOnForm = new ArrayList<String>(); List<String> literalsOnForm = new ArrayList<String>();
//add role activity and roleActivityType to uris on form //add role activity and roleActivityType to uris on form
urisOnForm.add("grant"); urisOnForm.add("grant");
urisOnForm.add("existingGrant");
editConfiguration.setUrisOnform(urisOnForm); editConfiguration.setUrisOnform(urisOnForm);
//activity label and role label are literals on form //activity label and role label are literals on form
literalsOnForm.add("grantLabel"); literalsOnForm.add("grantLabel");
literalsOnForm.add("existingGrantLabel"); literalsOnForm.add("grantLabelDisplay");
editConfiguration.setLiteralsOnForm(literalsOnForm); editConfiguration.setLiteralsOnForm(literalsOnForm);
} }
@ -324,7 +334,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) { private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
HashMap<String, String> map = new HashMap<String, String>(); HashMap<String, String> map = new HashMap<String, String>();
//Queries for role activity, activity type query, interval node, start node, end node, start field precision, endfield precision //Queries for role activity, activity type query, interval node, start node, end node, start field precision, endfield precision
map.put("grant", getGrantQuery(vreq)); map.put("existingGrant", getExistingGrantQuery(vreq));
map.put("intervalNode", getIntervalNodeQuery(vreq)); map.put("intervalNode", getIntervalNodeQuery(vreq));
map.put("startNode", getStartNodeQuery(vreq)); map.put("startNode", getStartNodeQuery(vreq));
map.put("endNode", getEndNodeQuery(vreq)); map.put("endNode", getEndNodeQuery(vreq));
@ -391,7 +401,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
return map; return map;
} }
private String getGrantLabelQuery(VitroRequest vreq) { private String getGrantLabelQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" + String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
"PREFIX rdfs: <" + RDFS.getURI() + "> \n"; "PREFIX rdfs: <" + RDFS.getURI() + "> \n";
@ -404,7 +413,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
return query; return query;
} }
private String getGrantQuery(VitroRequest vreq) { private String getExistingGrantQuery(VitroRequest vreq) {
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" + String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
"PREFIX rdfs: <" + RDFS.getURI() + "> \n"; "PREFIX rdfs: <" + RDFS.getURI() + "> \n";
@ -445,7 +454,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
//Multiple fields //Multiple fields
getGrantField(editConfiguration, vreq, fields); getGrantField(editConfiguration, vreq, fields);
getGrantLabelField(editConfiguration, vreq, fields); getGrantLabelField(editConfiguration, vreq, fields);
getExistingGrantLabelField(editConfiguration, vreq, fields); getGrantLabelDisplayField(editConfiguration, vreq, fields);
getExistingGrantField(editConfiguration, vreq, fields);
getStartField(editConfiguration, vreq, fields); getStartField(editConfiguration, vreq, fields);
getEndField(editConfiguration, vreq, fields); getEndField(editConfiguration, vreq, fields);
editConfiguration.setFields(fields); editConfiguration.setFields(fields);
@ -489,9 +499,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
//Not really interested in validators here //Not really interested in validators here
List<String> validators = new ArrayList<String>(); List<String> validators = new ArrayList<String>();
validators.add("datatype:" + stringDatatypeUri); validators.add("datatype:" + stringDatatypeUri);
if(isAddMode(vreq) || isRepairMode(vreq)) {
validators.add("nonempty");
}
field.setValidators(validators); field.setValidators(validators);
//subjectUri and subjectClassUri are not being used in Field //subjectUri and subjectClassUri are not being used in Field
@ -508,11 +515,34 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
} }
private void getGrantLabelDisplayField(EditConfigurationVTwo editConfiguration,
VitroRequest vreq, Map<String, FieldVTwo> fields) {
String fieldName = "grantLabelDisplay";
//get range data type uri and range language
String stringDatatypeUri = XSD.xstring.toString();
FieldVTwo field = new FieldVTwo();
field.setName(fieldName);
//queryForExisting is not being used anywhere in Field
//subjectUri and subjectClassUri are not being used in Field
field.setOptionsType("UNDEFINED");
//why isn't predicate uri set for data properties?
field.setPredicateUri(null);
field.setObjectClassUri(null);
field.setRangeDatatypeUri(null);
field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field);
}
//Need if returning from an invalid submission //Need if returning from an invalid submission
private void getExistingGrantLabelField( private void getExistingGrantField(
EditConfigurationVTwo editConfiguration, VitroRequest vreq, EditConfigurationVTwo editConfiguration, VitroRequest vreq,
Map<String, FieldVTwo> fields) { Map<String, FieldVTwo> fields) {
String fieldName = "existingGrantLabel"; String fieldName = "existingGrant";
FieldVTwo field = new FieldVTwo(); FieldVTwo field = new FieldVTwo();
field.setName(fieldName); field.setName(fieldName);
@ -635,8 +665,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
return EditModeUtils.isRepairMode(getEditMode(vreq)); return EditModeUtils.isRepairMode(getEditMode(vreq));
} }
/** /**
* Methods that are REQUIRED to be implemented in subclasses * Methods that are REQUIRED to be implemented in subclasses
**/ **/
@ -668,10 +696,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
} }
/** /**
* Methods with default values that may be overwritten when required by a subclass * Methods with default values that may be overwritten when required by a subclass
* Both Default value and method that can be overwritten are included below * Both Default value and method that can be overwritten are included below

View file

@ -153,6 +153,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
getN3ForConference(), getN3ForConference(),
getN3ForEvent(), getN3ForEvent(),
getN3ForEditor(), getN3ForEditor(),
getN3FirstNameAssertion(),
getN3LastNameAssertion(),
getN3ForPublisher(), getN3ForPublisher(),
getN3ForLocaleAssertion(), getN3ForLocaleAssertion(),
getN3ForVolumeAssertion(), getN3ForVolumeAssertion(),
@ -273,6 +275,16 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
"?editorUri vivo:editorOf ?pubUri . "; "?editorUri vivo:editorOf ?pubUri . ";
} }
private String getN3FirstNameAssertion() {
return "@prefix foaf: <" + foaf + "> . \n" +
"?newEditor foaf:firstName ?firstName .";
}
private String getN3LastNameAssertion() {
return "@prefix foaf: <" + foaf + "> . \n" +
"?newEditor foaf:lastName ?lastName .";
}
private String getN3ForNewPublisher() { private String getN3ForNewPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" + return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?newPublisher . \n" + "?pubUri vivo:publisher ?newPublisher . \n" +

View file

@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocesso
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.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;
/** /**
* Generates the edit configuration for adding a Role to a Person. * Generates the edit configuration for adding a Role to a Person.
@ -128,7 +129,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
editConfiguration.setN3Required(list( editConfiguration.setN3Required(list(
N3_PREFIX + "\n" + N3_PREFIX + "\n" +
"?person ?rolePredicate ?role .\n" + "?person ?rolePredicate ?role .\n" +
"?role a ?roleType .\n" "?role a ?roleType .\n" +
"?role ?inverseRolePredicate ?person ."
)); ));
// Optional N3 // Optional N3
@ -140,10 +142,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//independently evaluated and passed back with substitutions even if the other strings are not //independently evaluated and passed back with substitutions even if the other strings are not
//substituted correctly. //substituted correctly.
editConfiguration.setN3Optional( list( editConfiguration.setN3Optional( list(
"?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+ getN3ForNewRoleActivity(),
"?roleActivity " + getActivityToRolePlaceholder() + " ?role .", getN3ForExistingRoleActivity(),
"?role ?inverseRolePredicate ?person .",
getN3ForActivityLabel(),
getN3ForActivityType(), getN3ForActivityType(),
getN3RoleLabelAssertion(), getN3RoleLabelAssertion(),
getN3ForStart(), getN3ForStart(),
@ -173,6 +173,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//Add validator //Add validator
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") ); editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
editConfiguration.addValidator(new AntiXssValidation()); editConfiguration.addValidator(new AntiXssValidation());
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingRoleActivity", "activityLabel"));
//Add preprocessors //Add preprocessors
addPreprocessors(editConfiguration, vreq.getWebappDaoFactory()); addPreprocessors(editConfiguration, vreq.getWebappDaoFactory());
@ -191,8 +192,19 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
/* N3 Required and Optional Generators as well as supporting methods */ /* N3 Required and Optional Generators as well as supporting methods */
private String getN3ForActivityLabel() { private List<String> getN3ForNewRoleActivity() {
return "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel ."; List<String> n3ForNewRoleActivity = new ArrayList<String>();
n3ForNewRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+
"?roleActivity " + getActivityToRolePlaceholder() + " ?role . \n" +
"?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel .");
return n3ForNewRoleActivity;
}
private List<String> getN3ForExistingRoleActivity() {
List<String> n3ForExistingRoleActivity = new ArrayList<String>();
n3ForExistingRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?existingRoleActivity .\n"+
"?existingRoleActivity " + getActivityToRolePlaceholder() + " ?role . ");
return n3ForExistingRoleActivity;
} }
private String getN3ForActivityType() { private String getN3ForActivityType() {
@ -266,7 +278,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
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("roleActivity"); urisOnForm.add("existingRoleActivity");
urisOnForm.add("roleActivityType"); urisOnForm.add("roleActivityType");
//Also adding the predicates //Also adding the predicates
//TODO: Check how to override this in case of default parameter? Just write hidden input to form? //TODO: Check how to override this in case of default parameter? Just write hidden input to form?
@ -277,6 +289,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//activity label and role label are literals on form //activity label and role label are literals on form
List<String> literalsOnForm = new ArrayList<String>(); List<String> literalsOnForm = new ArrayList<String>();
literalsOnForm.add("activityLabel"); literalsOnForm.add("activityLabel");
literalsOnForm.add("activityLabelDisplay");
literalsOnForm.add("roleLabel"); literalsOnForm.add("roleLabel");
editConfiguration.setLiteralsOnForm(literalsOnForm); editConfiguration.setLiteralsOnForm(literalsOnForm);
} }
@ -295,7 +308,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//Queries for role activity, activity type query, interval node, //Queries for role activity, activity type query, interval node,
// start node, end node, start field precision, endfield precision // start node, end node, start field precision, endfield precision
map = new HashMap<String, String>(); map = new HashMap<String, String>();
map.put("roleActivity", getRoleActivityQuery(vreq)); map.put("existingRoleActivity", getExistingRoleActivityQuery(vreq));
map.put("roleActivityType", getActivityTypeQuery(vreq)); map.put("roleActivityType", getActivityTypeQuery(vreq));
map.put("intervalNode", getIntervalNodeQuery(vreq)); map.put("intervalNode", getIntervalNodeQuery(vreq));
map.put("startNode", getStartNodeQuery(vreq)); map.put("startNode", getStartNodeQuery(vreq));
@ -495,7 +508,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
} }
private String getRoleActivityQuery(VitroRequest vreq) { private String getExistingRoleActivityQuery(VitroRequest vreq) {
//If role to activity predicate is the default query, then we need to replace with a union //If role to activity predicate is the default query, then we need to replace with a union
//of both realizedIn and the other //of both realizedIn and the other
String query = "PREFIX core: <" + VIVO_NS + ">"; String query = "PREFIX core: <" + VIVO_NS + ">";
@ -503,8 +516,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//Portion below for multiple possible predicates //Portion below for multiple possible predicates
List<String> predicates = getPossibleRoleToActivityPredicates(); List<String> predicates = getPossibleRoleToActivityPredicates();
List<String> addToQuery = new ArrayList<String>(); List<String> addToQuery = new ArrayList<String>();
query += "SELECT ?existingActivity WHERE { \n" + query += "SELECT ?existingRoleActivity WHERE { \n" +
" ?role ?predicate ?existingActivity . \n "; " ?role ?predicate ?existingRoleActivity . \n ";
query += getFilterRoleToActivityPredicate("predicate"); query += getFilterRoleToActivityPredicate("predicate");
query += "}"; query += "}";
return query; return query;
@ -558,8 +571,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>(); Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
//Multiple fields //Multiple fields
getActivityLabelField(editConfiguration, vreq, fields); getActivityLabelField(editConfiguration, vreq, fields);
getActivityLabelDisplayField(editConfiguration, vreq, fields);
getRoleActivityTypeField(editConfiguration, vreq, fields); getRoleActivityTypeField(editConfiguration, vreq, fields);
getRoleActivityField(editConfiguration, vreq, fields); getExistingRoleActivityField(editConfiguration, vreq, fields);
getRoleLabelField(editConfiguration, vreq, fields); getRoleLabelField(editConfiguration, vreq, fields);
getStartField(editConfiguration, vreq, fields); getStartField(editConfiguration, vreq, fields);
getEndField(editConfiguration, vreq, fields); getEndField(editConfiguration, vreq, fields);
@ -638,10 +652,6 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
//queryForExisting is not being used anywhere in Field //queryForExisting is not being used anywhere in Field
List<String> validators = new ArrayList<String>(); List<String> validators = new ArrayList<String>();
//If add mode or repair, etc. need to add label required validator
if(isAddMode(vreq) || isRepairMode(vreq)) {
validators.add("nonempty");
}
validators.add("datatype:" + stringDatatypeUri); validators.add("datatype:" + stringDatatypeUri);
field.setValidators(validators); field.setValidators(validators);
@ -658,6 +668,29 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
fields.put(field.getName(), field); fields.put(field.getName(), field);
} }
private void getActivityLabelDisplayField(EditConfigurationVTwo editConfiguration,
VitroRequest vreq, Map<String, FieldVTwo> fields) {
String fieldName = "activityLabelDisplay";
//get range data type uri and range language
String stringDatatypeUri = XSD.xstring.toString();
FieldVTwo field = new FieldVTwo();
field.setName(fieldName);
//queryForExisting is not being used anywhere in Field
//subjectUri and subjectClassUri are not being used in Field
field.setOptionsType("UNDEFINED");
//why isn't predicate uri set for data properties?
field.setPredicateUri(null);
field.setObjectClassUri(null);
field.setRangeDatatypeUri(stringDatatypeUri);
field.setLiteralOptions(new ArrayList<List<String>>());
fields.put(field.getName(), field);
}
//type of "right side" of role, i.e. type of activity from role roleIn activity //type of "right side" of role, i.e. type of activity from role roleIn activity
private void getRoleActivityTypeField( private void getRoleActivityTypeField(
EditConfigurationVTwo editConfiguration, VitroRequest vreq, EditConfigurationVTwo editConfiguration, VitroRequest vreq,
@ -699,9 +732,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
} }
//Assuming URI for activity for role? //Assuming URI for activity for role?
private void getRoleActivityField(EditConfigurationVTwo editConfiguration, private void getExistingRoleActivityField(EditConfigurationVTwo editConfiguration,
VitroRequest vreq, Map<String, FieldVTwo> fields) { VitroRequest vreq, Map<String, FieldVTwo> fields) {
String fieldName = "roleActivity"; String fieldName = "existingRoleActivity";
//get range data type uri and range language //get range data type uri and range language
FieldVTwo field = new FieldVTwo(); FieldVTwo field = new FieldVTwo();

View file

@ -15,6 +15,7 @@ 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.edit.n3editing.OrganizationHasPositionValidator;
public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
implements EditConfigurationGenerator { implements EditConfigurationGenerator {
@ -115,11 +116,33 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
+ "\n" // + "\n" //
+ "?position a core:Position , ?positionType ; \n" + "?position a core:Position , ?positionType ; \n"
+ " rdfs:label ?positionTitle ; \n" + " rdfs:label ?positionTitle ; \n"
+ " core:positionInOrganization ?organization ; \n" + " core:positionInOrganization ?organization ; ";
+ " core:positionForPerson ?person . \n" //
private static final String N3_NEW_PERSON = ""
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
+ "\n" // + "\n" //
+ "?person core:personInPosition ?position ;" + "?position core:positionForPerson ?person . \n" //
+ " rdfs:label ?personLabel"; + "?person core:personInPosition ?position . \n"
+ "?person a foaf:Person . \n"
+ "?person rdfs:label ?personLabel";
private static final String N3_NEW_FIRST_NAME = ""
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
+ "\n" //
+ "?person foaf:firstName ?firstName .";
private static final String N3_NEW_LAST_NAME = ""
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
+ "\n" //
+ "?person foaf:lastName ?lastName .";
private static final String N3_EXISTING_PERSON = ""
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
+ "\n" //
+ "?position core:positionForPerson ?existingPerson . \n" //
+ "?existingPerson core:personInPosition ?position . ";
private static final String N3_NEW_START_NODE = "" private static final String N3_NEW_START_NODE = ""
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n" + "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
@ -161,7 +184,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
conf.setTemplate("organizationHasPositionHistory.ftl"); conf.setTemplate("organizationHasPositionHistory.ftl");
conf.setN3Required(Arrays.asList(N3_NEW_POSITION)); conf.setN3Required(Arrays.asList(N3_NEW_POSITION));
conf.setN3Optional(Arrays.asList(N3_NEW_START_NODE, N3_NEW_END_NODE)); conf.setN3Optional(Arrays.asList(N3_NEW_PERSON, N3_EXISTING_PERSON, N3_NEW_START_NODE, N3_NEW_END_NODE, N3_NEW_FIRST_NAME, N3_NEW_LAST_NAME));
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("person", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("person", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -169,7 +192,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.setUrisOnform(Arrays.asList("person", "position", "positionType")); conf.setUrisOnform(Arrays.asList("existingPerson", "position", "positionType"));
conf.addSparqlForExistingUris("positionType", conf.addSparqlForExistingUris("positionType",
QUERY_EXISTING_POSITION_TYPE); QUERY_EXISTING_POSITION_TYPE);
conf.addSparqlForExistingUris("person", QUERY_EXISTING_PERSON); conf.addSparqlForExistingUris("person", QUERY_EXISTING_PERSON);
@ -179,12 +202,13 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
conf.addSparqlForExistingUris("startNode", QUERY_EXISTING_START_NODE); conf.addSparqlForExistingUris("startNode", QUERY_EXISTING_START_NODE);
conf.addSparqlForExistingUris("endNode", QUERY_EXISTING_END_NODE); conf.addSparqlForExistingUris("endNode", QUERY_EXISTING_END_NODE);
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "personLabel")); conf.setLiteralsOnForm(Arrays.asList("positionTitle", "personLabelDisplay", "personLabel", "firstName", "lastName"));
conf.addSparqlForExistingLiteral("positionTitle", conf.addSparqlForExistingLiteral("positionTitle",
QUERY_EXISTING_POSITION_TITLE); QUERY_EXISTING_POSITION_TITLE);
conf.addSparqlForExistingLiteral("personLabel", conf.addSparqlForExistingLiteral("personLabel",
QUERY_EXISTING_PERSON_LABEL); QUERY_EXISTING_PERSON_LABEL);
conf.addSparqlForExistingUris("existingPerson",
QUERY_EXISTING_PERSON);
conf.addSparqlForExistingLiteral("startField-value", conf.addSparqlForExistingLiteral("startField-value",
QUERY_EXISTING_START_VALUE); QUERY_EXISTING_START_VALUE);
conf.addSparqlForExistingUris("startField-precision", conf.addSparqlForExistingUris("startField-precision",
@ -205,13 +229,25 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
.setRangeDatatypeUri(XSD.xstring.toString()) .setRangeDatatypeUri(XSD.xstring.toString())
.setValidators(list("nonempty"))); .setValidators(list("nonempty")));
conf.addField(new FieldVTwo().setName("person") conf.addField(new FieldVTwo().setName("existingPerson")
.setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS) .setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS)
.setObjectClassUri(personClass)); .setObjectClassUri(personClass));
conf.addField(new FieldVTwo().setName("personLabel") conf.addField(new FieldVTwo().setName("personLabel")
.setRangeDatatypeUri(XSD.xstring.toString()) .setRangeDatatypeUri(XSD.xstring.toString())
.setValidators(list("nonempty"))); .setValidators( list("datatype:" + XSD.xstring.toString()) ));
conf.addField(new FieldVTwo().setName("firstName")
.setRangeDatatypeUri(XSD.xstring.toString())
.setValidators( list("datatype:" + XSD.xstring.toString()) ));
conf.addField(new FieldVTwo().setName("lastName")
.setRangeDatatypeUri(XSD.xstring.toString())
.setValidators( list("datatype:" + XSD.xstring.toString()) ));
conf.addField(new FieldVTwo().setName("personLabelDisplay")
.setRangeDatatypeUri(XSD.xstring.toString())
.setValidators( list("datatype:" + XSD.xstring.toString()) ));
FieldVTwo startField = new FieldVTwo().setName("startField"); FieldVTwo startField = new FieldVTwo().setName("startField");
conf.addField(startField.setEditElement(new DateTimeWithPrecisionVTwo( conf.addField(startField.setEditElement(new DateTimeWithPrecisionVTwo(
@ -221,6 +257,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
conf.addField(endField.setEditElement(new DateTimeWithPrecisionVTwo( conf.addField(endField.setEditElement(new DateTimeWithPrecisionVTwo(
endField, URI_PRECISION_YEAR, URI_PRECISION_NONE))); endField, URI_PRECISION_YEAR, URI_PRECISION_NONE)));
conf.addValidator(new OrganizationHasPositionValidator());
conf.addValidator(new AntiXssValidation()); conf.addValidator(new AntiXssValidation());
conf.addValidator(new DateTimeIntervalValidationVTwo("startField", conf.addValidator(new DateTimeIntervalValidationVTwo("startField",
"endField")); "endField"));

View file

@ -20,6 +20,7 @@ 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.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;
/** /**
Form for adding an educational attainment to an individual Form for adding an educational attainment to an individual
@ -86,14 +87,13 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
conf.setVarNameForPredicate("predicate"); conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("edTraining"); conf.setVarNameForObject("edTraining");
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, orgLabelAssertion, orgTypeAssertion, trainingTypeAssertion ) ); conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
conf.setN3Optional(Arrays.asList( conf.setN3Optional(Arrays.asList(
n3ForEdTrainingToOrg, majorFieldAssertion, degreeAssertion, n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, majorFieldAssertion, degreeAssertion,
deptAssertion, infoAssertion, deptAssertion, infoAssertion, n3ForStart, n3ForEnd ));
n3ForStart, n3ForEnd, n3ForOrgToEdTraining ));
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("org",DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("newOrg",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);
conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("endNode",DEFAULT_NS_FOR_NEW_RESOURCE);
@ -101,8 +101,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
//uris in scope: none //uris in scope: none
//literals in scope: none //literals in scope: none
conf.setUrisOnform( Arrays.asList( "org", "orgType", "degree", "trainingType")); conf.setUrisOnform( Arrays.asList( "existingOrg", "orgType", "degree", "trainingType"));
conf.setLiteralsOnForm( Arrays.asList("orgLabel","majorField","dept","info")); conf.setLiteralsOnForm( Arrays.asList("orgLabel", "orgLabelDisplay", "majorField", "dept", "info"));
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery); conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
conf.addSparqlForExistingLiteral("majorField", majorFieldQuery); conf.addSparqlForExistingLiteral("majorField", majorFieldQuery);
@ -112,7 +112,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery); conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris("org", orgQuery); conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
conf.addSparqlForExistingUris("orgType", orgTypeQuery); conf.addSparqlForExistingUris("orgType", orgTypeQuery);
conf.addSparqlForExistingUris("trainingType", trainingTypeQuery); conf.addSparqlForExistingUris("trainingType", trainingTypeQuery);
conf.addSparqlForExistingUris("degree", degreeQuery); conf.addSparqlForExistingUris("degree", degreeQuery);
@ -135,7 +135,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
setValidators(list("datatype:" + XSD.xstring.toString()))); setValidators(list("datatype:" + XSD.xstring.toString())));
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("org"). setName("existingOrg").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS). setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri( orgClass )); setObjectClassUri( orgClass ));
//setLiteralOptions( [ "Select One" } ) //setLiteralOptions( [ "Select One" } )
@ -143,7 +143,11 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("orgLabel"). setName("orgLabel").
setRangeDatatypeUri(XSD.xstring.toString() ). setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("nonempty") )); setValidators( list("datatype:" + XSD.xstring.toString())));
conf.addField( new FieldVTwo().
setName("orgLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ));
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("orgType"). setName("orgType").
@ -197,15 +201,27 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
/* N3 assertions for working with educational training */ /* N3 assertions for working with educational training */
final static String orgTypeAssertion = final static String n3ForNewEdTraining =
"?org a ?orgType ."; "@prefix core: <"+ vivoCore +"> .\n"+
"?person core:educationalTraining ?edTraining .\n" +
final static String orgLabelAssertion = "?edTraining a core:EducationalTraining .\n" +
"?org <"+ label +"> ?orgLabel ."; "?edTraining core:educationalTrainingOf ?person .";
final static String trainingTypeAssertion = final static String trainingTypeAssertion =
"?edTraining a ?trainingType ."; "?edTraining a ?trainingType .";
final static String n3ForNewOrg =
"?edTraining <"+ trainingAtOrg +"> ?newOrg . \n" +
"?newOrg ?inverseTrainingAtOrg ?edTraining .\n" +
"?newOrg <"+ label +"> ?orgLabel .";
final static String n3ForExistingOrg =
"?edTraining <"+ trainingAtOrg +"> ?existingOrg . \n" +
"?existingOrg ?inverseTrainingAtOrg ?edTraining . ";
final static String orgTypeAssertion =
"?newOrg a ?orgType .";
final static String degreeAssertion = final static String degreeAssertion =
"?edTraining <"+ degreeEarned +"> ?degree .\n"+ "?edTraining <"+ degreeEarned +"> ?degree .\n"+
"?degree <"+ degreeOutcomeOf +"> ?edTraining ."; "?degree <"+ degreeOutcomeOf +"> ?edTraining .";
@ -235,22 +251,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
final static String infoAssertion = final static String infoAssertion =
"?edTraining <"+ infoPred +"> ?info ."; "?edTraining <"+ infoPred +"> ?info .";
final static String n3ForNewEdTraining =
"@prefix core: <"+ vivoCore +"> .\n"+
"?person core:educationalTraining ?edTraining .\n"+
"?edTraining a core:EducationalTraining ;\n"+
"core:educationalTrainingOf ?person ;\n"+
"<"+ trainingAtOrg +"> ?org .\n";
final static String n3ForEdTrainingToOrg =
"?edTraining <"+ trainingAtOrg +"> ?org .";
//The inverse of the above
final static String n3ForOrgToEdTraining =
"?org ?inverseTrainingAtOrg ?edTraining .";
/* Queries for editing an existing educational training entry */ /* Queries for editing an existing educational training entry */
final static String orgQuery = final static String existingOrgQuery =
"SELECT ?existingOrg WHERE {\n"+ "SELECT ?existingOrg WHERE {\n"+
"?edTraining <"+ trainingAtOrg +"> ?existingOrg . }\n"; "?edTraining <"+ trainingAtOrg +"> ?existingOrg . }\n";

View file

@ -21,6 +21,7 @@ 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.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 PersonHasPositionHistoryGenerator extends VivoBaseGenerator implements public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator { EditConfigurationGenerator {
@ -72,13 +73,11 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
conf.setN3Required( Arrays.asList( n3ForNewPosition, conf.setN3Required( Arrays.asList( n3ForNewPosition,
positionTitleAssertion, positionTitleAssertion,
positionTypeAssertion, positionTypeAssertion ) );
orgLabelAssertion, conf.setN3Optional( Arrays.asList( n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, n3ForStart, n3ForEnd ) );
orgTypeAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForStart, n3ForEnd ) );
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("org", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("newOrg", 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);
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -86,8 +85,8 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
//uris in scope: none //uris in scope: none
//literals in scope: none //literals in scope: none
conf.setUrisOnform(Arrays.asList("org", "orgType", "positionType")); conf.setUrisOnform(Arrays.asList("existingOrg", "orgType", "positionType"));
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel")); conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel", "orgLabelDisplay"));
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery); conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery); conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery);
@ -96,7 +95,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
conf.addSparqlForExistingLiteral( conf.addSparqlForExistingLiteral(
"endField-value", existingEndDateQuery); "endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris("org", orgQuery); conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
conf.addSparqlForExistingUris("orgType", orgTypeQuery); conf.addSparqlForExistingUris("orgType", orgTypeQuery);
conf.addSparqlForExistingUris("positionType", positionTypeQuery); conf.addSparqlForExistingUris("positionType", positionTypeQuery);
conf.addSparqlForExistingUris( conf.addSparqlForExistingUris(
@ -122,7 +121,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
); );
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("org"). setName("existingOrg").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS). setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(orgClass) setObjectClassUri(orgClass)
); );
@ -130,7 +129,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
setName("orgLabel"). setName("orgLabel").
setRangeDatatypeUri(XSD.xstring.toString() ). setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("nonempty") ) setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("orgLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() )
); );
conf.addField( new FieldVTwo(). conf.addField( new FieldVTwo().
@ -157,6 +161,7 @@ public class PersonHasPositionHistoryGenerator 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("existingOrg", "orgLabel"));
//Adding additional data, specifically edit mode //Adding additional data, specifically edit mode
addFormSpecificData(conf, vreq); addFormSpecificData(conf, vreq);
@ -165,24 +170,28 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
} }
final static String n3ForNewPosition = final static String n3ForNewPosition =
"@prefix core: <" + vivoCore + "> . \n\n" + "@prefix core: <" + vivoCore + "> . \n" +
"?person core:personInPosition ?position . \n" + "?person core:personInPosition ?position . \n" +
"?position a ?positionType ; \n" + "?position a ?positionType . \n" +
" core:positionForPerson ?person ; \n" + "?position core:positionForPerson ?person ; ";
" <" + positionInOrgPred + "> ?org . \n" +
"?org <" + orgForPositionPred + "> ?position .";
final static String positionTitleAssertion = final static String positionTitleAssertion =
"?position <" + RDFS.label.getURI() + "> ?positionTitle ."; "?position <" + label + "> ?positionTitle .";
final static String positionTypeAssertion = final static String positionTypeAssertion =
"?position a ?positionType ."; "?position a ?positionType .";
final static String orgLabelAssertion = final static String n3ForNewOrg =
"?org <" + RDFS.label.getURI() + "> ?orgLabel ."; "?position <" + positionInOrgPred + "> ?newOrg . \n" +
"?newOrg <" + orgForPositionPred + "> ?position . \n" +
"?newOrg <" + label + "> ?orgLabel .";
final static String n3ForExistingOrg =
"?position <" + positionInOrgPred + "> ?existingOrg . \n" +
"?existingOrg <" + orgForPositionPred + "> ?position . " ;
final static String orgTypeAssertion = final static String orgTypeAssertion =
"?org a ?orgType ."; "?newOrg a ?orgType .";
final static String n3ForStart = final static String n3ForStart =
"?position <" + positionToInterval + "> ?intervalNode . \n" + "?position <" + positionToInterval + "> ?intervalNode . \n" +
@ -203,12 +212,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
final static String orgLabelQuery = final static String orgLabelQuery =
"SELECT ?existingOrgLabel WHERE { \n" + "SELECT ?existingOrgLabel WHERE { \n" +
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" + " ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
" ?existingOrg <" + RDFS.label.getURI() + "> ?existingOrgLabel . \n" + " ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
"}"; "}";
final static String positionTitleQuery = final static String positionTitleQuery =
"SELECT ?existingPositionTitle WHERE { \n" + "SELECT ?existingPositionTitle WHERE { \n" +
"?position <" + RDFS.label.getURI() + "> ?existingPositionTitle . }"; "?position <" + label + "> ?existingPositionTitle . }";
final static String existingStartDateQuery = final static String existingStartDateQuery =
"SELECT ?existingDateStart WHERE { \n" + "SELECT ?existingDateStart WHERE { \n" +
@ -226,12 +235,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
" ?endNode a <" + dateTimeValueType + "> . \n" + " ?endNode a <" + dateTimeValueType + "> . \n" +
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }"; " ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
final static String orgQuery = final static String existingOrgQuery =
"SELECT ?existingOrg WHERE { \n" + "SELECT ?existingOrg WHERE { \n" +
" ?position <" + positionInOrgPred + "> ?existingOrg . }"; " ?position <" + positionInOrgPred + "> ?existingOrg . }";
final static String orgTypeQuery = final static String orgTypeQuery =
"PREFIX rdfs: <" + RDFS.getURI() + "> \n" + "PREFIX rdfs: <" + rdfs + "> \n" +
"SELECT ?existingOrgType WHERE { \n" + "SELECT ?existingOrgType WHERE { \n" +
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" + " ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
" ?existingOrg a ?existingOrgType . \n" + " ?existingOrg a ?existingOrgType . \n" +