updates related to autocomplete changes

This commit is contained in:
tworrall 2012-03-27 20:26:19 +00:00
parent 0eafc20767
commit f0ccf65ddd
9 changed files with 321 additions and 116 deletions

View file

@ -2,8 +2,12 @@
var advisingRelUtils = {
onLoad: function(subject) {
if ( subject ) { subjName = subject; }
onLoad: function(subject,blankSentinel) {
this.subjName = '';
if ( subject ) { this.subjName = subject; }
this.sentinel = '';
if ( blankSentinel ) { this.sentinel = blankSentinel; }
this.initObjectReferences();
this.bindEventListeners();
@ -12,35 +16,54 @@ var advisingRelUtils = {
initObjectReferences: function() {
this.form = $('#personHasAdvisingRelationship');
this.label = $('#advisingRelLabel');
this.adRelshiplabel = $('#advisingRelLabel');
this.advisee = $('#advisee');
this.subjArea = $('#SubjectArea');
this.firstName = $('#firstName');
this.lastName = $('#lastName');
this.adviseeUri = $('#adviseeUri');
this.subjAreaUri = $('#subjAreaUri');
this.saveAdviseeLabel = $('#saveAdviseeLabel');
this.adviseeAcSelection = $('div#adviseeAcSelection');
// may not need this
this.firstName.attr('disabled', '');
},
bindEventListeners: function() {
this.idCache = {};
//we want to use the advisee label in the relationship label.
// since the former gets cleared on submit in some cases, store
//the value in a hidden field and map to relationship label
this.advisee.change( function(objEvent) {
window.setTimeout('advisingRelUtils.mapAdviseeValue()', 180);
});
this.advisee.blur( function(objEvent) {
window.setTimeout('advisingRelUtils.mapAdviseeValue()', 180);
});
this.form.submit(function() {
advisingRelUtils.resolveAdviseeNames();
advisingRelUtils.buildAdvisingRelLabel();
});
},
mapAdviseeValue: function() {
if ( this.adviseeAcSelection.attr('class').indexOf('userSelected') != -1 ) {
this.saveAdviseeLabel.val(this.advisee.val());
}
},
resolveAdviseeNames: function() {
var firstName,
lastName,
name;
// If selecting an existing person, don't submit name fields
if (this.adviseeUri.val() != '') {
this.firstName.attr('disabled', 'disabled');
this.lastName.attr('disabled', 'disabled');
}
else {
if (this.adviseeUri.val() == '' || this.adviseeUri.val() == this.sentinel ) {
firstName = this.firstName.val();
lastName = this.advisee.val();
@ -50,19 +73,22 @@ var advisingRelUtils = {
}
this.advisee.val(name);
this.lastName.val(lastName);
}
else {
this.firstName.attr('disabled', 'disabled');
this.lastName.attr('disabled', 'disabled');
}
},
buildAdvisingRelLabel: function() {
if ( this.advisee.val().substring(0, 18) != "Select an existing") {
this.label.val(subjName + " advising " + this.advisee.val());
if ( this.advisee.val() != "" ) {
this.adRelshiplabel.val(this.subjName + " advising " + this.advisee.val());
}
else if ( this.subjArea.val().substring(0, 18) != "Select an existing" ) {
this.label.val(subjName + " advising in " + this.subjArea.val());
else if ( this.saveAdviseeLabel.val() != "" ){
this.adRelshiplabel.val(this.subjName + " advising " + this.saveAdviseeLabel.val());
}
else {
this.label.val(subjName + " advising relationship");
this.adRelshiplabel.val(this.subjName + " advising relationship");
}
}

View file

@ -3,14 +3,22 @@
var awardReceiptUtils = {
onLoad: function(mode, subjectName) {
onLoad: function(mode, subjectName, href) {
this.initObjectReferences();
this.bindEventListeners();
// in edit mode, copy the year awarded to the displayed input element
if ( mode == "edit" ) {
this.baseHref = href;
this.editMode = mode;
// in edit mode copy the year awarded to the displayed input element
if ( this.editMode == "edit" ) {
this.hiddenOrgDiv = $('div#hiddenOrgLabel');
this.displayedYear.val(this.yearAwarded.val());
if ( this.org.val() != '' ) {
window.setTimeout('awardReceiptUtils.hiddenOrgDiv.removeClass("hidden")', 100);
window.setTimeout('awardReceiptUtils.orgAcSelection.hide()', 100);
}
}
this.subjectName = subjectName;
$.extend(this, vitro.customFormUtils);
},
initObjectReferences: function() {
@ -18,19 +26,64 @@ var awardReceiptUtils = {
this.form = $('#personHasAwardOrHonor');
this.recLabel = $('#awardReceiptLabel');
this.award = $('#award');
this.org = $('#org');
this.yearAwarded = $('#yearAwarded-year');
this.displayedYear = $('#yearAwardedDisplay');
this.awardAcSelection = $('div#awardAcSelection');
this.orgAcSelection = $('div#orgAcSelection');
this.orgUriReceiver = $('input#orgUri');
this.changeLink = this.awardAcSelection.children('p').children('#changeSelection');
},
bindEventListeners: function() {
this.idCache = {};
// the delay ensures that the function is called after the ac selection is completed
this.award.change( function(objEvent) {
window.setTimeout('awardReceiptUtils.hideConferredBy()', 180);
});
this.award.blur( function(objEvent) {
window.setTimeout('awardReceiptUtils.hideConferredBy()', 180);
});
this.form.submit(function() {
awardReceiptUtils.setYearAwardedLabel();
awardReceiptUtils.setYearAwardedValue();
awardReceiptUtils.buildAwardReceiptLabel();
});
this.changeLink.click( function() {
awardReceiptUtils.showConferredBy();
});
},
hideConferredBy: function() {
if ( this.awardAcSelection.attr('class').indexOf('userSelected') != -1 ) {
this.org.parent('p').hide();
this.org.val('');
this.resetAcSelection(); }
},
showConferredBy: function() {
this.org.val('Select an existing Organization or create a new one.');
this.org.addClass('acSelectorWithHelpText');
this.org.parent('p').show();
if ( this.editMode == "edit" ) {
this.hiddenOrgDiv.hide();
}
this.resetAcSelection();
},
resetAcSelection: function() {
var $acSelection = $("div.acSelection[acGroupName='org']");
if ( this.orgUriReceiver.val() != '' ) {
this.hideFields($acSelection);
$acSelection.removeClass('userSelected');
$acSelection.find("span.acSelectionInfo").text('');
$acSelection.find("a.verifyMatch").attr('href', this.baseHref);
}
},
buildAwardReceiptLabel: function() {
@ -41,7 +94,7 @@ var awardReceiptUtils = {
this.recLabel.val(rdfsLabel);
},
setYearAwardedLabel: function() {
setYearAwardedValue: function() {
this.yearAwarded.val(this.displayedYear.val());
}

View file

@ -271,10 +271,10 @@ var customForm = {
//if user selected, then clear out the label since we only
//want to submit the label as value on form if it's a new label
if(inputs.length && $(inputs.eq(0)).attr(customForm.flagClearLabelForExisting)) {
//if(inputs.length) {
$("input.acSelector[acGroupName='" + groupName + "']").each(function() {
$(this).val('');
});
var $selectorInput = $("input.acSelector[acGroupName='" + groupName + "']");
var $displayInput = $("input.display[acGroupName='" + groupName + "']");
$displayInput.val($selectorInput.val());
$selectorInput.val('');
}
});
}
@ -480,7 +480,7 @@ var customForm = {
if ( $checkSelection.is(':hidden') && $checkSelection.attr('acGroupName') != $acSelectionObj.attr('acGroupName') ) {
customForm.resetAcSelection($checkSelection);
$acSelector = customForm.getAcSelector($checkSelection);
$acSelector.parent("p").show();
$acSelector.parent('p').show();
}
});
}
@ -490,7 +490,7 @@ var customForm = {
}
$acSelector = this.getAcSelector($acSelectionObj);
$acSelector.parent("p").show();
$acSelector.parent('p').show();
this.resetAcSelection($acSelectionObj);
if ( clearAcSelectorVal == true ) {
$acSelector.val('');

View file

@ -24,14 +24,16 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign adviseeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "advisee") />
<#assign adviseeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingAdvisee") />
<#assign adviseeLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "adviseeLabel") />
<#assign adviseeLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "adviseeLabelDisplay") />
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName") />
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName") />
<#assign advisingRelTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "advisingRelType") />
<#assign advisingRelLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "advisingRelLabel") />
<#assign subjAreaValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingSubjArea") />
<#assign subjAreaLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "subjAreaLabel") />
<#assign subjAreaLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "subjAreaLabelDisplay") />
<#assign degreeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "degree") />
<#assign acFilterForIndividuals = "['" + editConfiguration.subjectUri + "']" />
<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter />
@ -58,6 +60,8 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#assign adviseeLabelValue = adviseeLabelDisplayValue />
<#assign subjAreaLabelValue = subjAreaLabelDisplayValue />
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
@ -117,21 +121,23 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<input class="acSelector" size="50" type="text" acGroupName="advisee" id="advisee" name="adviseeLabel" value="${adviseeLabelValue}" >
<input size="30" type="text" id="firstName" name="firstName" value="" ><br />
<input type="hidden" id="lastName" name="lastName" value="">
<input class="display" type="hidden" acGroupName="advisee" id="adviseeDisplay" name="adviseeLabelDisplay" value="${adviseeLabelDisplayValue}" >
</p>
<div class="acSelection" acGroupName="advisee">
<div class="acSelection" acGroupName="advisee" id="adviseeAcSelection">
<p class="inline">
<label>Selected Advisee:</label>
<span class="acSelectionInfo" id="arf"></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="adviseeUri" name="advisee" value="${adviseeValue}" />
<input class="acUriReceiver" type="hidden" id="adviseeUri" name="existingAdvisee" value="${adviseeValue}" ${flagClearLabelForExisting}="true"/>
</div>
<p>
<label for="SubjectArea">Subject Area</label>
<input class="acSelector" size="50" type="text" id="SubjectArea" acGroupName="SubjectArea" name="subjAreaLabel" value="${subjAreaLabelValue}" />
<input class="display" type="hidden" id="SubjectAreaDisplay" acGroupName="SubjectArea" name="subjAreaLabelDisplay" value="${subjAreaLabelDisplayValue}" />
</p>
<div class="acSelection" acGroupName="SubjectArea">
<p class="inline">
@ -172,7 +178,8 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
${htmlForElements["endField"]} ${yearHint}
</#if>
<#--End draw elements-->
<input type="hidden" size="50" id="advisingRelLabel" name="advisingRelLabel" value="${advisingRelLabelValue}"/>
<input type="hidden" id="advisingRelLabel" name="advisingRelLabel" value="${advisingRelLabelValue}"/>
<input type="hidden" id="saveAdviseeLabel" name="saveAdviseeLabel" value="${adviseeLabelValue}"/>
<input type="hidden" id="editKey" name="editKey" value="${editKey}"/>
<p class="submit">
@ -207,7 +214,7 @@ var customFormData = {
<script type="text/javascript">
$(document).ready(function(){
advisingRelUtils.onLoad("${editConfiguration.subjectName}");
advisingRelUtils.onLoad('${editConfiguration.subjectName}', '${blankSentinel}');
});
</script>

View file

@ -13,21 +13,31 @@
<#assign editMode = "add">
</#if>
<#assign newUriSentinel = "" />
<#if editConfigurationConstants?has_content>
<#assign newUriSentinel = editConfigurationConstants["NEW_URI_SENTINEL"] />
<#--The blank sentinel indicates what value should be put in a URI when no autocomplete result has been selected.
If the blank value is non-null or non-empty, n3 editing for an existing object will remove the original relationship
if nothing is selected for that object-->
<#assign blankSentinel = "" />
<#if editConfigurationConstants?has_content && editConfigurationConstants?keys?seq_contains("BLANK_SENTINEL")>
<#assign blankSentinel = editConfigurationConstants["BLANK_SENTINEL"] />
</#if>
<#--This flag is for clearing the label field on submission for an existing object being selected from autocomplete.
Set this flag on the input acUriReceiver where you would like this behavior to occur. -->
<#assign flagClearLabelForExisting = "flagClearLabelForExisting" />
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<#--Retrieve variables needed-->
<#assign awardValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "award") />
<#assign awardValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingAward") />
<#assign awardLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "awardLabel") />
<#assign awardReceiptLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "awardReceiptLabel") />
<#assign orgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "org") />
<#assign orgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "existingOrg") />
<#assign orgLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabel") />
<#assign descriptionValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "description") />
<#assign yearAwardedValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "yearAwarded") />
<#assign yearAwardedDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "yearAwardedDisplay") />
<#assign orgLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "orgLabelDisplay") />
<#assign awardLabelDisplayValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "awardLabelDisplay") />
<#--If edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
@ -51,6 +61,8 @@
<#--Display error messages if any-->
<#if submissionErrors?has_content>
<#assign orgLabelValue = orgLabelDisplayValue />
<#assign awardLabelValue = awardLabelDisplayValue />
<section id="error-alert" role="alert">
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
<p>
@ -86,31 +98,41 @@
<p>
<label for="relatedIndLabel">Award or Honor Name ${requiredHint}</label>
<input class="acSelector" size="50" type="text" id="award" acGroupName="award" name="awardLabel" value="${awardLabelValue}">
<input class="display" type="hidden" id="awardDisplay" acGroupName="award" name="awardLabelDisplay" value="${awardLabelDisplayValue}">
</p>
<div class="acSelection" acGroupName="award">
<div class="acSelection" acGroupName="award" id="awardAcSelection">
<p class="inline">
<label>Selected Award:</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="awardUri" name="award" value="${awardValue}" />
<input class="acUriReceiver" type="hidden" id="awardUri" name="existingAward" value="${awardValue}" ${flagClearLabelForExisting}="true" />
</div>
<p>
<label for="org">Conferred by</label>
<input class="acSelector" size="50" acGroupName="org" type="text" id="org" name="orgLabel" value="${orgLabelValue}" />
<input class="display" type="hidden" id="orgDisplay" acGroupName="org" name="orgLabelDisplay" value="${orgLabelDisplayValue}" />
</p>
<div class="acSelection" acGroupName="org">
<div class="acSelection" acGroupName="org" id="orgAcSelection">
<p class="inline">
<label>Selected Conferrer:</label>
<span class="acSelectionInfo"></span>
<a href="" class="verifyMatch" title="verify match">(Verify this match</a> or
<a href="#" class="changeSelection" id="changeSelection">change selection)</a>
</p>
<input class="acUriReceiver" type="hidden" id="orgUri" name="org" value="${orgValue}" />
<input class="acUriReceiver" type="hidden" id="orgUri" name="existingOrg" value="${orgValue}" ${flagClearLabelForExisting}="true"/>
</div>
<#if editMode == "edit">
<div class="hidden" id="hiddenOrgLabel">
<p class="inline">
<label>Selected Conferrer: </label>
<span class="readOnly">${orgLabelValue}</span>
</p>
</div>
</#if>
<p>
<label for="description">Description</label>
<input size="50" type="text" id="description" name="description" value="${descriptionValue}" />
@ -118,7 +140,7 @@
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
<p>
<label for="yearAwardedDisplay" id="yearAwarded">Year Awarded</label>
<input size="4" type="text" id="yearAwardedDisplay" name="yearAwardedDisplay" value="" /> ${yearHint}
<input size="4" type="text" id="yearAwardedDisplay" name="yearAwardedDisplay" value="${yearAwardedDisplayValue}" /> ${yearHint}
</p>
<p>
<h4>Years Inclusive <span class="hint">&nbsp;(e.g., for multi-year awards)</span></h4>
@ -165,14 +187,14 @@ var customFormData = {
defaultTypeName: 'award',
multipleTypeNames: {award: 'award', org: 'organization'},
baseHref: '${urls.base}/individual?uri=',
newUriSentinel : '${newUriSentinel}'
};
blankSentinel: '${blankSentinel}',
flagClearLabelForExisting: '${flagClearLabelForExisting}'};
</script>
<script type="text/javascript">
$(document).ready(function(){
awardReceiptUtils.onLoad('${editMode}', '${editConfiguration.subjectName}');
awardReceiptUtils.onLoad('${editMode}', '${editConfiguration.subjectName}', '${urls.base}/individual?uri=');
});
</script>

View file

@ -26,7 +26,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
Map<String,String> errors = new HashMap<String,String>();
List<String> adviseeUri = urisFromForm.get("advisee");
List<String> adviseeUri = urisFromForm.get("existingAdvisee");
if (allListElementsEmpty(adviseeUri)) {
adviseeUri = null;
}

View file

@ -0,0 +1,68 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.hp.hpl.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
public class PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
private static String MISSING_AWARD_LABEL_ERROR = "You must select an existing award or type the name of a new award.";
;
@Override
public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) {
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
Map<String,String> errors = new HashMap<String,String>();
List<String> awardUri = urisFromForm.get("existingAward");
if (allListElementsEmpty(awardUri)) {
awardUri = null;
}
// If there's an awardUri, then we're done. If not, check to see if the label exists.
// If that's null, too, it's an error.
if (awardUri != null) {
return null;
}
else {
List<String> awardLabel = urisFromForm.get("awardLabel");
if (allListElementsEmpty(awardLabel)) {
awardLabel = null;
}
if (awardLabel != null) {
return null;
}
else {
errors.put("awardLabel", MISSING_AWARD_LABEL_ERROR);
}
}
return errors.size() != 0 ? errors : null;
}
private boolean allListElementsEmpty(List<String> checkList) {
if(checkList == null)
return true;
if(checkList.isEmpty()) {
return true;
}
boolean allEmpty = true;
for(String s: checkList) {
if(s.length() != 0){
allEmpty = false;
break;
}
}
return allEmpty;
}
}

View file

@ -67,8 +67,8 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
advisingRelLabelAssertion,
advisingRelTypeAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForAdviseeAssertion,
adviseeLabelAssertion,
conf.setN3Optional( Arrays.asList( n3ForNewAdviseeAssertion,
n3ForExistingAdviseeAssertion,
degreeAssertion,
firstNameAssertion,
lastNameAssertion,
@ -78,7 +78,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
n3ForEnd ) );
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("advisee", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newAdvisee", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newSubjArea", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -87,21 +87,18 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
//uris in scope: none
//literals in scope: none
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "advisee"));
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName" ));
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisee"));
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName", "subjAreaLabelDisplay", "adviseeLabelDisplay" ));
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
conf.addSparqlForExistingLiteral("adviseeLabel", adviseeLabelQuery);
// may not need these two because in edit mode the display will be an acSelection div
// conf.addSparqlForExistingLiteral("firstName", firstNameQuery);
// conf.addSparqlForExistingLiteral("lastName", lastNameQuery);
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
conf.addSparqlForExistingUris("existingSubjArea", subjAreaQuery);
conf.addSparqlForExistingUris("advisee", adviseeQuery);
conf.addSparqlForExistingUris("existingAdvisee", adviseeQuery);
conf.addSparqlForExistingUris("degree", degreeQuery);
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
@ -153,7 +150,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
);
conf.addField( new FieldVTwo().
setName("advisee").
setName("existingAdvisee").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri( adviseeClass )
);
@ -164,6 +161,18 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("subjAreaLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("adviseeLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().setName("startField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
@ -203,27 +212,27 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
final static String advisingRelTypeAssertion =
"?advisingRelationship a ?advisingRelType .";
final static String n3ForAdviseeAssertion =
"?advisingRelationship <" + adviseePred + "> ?advisee . \n" +
"?advisee <" + adviseeInPred + "> ?advisingRelationship . ";
final static String n3ForNewAdviseeAssertion =
"?advisingRelationship <" + adviseePred + "> ?newAdvisee . \n" +
"?newAdvisee <" + adviseeInPred + "> ?advisingRelationship . \n" +
"?newAdvisee <" + label + "> ?adviseeLabel . \n" +
"?newAdvisee a <" + adviseeClass + "> . ";
final static String adviseeLabelAssertion =
"?advisee <" + label + "> ?adviseeLabel .";
final static String n3ForExistingAdviseeAssertion =
"?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
"?existingAdvisee <" + adviseeInPred + "> ?advisingRelationship . ";
final static String firstNameAssertion =
"@prefix foaf: <" + foaf + "> . \n" +
"?advisee foaf:firstName ?firstName .";
"?newAdvisee foaf:firstName ?firstName .";
final static String lastNameAssertion =
"@prefix foaf: <" + foaf + "> . \n" +
"?advisee foaf:lastName ?lastName .";
"?newAdvisee foaf:lastName ?lastName .";
final static String degreeAssertion =
"?advisingRelationship <"+ degreePred +"> ?degree .";
final static String n3ForSubjAreaType =
"?subjArea a <" + subjAreaClass + "> . ";
//This is for an existing subject area
//Where we only need the existing subject area label
final static String n3ForExistingSubjAreaAssertion =
@ -273,21 +282,6 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
" ?existingAdvisee <" + label + "> ?existingAdviseeLabel . \n" +
"}";
/* May not need these
final static String firstNameQuery =
"prefix foaf: <" + foaf + "> \n" +
"SELECT ?existingFirstName WHERE { \n" +
" ?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
" ?existingAdvisee foaf:firstName ?existingFirstName . \n" +
"}";
final static String lastNameQuery =
"prefix foaf: <" + foaf + "> \n" +
"SELECT ?existingLastName WHERE { \n" +
" ?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
" ?existingAdvisee foaf:lastName ?existingLastName . \n" +
"}";
*/
final static String subjAreaQuery =
"SELECT ?existingSubjArea WHERE { \n" +
" ?advisingRelationship <" + subjAreaPred + "> ?existingSubjArea . \n" +

View file

@ -22,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasAwardOrHonorValidator;
public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
@ -65,18 +66,20 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.setN3Required( Arrays.asList( n3ForNewAwardReceipt,
awardReceiptLabelAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForReceiptToAward,
n3ForAwardToReceipt,
conf.setN3Optional( Arrays.asList( n3ForNewAwardAssertion,
n3ForExistingAwardAssertion,
descriptionAssertion,
n3ForOrgAssertion,
awardLabelAssertion,
n3ForNewOrgNewAwardAssertion,
n3ForExistingOrgNewAwardAssertion,
n3ForNewOrgExistingAwardAssertion,
n3ForExistingOrgExistingAwardAssertion,
n3ForYearAwarded,
n3ForStart,
n3ForEnd ) );
conf.addNewResource("award", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("awardReceipt", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("org", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("yearAwardedNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -85,8 +88,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
//uris in scope: none
//literals in scope: none
conf.setUrisOnform(Arrays.asList("award", "org"));
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel" ));
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
conf.addSparqlForExistingLiteral("awardReceiptLabel", awardReceiptLabelQuery);
conf.addSparqlForExistingLiteral("awardLabel", awardLabelQuery);
@ -96,8 +99,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris("award", awardQuery);
conf.addSparqlForExistingUris("org", orgQuery);
conf.addSparqlForExistingUris("existingAward", existingAwardQuery);
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
conf.addSparqlForExistingUris("yearAwardedNode",existingYearAwardedNodeQuery);
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
@ -113,13 +116,13 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
);
conf.addField( new FieldVTwo().
setName("org").
setName("existingOrg").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri( orgClass )
);
conf.addField( new FieldVTwo().
setName("award").
setName("existingAward").
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
setObjectClassUri( awardClass )
);
@ -139,7 +142,25 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.addField( new FieldVTwo().
setName("awardLabel").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("nonempty") )
setValidators( list("datatype:" + XSD.xstring.toString()))
);
conf.addField( new FieldVTwo().
setName("yearAwardedDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()))
);
conf.addField( new FieldVTwo().
setName("orgLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()))
);
conf.addField( new FieldVTwo().
setName("awardLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()))
);
conf.addField( new FieldVTwo().setName("yearAwarded").
@ -168,7 +189,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation());
conf.addValidator(new PersonHasAwardOrHonorValidator());
prepare(vreq, conf);
return conf;
}
@ -179,30 +200,43 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
"@prefix vivo: <" + vivoCore + "> . \n\n" +
"?person <" + awardReceiptPred + "> ?awardReceipt . \n" +
"?awardReceipt a <" + awardReceiptClass + "> . \n" +
"?awardReceipt <" + awardForPred + "> ?person . \n" +
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
"?award a <" + awardClass + "> . " ;
"?awardReceipt <" + awardForPred + "> ?person . " ;
final static String awardReceiptLabelAssertion =
"?awardReceipt <"+ label + "> ?awardReceiptLabel .";
final static String n3ForReceiptToAward =
"?awardReceipt <" + receiptOfPred + "> ?award .";
final static String awardLabelAssertion =
final static String n3ForNewAwardAssertion =
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
"?award a <" + awardClass + "> . \n" +
"?award <" + receiptPred + "> ?awardReceipt . \n" +
"?award <"+ label + "> ?awardLabel .";
final static String n3ForAwardToReceipt =
"?award <" + receiptPred + "> ?awardReceipt .";
final static String n3ForExistingAwardAssertion =
"?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
"?existingAward <" + receiptPred + "> ?awardReceipt . " ;
final static String descriptionAssertion =
"?awardReceipt <"+ descriptionPred +"> ?description .";
final static String n3ForOrgAssertion =
"?award <" + awardConferredByPred +"> ?org . \n" +
"?org a <" + orgClass + "> . \n" +
"?org <" + awardConferredPred + "> ?award . \n" +
"?org <"+ label + "> ?orgLabel .";
final static String n3ForExistingOrgNewAwardAssertion =
"?award <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?award . ";
final static String n3ForExistingOrgExistingAwardAssertion =
"?existingAward <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?existingAward . ";
final static String n3ForNewOrgNewAwardAssertion =
"?newOrg a <" + orgClass + "> . \n" +
"?award <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?award . \n" +
"?newOrg <"+ label + "> ?orgLabel .";
final static String n3ForNewOrgExistingAwardAssertion =
"?newOrg a <" + orgClass + "> . \n" +
"?existingAward <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?existingAward . \n" +
"?newOrg <"+ label + "> ?orgLabel .";
final static String n3ForYearAwarded =
"?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
@ -228,15 +262,16 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
/* Queries for editing an existing entry */
final static String awardQuery =
final static String existingAwardQuery =
"SELECT ?existingAward WHERE { \n" +
" ?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
"}";
final static String orgQuery =
final static String existingOrgQuery =
"SELECT ?existingOrg WHERE { \n" +
" ?award <" + awardConferredByPred + "> ?existingOrg . \n" +
" ?existingOrg <" + awardConferredPred + "> ?award . }";
" ?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
" ?existingAward<" + awardConferredByPred + "> ?existingOrg . \n" +
" ?existingOrg <" + awardConferredPred + "> ?existingAward . }";
final static String awardReceiptLabelQuery =
"SELECT ?existingAwardReceiptLabel WHERE { \n" +