custom form changes for NIHVIVO-601, 764 and 2602 plus all related subtasks

This commit is contained in:
tworrall 2012-03-06 14:40:12 +00:00
parent b7b7607242
commit 4782e06ff3
11 changed files with 1161 additions and 115 deletions

View file

@ -1,27 +1,197 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#--Two stage form for service provider role-->
<#-- <#-- this is in request.subject.name -->
Required Values to be set for each form that includes addRoleToPersonTwoStage.ftl are:
roleDescriptor.
The other required values (roleType, optionsType, objectClassUri, and literalOptions are
set in the JAVA class corresponding to the form, e.g. AddPresenterRoleToPersonGenerator.java.
Optional values can be set, but each of these has default values <#-- leaving this edit/add mode code in for reference in case we decide we need it -->
set in addRoleToPersonTwoStage.ftl:
buttonText <#import "lib-vivo-form.ftl" as lvf>
typeSelectorLabel
numDateFields <#--Retrieve certain edit configuration information-->
showRoleLAbelField <#if editConfiguration.objectUri?has_content>
roleExamples--> <#assign editMode = "edit">
<#else>
<#assign editMode = "add">
</#if>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign presentationValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentation") />
<#assign presentationLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationLabel") />
<#assign presentationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "presentationType") />
<#assign roleLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "roleLabel") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") />
<#assign conferenceLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceLabel") />
<#--If edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
<#assign submissionErrors = editSubmission.validationErrors/>
</#if>
<#if editMode == "edit">
<#assign titleVerb="Edit">
<#assign submitButtonText="Save Changes">
<#assign disabledVal="disabled">
<#else>
<#assign titleVerb="Create">
<#assign submitButtonText="Create Entry">
<#assign disabledVal=""/>
</#if>
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
<#assign yearHint = "<span class='hint'>(YYYY)</span>" />
<h2>${titleVerb}&nbsp;award or honor for ${editConfiguration.subjectName}</h2>
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
<#--Checking if any required fields are empty-->
<#if lvf.submissionErrorExists(editSubmission, "presentationLabel")>
Please select an existing value or enter a new value in the Name field.
</#if>
<#if lvf.submissionErrorExists(editSubmission, "roleLabel")>
Please enter a new value in the Role field.
</#if>
<#list submissionErrors?keys as errorFieldName>
<#if errorFieldName == "startField">
<#if submissionErrors[errorFieldName]?contains("before")>
The Start Year must be earlier than the End Year.
<#else>
${submissionErrors[errorFieldName]}
</#if>
<#elseif errorFieldName == "endField">
<#if submissionErrors[errorFieldName]?contains("after")>
The End Year must be later than the Start Year.
<#else>
${submissionErrors[errorFieldName]}
</#if>
</#if><br />
</#list>
</p>
</section>
</#if>
<@lvf.unsupportedBrowser urls.base />
<section id="addPresenterRoleToPerson" role="region">
<form id="addPresenterRoleToPerson" class="customForm noIE67" action="${submitUrl}" role="add/edit Presentation">
<p class="inline">
<label for="presentationType">Presentation Type<#if editMode != "edit"> ${requiredHint}<#else>:</#if></label>
<#assign presentationTypeOpts = editConfiguration.pageData.presentationType />
<#if editMode == "edit">
<#list presentationTypeOpts?keys as key>
<#if presentationTypeValue = key >
<span class="readOnly" id="typeSelectorSpan">${presentationTypeOpts[key]}</span>
<input type="hidden" id="typeSelectorInput" name="presentationType" acGroupName="presentation" value="${presentationTypeValue}">
</#if>
</#list>
<#else>
<select id="typeSelector" name="presentationType" acGroupName="presentation">
<option value="" selected="selected">Select one</option>
<#list presentationTypeOpts?keys as key>
<option value="${key}" <#if presentationTypeValue = key>selected</#if>> <#if presentationTypeOpts[key] == "Other">Presentation<#else>${presentationTypeOpts[key]}</#if></option>
</#list>
</select>
</#if>
</p>
<div class="fullViewOnly">
<p>
<label for="presentation">### Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="presentation" acGroupName="presentation" name="presentationLabel" value="${presentationLabelValue}">
</p>
<div class="acSelection" acGroupName="presentation">
<p class="inline">
<label></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="presentationUri" name="presentation" value="${presentationValue}" />
</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}" />
</p>
<p>
<label for="org">Presented At</label>
<input class="acSelector" size="50" acGroupName="conference" type="text" id="conference" name="conferenceLabel" value="${conferenceLabelValue}" />
</p>
<div class="acSelection" acGroupName="conference">
<p class="inline">
<label>Selected Conference:</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="conferenceUri" name="conference" value="${conferenceValue}" />
</div>
<p>
<h4>Years of Participation in ###</h4>
</p>
<#--Need to draw edit elements for dates here-->
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#if htmlForElements?keys?seq_contains("startField")>
<label class="dateTime" for="startField">Start</label>
${htmlForElements["startField"]} ${yearHint}
</#if>
<br/>
<#if htmlForElements?keys?seq_contains("endField")>
<label class="dateTime" for="endField">End</label>
${htmlForElements["endField"]} ${yearHint}
</#if>
<#--End draw elements-->
<input type="hidden" id="editKey" name="editKey" value="${editKey}"/>
</div>
<p class="submit">
<input type="submit" class="submit" value="${submitButtonText}"/><span class="or"> or </span>
<a class="cancel" href="${cancelUrl}" title="Cancel">Cancel</a>
</p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
<#-- hide the html that gets written, and use java script to pass the value between the two -->
<div class="hidden">
<#if htmlForElements?keys?seq_contains("yearAwarded")>
${htmlForElements["yearAwarded"]}
</#if>
</div>
</form>
</section>
<script type="text/javascript">
var customFormData = {
acUrl: '${urls.base}/autocomplete?tokenize=true&stem=true',
acTypes: {conference: 'http://purl.org/ontology/bibo/Conference'},
editMode: '${editMode}',
defaultTypeName: 'presentation',
multipleTypeNames: {presentation: 'presentation', conference: 'conference'},
baseHref: '${urls.base}/individual?uri='
};
</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" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}
<#--Variable assignments for Add Clinical Role To Person-->
<#assign roleDescriptor = "presentation" />
<#assign typeSelectorLabel = "presentation type" />
<#assign buttonText = "Presentation Role" />
<#assign roleExamples = "<span class='hint'>&nbsp;(e.g., Moderator, Speaker, Panelist)</span>" />
<#--Each of the two stage forms will include the form below-->
<#include "addRoleToPersonTwoStage.ftl">

View file

@ -23,6 +23,24 @@
<#assign publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") /> <#assign publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") />
<#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") /> <#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") />
<#assign pubUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubUri") /> <#assign pubUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubUri") />
<#assign collectionValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collection") />
<#assign collectionUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "collectionUri") />
<#assign bookValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "book") />
<#assign bookUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "bookUri") />
<#assign conferenceValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conference") />
<#assign conferenceUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "conferenceUri") />
<#assign eventValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "event") />
<#assign eventUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "eventUri") />
<#assign editorValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editor") />
<#assign editorUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "editorUri") />
<#assign publisherValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisher") />
<#assign publisherUriValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "publisherUri") />
<#assign localeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "locale") />
<#assign volumeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "volume") />
<#assign numberValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "number") />
<#assign issueValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "issue") />
<#assign startPageValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "startPage") />
<#assign endPageValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "endPage") />
<#if editMode == "edit"> <#if editMode == "edit">
<#assign titleVerb="Edit"> <#assign titleVerb="Edit">
@ -74,11 +92,11 @@
</p> </p>
<div class="fullViewOnly"> <div class="fullViewOnly">
<p> <p>
<label for="relatedIndLabel">Title ${requiredHint}</label> <label for="title">Title ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="title" name="title" acGroupName="publication" value="${titleValue}" /> <input class="acSelector" size="60" type="text" id="title" name="title" acGroupName="publication" value="${titleValue}" />
</p> </p>
<div class="acSelection" acGroupName="publication" > <div class="acSelection" acGroupName="publication" id="pubAcSelection">
<p class="inline"> <p class="inline">
<label>Selected Publication:</label> <label>Selected Publication:</label>
<span class="acSelectionInfo"></span> <span class="acSelectionInfo"></span>
@ -87,8 +105,142 @@
</p> </p>
<input class="acUriReceiver" type="hidden" id="pubUri" name="pubUri" value="${pubUriValue}" /> <input class="acUriReceiver" type="hidden" id="pubUri" name="pubUri" value="${pubUriValue}" />
</div> </div>
<div id="fieldsForNewPub">
<#-- Published In: collection -->
<p>
<label for="collection">Published in</label>
<input class="acSelector" size="50" type="text" id="collection" name="collection" acGroupName="collection" value="${collectionValue}" />
</p>
<div class="acSelection" acGroupName="collection" >
<p class="inline">
<label>Selected Venue:</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="collectionUri" name="collectionUri" value="${collectionUriValue}" />
</div> </div>
<#-- Published In: book -->
<p>
<label for="book">Published in</label>
<input class="acSelector" size="50" type="text" id="book" name="book" acGroupName="book" value="${bookValue}" />
</p>
<div class="acSelection" acGroupName="book" >
<p class="inline">
<label>Selected Venue:</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="bookUri" name="bookUri" value="${bookUriValue}" />
</div>
<#-- Presented At -->
<p>
<label for="conference">Presented at</label>
<input class="acSelector" size="50" type="text" id="conference" name="conference" acGroupName="conference" value="${conferenceValue}" />
</p>
<div class="acSelection" acGroupName="conference" >
<p class="inline">
<label>Selected Venue:</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="conferenceUri" name="conferenceUri" value="${conferenceUriValue}" />
</div>
<#-- Proceedings of -->
<p>
<label for="event">Proceedings of</label>
<input class="acSelector" size="50" type="text" id="event" name="event" acGroupName="event" value="${eventValue}" />
</p>
<div class="acSelection" acGroupName="event" >
<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="eventUri" name="eventUri" value="${eventUriValue}" />
</div>
<#-- Editor -->
<p>
<label for="editor">Editor</label>
<input class="acSelector" size="50" type="text" id="editor" name="editor" acGroupName="editor" value="${editorValue}" />
</p>
<div class="acSelection" acGroupName="editor" >
<p class="inline">
<label>Selected Editor:</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="editorUri" name="editorUri" value="${editorUriValue}" />
</div>
<#-- Publisher -->
<p>
<label for="publisher">Publisher</label>
<input class="acSelector" size="50" type="text" id="publisher" name="publisher" acGroupName="publisher" value="${publisherValue}" />
</p>
<div class="acSelection" acGroupName="publisher" >
<p class="inline">
<label>Selected Publisher:</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="publisherUri" name="publisherUri" value="${publisherUriValue}" />
</div>
<#-- Place of Publication -->
<p>
<label for="locale">Place of Publication</label>
<input size="30" type="text" id="locale" name="locale" acGroupName="locale" value="${localeValue}" />
</p>
<#-- Volume, Number and Issue -->
<p class="inline">
<label for="volume" id="volLabel">Volume</label>
<label for="number" id="nbrLabel" class="vniLabels">Number</label>
<label for="issue" id="issueLabel" class="vniLabels">Issue</label>
</p>
<p>
<input size="4" type="text" id="volume" name="volume" value="${volumeValue}" />
<input size="4" class="vniInputs" type="text" id="number" name="number" value="${numberValue}" />
<input size="4" class="vniInputs" type="text" id="issue" name="issue" value="${issueValue}" />
</p>
<#-- Start/End Pages -->
<p class="inline">
<label for="startPage" id="sPLabel">Start Page</label>
<label for="endPage" class="sepLabels">End Page</label>
</p>
<p>
<input size="4" type="text" id="startPage" name="startPage" value="${startPageValue}" />
<input size="4" class="sepInputs" type="text" id="endPage" name="endPage" value="${endPageValue}" />
</p>
<#-- Publication Date -->
<p>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#if htmlForElements?keys?seq_contains("dateTime")>
<label class="dateTime" for="pubDate">Publication Date</label><p></p>
${htmlForElements["dateTime"]} ${yearHint}
</#if>
</p>
</div> <!-- end fieldsForNewPub -->
</div> <!-- end fullViewOnly -->
<p class="submit"> <p class="submit">
<input type="hidden" name = "editKey" value="${editKey}"/> <input type="hidden" name = "editKey" value="${editKey}"/>
<input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> or </span><a class="cancel" href="${cancelUrl}">Cancel</a> <input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> or </span><a class="cancel" href="${cancelUrl}">Cancel</a>
@ -105,11 +257,19 @@
sparqlForAcFilter: '${sparqlForAcFilter}', sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}', sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${urls.base}/autocomplete?tokenize=true', acUrl: '${urls.base}/autocomplete?tokenize=true',
acTypes: {collection: 'http://purl.org/ontology/bibo/Periodical', book: 'http://purl.org/ontology/bibo/Book', conference: 'http://purl.org/NET/c4dm/event.owl#Event', event: 'http://purl.org/NET/c4dm/event.owl#Event', editor: 'http://xmlns.com/foaf/0.1/Person', publisher: 'http://xmlns.com/foaf/0.1/Organization'},
editMode: '${editMode}', editMode: '${editMode}',
defaultTypeName: 'publication', // used in repair mode to generate button text defaultTypeName: 'publication', // used in repair mode to generate button text
multipleTypeNames: {collection: 'publication', book: 'book', conference: 'conference', event: 'event', editor: 'editor', publisher: 'publisher'},
baseHref: '${urls.base}/individual?uri=' baseHref: '${urls.base}/individual?uri='
}; };
</script> </script>
<script type="text/javascript">
$(document).ready(function(){
publicationToPersonUtils.onLoad();
});
</script>
</section> </section>
</#if> </#if>
@ -121,4 +281,5 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/sm
${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/browserUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/publicationToPersonUtils.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

@ -34,3 +34,17 @@ form.customForm h4 {
span.readOnly { span.readOnly {
color: #000; color: #000;
} }
/* special styles for addPublicationToPerson.ftl
volume, number, issue fields and start/end page fields */
label.vniLabels {
padding-left: 50px;
}
input.vniInputs {
margin-left: 57px;
}
label.sepLabels {
padding-left: 31px;
}
input.sepInputs {
margin-left: 57px;
}

View file

@ -209,10 +209,9 @@ var customForm = {
// If an autocomplete selection has been made, undo it. // If an autocomplete selection has been made, undo it.
// NEED TO LINK THE TYPE SELECTOR TO THE ACSELECTOR IT'S ASSOCIATED WITH // NEED TO LINK THE TYPE SELECTOR TO THE ACSELECTOR IT'S ASSOCIATED WITH
// BECAUSE THERE COULD BE MORE THAN ON AC FIELD. ASSOCIATION IS MADE BY // BECAUSE THERE COULD BE MORE THAN ONE AC FIELD. ASSOCIATION IS MADE VIA
// SHARING THE SAME ID -- "typeSelector" -- AMONG THE SELECT AND THE INPUT // THE SPECIAL "acGroupName" ATTRIBUTE WHICH IS SHARED AMONG THE SELECT AND
// AND THE AC SELECTION DIV // THE INPUT AND THE AC SELECTION DIV.
// DO WE NEED AN IF STATEMENT AROUND THIS ****
customForm.undoAutocompleteSelection($(this)); customForm.undoAutocompleteSelection($(this));
// Reinitialize view. If no type selection in a two-step form, go back to type view; // Reinitialize view. If no type selection in a two-step form, go back to type view;
@ -246,7 +245,6 @@ var customForm = {
}, },
initAutocomplete: function(selectedObj) { initAutocomplete: function(selectedObj) {
this.getAcFilter(); this.getAcFilter();
//If specific individuals are to be filtered out, add them here //If specific individuals are to be filtered out, add them here
//to the filtering list //to the filtering list
@ -387,6 +385,9 @@ var customForm = {
var $acDiv = this.acSelections[$(selectedObj).attr('acGroupName')]; var $acDiv = this.acSelections[$(selectedObj).attr('acGroupName')];
// provides a way to monitor selection in other js files, e.g. to hide fields upon selection
$acDiv.addClass("userSelected");
// If the form has a type selector, add type name to label in add mode. In edit mode, use typeSelectorSpan // If the form has a type selector, add type name to label in add mode. In edit mode, use typeSelectorSpan
// html. The second case is an "else if" and not an else because the template may not be passing the label // html. The second case is an "else if" and not an else because the template may not be passing the label
// to the acSelection macro or it may not be using the macro at all and the label is hard-coded in the html. // to the acSelection macro or it may not be using the macro at all and the label is hard-coded in the html.
@ -403,7 +404,6 @@ var customForm = {
$acDiv.find("a.verifyMatch").attr('href', this.baseHref + uri); $acDiv.find("a.verifyMatch").attr('href', this.baseHref + uri);
$changeLink = $acDiv.find('a.changeSelection'); $changeLink = $acDiv.find('a.changeSelection');
$changeLink.unbind('click');
$changeLink.click(function() { $changeLink.click(function() {
customForm.undoAutocompleteSelection($acDiv); customForm.undoAutocompleteSelection($acDiv);
}); });
@ -430,7 +430,6 @@ var customForm = {
else { else {
$acSelectionObj = $(selectedObj); $acSelectionObj = $(selectedObj);
} }
if ( !$acSelectionObj.is(':hidden') ) {
var $acSelector = null; var $acSelector = null;
$.each(this.acSelectors, function() { $.each(this.acSelectors, function() {
if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) { if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) {
@ -439,6 +438,7 @@ var customForm = {
}); });
$acSelector.parent("p").show(); $acSelector.parent("p").show();
this.hideFields($acSelectionObj); this.hideFields($acSelectionObj);
$acSelectionObj.removeClass('userSelected');
$acSelectionObj.find("input.acUriReceiver").val(''); $acSelectionObj.find("input.acUriReceiver").val('');
$acSelectionObj.find("span").text(''); $acSelectionObj.find("span").text('');
$acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref); $acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref);
@ -449,7 +449,6 @@ var customForm = {
if ( this.acSelectOnly ) { if ( this.acSelectOnly ) {
this.disableSubmit(); this.disableSubmit();
} }
}
}, },
// Set type uri for autocomplete, and type name for labels and button text. // Set type uri for autocomplete, and type name for labels and button text.
@ -496,12 +495,15 @@ var customForm = {
// If this.acType is empty, we are either in a one-step form with no type yet selected, // If this.acType is empty, we are either in a one-step form with no type yet selected,
// or in repair mode in a two-step form with no type selected. Use the default type // or in repair mode in a two-step form with no type selected. Use the default type
// name specified in the form data. // name specified in the form data.
if ( selectedObj && this.hasMultipleTypeNames ) { if ( !selectedObj || !this.hasMultipleTypeNames ) {
var name = customForm.multipleTypeNames[$(selectedObj).attr('id')]; return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName);
return this.capitalize(name); }
else if ( selectedObj && ( $(selectedObj).attr('acGroupName') == this.typeSelector.attr('acGroupName') ) ) {
return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName);
} }
else { else {
return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName); var name = customForm.multipleTypeNames[$(selectedObj).attr('id')];
return this.capitalize(name);
} }
}, },

View file

@ -0,0 +1,139 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var publicationToPersonUtils = {
onLoad: function(mode) {
this.initObjectReferences();
this.bindEventListeners();
this.autoDateLabel.hide();
},
initObjectReferences: function() {
this.form = $('#addpublicationToPerson');
this.collection = $('#collection');
this.book = $('#book');
this.presentedAt = $('#conference');
this.proceedingsOf = $('#event');
this.editor = $('#editor');
this.editorUri = $('#editorUri');
this.publisher = $('#publisher');
this.locale = $('#locale');
this.volume = $('#volume');
this.volLabel = $('#volLabel');
this.number = $('#number');
this.nbrLabel = $('#nbrLabel');
this.issue = $('#issue');
this.issueLabel = $('#issueLabel');
this.startPage = $('#startPage');
this.sPLabel = $('#sPLabel');
this.endPage = $('#endPage');
this.ePLabel = $('#ePLabel');
this.typeSelector = $('#typeSelector');
this.autoDateLabel = null;
this.form.find('label').each(function() {
if ( $(this).attr('for') == "dateTime-year") {
publicationToPersonUtils.autoDateLabel = $(this);
}
});
this.pubTitle = $('input#title');
this.pubAcSelection = $('div#pubAcSelection');
this.fieldsForNewPub = $('#fieldsForNewPub');
this.changeLink = this.pubAcSelection.children('p').children('#changeSelection');
},
bindEventListeners: function() {
this.idCache = {};
this.typeSelector.change(function() {
publicationToPersonUtils.showFieldsForPub();
publicationToPersonUtils.displayFieldsForType();
});
// we need the delay in the next two functions to ensure the correct timing after the user
// selects the ac item. The .change handles a mouse click; .blur an arrow key and tab selection
this.pubTitle.change( function(objEvent) {
window.setTimeout('publicationToPersonUtils.hideFieldsForPub()', 180);
});
this.pubTitle.blur( function(objEvent) {
window.setTimeout('publicationToPersonUtils.hideFieldsForPub()', 180);
});
this.changeLink.click( function() {
publicationToPersonUtils.showFieldsForPub();
});
},
hideFieldsForPub: function() {
if ( this.pubAcSelection.attr('class').indexOf('userSelected') != -1 ) {
this.fieldsForNewPub.slideUp(250);
}
},
showFieldsForPub: function() {
this.fieldsForNewPub.show();
},
displayFieldsForType: function() {
// hide everything, then show what's needed based on type
// simpler in the event the user changes the type
this.collection.parent('p').hide();
this.book.parent('p').hide();
this.presentedAt.parent('p').hide();
this.proceedingsOf.parent('p').hide();
this.editor.parent('p').hide();
this.publisher.parent('p').hide();
this.locale.parent('p').hide();
this.volume.hide();
this.volLabel.hide();
this.number.hide();
this.nbrLabel.hide();
this.issue.hide();
this.issueLabel.hide();
this.startPage.parent('p').hide();
this.sPLabel.parent('p').hide();
var selectedType = this.typeSelector.find(':selected').text();
if ( selectedType == 'Academic Article' || selectedType == 'Article' || selectedType == 'Editorial Article' || selectedType == 'Review') {
this.collection.parent('p').show();
this.volume.show();
this.volLabel.show();
this.number.show();
this.nbrLabel.show();
this.issue.show();
this.issueLabel.show();
this.startPage.parent('p').show();
this.sPLabel.parent('p').show();
}
else if ( selectedType == 'Chapter' ) {
this.book.parent('p').show();
this.editor.parent('p').show();
this.publisher.parent('p').show();
this.locale.parent('p').show();
this.volume.show();
this.volLabel.show();
}
else if ( selectedType == 'Book' || selectedType == 'Edited Book' ) {
this.editor.parent('p').show();
this.publisher.parent('p').show();
this.locale.parent('p').show();
this.volume.show();
this.volLabel.show();
}
else if ( selectedType == 'Conference Paper' ) {
// this.collection.parent('p').show();
this.presentedAt.parent('p').show();
// this.startPage.parent('p').show();
// this.sPLabel.parent('p').show();
}
else if ( selectedType == 'Conference Poster' || selectedType == 'Speech') {
this.presentedAt.parent('p').show();
}
}
}

View file

@ -110,17 +110,15 @@
<label for="description">Description</label> <label for="description">Description</label>
<input size="50" type="text" id="description" name="description" value="${descriptionValue}" /> <input size="50" type="text" id="description" name="description" value="${descriptionValue}" />
</p> </p>
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<p> <p>
<label for="yearAwarded" id="yearAwarded">Year Awarded</label> <label for="yearAwardedDisplay" id="yearAwarded">Year Awarded</label>
<input size="4" type="text" id="yearAwarded" name="yearAwarded" value="${yearAwardedValue}" /> ${yearHint} <input size="4" type="text" id="yearAwardedDisplay" name="yearAwardedDisplay" value="" /> ${yearHint}
</p> </p>
<p> <p>
<h4>Years Inclusive <span class="hint">&nbsp;(e.g., for multi-year awards)</span></h4> <h4>Years Inclusive <span class="hint">&nbsp;(e.g., for multi-year awards)</span></h4>
</p> </p>
<#--Need to draw edit elements for dates here--> <#--Need to draw edit elements for dates here-->
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#if htmlForElements?keys?seq_contains("startField")> <#if htmlForElements?keys?seq_contains("startField")>
<label class="dateTime" for="startField">Start</label> <label class="dateTime" for="startField">Start</label>
${htmlForElements["startField"]} ${yearHint} ${htmlForElements["startField"]} ${yearHint}
@ -142,6 +140,13 @@
<p id="requiredLegend" class="requiredHint">* required fields</p> <p id="requiredLegend" class="requiredHint">* required fields</p>
<#-- hide the html that gets written, and use java script to pass the value between the two -->
<div class="hidden">
<#if htmlForElements?keys?seq_contains("yearAwarded")>
${htmlForElements["yearAwarded"]}
</#if>
</div>
</form> </form>
</section> </section>

View file

@ -20,7 +20,8 @@
<p class="inline"> <p class="inline">
<label>${labelValue}</label> <label>${labelValue}</label>
<span class="acSelectionInfo"></span> <span class="acSelectionInfo"></span>
<a href="${urlsBase}/individual?uri=" class="verifyMatch" title="verify match">(Verify this match)</a> <a href="${urlsBase}/individual?uri=" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p> </p>
<input class="acUriReceiver" type="hidden" id="${inputId}" name="${inputName}" value="${inputValue}" /> <input class="acUriReceiver" type="hidden" id="${inputId}" name="${inputName}" value="${inputValue}" />
<!-- Field value populated by JavaScript --> <!-- Field value populated by JavaScript -->

View file

@ -2,47 +2,284 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators; package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpSession;
import com.hp.hpl.jena.vocabulary.RDFS;
import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
public class AddPresenterRoleToPersonGenerator extends AddRoleToPersonTwoStageGenerator { public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
private static String template = "addPresenterRoleToPerson.ftl"; final static String presentationClass = vivoCore + "Presentation";
final static String roleClass = vivoCore + "PresenterRole";
final static String conferenceClass = bibo + "Conference";
final static String hasRolePred = vivoCore + "hasPresenterRole";
final static String roleOfPred = vivoCore + "presenterRoleOf";
final static String roleRealizedInPred = vivoCore + "roleRealizedIn";
final static String realizedRolePred = vivoCore + "realizedRole";
final static String includesEventPred = vivoCore + "includesEvent";
final static String eventWithinPred = vivoCore + "eventWithin";
final static String roleToInterval = vivoCore + "dateTimeInterval";
final static String intervalType = vivoCore + "DateTimeInterval";
final static String intervalToStart = vivoCore + "start";
final static String intervalToEnd = vivoCore + "end";
final static String dateTimeValueType = vivoCore + "DateTimeValue";
final static String dateTimeValue = vivoCore + "dateTime";
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
public AddPresenterRoleToPersonGenerator() {}
@Override @Override
String getTemplate() { public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
return template; HttpSession session) {
EditConfigurationVTwo conf = new EditConfigurationVTwo();
initBasics(conf, vreq);
initPropertyParameters(vreq, session, conf);
initObjectPropForm(conf, vreq);
conf.setTemplate("addPresenterRoleToPerson.ftl");
conf.setVarNameForSubject("person");
conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("role");
conf.setN3Required( Arrays.asList( n3ForNewRole,
roleLabelAssertion,
presTypeAssertion,
presLabelAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForConference, n3ForConfLabel, n3ForStart, n3ForEnd ) );
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("role", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
//uris in scope: none
//literals in scope: none
conf.setUrisOnform(Arrays.asList("presentation", "conference", "role", "presentationType"));
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "conferenceLabel", "roleLabel"));
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
conf.addSparqlForExistingUris("presentation", presentationQuery);
conf.addSparqlForExistingUris("conference", conferenceQuery);
conf.addSparqlForExistingUris("presentationType", presentationTypeQuery);
conf.addSparqlForExistingLiteral(
"startField-value", existingStartDateQuery);
conf.addSparqlForExistingLiteral(
"endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris(
"intervalNode", existingIntervalNodeQuery);
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
conf.addSparqlForExistingUris("startField-precision",
existingStartPrecisionQuery);
conf.addSparqlForExistingUris("endField-precision",
existingEndPrecisionQuery);
conf.addField( new FieldVTwo().
setName("presentation").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(presentationClass)
);
conf.addField( new FieldVTwo().
setName("presentationLabel")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("nonempty") )
);
conf.addField( new FieldVTwo().
setName("presentationType").
setOptionsType(FieldVTwo.OptionsType.CHILD_VCLASSES_WITH_PARENT).
setObjectClassUri(presentationClass).
setValidators( list("nonempty") )
);
conf.addField( new FieldVTwo().
setName("roleLabel")
.setRangeDatatypeUri( XSD.xstring.toString() ).
setValidators( list("nonempty") )
);
conf.addField( new FieldVTwo().
setName("conference").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri(conferenceClass)
);
conf.addField( new FieldVTwo().
setName("conferenceLabel").
setRangeDatatypeUri(XSD.xstring.toString() )
);
conf.addField( new FieldVTwo().setName("startField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri())
)
);
conf.addField( new FieldVTwo().setName("endField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri())
)
);
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation());
prepare(vreq, conf);
return conf;
} }
/* N3 assertions */
final static String n3ForNewRole =
"@prefix core: <" + vivoCore + "> . \n\n" +
"?person <" + hasRolePred + "> ?role . \n" +
"?role a <" + roleClass + "> . \n" +
"?role <" + roleOfPred + "> ?person . \n" +
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
"?presentation <" + realizedRolePred + "> ?role .";
@Override final static String roleLabelAssertion =
String getRoleType() { "?role <" + label + "> ?roleLabel .";
return "http://vivoweb.org/ontology/core#PresenterRole";
}
@Override final static String presLabelAssertion =
RoleActivityOptionTypes getRoleActivityTypeOptionsType() { "?presentation <" + label + "> ?presentationLabel .";
return RoleActivityOptionTypes.HARDCODED_LITERALS;
}
final static String presTypeAssertion =
"?presentation a ?presentationType .";
@Override final static String n3ForConference =
String getRoleActivityTypeObjectClassUri(VitroRequest vreq) { "?conference a <" + conferenceClass + "> . \n" +
return null; "?conference <" + includesEventPred + "> ?presentation . \n" +
} "?presentation <" + eventWithinPred + "> ?conference . ";
final static String n3ForConfLabel =
"?conference <" + label + "> ?conferenceLabel .";
//Presenter role involves hard-coded options for the "right side" of the role or activity final static String n3ForStart =
@Override "?role <" + roleToInterval + "> ?intervalNode . \n" +
protected HashMap<String, String> getRoleActivityTypeLiteralOptions() { "?intervalNode a <" + intervalType + "> . \n" +
HashMap<String, String> literalOptions = new HashMap<String, String>(); "?intervalNode <" + intervalToStart + "> ?startNode . \n" +
literalOptions.put("", "Select type"); "?startNode a <" + dateTimeValueType + "> . \n" +
literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation"); "?startNode <" + dateTimeValue + "> ?startField-value . \n" +
literalOptions.put("http://vivoweb.org/ontology/core#InvitedTalk","Invited Talk"); "?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
return literalOptions;
} final static String n3ForEnd =
"?role <" + roleToInterval + "> ?intervalNode . \n" +
"?intervalNode a <" + intervalType + "> . \n" +
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
"?endNode a <" + dateTimeValueType + "> . \n" +
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
/* Queries for editing an existing entry */
final static String roleLabelQuery =
"SELECT ?existingRoleLabel WHERE { \n" +
"?role <" + label + "> ?existingRoleLabel . }";
final static String presentationQuery =
"SELECT ?existingPresentation WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . }";
final static String presentationLabelQuery =
"SELECT ?existingPresentationLabel WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation <" + label + "> ?existingPresentationLabel . }";
final static String presentationTypeQuery =
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingPresentationType WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
final static String conferenceQuery =
"SELECT ?existingConference WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }";
final static String conferenceLabelQuery =
"SELECT ?existingConferenceLabel WHERE { \n" +
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
"?existingPresentation <" + eventWithinPred + "> ?existingConference . \n" +
"?existingConference <" + label + "> ?existingConferenceLabel . }";
final static String existingStartDateQuery =
"SELECT ?existingDateStart WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
" ?startNode a <" + dateTimeValueType +"> . \n" +
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
final static String existingEndDateQuery =
"SELECT ?existingEndDate WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n " +
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
" ?endNode a <" + dateTimeValueType + "> . \n" +
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
final static String existingIntervalNodeQuery =
"SELECT ?existingIntervalNode WHERE { \n" +
" ?role <" + roleToInterval + "> ?existingIntervalNode . \n" +
" ?existingIntervalNode a <" + intervalType + "> . }";
final static String existingStartNodeQuery =
"SELECT ?existingStartNode WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
" ?existingStartNode a <" + dateTimeValueType + "> . } ";
final static String existingEndNodeQuery =
"SELECT ?existingEndNode WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
" ?existingEndNode a <" + dateTimeValueType + "> .} ";
final static String existingStartPrecisionQuery =
"SELECT ?existingStartPrecision WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
" ?startNode a <" + dateTimeValueType + "> . \n" +
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
final static String existingEndPrecisionQuery =
"SELECT ?existingEndPrecision WHERE { \n" +
" ?role <" + roleToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
" ?endNode a <" + dateTimeValueType + "> . \n" +
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
@Override
boolean isShowRoleLabelField(){return true;}
} }

View file

@ -13,6 +13,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.vocabulary.XSD; import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
@ -21,7 +22,11 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUti
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.utils.FrontEndEditingUtils.EditMode; import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
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.configuration.validators.AntiXssValidation;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
/** /**
* On an add/new, this will show a form, on an edit/update this will skip to the * On an add/new, this will show a form, on an edit/update this will skip to the
@ -29,6 +34,25 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
*/ */
public class AddPublicationToPersonGenerator extends VivoBaseGenerator implements EditConfigurationGenerator { public class AddPublicationToPersonGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
final static String collectionClass = bibo + "Periodical";
final static String bookClass = bibo + "Document";
final static String conferenceClass = bibo + "Conference";
final static String editorClass = foaf + "Person";
final static String publisherClass = vivoCore + "Publisher";
final static String presentedAtPred = bibo + "presentedAt";
final static String localePred = vivoCore + "placeOfPublication";
final static String volumePred = bibo + "volume";
final static String numberPred = bibo + "number";
final static String issuePred = bibo + "issue";
final static String startPagePred = bibo + "pageStart";
final static String endPagePred = bibo + "pageEnd";
final static String dateTimePred = vivoCore + "dateTimeValue";
final static String dateTimeValueType = vivoCore + "DateTimeValue";
final static String dateTimeValue = vivoCore + "dateTime";
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
public AddPublicationToPersonGenerator() {}
@Override @Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) { public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
@ -89,6 +113,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
editConfiguration.setTemplate("addPublicationToPerson.ftl"); editConfiguration.setTemplate("addPublicationToPerson.ftl");
// adding person has publication validator // adding person has publication validator
editConfiguration.addValidator(new PersonHasPublicationValidator()); editConfiguration.addValidator(new PersonHasPublicationValidator());
editConfiguration.addValidator(new AntiXssValidation());
// Adding additional data, specifically edit mode // Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq); addFormSpecificData(editConfiguration, vreq);
@ -113,14 +138,32 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
} }
/***N3 strings both required and optional***/ /***N3 strings both required and optional***/
private List<String> generateN3Optional() { private List<String> generateN3Optional() {
return list(getN3ForExistingPub(), return list(getN3ForExistingPub(),
getN3ForNewPub(), getN3ForNewPub(),
getN3NewPubNameAssertion(), getN3NewPubNameAssertion(),
getN3NewPubTypeAssertion()); getN3NewPubTypeAssertion(),
getN3ForCollection(),
getN3CollectionNameAssertion(),
getN3ForBook(),
getN3BookNameAssertion(),
getN3ForConference(),
getN3ConferenceNameAssertion(),
getN3ForEvent(),
getN3EventNameAssertion(),
getN3ForEditor(),
getN3EditorNameAssertion(),
getN3ForPublisher(),
getN3PublisherNameAssertion(),
getN3ForLocaleAssertion(),
getN3ForVolumeAssertion(),
getN3ForNumberAssertion(),
getN3ForIssueAssertion(),
getN3ForStartPageAssertion(),
getN3ForEndPageAssertion(),
getN3ForDateTimeAssertion()
);
} }
@ -158,6 +201,110 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
} }
private String getN3ForCollection() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?collectionUri . \n" +
"?collectionUri a <" + collectionClass + "> . \n" +
"?collectionUri vivo:publicationVenueFor ?pubUri . ";
}
private String getN3CollectionNameAssertion() {
return "?collectionUri <" + label + "> ?collection .";
}
private String getN3ForBook() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:hasPublicationVenue ?bookUri . \n" +
"?bookUri a <" + bookClass + "> . \n" +
"?bookUri vivo:publicationVenueFor ?pubUri . ";
}
private String getN3BookNameAssertion() {
return "?bookUri <" + label + "> ?book .";
}
private String getN3ForConference() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" +
"?conferenceUri a <" + conferenceClass + "> . \n" +
"?conferenceUri vivo:includesEvent ?pubUri . ";
}
private String getN3ConferenceNameAssertion() {
return "?conferenceUri <" + label + "> ?conference .";
}
private String getN3ForEvent() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:proceedingsOf ?eventUri . \n" +
"?eventUri a <" + conferenceClass + "> . \n" +
"?eventUri vivo:hasProceedings ?pubUri . ";
}
private String getN3EventNameAssertion() {
return "?eventUri <" + label + "> ?event .";
}
private String getN3ForEditor() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:editor ?editorUri . \n" +
"?editorUri a <" + editorClass + "> . \n" +
"?editorUri vivo:editorOf ?pubUri . ";
}
private String getN3EditorNameAssertion() {
return "?editorUri <" + label + "> ?editor .";
}
private String getN3ForPublisher() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri vivo:publisher ?publisherUri . \n" +
"?publisherUri a <" + publisherClass + "> . \n" +
"?publisherUri vivo:publisherOf ?pubUri . ";
}
private String getN3PublisherNameAssertion() {
return "?publisherUri <" + label + "> ?publisher .";
}
private String getN3ForLocaleAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + localePred + "> ?locale . ";
}
private String getN3ForVolumeAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + volumePred + "> ?volume . ";
}
private String getN3ForNumberAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + numberPred + "> ?number . ";
}
private String getN3ForIssueAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + issuePred + "> ?issue . ";
}
private String getN3ForStartPageAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + startPagePred + "> ?startPage . ";
}
private String getN3ForEndPageAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + endPagePred + ">?endPage . ";
}
private String getN3ForDateTimeAssertion() {
return "@prefix vivo: <" + vivoCore + "> . \n" +
"?pubUri <" + dateTimePred + "> ?dateTimeNode . \n" +
"?dateTimeNode a <" + dateTimeValueType + "> . \n" +
"?dateTimeNode <" + dateTimeValue + "> ?dateTime-value . \n" +
"?dateTimeNode <" + dateTimePrecision + "> ?dateTime-precision . ";
}
/** Get new resources */ /** Get new resources */
private Map<String, String> generateNewResources(VitroRequest vreq) { private Map<String, String> generateNewResources(VitroRequest vreq) {
String DEFAULT_NS_TOKEN=null; //null forces the default NS String DEFAULT_NS_TOKEN=null; //null forces the default NS
@ -165,6 +312,13 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
HashMap<String, String> newResources = new HashMap<String, String>(); HashMap<String, String> newResources = new HashMap<String, String>();
newResources.put("authorshipUri", DEFAULT_NS_TOKEN); newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
newResources.put("pubUri", DEFAULT_NS_TOKEN); newResources.put("pubUri", DEFAULT_NS_TOKEN);
newResources.put("collectionUri", DEFAULT_NS_TOKEN);
newResources.put("bookUri", DEFAULT_NS_TOKEN);
newResources.put("conferenceUri", DEFAULT_NS_TOKEN);
newResources.put("eventUri", DEFAULT_NS_TOKEN);
newResources.put("editorUri", DEFAULT_NS_TOKEN);
newResources.put("publisherUri", DEFAULT_NS_TOKEN);
newResources.put("dateTimeNode", DEFAULT_NS_TOKEN);
return newResources; return newResources;
} }
@ -186,11 +340,23 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
//add role activity and roleActivityType to uris on form //add role activity and roleActivityType to uris on form
urisOnForm.add("pubUri"); urisOnForm.add("pubUri");
urisOnForm.add("pubType"); urisOnForm.add("pubType");
urisOnForm.add("collectionUri");
urisOnForm.add("bookUri");
urisOnForm.add("conferenceUri");
urisOnForm.add("eventUri");
urisOnForm.add("editorUri");
urisOnForm.add("publisherUri");
editConfiguration.setUrisOnform(urisOnForm); editConfiguration.setUrisOnform(urisOnForm);
//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("title"); literalsOnForm.add("title");
literalsOnForm.add("locale");
literalsOnForm.add("volume");
literalsOnForm.add("number");
literalsOnForm.add("issue");
literalsOnForm.add("startPage");
literalsOnForm.add("endPage");
editConfiguration.setLiteralsOnForm(literalsOnForm); editConfiguration.setLiteralsOnForm(literalsOnForm);
} }
@ -212,6 +378,25 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setTitleField(editConfiguration); setTitleField(editConfiguration);
setPubTypeField(editConfiguration); setPubTypeField(editConfiguration);
setPubUriField(editConfiguration); setPubUriField(editConfiguration);
setCollectionLabelField(editConfiguration);
setCollectionUriField(editConfiguration);
setBookLabelField(editConfiguration);
setBookUriField(editConfiguration);
setConferenceLabelField(editConfiguration);
setConferenceUriField(editConfiguration);
setEventLabelField(editConfiguration);
setEventUriField(editConfiguration);
setEditorLabelField(editConfiguration);
setEditorUriField(editConfiguration);
setPublisherLabelField(editConfiguration);
setPublisherUriField(editConfiguration);
setLocaleField(editConfiguration);
setVolumeField(editConfiguration);
setNumberField(editConfiguration);
setIssueField(editConfiguration);
setStartPageField(editConfiguration);
setEndPageField(editConfiguration);
setDateTimeField(editConfiguration);
} }
private void setTitleField(EditConfigurationVTwo editConfiguration) { private void setTitleField(EditConfigurationVTwo editConfiguration) {
@ -220,13 +405,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setName("title"). setName("title").
setValidators(list("datatype:" + stringDatatypeUri)). setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri)); setRangeDatatypeUri(stringDatatypeUri));
} }
private void setPubTypeField(EditConfigurationVTwo editConfiguration) { private void setPubTypeField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
setName("pubType"). setName("pubType").
@ -234,16 +414,154 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setLiteralOptions(getPublicationTypeLiteralOptions())); setLiteralOptions(getPublicationTypeLiteralOptions()));
} }
private void setPubUriField(EditConfigurationVTwo editConfiguration) { private void setPubUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo(). editConfiguration.addField(new FieldVTwo().
setName("pubUri"). setName("pubUri").
setObjectClassUri(personClass)); setObjectClassUri(personClass));
} }
private void setCollectionLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("collection").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setCollectionUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("collectionUri").
setObjectClassUri(collectionClass));
}
private void setBookLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("book").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setBookUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("bookUri").
setObjectClassUri(bookClass));
}
private void setConferenceLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("conference").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setConferenceUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("conferenceUri").
setObjectClassUri(conferenceClass));
}
private void setEventLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("event").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEventUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("eventUri").
setObjectClassUri(conferenceClass));
}
private void setEditorLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("editor").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEditorUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("editorUri").
setObjectClassUri(editorClass));
}
private void setPublisherLabelField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("publisher").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setPublisherUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("publisherUri").
setObjectClassUri(publisherClass));
}
private void setLocaleField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("locale").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setVolumeField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("volume").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setNumberField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("number").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setIssueField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("issue").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setStartPageField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("startPage").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setEndPageField(EditConfigurationVTwo editConfiguration) {
String stringDatatypeUri = XSD.xstring.toString();
editConfiguration.addField(new FieldVTwo().
setName("endPage").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
}
private void setDateTimeField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("dateTime").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri())
)
);
}
private List<List<String>> getPublicationTypeLiteralOptions() { private List<List<String>> getPublicationTypeLiteralOptions() {
List<List<String>> literalOptions = new ArrayList<List<String>>(); List<List<String>> literalOptions = new ArrayList<List<String>>();
@ -278,8 +596,6 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
return literalOptions; return literalOptions;
} }
//Form specific data //Form specific data
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) { public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap<String, Object> formSpecificData = new HashMap<String, Object>(); HashMap<String, Object> formSpecificData = new HashMap<String, Object>();

View file

@ -200,9 +200,9 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
"?awardReceipt <"+ descriptionPred +"> ?description ."; "?awardReceipt <"+ descriptionPred +"> ?description .";
final static String n3ForOrgAssertion = final static String n3ForOrgAssertion =
"?award <" + awardConferredByPred +"> ?org . \n" + "?awardReceipt <" + awardConferredByPred +"> ?org . \n" +
"?org a <" + orgClass + "> . \n" + "?org a <" + orgClass + "> . \n" +
"?org <" + awardConferredPred + "> ?award ."; "?org <" + awardConferredPred + "> ?awardReceipt .";
final static String orgLabelAssertion = final static String orgLabelAssertion =
"?org <"+ label + "> ?orgLabel ."; "?org <"+ label + "> ?orgLabel .";
@ -238,8 +238,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
final static String orgQuery = final static String orgQuery =
"SELECT ?existingOrg WHERE { \n" + "SELECT ?existingOrg WHERE { \n" +
" ?award <" + awardConferredByPred + "> ?existingOrg . \n" + " ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
"}"; " ?existingOrg <" + awardConferredPred + "> ?awardReceipt . }";
final static String awardReceiptLabelQuery = final static String awardReceiptLabelQuery =
"SELECT ?existingAwardReceiptLabel WHERE { \n" + "SELECT ?existingAwardReceiptLabel WHERE { \n" +

View file

@ -16,6 +16,7 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i
final static String foaf = "http://xmlns.com/foaf/0.1/"; final static String foaf = "http://xmlns.com/foaf/0.1/";
final static String type =VitroVocabulary.RDF_TYPE ; final static String type =VitroVocabulary.RDF_TYPE ;
final static String label =rdfs+"label" ; final static String label =rdfs+"label" ;
final static String bibo = "http://purl.org/ontology/bibo/";
final static String trainingClass = vivoCore+"EducationalTraining" ; final static String trainingClass = vivoCore+"EducationalTraining" ;
final static String degreeClass =vivoCore+"AcademicDegree" ; final static String degreeClass =vivoCore+"AcademicDegree" ;