NIHVIVO-3709: updates to support editable autocomplete fields
This commit is contained in:
parent
5e13309e8a
commit
028d367461
18 changed files with 519 additions and 187 deletions
|
@ -17,6 +17,19 @@
|
|||
<#assign disabledVal = "disabled=\"disabled\"" />
|
||||
</#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-->
|
||||
|
||||
<#assign formHeading = "investigator entry for "/>
|
||||
|
@ -43,11 +56,10 @@
|
|||
|
||||
<#--Get selected activity type value if it exists, this is alternative to below-->
|
||||
|
||||
<#assign grantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/>
|
||||
<#--Get existing grant label value-->
|
||||
<#assign existingGrantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrantLabel")/>
|
||||
<#assign grantLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/>
|
||||
<#assign grantLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabelDisplay")/>
|
||||
<#--Get existing grant value-->
|
||||
<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "grant")/>
|
||||
<#assign existingGrantValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingGrant")/>
|
||||
|
||||
|
||||
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
|
||||
|
@ -62,6 +74,10 @@
|
|||
|
||||
<#--Display error messages if any-->
|
||||
<#if submissionErrors?has_content>
|
||||
<#if grantLabelDisplayValue?has_content >
|
||||
<#assign grantLabelValue = grantLabelDisplayValue />
|
||||
</#if>
|
||||
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>
|
||||
|
@ -100,10 +116,19 @@
|
|||
|
||||
<p>
|
||||
<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>
|
||||
|
||||
<@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>
|
||||
<#if htmlForElements?keys?seq_contains("startField")>
|
||||
|
@ -137,8 +162,10 @@ var customFormData = {
|
|||
acTypes: {grant: 'http://vivoweb.org/ontology/core#Grant'},
|
||||
editMode: '${editMode}',
|
||||
typeName: 'Grant',
|
||||
baseHref: '${urls.base}/individual?uri='
|
||||
};
|
||||
baseHref: '${urls.base}/individual?uri=',
|
||||
blankSentinel: '${blankSentinel}',
|
||||
flagClearLabelForExisting: '${flagClearLabelForExisting}'
|
||||
};
|
||||
</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}/templates/freemarker/edit/forms/css/customForm.css" />')}
|
||||
|
|
|
@ -26,7 +26,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
|
|||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||
|
||||
<#--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 presentationLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabelDisplay") />
|
||||
<#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="changeSelection" id="changeSelection">change selection)</a>
|
||||
</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>
|
||||
<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}" />
|
||||
|
|
|
@ -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" />
|
||||
<p>
|
||||
<#--below shows examples of both printing out all error messages and checking the error message for a specific field-->
|
||||
<#list submissionErrors?keys as errorFieldName>
|
||||
${submissionErrors[errorFieldName]} <br/>
|
||||
</#list>
|
||||
|
||||
<#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>
|
||||
${submissionErrors[errorFieldName]} <br/>
|
||||
</#list>
|
||||
</#if>
|
||||
</p>
|
||||
</section>
|
||||
</#if>
|
||||
|
@ -222,7 +225,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
|
|||
|
||||
<#-- Editor -->
|
||||
<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 size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" ><br />
|
||||
<input type="hidden" id="lastName" name="lastName" value="">
|
||||
|
|
|
@ -492,7 +492,8 @@ var customForm = {
|
|||
$acSelector.parent('p').show();
|
||||
this.resetAcSelection($acSelectionObj);
|
||||
if ( clearAcSelectorVal == true ) {
|
||||
$acSelector.val('');
|
||||
$acSelector.val('');
|
||||
$("input.display[acGroupName='" + $acSelectionObj.attr('acGroupName') + "']").val("");
|
||||
}
|
||||
customForm.addAcHelpText($acSelector);
|
||||
|
||||
|
|
|
@ -381,23 +381,35 @@ var publicationToPersonUtils = {
|
|||
|
||||
// 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');
|
||||
}
|
||||
|
||||
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();
|
||||
lastName = this.editor.val();
|
||||
name = lastName;
|
||||
if (firstName) {
|
||||
name += ', ' + firstName;
|
||||
}
|
||||
this.editor.val(name);
|
||||
this.lastName.val(lastName);
|
||||
}
|
||||
else {
|
||||
this.disableNameFields();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.disableNameFields();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
disableNameFields: function() {
|
||||
this.firstName.attr('disabled', 'disabled');
|
||||
this.lastName.attr('disabled', 'disabled');
|
||||
},
|
||||
|
||||
resetLastNameLabel: function() {
|
||||
var indx = this.editor.val().indexOf(", ");
|
||||
if ( indx != -1 ) {
|
||||
|
|
|
@ -23,10 +23,22 @@
|
|||
<#assign requiredHint = "<span class='requiredHint'> *</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 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 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>
|
||||
<#assign submissionErrors = editSubmission.validationErrors/>
|
||||
|
@ -35,6 +47,9 @@
|
|||
<h2>${titleVerb} position history entry for ${editConfiguration.subjectName}</h2>
|
||||
|
||||
<#if submissionErrors?has_content>
|
||||
<#if personLabelDisplayValue?has_content >
|
||||
<#assign personLabelValue = personLabelDisplayValue />
|
||||
</#if>
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>
|
||||
|
@ -62,6 +77,8 @@
|
|||
<#else>
|
||||
${submissionErrors[errorFieldName]}
|
||||
</#if>
|
||||
<#else>
|
||||
${submissionErrors[errorFieldName]}
|
||||
</#if><br />
|
||||
</#list>
|
||||
</p>
|
||||
|
@ -93,8 +110,11 @@
|
|||
</#if>
|
||||
</select>
|
||||
<p>
|
||||
<label for="relatedIndLabel">Person ${requiredHint}</label>
|
||||
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="personLabel" acGroupName="person" value="${personLabelValue}" >
|
||||
<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="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>
|
||||
|
||||
<div class="acSelection" acGroupName="person">
|
||||
|
@ -104,7 +124,7 @@
|
|||
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
|
||||
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
|
||||
</p>
|
||||
<input class="acUriReceiver" type="hidden" id="personUri" name="person" value="${personValue}" />
|
||||
<input class="acUriReceiver" type="hidden" id="personUri" name="existingPerson" value="${existingPersonValue}" ${flagClearLabelForExisting}="true" />
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
@ -139,11 +159,19 @@
|
|||
acTypes: {person: 'http://xmlns.com/foaf/0.1/Person'},
|
||||
editMode: '${editMode}',
|
||||
defaultTypeName: 'person',
|
||||
baseHref: '${urls.base}/individual?uri='
|
||||
baseHref: '${urls.base}/individual?uri=',
|
||||
blankSentinel: '${blankSentinel}',
|
||||
flagClearLabelForExisting: '${flagClearLabelForExisting}'
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
</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}/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>',
|
||||
'<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}/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/jquery_plugins/jquery.bgiframe.pack.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
||||
|
|
|
@ -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. -->
|
||||
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
|
||||
|
||||
|
||||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||
|
||||
<#--Retrieve variables needed-->
|
||||
|
|
|
@ -14,14 +14,27 @@
|
|||
<#assign editMode = editConfiguration.pageData.editMode />
|
||||
<#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-->
|
||||
<#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/>
|
||||
<#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel") />
|
||||
<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay") />
|
||||
<#assign deptValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "dept") />
|
||||
<#assign infoValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "info") />
|
||||
<#assign majorFieldValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "majorField") />
|
||||
<#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")/>
|
||||
|
||||
<#--If edit submission exists, then retrieve validation errors if they exist-->
|
||||
|
@ -47,6 +60,9 @@
|
|||
|
||||
<#--Display error messages if any-->
|
||||
<#if submissionErrors?has_content>
|
||||
<#if orgLabelDisplayValue?has_content >
|
||||
<#assign orgLabelValue = orgLabelDisplayValue />
|
||||
</#if>
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>
|
||||
|
@ -121,9 +137,18 @@
|
|||
<p>
|
||||
<label for="relatedIndLabel">### Name ${requiredHint}</label>
|
||||
<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>
|
||||
|
||||
<@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>
|
||||
<#assign trainingTypeOpts = editConfiguration.pageData.trainingType />
|
||||
|
@ -157,7 +182,7 @@
|
|||
|
||||
<p>
|
||||
<label for="info">Supplemental Information
|
||||
<span class="hint"> (e.g., Postdoctoral training or Transferred)</span>
|
||||
<span class="hint"> (e.g., Thesis title, Transfer info, etc.)</span>
|
||||
</label>
|
||||
<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',
|
||||
editMode: '${editMode}',
|
||||
defaultTypeName: 'organization',
|
||||
baseHref: '${urls.base}/individual?uri='
|
||||
baseHref: '${urls.base}/individual?uri=',
|
||||
blankSentinel: '${blankSentinel}',
|
||||
flagClearLabelForExisting: '${flagClearLabelForExisting}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -8,12 +8,22 @@
|
|||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||
<#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-->
|
||||
<#assign orgTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgType")/>
|
||||
<#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingOrg")/>
|
||||
<#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel")/>
|
||||
<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay")/>
|
||||
<#assign positionTitleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "positionTitle")/>
|
||||
<#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 editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
|
||||
|
@ -38,6 +48,9 @@
|
|||
|
||||
<#--Display error messages if any-->
|
||||
<#if submissionErrors?has_content>
|
||||
<#if orgLabelDisplayValue?has_content >
|
||||
<#assign orgLabelValue = orgLabelDisplayValue />
|
||||
</#if>
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>
|
||||
|
@ -106,9 +119,18 @@
|
|||
<p>
|
||||
<label for="relatedIndLabel">### Name ${requiredHint}</label>
|
||||
<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>
|
||||
<@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>
|
||||
<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',
|
||||
editMode: '${editMode}',
|
||||
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>
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -16,6 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
|||
|
||||
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_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.";
|
||||
|
@ -29,35 +33,25 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
|||
|
||||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
// If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted.
|
||||
List<String> editorUriList = urisFromForm.get("editorUri");
|
||||
//This method will return null if the list is null or empty, otherwise returns first element
|
||||
//Assumption is that only one value for uri, type, or title will be sent back
|
||||
String editorUri = (String) getFirstElement(editorUriList);
|
||||
if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
|
||||
editorUri = null;
|
||||
}
|
||||
if ( editorUri != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// The Editor field is optional for all publication subclasses. Validation is only necessary if the user only enters a
|
||||
// last name or only enters a first name
|
||||
|
||||
//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");
|
||||
Literal firstName = null;
|
||||
if(firstNameList != null && firstNameList.size() > 0) {
|
||||
firstName = firstNameList.get(0);
|
||||
firstName = firstNameList.get(0);
|
||||
}
|
||||
if( firstName != null &&
|
||||
firstName.getLexicalForm() != null &&
|
||||
"".equals(firstName.getLexicalForm()) )
|
||||
firstName = null;
|
||||
|
||||
if ( firstName != null &&
|
||||
firstName.getLexicalForm() != null &&
|
||||
"".equals(firstName.getLexicalForm()) )
|
||||
firstName = null;
|
||||
|
||||
List<Literal> lastNameList = literalsFromForm.get("lastName");
|
||||
Literal lastName = null;
|
||||
if(lastNameList != null && lastNameList.size() > 0) {
|
||||
lastName = lastNameList.get(0);
|
||||
lastName = lastNameList.get(0);
|
||||
}
|
||||
String lastNameValue = "";
|
||||
if (lastName != null) {
|
||||
|
@ -67,15 +61,18 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
|||
}
|
||||
}
|
||||
|
||||
if (lastName == null) {
|
||||
if ( lastName == null && firstName != null ) {
|
||||
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||
// Don't reject space in the last name: de Vries, etc.
|
||||
} else if (lastNameValue.contains(",")) {
|
||||
// Don't reject space in the last name: de Vries, etc.
|
||||
}
|
||||
else if ( firstName == null && lastName != null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
}
|
||||
else if (lastNameValue.contains(",")) {
|
||||
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
||||
}
|
||||
|
||||
if (firstName == null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return errors.size() != 0 ? errors : null;
|
||||
|
|
|
@ -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.EditMode;
|
||||
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
|
||||
and hasPrincipalInvestigatorRole.
|
||||
|
@ -109,7 +111,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Add validators
|
||||
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
|
||||
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingGrant","grantLabel"));
|
||||
//no preprocessors required here
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
|
@ -183,8 +185,10 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
|
||||
private List<String> generateN3Optional(VitroRequest vreq) {
|
||||
List<String> n3Optional = new ArrayList<String>();
|
||||
//n3 for grant label
|
||||
n3Optional.add(getN3ForGrantLabel(vreq));
|
||||
//n3 for new grant
|
||||
n3Optional.add(getN3ForNewGrant(vreq));
|
||||
//n3 for existing grant
|
||||
n3Optional.add(getN3ForExistingGrant(vreq));
|
||||
//n3 for inverse
|
||||
n3Optional.add("?role ?inverseRolePredicate ?person .");
|
||||
//N3ForStart
|
||||
|
@ -198,17 +202,25 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
String editString = getPrefixesString();
|
||||
editString += "?person ?rolePredicate ?role .";
|
||||
editString += "?role a <" + getRoleType(vreq) + "> .";
|
||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
|
||||
editString += "?grant a core:Grant ;" +
|
||||
"<" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||
return editString;
|
||||
}
|
||||
|
||||
public String getN3ForGrantLabel(VitroRequest vreq) {
|
||||
return "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
|
||||
|
||||
public String getN3ForNewGrant(VitroRequest vreq) {
|
||||
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
|
||||
private List<String> getN3ForStart() {
|
||||
List<String> n3ForStart = new ArrayList<String>();
|
||||
|
@ -248,9 +260,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
newResources.put("endNode", defaultNamespace + "individual");
|
||||
return newResources;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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>();
|
||||
//add role activity and roleActivityType to uris on form
|
||||
urisOnForm.add("grant");
|
||||
urisOnForm.add("existingGrant");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
//activity label and role label are literals on form
|
||||
literalsOnForm.add("grantLabel");
|
||||
literalsOnForm.add("existingGrantLabel");
|
||||
literalsOnForm.add("grantLabelDisplay");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
|
@ -324,7 +334,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
|
||||
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
|
||||
map.put("grant", getGrantQuery(vreq));
|
||||
map.put("existingGrant", getExistingGrantQuery(vreq));
|
||||
map.put("intervalNode", getIntervalNodeQuery(vreq));
|
||||
map.put("startNode", getStartNodeQuery(vreq));
|
||||
map.put("endNode", getEndNodeQuery(vreq));
|
||||
|
@ -390,7 +400,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
map.put("endField-value", getExistingEndDateQuery(vreq));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private String getGrantLabelQuery(VitroRequest vreq) {
|
||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||
|
@ -404,7 +413,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
return query;
|
||||
}
|
||||
|
||||
private String getGrantQuery(VitroRequest vreq) {
|
||||
private String getExistingGrantQuery(VitroRequest vreq) {
|
||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
||||
|
||||
|
@ -445,7 +454,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Multiple fields
|
||||
getGrantField(editConfiguration, vreq, fields);
|
||||
getGrantLabelField(editConfiguration, vreq, fields);
|
||||
getExistingGrantLabelField(editConfiguration, vreq, fields);
|
||||
getGrantLabelDisplayField(editConfiguration, vreq, fields);
|
||||
getExistingGrantField(editConfiguration, vreq, fields);
|
||||
getStartField(editConfiguration, vreq, fields);
|
||||
getEndField(editConfiguration, vreq, fields);
|
||||
editConfiguration.setFields(fields);
|
||||
|
@ -489,9 +499,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Not really interested in validators here
|
||||
List<String> validators = new ArrayList<String>();
|
||||
validators.add("datatype:" + stringDatatypeUri);
|
||||
if(isAddMode(vreq) || isRepairMode(vreq)) {
|
||||
validators.add("nonempty");
|
||||
}
|
||||
field.setValidators(validators);
|
||||
|
||||
//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
|
||||
private void getExistingGrantLabelField(
|
||||
private void getExistingGrantField(
|
||||
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
||||
Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "existingGrantLabel";
|
||||
String fieldName = "existingGrant";
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName(fieldName);
|
||||
|
@ -634,9 +664,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
private boolean isRepairMode(VitroRequest vreq) {
|
||||
return EditModeUtils.isRepairMode(getEditMode(vreq));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Both Default value and method that can be overwritten are included below
|
||||
|
|
|
@ -153,6 +153,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
getN3ForConference(),
|
||||
getN3ForEvent(),
|
||||
getN3ForEditor(),
|
||||
getN3FirstNameAssertion(),
|
||||
getN3LastNameAssertion(),
|
||||
getN3ForPublisher(),
|
||||
getN3ForLocaleAssertion(),
|
||||
getN3ForVolumeAssertion(),
|
||||
|
@ -273,6 +275,16 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
"?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() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:publisher ?newPublisher . \n" +
|
||||
|
|
|
@ -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.utils.FrontEndEditingUtils.EditMode;
|
||||
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.
|
||||
|
||||
|
@ -128,7 +129,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
editConfiguration.setN3Required(list(
|
||||
N3_PREFIX + "\n" +
|
||||
"?person ?rolePredicate ?role .\n" +
|
||||
"?role a ?roleType .\n"
|
||||
"?role a ?roleType .\n" +
|
||||
"?role ?inverseRolePredicate ?person ."
|
||||
));
|
||||
|
||||
// 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
|
||||
//substituted correctly.
|
||||
editConfiguration.setN3Optional( list(
|
||||
"?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+
|
||||
"?roleActivity " + getActivityToRolePlaceholder() + " ?role .",
|
||||
"?role ?inverseRolePredicate ?person .",
|
||||
getN3ForActivityLabel(),
|
||||
getN3ForNewRoleActivity(),
|
||||
getN3ForExistingRoleActivity(),
|
||||
getN3ForActivityType(),
|
||||
getN3RoleLabelAssertion(),
|
||||
getN3ForStart(),
|
||||
|
@ -173,6 +173,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Add validator
|
||||
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingRoleActivity", "activityLabel"));
|
||||
|
||||
//Add preprocessors
|
||||
addPreprocessors(editConfiguration, vreq.getWebappDaoFactory());
|
||||
|
@ -191,8 +192,19 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
|
||||
/* N3 Required and Optional Generators as well as supporting methods */
|
||||
|
||||
private String getN3ForActivityLabel() {
|
||||
return "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel .";
|
||||
private List<String> getN3ForNewRoleActivity() {
|
||||
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() {
|
||||
|
@ -266,7 +278,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//add role activity and roleActivityType to uris on form
|
||||
urisOnForm.add("roleActivity");
|
||||
urisOnForm.add("existingRoleActivity");
|
||||
urisOnForm.add("roleActivityType");
|
||||
//Also adding the predicates
|
||||
//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
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("activityLabel");
|
||||
literalsOnForm.add("activityLabelDisplay");
|
||||
literalsOnForm.add("roleLabel");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
@ -295,7 +308,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Queries for role activity, activity type query, interval node,
|
||||
// start node, end node, start field precision, endfield precision
|
||||
map = new HashMap<String, String>();
|
||||
map.put("roleActivity", getRoleActivityQuery(vreq));
|
||||
map.put("existingRoleActivity", getExistingRoleActivityQuery(vreq));
|
||||
map.put("roleActivityType", getActivityTypeQuery(vreq));
|
||||
map.put("intervalNode", getIntervalNodeQuery(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
|
||||
//of both realizedIn and the other
|
||||
String query = "PREFIX core: <" + VIVO_NS + ">";
|
||||
|
@ -503,8 +516,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Portion below for multiple possible predicates
|
||||
List<String> predicates = getPossibleRoleToActivityPredicates();
|
||||
List<String> addToQuery = new ArrayList<String>();
|
||||
query += "SELECT ?existingActivity WHERE { \n" +
|
||||
" ?role ?predicate ?existingActivity . \n ";
|
||||
query += "SELECT ?existingRoleActivity WHERE { \n" +
|
||||
" ?role ?predicate ?existingRoleActivity . \n ";
|
||||
query += getFilterRoleToActivityPredicate("predicate");
|
||||
query += "}";
|
||||
return query;
|
||||
|
@ -558,8 +571,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||
//Multiple fields
|
||||
getActivityLabelField(editConfiguration, vreq, fields);
|
||||
getActivityLabelDisplayField(editConfiguration, vreq, fields);
|
||||
getRoleActivityTypeField(editConfiguration, vreq, fields);
|
||||
getRoleActivityField(editConfiguration, vreq, fields);
|
||||
getExistingRoleActivityField(editConfiguration, vreq, fields);
|
||||
getRoleLabelField(editConfiguration, vreq, fields);
|
||||
getStartField(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
|
||||
|
||||
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);
|
||||
field.setValidators(validators);
|
||||
|
||||
|
@ -658,6 +668,29 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
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
|
||||
private void getRoleActivityTypeField(
|
||||
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
||||
|
@ -699,9 +732,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
}
|
||||
|
||||
//Assuming URI for activity for role?
|
||||
private void getRoleActivityField(EditConfigurationVTwo editConfiguration,
|
||||
private void getExistingRoleActivityField(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "roleActivity";
|
||||
String fieldName = "existingRoleActivity";
|
||||
//get range data type uri and range language
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
|
|
|
@ -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.FieldVTwo;
|
||||
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
|
||||
implements EditConfigurationGenerator {
|
||||
|
@ -115,11 +116,33 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
+ "\n" //
|
||||
+ "?position a core:Position , ?positionType ; \n"
|
||||
+ " rdfs:label ?positionTitle ; \n"
|
||||
+ " core:positionInOrganization ?organization ; \n"
|
||||
+ " core:positionForPerson ?person . \n" //
|
||||
+ "\n" //
|
||||
+ "?person core:personInPosition ?position ;"
|
||||
+ " rdfs:label ?personLabel";
|
||||
+ " core:positionInOrganization ?organization ; ";
|
||||
|
||||
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" //
|
||||
+ "?position core:positionForPerson ?person . \n" //
|
||||
+ "?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 = ""
|
||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||
|
@ -161,7 +184,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.setTemplate("organizationHasPositionHistory.ftl");
|
||||
|
||||
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("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("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("person", "position", "positionType"));
|
||||
conf.setUrisOnform(Arrays.asList("existingPerson", "position", "positionType"));
|
||||
conf.addSparqlForExistingUris("positionType",
|
||||
QUERY_EXISTING_POSITION_TYPE);
|
||||
conf.addSparqlForExistingUris("person", QUERY_EXISTING_PERSON);
|
||||
|
@ -179,12 +202,13 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.addSparqlForExistingUris("startNode", QUERY_EXISTING_START_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",
|
||||
QUERY_EXISTING_POSITION_TITLE);
|
||||
conf.addSparqlForExistingLiteral("personLabel",
|
||||
QUERY_EXISTING_PERSON_LABEL);
|
||||
|
||||
conf.addSparqlForExistingUris("existingPerson",
|
||||
QUERY_EXISTING_PERSON);
|
||||
conf.addSparqlForExistingLiteral("startField-value",
|
||||
QUERY_EXISTING_START_VALUE);
|
||||
conf.addSparqlForExistingUris("startField-precision",
|
||||
|
@ -205,13 +229,25 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
.setRangeDatatypeUri(XSD.xstring.toString())
|
||||
.setValidators(list("nonempty")));
|
||||
|
||||
conf.addField(new FieldVTwo().setName("person")
|
||||
conf.addField(new FieldVTwo().setName("existingPerson")
|
||||
.setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS)
|
||||
.setObjectClassUri(personClass));
|
||||
|
||||
conf.addField(new FieldVTwo().setName("personLabel")
|
||||
.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");
|
||||
conf.addField(startField.setEditElement(new DateTimeWithPrecisionVTwo(
|
||||
|
@ -221,6 +257,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.addField(endField.setEditElement(new DateTimeWithPrecisionVTwo(
|
||||
endField, URI_PRECISION_YEAR, URI_PRECISION_NONE)));
|
||||
|
||||
conf.addValidator(new OrganizationHasPositionValidator());
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField",
|
||||
"endField"));
|
||||
|
|
|
@ -86,7 +86,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
||||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
|
||||
|
|
|
@ -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.utils.FrontEndEditingUtils.EditMode;
|
||||
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
|
||||
|
@ -86,14 +87,13 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.setVarNameForPredicate("predicate");
|
||||
conf.setVarNameForObject("edTraining");
|
||||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, orgLabelAssertion, orgTypeAssertion, trainingTypeAssertion ) );
|
||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
||||
conf.setN3Optional(Arrays.asList(
|
||||
n3ForEdTrainingToOrg, majorFieldAssertion, degreeAssertion,
|
||||
deptAssertion, infoAssertion,
|
||||
n3ForStart, n3ForEnd, n3ForOrgToEdTraining ));
|
||||
n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, majorFieldAssertion, degreeAssertion,
|
||||
deptAssertion, infoAssertion, n3ForStart, n3ForEnd ));
|
||||
|
||||
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("startNode",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
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform( Arrays.asList( "org", "orgType", "degree", "trainingType"));
|
||||
conf.setLiteralsOnForm( Arrays.asList("orgLabel","majorField","dept","info"));
|
||||
conf.setUrisOnform( Arrays.asList( "existingOrg", "orgType", "degree", "trainingType"));
|
||||
conf.setLiteralsOnForm( Arrays.asList("orgLabel", "orgLabelDisplay", "majorField", "dept", "info"));
|
||||
|
||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("majorField", majorFieldQuery);
|
||||
|
@ -112,7 +112,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||
|
||||
|
||||
conf.addSparqlForExistingUris("org", orgQuery);
|
||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||
conf.addSparqlForExistingUris("trainingType", trainingTypeQuery);
|
||||
conf.addSparqlForExistingUris("degree", degreeQuery);
|
||||
|
@ -135,7 +135,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("org").
|
||||
setName("existingOrg").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri( orgClass ));
|
||||
//setLiteralOptions( [ "Select One" } )
|
||||
|
@ -143,7 +143,11 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabel").
|
||||
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().
|
||||
setName("orgType").
|
||||
|
@ -197,14 +201,26 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
|
||||
/* N3 assertions for working with educational training */
|
||||
|
||||
final static String orgTypeAssertion =
|
||||
"?org a ?orgType .";
|
||||
|
||||
final static String orgLabelAssertion =
|
||||
"?org <"+ label +"> ?orgLabel .";
|
||||
final static String n3ForNewEdTraining =
|
||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||
"?person core:educationalTraining ?edTraining .\n" +
|
||||
"?edTraining a core:EducationalTraining .\n" +
|
||||
"?edTraining core:educationalTrainingOf ?person .";
|
||||
|
||||
final static String trainingTypeAssertion =
|
||||
"?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 =
|
||||
"?edTraining <"+ degreeEarned +"> ?degree .\n"+
|
||||
|
@ -235,22 +251,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
final static String infoAssertion =
|
||||
"?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 */
|
||||
|
||||
final static String orgQuery =
|
||||
final static String existingOrgQuery =
|
||||
"SELECT ?existingOrg WHERE {\n"+
|
||||
"?edTraining <"+ trainingAtOrg +"> ?existingOrg . }\n";
|
||||
|
||||
|
|
|
@ -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.utils.FrontEndEditingUtils.EditMode;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
|
||||
|
||||
public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator implements
|
||||
EditConfigurationGenerator {
|
||||
|
@ -72,13 +73,11 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewPosition,
|
||||
positionTitleAssertion,
|
||||
positionTypeAssertion,
|
||||
orgLabelAssertion,
|
||||
orgTypeAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForStart, n3ForEnd ) );
|
||||
positionTypeAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, n3ForStart, n3ForEnd ) );
|
||||
|
||||
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("startNode", 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
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("org", "orgType", "positionType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel"));
|
||||
conf.setUrisOnform(Arrays.asList("existingOrg", "orgType", "positionType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel", "orgLabelDisplay"));
|
||||
|
||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery);
|
||||
|
@ -96,7 +95,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
conf.addSparqlForExistingLiteral(
|
||||
"endField-value", existingEndDateQuery);
|
||||
|
||||
conf.addSparqlForExistingUris("org", orgQuery);
|
||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||
conf.addSparqlForExistingUris("positionType", positionTypeQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
|
@ -122,7 +121,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("org").
|
||||
setName("existingOrg").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri(orgClass)
|
||||
);
|
||||
|
@ -130,7 +129,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabel").
|
||||
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().
|
||||
|
@ -157,6 +161,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrg", "orgLabel"));
|
||||
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(conf, vreq);
|
||||
|
@ -165,24 +170,28 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
}
|
||||
|
||||
final static String n3ForNewPosition =
|
||||
"@prefix core: <" + vivoCore + "> . \n\n" +
|
||||
"@prefix core: <" + vivoCore + "> . \n" +
|
||||
"?person core:personInPosition ?position . \n" +
|
||||
"?position a ?positionType ; \n" +
|
||||
" core:positionForPerson ?person ; \n" +
|
||||
" <" + positionInOrgPred + "> ?org . \n" +
|
||||
"?org <" + orgForPositionPred + "> ?position .";
|
||||
"?position a ?positionType . \n" +
|
||||
"?position core:positionForPerson ?person ; ";
|
||||
|
||||
final static String positionTitleAssertion =
|
||||
"?position <" + RDFS.label.getURI() + "> ?positionTitle .";
|
||||
"?position <" + label + "> ?positionTitle .";
|
||||
|
||||
final static String positionTypeAssertion =
|
||||
"?position a ?positionType .";
|
||||
|
||||
final static String orgLabelAssertion =
|
||||
"?org <" + RDFS.label.getURI() + "> ?orgLabel .";
|
||||
"?position a ?positionType .";
|
||||
|
||||
final static String n3ForNewOrg =
|
||||
"?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 =
|
||||
"?org a ?orgType .";
|
||||
"?newOrg a ?orgType .";
|
||||
|
||||
final static String n3ForStart =
|
||||
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||
|
@ -203,12 +212,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
final static String orgLabelQuery =
|
||||
"SELECT ?existingOrgLabel WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg <" + RDFS.label.getURI() + "> ?existingOrgLabel . \n" +
|
||||
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
||||
"}";
|
||||
|
||||
final static String positionTitleQuery =
|
||||
"SELECT ?existingPositionTitle WHERE { \n" +
|
||||
"?position <" + RDFS.label.getURI() + "> ?existingPositionTitle . }";
|
||||
"?position <" + label + "> ?existingPositionTitle . }";
|
||||
|
||||
final static String existingStartDateQuery =
|
||||
"SELECT ?existingDateStart WHERE { \n" +
|
||||
|
@ -226,12 +235,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||
|
||||
final static String orgQuery =
|
||||
final static String existingOrgQuery =
|
||||
"SELECT ?existingOrg WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . }";
|
||||
|
||||
final static String orgTypeQuery =
|
||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n" +
|
||||
"PREFIX rdfs: <" + rdfs + "> \n" +
|
||||
"SELECT ?existingOrgType WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg a ?existingOrgType . \n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue