From 4782e06ff3d84146ba25b4557acc7e770b9d5e15 Mon Sep 17 00:00:00 2001
From: tworrall
Date: Tue, 6 Mar 2012 14:40:12 +0000
Subject: [PATCH] custom form changes for NIHVIVO-601, 764 and 2602 plus all
related subtasks
---
.../edit/forms/addPresenterRoleToPerson.ftl | 210 ++++++++++-
.../edit/forms/addPublicationToPerson.ftl | 169 ++++++++-
.../forms/css/customFormWithAutocomplete.css | 14 +
.../forms/js/customFormWithAutocomplete.js | 64 ++--
.../edit/forms/js/publicationToPersonUtils.js | 139 +++++++
.../edit/forms/personHasAwardOrHonor.ftl | 15 +-
.../freemarker/lib/lib-vivo-form.ftl | 3 +-
.../AddPresenterRoleToPersonGenerator.java | 309 ++++++++++++++--
.../AddPublicationToPersonGenerator.java | 344 +++++++++++++++++-
.../PersonHasAwardOrHonorGenerator.java | 8 +-
.../generators/VivoBaseGenerator.java | 1 +
11 files changed, 1161 insertions(+), 115 deletions(-)
create mode 100644 productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js
diff --git a/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl
index 75753ea2..854899b1 100644
--- a/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl
+++ b/productMods/templates/freemarker/edit/forms/addPresenterRoleToPerson.ftl
@@ -1,27 +1,197 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
-<#--Two stage form for service provider role-->
-<#--
-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.
+<#-- this is in request.subject.name -->
-Optional values can be set, but each of these has default values
-set in addRoleToPersonTwoStage.ftl:
+<#-- leaving this edit/add mode code in for reference in case we decide we need it -->
-buttonText
-typeSelectorLabel
-numDateFields
-showRoleLAbelField
-roleExamples-->
+<#import "lib-vivo-form.ftl" as lvf>
+
+<#--Retrieve certain edit configuration information-->
+<#if editConfiguration.objectUri?has_content>
+ <#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 = " * " />
+<#assign yearHint = "(YYYY) " />
+
+${titleVerb} award or honor for ${editConfiguration.subjectName}
+
+<#--Display error messages if any-->
+<#if submissionErrors?has_content>
+
+
+
+ <#--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>
+ #list>
+
+
+#if>
+
+<@lvf.unsupportedBrowser urls.base />
+
+
+
+
+
+
+
+${stylesheets.add(' ')}
+${stylesheets.add(' ')}
+${stylesheets.add(' ')}
+
+${scripts.add('',
+ '',
+ '',
+ '',
+ '',
+ '')}
-<#--Variable assignments for Add Clinical Role To Person-->
-<#assign roleDescriptor = "presentation" />
-<#assign typeSelectorLabel = "presentation type" />
-<#assign buttonText = "Presentation Role" />
-<#assign roleExamples = " (e.g., Moderator, Speaker, Panelist) " />
-<#--Each of the two stage forms will include the form below-->
-<#include "addRoleToPersonTwoStage.ftl">
\ No newline at end of file
diff --git a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl
index ca01b8a3..47de932b 100644
--- a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl
+++ b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl
@@ -23,6 +23,24 @@
<#assign publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") />
<#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") />
<#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">
<#assign titleVerb="Edit">
@@ -74,11 +92,11 @@
or Cancel
@@ -105,11 +257,19 @@
sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}',
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}',
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='
};
+
+
#if>
@@ -121,4 +281,5 @@ ${stylesheets.add(' ',
'',
'',
+ '',
'')}
diff --git a/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css b/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css
index 742fb8a7..54218bd2 100644
--- a/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css
+++ b/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css
@@ -34,3 +34,17 @@ form.customForm h4 {
span.readOnly {
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;
+}
diff --git a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js
index 9b84c994..55a215ad 100644
--- a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js
+++ b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js
@@ -11,7 +11,7 @@ var customForm = {
}
this.mixIn();
this.initObjects();
- this.initPage();
+ this.initPage();
},
disableFormInUnsupportedBrowsers: function() {
@@ -54,7 +54,7 @@ var customForm = {
// the verify popup window. Although there could be multiple verifyMatch objects
// selecting one and binding the event works for all of them
this.verifyMatch = this.form.find('.verifyMatch');
-
+
// find all the acSelector input elements
this.acSelectors = [] ;
@@ -209,10 +209,9 @@ var customForm = {
// If an autocomplete selection has been made, undo it.
// 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
- // SHARING THE SAME ID -- "typeSelector" -- AMONG THE SELECT AND THE INPUT
- // AND THE AC SELECTION DIV
- // DO WE NEED AN IF STATEMENT AROUND THIS ****
+ // BECAUSE THERE COULD BE MORE THAN ONE AC FIELD. ASSOCIATION IS MADE VIA
+ // THE SPECIAL "acGroupName" ATTRIBUTE WHICH IS SHARED AMONG THE SELECT AND
+ // THE INPUT AND THE AC SELECTION DIV.
customForm.undoAutocompleteSelection($(this));
// 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) {
-
this.getAcFilter();
//If specific individuals are to be filtered out, add them here
//to the filtering list
@@ -387,6 +385,9 @@ var customForm = {
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
// 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.
@@ -403,7 +404,6 @@ var customForm = {
$acDiv.find("a.verifyMatch").attr('href', this.baseHref + uri);
$changeLink = $acDiv.find('a.changeSelection');
- $changeLink.unbind('click');
$changeLink.click(function() {
customForm.undoAutocompleteSelection($acDiv);
});
@@ -430,25 +430,24 @@ var customForm = {
else {
$acSelectionObj = $(selectedObj);
}
- if ( !$acSelectionObj.is(':hidden') ) {
- var $acSelector = null;
- $.each(this.acSelectors, function() {
- if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) {
- $acSelector = $(this);
- }
- });
- $acSelector.parent("p").show();
- this.hideFields($acSelectionObj);
- $acSelectionObj.find("input.acUriReceiver").val('');
- $acSelectionObj.find("span").text('');
- $acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref);
- $acSelector.val('');
- customForm.addAcHelpText($acSelector);
-
- //Resetting so disable submit button again for object property autocomplete
- if ( this.acSelectOnly ) {
- this.disableSubmit();
+ var $acSelector = null;
+ $.each(this.acSelectors, function() {
+ if ( $(this).attr('acGroupName') == $acSelectionObj.attr('acGroupName') ) {
+ $acSelector = $(this);
}
+ });
+ $acSelector.parent("p").show();
+ this.hideFields($acSelectionObj);
+ $acSelectionObj.removeClass('userSelected');
+ $acSelectionObj.find("input.acUriReceiver").val('');
+ $acSelectionObj.find("span").text('');
+ $acSelectionObj.find("a.verifyMatch").attr('href', this.baseHref);
+ $acSelector.val('');
+ customForm.addAcHelpText($acSelector);
+
+ //Resetting so disable submit button again for object property autocomplete
+ if ( this.acSelectOnly ) {
+ this.disableSubmit();
}
},
@@ -496,12 +495,15 @@ var customForm = {
// 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
// name specified in the form data.
- if ( selectedObj && this.hasMultipleTypeNames ) {
+ if ( !selectedObj || !this.hasMultipleTypeNames ) {
+ return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName);
+ }
+ else if ( selectedObj && ( $(selectedObj).attr('acGroupName') == this.typeSelector.attr('acGroupName') ) ) {
+ return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName);
+ }
+ else {
var name = customForm.multipleTypeNames[$(selectedObj).attr('id')];
return this.capitalize(name);
- }
- else {
- return this.acTypes ? this.typeName : this.capitalize(this.defaultTypeName);
}
},
@@ -510,7 +512,7 @@ var customForm = {
var typeText;
// First case applies on page load; second case applies when the type gets changed. With multiple
// ac fields there are cases where we also have to check if the help text is already there
- if (!$(selectedObj).val() || $(selectedObj).hasClass(this.acHelpTextClass) || $(selectedObj).val().substring(0, 18) == "Select an existing" ) {
+ if (!$(selectedObj).val() || $(selectedObj).hasClass(this.acHelpTextClass) || $(selectedObj).val().substring(0, 18) == "Select an existing" ) {
typeText = this.getTypeNameForLabels($(selectedObj));
var helpText = "Select an existing " + typeText + " or create a new one.";
//Different for object property autocomplete
diff --git a/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js
new file mode 100644
index 00000000..bd7493e2
--- /dev/null
+++ b/productMods/templates/freemarker/edit/forms/js/publicationToPersonUtils.js
@@ -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();
+ }
+ }
+
+}
\ 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 95c58aa1..7f2890b3 100644
--- a/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl
+++ b/productMods/templates/freemarker/edit/forms/personHasAwardOrHonor.ftl
@@ -110,17 +110,15 @@
Description
-
+ <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
- Year Awarded
- ${yearHint}
+ Year Awarded
+ ${yearHint}
-
Years Inclusive (e.g., for multi-year awards)
<#--Need to draw edit elements for dates here-->
- <#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#if htmlForElements?keys?seq_contains("startField")>
Start
${htmlForElements["startField"]} ${yearHint}
@@ -142,6 +140,13 @@
* required fields
+ <#-- hide the html that gets written, and use java script to pass the value between the two -->
+
+ <#if htmlForElements?keys?seq_contains("yearAwarded")>
+ ${htmlForElements["yearAwarded"]}
+ #if>
+
+
diff --git a/productMods/templates/freemarker/lib/lib-vivo-form.ftl b/productMods/templates/freemarker/lib/lib-vivo-form.ftl
index ea900a5b..23270e0b 100644
--- a/productMods/templates/freemarker/lib/lib-vivo-form.ftl
+++ b/productMods/templates/freemarker/lib/lib-vivo-form.ftl
@@ -20,7 +20,8 @@
${labelValue}
- (Verify this match)
+ (Verify this match or
+ change selection)
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 f23b4eaa..8e8f5ccc 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
@@ -2,47 +2,284 @@
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.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.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 {
-
- private static String template = "addPresenterRoleToPerson.ftl";
-
- @Override
- String getTemplate() {
- return template;
- }
+public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements
+ EditConfigurationGenerator {
-
- @Override
- String getRoleType() {
- return "http://vivoweb.org/ontology/core#PresenterRole";
- }
-
- @Override
- RoleActivityOptionTypes getRoleActivityTypeOptionsType() {
- return RoleActivityOptionTypes.HARDCODED_LITERALS;
- }
-
-
- @Override
- String getRoleActivityTypeObjectClassUri(VitroRequest vreq) {
- return null;
- }
-
+ 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
+ public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
+ 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)
+ );
- //Presenter role involves hard-coded options for the "right side" of the role or activity
- @Override
- protected HashMap getRoleActivityTypeLiteralOptions() {
- HashMap literalOptions = new HashMap();
- literalOptions.put("", "Select type");
- literalOptions.put("http://vivoweb.org/ontology/core#Presentation", "Presentation");
- literalOptions.put("http://vivoweb.org/ontology/core#InvitedTalk","Invited Talk");
- return literalOptions;
- }
+ 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") )
+ );
- @Override
- boolean isShowRoleLabelField(){return true;}
+ 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 .";
+
+ final static String roleLabelAssertion =
+ "?role <" + label + "> ?roleLabel .";
+
+ final static String presLabelAssertion =
+ "?presentation <" + label + "> ?presentationLabel .";
+
+ final static String presTypeAssertion =
+ "?presentation a ?presentationType .";
+
+ final static String n3ForConference =
+ "?conference a <" + conferenceClass + "> . \n" +
+ "?conference <" + includesEventPred + "> ?presentation . \n" +
+ "?presentation <" + eventWithinPred + "> ?conference . ";
+
+ final static String n3ForConfLabel =
+ "?conference <" + label + "> ?conferenceLabel .";
+
+ final static String n3ForStart =
+ "?role <" + roleToInterval + "> ?intervalNode . \n" +
+ "?intervalNode a <" + intervalType + "> . \n" +
+ "?intervalNode <" + intervalToStart + "> ?startNode . \n" +
+ "?startNode a <" + dateTimeValueType + "> . \n" +
+ "?startNode <" + dateTimeValue + "> ?startField-value . \n" +
+ "?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
+
+ 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 . }";
+
}
+
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 4f7fedc9..d92873b9 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
@@ -13,6 +13,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.vocabulary.XSD;
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.controller.VitroRequest;
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.FieldVTwo;
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.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
@@ -29,6 +34,25 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
*/
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
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
@@ -89,6 +113,7 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
editConfiguration.setTemplate("addPublicationToPerson.ftl");
// adding person has publication validator
editConfiguration.addValidator(new PersonHasPublicationValidator());
+ editConfiguration.addValidator(new AntiXssValidation());
// Adding additional data, specifically edit mode
addFormSpecificData(editConfiguration, vreq);
@@ -113,14 +138,32 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
}
-
-
/***N3 strings both required and optional***/
private List generateN3Optional() {
return list(getN3ForExistingPub(),
getN3ForNewPub(),
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 */
private Map generateNewResources(VitroRequest vreq) {
String DEFAULT_NS_TOKEN=null; //null forces the default NS
@@ -165,6 +312,13 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
HashMap newResources = new HashMap();
newResources.put("authorshipUri", 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;
}
@@ -186,11 +340,23 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
//add role activity and roleActivityType to uris on form
urisOnForm.add("pubUri");
urisOnForm.add("pubType");
+ urisOnForm.add("collectionUri");
+ urisOnForm.add("bookUri");
+ urisOnForm.add("conferenceUri");
+ urisOnForm.add("eventUri");
+ urisOnForm.add("editorUri");
+ urisOnForm.add("publisherUri");
editConfiguration.setUrisOnform(urisOnForm);
//activity label and role label are literals on form
List literalsOnForm = new ArrayList();
literalsOnForm.add("title");
+ literalsOnForm.add("locale");
+ literalsOnForm.add("volume");
+ literalsOnForm.add("number");
+ literalsOnForm.add("issue");
+ literalsOnForm.add("startPage");
+ literalsOnForm.add("endPage");
editConfiguration.setLiteralsOnForm(literalsOnForm);
}
@@ -212,6 +378,25 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setTitleField(editConfiguration);
setPubTypeField(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) {
@@ -220,13 +405,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setName("title").
setValidators(list("datatype:" + stringDatatypeUri)).
setRangeDatatypeUri(stringDatatypeUri));
-
}
-
-
-
-
private void setPubTypeField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("pubType").
@@ -234,16 +414,154 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
setLiteralOptions(getPublicationTypeLiteralOptions()));
}
-
-
-
-
private void setPubUriField(EditConfigurationVTwo editConfiguration) {
editConfiguration.addField(new FieldVTwo().
setName("pubUri").
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> getPublicationTypeLiteralOptions() {
List> literalOptions = new ArrayList>();
@@ -278,8 +596,6 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
return literalOptions;
}
-
-
//Form specific data
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap formSpecificData = new HashMap();
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 0925cd88..fbda832c 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
@@ -200,9 +200,9 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
"?awardReceipt <"+ descriptionPred +"> ?description .";
final static String n3ForOrgAssertion =
- "?award <" + awardConferredByPred +"> ?org . \n" +
+ "?awardReceipt <" + awardConferredByPred +"> ?org . \n" +
"?org a <" + orgClass + "> . \n" +
- "?org <" + awardConferredPred + "> ?award .";
+ "?org <" + awardConferredPred + "> ?awardReceipt .";
final static String orgLabelAssertion =
"?org <"+ label + "> ?orgLabel .";
@@ -238,8 +238,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
final static String orgQuery =
"SELECT ?existingOrg WHERE { \n" +
- " ?award <" + awardConferredByPred + "> ?existingOrg . \n" +
- "}";
+ " ?awardReceipt <" + awardConferredByPred + "> ?existingOrg . \n" +
+ " ?existingOrg <" + awardConferredPred + "> ?awardReceipt . }";
final static String awardReceiptLabelQuery =
"SELECT ?existingAwardReceiptLabel WHERE { \n" +
diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java
index 1b39efda..7bd8818a 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java
@@ -16,6 +16,7 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i
final static String foaf = "http://xmlns.com/foaf/0.1/";
final static String type =VitroVocabulary.RDF_TYPE ;
final static String label =rdfs+"label" ;
+ final static String bibo = "http://purl.org/ontology/bibo/";
final static String trainingClass = vivoCore+"EducationalTraining" ;
final static String degreeClass =vivoCore+"AcademicDegree" ;