From 07c9c7c066c1917e5165a534510c058db5db681b Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 13 Mar 2012 16:17:11 +0000 Subject: [PATCH] additional custom form changes to support multiple autocomplete fields --- .../edit/forms/addPresenterRoleToPerson.ftl | 10 +- .../edit/forms/addPublicationToPerson.ftl | 16 +- .../edit/forms/js/awardReceiptUtils.js | 5 +- .../forms/js/customFormWithAutocomplete.js | 84 ++++-- .../edit/forms/js/publicationToPersonUtils.js | 262 ++++++++++++++++-- .../edit/forms/personHasAwardOrHonor.ftl | 10 +- .../AddPresenterRoleToPersonGenerator.java | 6 +- .../AddPublicationToPersonGenerator.java | 54 ++-- .../PersonHasAwardOrHonorGenerator.java | 11 +- 9 files changed, 355 insertions(+), 103 deletions(-) diff --git a/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl index 11caa3f9..6b34ccb1 100644 --- a/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl @@ -13,6 +13,11 @@ <#assign editMode = "add"> +<#assign newUriSentinel = "" /> +<#if editConfigurationConstants?has_content> + <#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] /> + + <#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#--Retrieve variables needed--> @@ -41,7 +46,7 @@ <#assign requiredHint = " *" /> <#assign yearHint = "(YYYY)" /> -

${titleVerb} award or honor for ${editConfiguration.subjectName}

+

${titleVerb} presentation entry for ${editConfiguration.subjectName}

<#--Display error messages if any--> <#if submissionErrors?has_content> @@ -177,7 +182,8 @@ var customFormData = { editMode: '${editMode}', defaultTypeName: 'presentation', multipleTypeNames: {presentation: 'presentation', conference: 'conference'}, - baseHref: '${urls.base}/individual?uri=' + baseHref: '${urls.base}/individual?uri=', + newUriSentinel : '${newUriSentinel}' }; diff --git a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl index 47de932b..85c17834 100644 --- a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl @@ -7,6 +7,10 @@ <#--Retrieve certain edit configuration information--> <#assign editMode = editConfiguration.pageData.editMode /> +<#assign newUriSentinel = "" /> +<#if editConfigurationConstants?has_content> + <#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] /> + <#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter /> @@ -114,7 +118,7 @@

- + (Verify this match or change selection) @@ -130,7 +134,7 @@

- + (Verify this match or change selection) @@ -146,7 +150,7 @@

- + (Verify this match or change selection) @@ -170,6 +174,7 @@

+ <#-- Editor -->

@@ -261,13 +266,14 @@ editMode: '${editMode}', 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=', + newUriSentinel : '${newUriSentinel}' }; diff --git a/productMods/templates/freemarker/edit/forms/js/awardReceiptUtils.js b/productMods/templates/freemarker/edit/forms/js/awardReceiptUtils.js index 64720c1a..b804fa40 100644 --- a/productMods/templates/freemarker/edit/forms/js/awardReceiptUtils.js +++ b/productMods/templates/freemarker/edit/forms/js/awardReceiptUtils.js @@ -3,13 +3,14 @@ var awardReceiptUtils = { - onLoad: function(mode) { + onLoad: function(mode, subjectName) { this.initObjectReferences(); this.bindEventListeners(); // in edit mode, copy the year awarded to the displayed input element if ( mode == "edit" ) { this.displayedYear.val(this.yearAwarded.val()); } + this.subjectName = subjectName; }, initObjectReferences: function() { @@ -35,7 +36,7 @@ var awardReceiptUtils = { buildAwardReceiptLabel: function() { var rdfsLabel = this.award.val(); if ( this.yearAwarded.val().length ) { - rdfsLabel += " (" + this.yearAwarded.val() + ")"; + rdfsLabel += " (" + this.subjectName + ' - ' + this.yearAwarded.val() + ")"; } this.recLabel.val(rdfsLabel); }, diff --git a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js index 93bb33d5..937375da 100644 --- a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js +++ b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js @@ -82,6 +82,9 @@ var customForm = { if ( this.multipleTypeNames != undefined || this.multipleTypeNames != null ) { this.hasMultipleTypeNames = true; } + // Used with the cancel link. If the user cancels after a type selection, this check + // ensures that any a/c fields (besides the one associated with the type) will be reset + this.clearAcSelections = false; }, @@ -170,6 +173,7 @@ var customForm = { this.cancel.click(function() { customForm.clearFormData(); // clear any input and validation errors customForm.initFormTypeView(); + customForm.clearAcSelections = true; return false; }); // In one-step forms, if there is a type selection field, but no value is selected, @@ -206,6 +210,7 @@ var customForm = { this.typeSelector.change(function() { var typeVal = $(this).val(); + this.acCache = {}; // If an autocomplete selection has been made, undo it. // NEED TO LINK THE TYPE SELECTOR TO THE ACSELECTOR IT'S ASSOCIATED WITH @@ -371,16 +376,6 @@ var customForm = { customForm.acFilter = customForm.acFilter.concat(this.acFilterForIndividuals); }, - // Reset some autocomplete values after type is changed - resetAutocomplete: function(typeVal) { - // Append the type parameter to the base autocomplete url - var glue = this.baseAcUrl.indexOf('?') > -1 ? '&' : '?'; - this.acUrl = this.baseAcUrl + glue + 'type=' + typeVal; - - // Flush autocomplete cache when type is reset, since the cached values - // pertain only to the previous type. - this.acCache = {}; - }, showAutocompleteSelection: function(label, uri, selectedObj) { // hide the acSelector field and set it's value to the selected ac item @@ -428,36 +423,73 @@ var customForm = { // change the type but keep the value. If no new value has been selected, form initialization // below will correctly empty the value anyway. - // Check to see if the parameter is the typeSelector. If it is, we need to get the acSelection div - // that is associated with it. var $acSelectionObj = null; + var $acSelector = null; + + // Check to see if the parameter is the typeSelector. If it is, we need to get the acSelection div + // that is associated with it. Also, when the type is changed, we need to determine whether the user + // has selected an existing individual in the corresponding name field or typed the label for a new + // individual. If the latter, we do not want to clear the value on type change. The clearAcSelectorVal + // boolean controls whether the acSelector value gets cleared. + + var clearAcSelectorVal = true; + if ( $(selectedObj).attr('id') == "typeSelector" ) { $acSelectionObj = customForm.acSelections[$(selectedObj).attr('acGroupName')]; + if ( $acSelectionObj.is(':hidden') ) { + clearAcSelectorVal = false; + } + // if the type is being changed after a cancel, any additional a/c fields that may have been set + // by the user should be "undone". Only loop through these if this is not the initial type selection + if ( customForm.clearAcSelections ) { + $.each(customForm.acSelections, function(i, acS) { + var $checkSelection = customForm.acSelections[i]; + if ( $checkSelection.is(':hidden') && $checkSelection.attr('acGroupName') != $acSelectionObj.attr('acGroupName') ) { + customForm.resetAcSelection($checkSelection); + $acSelector = customForm.getAcSelector($checkSelection); + $acSelector.parent("p").show(); + } + }); + } } else { $acSelectionObj = $(selectedObj); } - var $acSelector = null; - $.each(this.acSelectors, function() { - if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) { - $acSelector = $(this); - } - }); + + $acSelector = this.getAcSelector($acSelectionObj); $acSelector.parent("p").show(); - this.hideFields($acSelectionObj); - $acSelectionObj.removeClass('userSelected'); - //Might be useful here to replace the uri with the default "new uri needs to be created" value - //$acSelectionObj.find("input.acUriReceiver").val(''); - $acSelectionObj.find("input.acUriReceiver").val(customForm.newUriSentinel); - $acSelectionObj.find("span").text(''); - $acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref); - $acSelector.val(''); + this.resetAcSelection($acSelectionObj); + if ( clearAcSelectorVal == true ) { + $acSelector.val(''); + } customForm.addAcHelpText($acSelector); //Resetting so disable submit button again for object property autocomplete if ( this.acSelectOnly ) { this.disableSubmit(); } + this.clearAcSelections = false; + }, + + // this is essentially a subtask of undoAutocompleteSelection + resetAcSelection: function(selectedObj) { + this.hideFields($(selectedObj)); + $(selectedObj).removeClass('userSelected'); + $(selectedObj).find("input.acUriReceiver").val(this.newUriSentinel); + $(selectedObj).find("span").text(''); + $(selectedObj).find("a.verifyMatch").attr('href', this.baseHref); + }, + + // loops through the array of acSelector fields and returns the one + // associated with the selected object + getAcSelector: function(selectedObj){ + var $selector = null + $.each(this.acSelectors, function() { + if ( $(this).attr('acGroupName') == $(selectedObj).attr('acGroupName') ) { + $selector = $(this); + } + }); + return $selector; }, // Set type uri for autocomplete, and type name for labels and button text. diff --git a/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js index bd7493e2..4ac3c178 100644 --- a/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js +++ b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js @@ -3,11 +3,13 @@ var publicationToPersonUtils = { - onLoad: function(mode) { + onLoad: function(href, sentinel) { this.initObjectReferences(); this.bindEventListeners(); - this.autoDateLabel.hide(); + this.baseHref = href; + this.newUriSentinel = sentinel; + $.extend(this, vitro.customFormUtils); }, initObjectReferences: function() { @@ -32,6 +34,8 @@ var publicationToPersonUtils = { this.endPage = $('#endPage'); this.ePLabel = $('#ePLabel'); this.typeSelector = $('#typeSelector'); + this.cancel = $('.cancel'); + this.fullViewOnly = $('.fullViewOnly'); this.autoDateLabel = null; this.form.find('label').each(function() { @@ -50,8 +54,13 @@ var publicationToPersonUtils = { this.idCache = {}; this.typeSelector.change(function() { + // controls the fieldsForNewPub div. If the user selects an existing pub/title, + // this div gets hidden. publicationToPersonUtils.showFieldsForPub(); - publicationToPersonUtils.displayFieldsForType(); + // after a cancel, the first reset of the type selector resulted in all fields being displayed. + // by delaying this function just slightly, the timing issue between this js and the + // customFormWithAutocomplete js is resolved + window.setTimeout('publicationToPersonUtils.displayFieldsForType()', 60); }); // we need the delay in the next two functions to ensure the correct timing after the user @@ -67,6 +76,7 @@ var publicationToPersonUtils = { this.changeLink.click( function() { publicationToPersonUtils.showFieldsForPub(); }); + }, hideFieldsForPub: function() { @@ -76,12 +86,24 @@ var publicationToPersonUtils = { }, showFieldsForPub: function() { - this.fieldsForNewPub.show(); + this.fieldsForNewPub.show(); }, - displayFieldsForType: function() { - // hide everything, then show what's needed based on type - // simpler in the event the user changes the type + resetAcSelection: function(groupName) { + var $acSelection = this.form.find('div.acSelection').attr('acGroupName', groupName); + this.hideFields($acSelection); + $acSelection.removeClass('userSelected'); + $acSelection.find("input.acUriReceiver").val(this.newUriSentinel); + $acSelection.find("span").text(''); + $acSelection.find("a.verifyMatch").attr('href', this.baseHref); + }, + + getAcUriReceiverVal: function(groupName) { + var $collectionDiv = this.form.find('div.acSelection').attr('acGroupName', groupName); + return $collectionDiv.find('input#'+ groupName + 'Uri').val(); + }, + + hideAllFields: function() { this.collection.parent('p').hide(); this.book.parent('p').hide(); this.presentedAt.parent('p').hide(); @@ -97,10 +119,21 @@ var publicationToPersonUtils = { this.issueLabel.hide(); this.startPage.parent('p').hide(); this.sPLabel.parent('p').hide(); - + }, + + displayFieldsForType: function() { + // hide everything, then show what's needed based on type + // simpler in the event the user changes the type + this.hideAllFields(); var selectedType = this.typeSelector.find(':selected').text(); + if ( selectedType == 'Academic Article' || selectedType == 'Article' || selectedType == 'Editorial Article' || selectedType == 'Review') { - this.collection.parent('p').show(); + // if the user has changed type, keep any relevant values and display the + // acSelection as appropriate + var ckForVal = this.getAcUriReceiverVal('collection'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.collection.parent('p').show(); + } this.volume.show(); this.volLabel.show(); this.number.show(); @@ -109,31 +142,222 @@ var publicationToPersonUtils = { this.issueLabel.show(); this.startPage.parent('p').show(); this.sPLabel.parent('p').show(); + + // if the user has changed type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) { + alert(this.book.val()); + this.book.val(''); + this.resetAcSelection('book'); + alert(this.book.val()); + } + if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) { + this.editor.val(''); + this.resetAcSelection('editor'); + } + if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) { + this.publisher.val(''); + this.resetAcSelection('publisher'); + } + if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) { + this.presentedAt.val(''); + this.resetAcSelection('conference'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + + this.locale.val(''); } else if ( selectedType == 'Chapter' ) { - this.book.parent('p').show(); - this.editor.parent('p').show(); - this.publisher.parent('p').show(); + // if the user has changed type, keep any relevant values and display the + // acSelection as appropriate + var ckForVal = this.getAcUriReceiverVal('book'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.book.parent('p').show(); + } + ckForVal = this.getAcUriReceiverVal('editor'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.editor.parent('p').show(); + } + ckForVal = this.getAcUriReceiverVal('publisher'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.publisher.parent('p').show(); + } + this.locale.parent('p').show(); this.volume.show(); this.volLabel.show(); + + // if the user is changing type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) { + this.collection.val(''); + this.resetAcSelection('collection'); + } + if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) { + this.presentedAt.val(''); + this.resetAcSelection('conference'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + + this.number.val(''); + this.issue.val(''); + this.startPage.val(''); + this.endPage.val(''); } else if ( selectedType == 'Book' || selectedType == 'Edited Book' ) { - this.editor.parent('p').show(); - this.publisher.parent('p').show(); + // if the user has changed type, keep any relevant values and display the + // acSelection as appropriate + var ckForVal = this.getAcUriReceiverVal('editor'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.editor.parent('p').show(); + } + ckForVal = this.getAcUriReceiverVal('publisher'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.publisher.parent('p').show(); + } + this.locale.parent('p').show(); this.volume.show(); this.volLabel.show(); + + // if the user is changing type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) { + this.collection.val(''); + this.resetAcSelection('collection'); + } + if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) { + this.presentedAt.val(''); + this.resetAcSelection('conference'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + + this.number.val(''); + this.issue.val(''); + this.startPage.val(''); + this.endPage.val(''); } 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(); + // if the user has changed type, keep any relevant values and display the + // acSelection as appropriate + var ckForVal = this.getAcUriReceiverVal('collection'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.collection.parent('p').show(); + } + ckForVal = this.getAcUriReceiverVal('conference'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.presentedAt.parent('p').show(); + } + + this.startPage.parent('p').show(); + this.sPLabel.parent('p').show(); + + // if the user is changing type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) { + this.book.val(''); + this.resetAcSelection('book'); + } + if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) { + this.editor.val(''); + this.resetAcSelection('editor'); + } + if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) { + this.publisher.val(''); + this.resetAcSelection('publisher'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + + this.number.val(''); + this.issue.val(''); + this.startPage.val(''); + this.endPage.val(''); } else if ( selectedType == 'Conference Poster' || selectedType == 'Speech') { - this.presentedAt.parent('p').show(); + // if the user has changed type, keep any relevant values and display the + // acSelection as appropriate + var ckForVal = this.getAcUriReceiverVal('conference'); + if ( ckForVal == '' || ckForVal == this.newUriSentinel ) { + this.presentedAt.parent('p').show(); + } + + // if the user is changing type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) { + this.collection.val(''); + this.resetAcSelection('collection'); + } + if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) { + this.book.val(''); + this.resetAcSelection('book'); + } + if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) { + this.editor.val(''); + this.resetAcSelection('editor'); + } + if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) { + this.publisher.val(''); + this.resetAcSelection('publisher'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + + this.number.val(''); + this.issue.val(''); + this.startPage.val(''); + this.endPage.val(''); } + else { + + // if the user is changing type, ensure that irrelevant fields are cleared + // and reset an acSelection divs + if ( this.collection.val() != '' && this.collection.val().substring(0, 18) != "Select an existing" ) { + this.collection.val(''); + this.resetAcSelection('collection'); + } + if ( this.book.val() != '' && this.book.val().substring(0, 18) != "Select an existing" ) { + this.book.val(''); + this.resetAcSelection('book'); + } + if ( this.editor.val() != '' && this.editor.val().substring(0, 18) != "Select an existing" ) { + this.editor.val(''); + this.resetAcSelection('editor'); + } + if ( this.publisher.val() != '' && this.publisher.val().substring(0, 18) != "Select an existing" ) { + this.publisher.val(''); + this.resetAcSelection('publisher'); + } + if ( this.proceedingsOf.val() != '' && this.proceedingsOf.val().substring(0, 18) != "Select an existing" ) { + this.proceedingsOf.val(''); + this.resetAcSelection('event'); + } + if ( this.presentedAt.val() != '' && this.presentedAt.val().substring(0, 18) != "Select an existing" ) { + this.presentedAt.val(''); + this.resetAcSelection('conference'); + } + + this.volume.val(''); + this.number.val(''); + this.issue.val(''); + this.startPage.val(''); + this.endPage.val(''); + + } + } } \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl b/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl index 7f2890b3..394b9735 100644 --- a/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl @@ -13,6 +13,11 @@ <#assign editMode = "add"> +<#assign newUriSentinel = "" /> +<#if editConfigurationConstants?has_content> + <#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] /> + + <#assign htmlForElements = editConfiguration.pageData.htmlForElements /> <#--Retrieve variables needed--> @@ -159,14 +164,15 @@ var customFormData = { editMode: '${editMode}', defaultTypeName: 'award', multipleTypeNames: {award: 'award', org: 'organization'}, - baseHref: '${urls.base}/individual?uri=' + baseHref: '${urls.base}/individual?uri=', + newUriSentinel : '${newUriSentinel}' }; diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java index 8e8f5ccc..995dd349 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPresenterRoleToPersonGenerator.java @@ -64,7 +64,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme roleLabelAssertion, presTypeAssertion, presLabelAssertion ) ); - conf.setN3Optional( Arrays.asList( n3ForConference, n3ForConfLabel, n3ForStart, n3ForEnd ) ); + conf.setN3Optional( Arrays.asList( n3ForConference, n3ForStart, n3ForEnd ) ); conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE); conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE); @@ -178,9 +178,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme final static String n3ForConference = "?conference a <" + conferenceClass + "> . \n" + "?conference <" + includesEventPred + "> ?presentation . \n" + - "?presentation <" + eventWithinPred + "> ?conference . "; - - final static String n3ForConfLabel = + "?presentation <" + eventWithinPred + "> ?conference . \n" + "?conference <" + label + "> ?conferenceLabel ."; final static String n3ForStart = diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPublicationToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPublicationToPersonGenerator.java index d92873b9..45a7ab14 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPublicationToPersonGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddPublicationToPersonGenerator.java @@ -145,17 +145,11 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement getN3NewPubNameAssertion(), getN3NewPubTypeAssertion(), getN3ForCollection(), - getN3CollectionNameAssertion(), getN3ForBook(), - getN3BookNameAssertion(), getN3ForConference(), - getN3ConferenceNameAssertion(), getN3ForEvent(), - getN3EventNameAssertion(), getN3ForEditor(), - getN3EditorNameAssertion(), getN3ForPublisher(), - getN3PublisherNameAssertion(), getN3ForLocaleAssertion(), getN3ForVolumeAssertion(), getN3ForNumberAssertion(), @@ -205,66 +199,48 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement 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 ."; + "?collectionUri vivo:publicationVenueFor ?pubUri . \n" + + "?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 ."; + "?bookUri vivo:publicationVenueFor ?pubUri . \n " + + "?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 ."; + "?conferenceUri vivo:includesEvent ?pubUri . \n" + + "?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 ."; + "?eventUri vivo:hasProceedings ?pubUri . \n" + + "?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 ."; + "?editorUri vivo:editorOf ?pubUri . \n" + + "?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 ."; + "?publisherUri vivo:publisherOf ?pubUri . \n" + + "?publisherUri <" + label + "> ?publisher ."; } private String getN3ForLocaleAssertion() { @@ -351,6 +327,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement //activity label and role label are literals on form List literalsOnForm = new ArrayList(); literalsOnForm.add("title"); + literalsOnForm.add("collection"); + literalsOnForm.add("book"); + literalsOnForm.add("conference"); + literalsOnForm.add("event"); + literalsOnForm.add("editor"); + literalsOnForm.add("publisher"); literalsOnForm.add("locale"); literalsOnForm.add("volume"); literalsOnForm.add("number"); diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAwardOrHonorGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAwardOrHonorGenerator.java index fbda832c..e9d9b738 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAwardOrHonorGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasAwardOrHonorGenerator.java @@ -69,7 +69,6 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements n3ForAwardToReceipt, descriptionAssertion, n3ForOrgAssertion, - orgLabelAssertion, awardLabelAssertion, n3ForYearAwarded, n3ForStart, @@ -200,11 +199,9 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements "?awardReceipt <"+ descriptionPred +"> ?description ."; final static String n3ForOrgAssertion = - "?awardReceipt <" + awardConferredByPred +"> ?org . \n" + + "?award <" + awardConferredByPred +"> ?org . \n" + "?org a <" + orgClass + "> . \n" + - "?org <" + awardConferredPred + "> ?awardReceipt ."; - - final static String orgLabelAssertion = + "?org <" + awardConferredPred + "> ?award . \n" + "?org <"+ label + "> ?orgLabel ."; final static String n3ForYearAwarded = @@ -238,8 +235,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements final static String orgQuery = "SELECT ?existingOrg WHERE { \n" + - " ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" + - " ?existingOrg <" + awardConferredPred + "> ?awardReceipt . }"; + " ?award <" + awardConferredByPred + "> ?existingOrg . \n" + + " ?existingOrg <" + awardConferredPred + "> ?award . }"; final static String awardReceiptLabelQuery = "SELECT ?existingAwardReceiptLabel WHERE { \n" +