Adding user defined concept generators and updating publication and authors generators/forms. Adding validation to addAuthorsToInformationResource
This commit is contained in:
parent
57dfb86262
commit
c5743ce2fa
9 changed files with 384 additions and 103 deletions
|
@ -2,6 +2,8 @@
|
||||||
<#import "lib-vivo-form.ftl" as lvf>
|
<#import "lib-vivo-form.ftl" as lvf>
|
||||||
|
|
||||||
<#assign existingConcepts = editConfiguration.pageData.existingConcepts/>
|
<#assign existingConcepts = editConfiguration.pageData.existingConcepts/>
|
||||||
|
<#assign userDefinedConceptUrl = editConfiguration.pageData.userDefinedConceptUrl/>
|
||||||
|
|
||||||
<#--If edit submission exists, then retrieve validation errors if they exist-->
|
<#--If edit submission exists, then retrieve validation errors if they exist-->
|
||||||
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
|
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
|
||||||
<#assign submissionErrors = editSubmission.validationErrors/>
|
<#assign submissionErrors = editSubmission.validationErrors/>
|
||||||
|
@ -97,7 +99,7 @@
|
||||||
<!-- Field value populated by JavaScript -->
|
<!-- Field value populated by JavaScript -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="" > Can't find the concept you want? Create your own.</a>
|
<a href="${userDefinedConceptUrl}" > Can't find the concept you want? Create your own.</a>
|
||||||
|
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<input type="submit" id="submit" name="submit" value="Add Term" />
|
<input type="submit" id="submit" name="submit" value="Add Term" />
|
||||||
|
|
|
@ -9,7 +9,15 @@
|
||||||
<#assign existingAuthorInfo = editConfiguration.pageData.existingAuthorInfo />
|
<#assign existingAuthorInfo = editConfiguration.pageData.existingAuthorInfo />
|
||||||
<#assign rankPredicate = editConfiguration.pageData.rankPredicate />
|
<#assign rankPredicate = editConfiguration.pageData.rankPredicate />
|
||||||
|
|
||||||
<#--Values from edit configuration to populate fields -->
|
<#--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>
|
||||||
|
|
||||||
|
<#--Submission values for these fields may be returned if user did not fill out fields for new person-->
|
||||||
|
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName") />
|
||||||
|
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName") />
|
||||||
|
<#assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName") />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +35,20 @@
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
|
<#if submissionErrors?has_content>
|
||||||
|
<section id="error-alert" role="alert" class="validationError">
|
||||||
|
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||||
|
<p>
|
||||||
|
<#--below shows examples of both printing out all error messages and checking the error message for a specific field-->
|
||||||
|
<#list submissionErrors?keys as errorFieldName>
|
||||||
|
${errorFieldName} : ${submissionErrors[errorFieldName]} <br/>
|
||||||
|
</#list>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
<ul id="authorships" ${ulClass}>
|
<ul id="authorships" ${ulClass}>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -89,18 +111,18 @@
|
||||||
should be visible even when first name/middle name are not, the parents should be separate for each field-->
|
should be visible even when first name/middle name are not, the parents should be separate for each field-->
|
||||||
<p class="inline">
|
<p class="inline">
|
||||||
<label for="lastName">Last name <span class='requiredHint'> *</span></label>
|
<label for="lastName">Last name <span class='requiredHint'> *</span></label>
|
||||||
<input class="acSelector" size="35" type="text" id="lastName" name="lastName" value="" role="input" />
|
<input class="acSelector" size="35" type="text" id="lastName" name="lastName" value="${lastNameValue}" role="input" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="inline">
|
<p class="inline">
|
||||||
<label for="firstName">First name ${requiredHint} ${initialHint}</label>
|
<label for="firstName">First name ${requiredHint} ${initialHint}</label>
|
||||||
<input size="20" type="text" id="firstName" name="firstName" value="" role="input" />
|
<input size="20" type="text" id="firstName" name="firstName" value="${firstNameValue}" role="input" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<p class="inline">
|
<p class="inline">
|
||||||
<label for="middleName">Middle name <span class='hint'>(initial okay)</span></label>
|
<label for="middleName">Middle name <span class='hint'>(initial okay)</span></label>
|
||||||
<input size="20" type="text" id="middleName" name="middleName" value="" role="input" />
|
<input size="20" type="text" id="middleName" name="middleName" value="${middleNameValue}" role="input" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<input type="hidden" id="label" name="label" value="" role="input" /> <!-- Field value populated by JavaScript -->
|
<input type="hidden" id="label" name="label" value="" role="input" /> <!-- Field value populated by JavaScript -->
|
||||||
|
|
|
@ -4,61 +4,74 @@
|
||||||
|
|
||||||
<#import "lib-vivo-form.ftl" as lvf>
|
<#import "lib-vivo-form.ftl" as lvf>
|
||||||
|
|
||||||
<#if editConfig.object?has_content>
|
<#--Retrieve certain edit configuration information-->
|
||||||
<#assign editMode = "edit">
|
<#assign editMode = editConfiguration.pageData.editMode />
|
||||||
<#else>
|
<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter />
|
||||||
<#assign editMode = "add">
|
|
||||||
|
<#--assign htmlForElements = editConfiguration.pageData.htmlForElements ! {}/-->
|
||||||
|
|
||||||
|
<#--drop down options for a field are included in page data with that field name-->
|
||||||
|
<#assign pubTypeLiteralOptions = editConfiguration.pageData.pubType />
|
||||||
|
<#--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>
|
||||||
|
|
||||||
|
<#--In case of submission error, may already have publication type or title - although latter not likely, but storing values to be on safe side-->
|
||||||
|
<#assign publicationTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "pubType") />
|
||||||
|
<#assign titleValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "title") />
|
||||||
<#if editMode == "edit">
|
<#if editMode == "edit">
|
||||||
<#assign titleVerb="Edit">
|
<#assign titleVerb="Edit">
|
||||||
<#assign submitButtonText="Edit Publication">
|
<#assign submitButtonText="Edit Publication">
|
||||||
<#assign disabledVal="disabled">
|
<#assign disabledVal="disabled">
|
||||||
<#else>
|
<#else>
|
||||||
<#assign titleVerb="Create">
|
<#assign titleVerb="Create">
|
||||||
<#assign submitButtonText="Create Publication">
|
<#assign submitButtonText="Publication">
|
||||||
<#assign disabledVal=""/>
|
<#assign disabledVal=""/>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
<h2>${titleVerb} ${roleDescriptor} entry for ${subjectName}</h2>
|
<h2>${titleVerb} publication entry for ${editConfiguration.subjectName}</h2>
|
||||||
|
|
||||||
<#if errorTitleFieldIsEmpty??>
|
<#if submissionErrors?has_content>
|
||||||
<#assign errorMessage = "Enter a title for the publication." />
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
<#if errorMessage?has_content>
|
|
||||||
<section id="error-alert" role="alert">
|
<section id="error-alert" role="alert">
|
||||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||||
<p>${errorMessage}</p>
|
<p>
|
||||||
|
<#--below shows examples of both printing out all error messages and checking the error message for a specific field-->
|
||||||
|
<#list submissionErrors?keys as errorFieldName>
|
||||||
|
${errorFieldName} : ${submissionErrors[errorFieldName]}
|
||||||
|
</#list>
|
||||||
|
|
||||||
|
</p>
|
||||||
</section>
|
</section>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
|
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
|
||||||
<#assign yearHint = "<span class='hint'>(YYYY)</span>" />
|
<#assign yearHint = "<span class='hint'>(YYYY)</span>" />
|
||||||
|
|
||||||
<#if editMode = “ERROR”>
|
<#if editMode = "error">
|
||||||
<div>This form is unable to handle the editing of this position because it is associated with
|
<div>This form is unable to handle the editing of this position because it is associated with
|
||||||
multiple Position individuals.</div>
|
multiple Position individuals.</div>
|
||||||
<#else>
|
<#else>
|
||||||
|
|
||||||
<section id="addPublicationToPerson" role="region">
|
<section id="addPublicationToPerson" role="region">
|
||||||
|
|
||||||
<@lvf.unsupportedBrowser>
|
<@lvf.unsupportedBrowser urls.base/>
|
||||||
|
<form id="addpublicationToPerson" class="customForm noIE67" action="${submitUrl}" role="add/edit publication">
|
||||||
<form id="addpublicationToPerson" class="customForm noIE67" action="${submitUrl}" role="add/edit publication">
|
|
||||||
|
|
||||||
|
<#--TODO: Check if possible to have existing publication options here in order to select-->
|
||||||
<p class="inline"><label for="typeSelector">Publication Type ${requiredHint}</label>
|
<p class="inline"><label for="typeSelector">Publication Type ${requiredHint}</label>
|
||||||
<select id="typeSelector" name="roleActivityType" disabled="${disabledVal}" >
|
<select id="typeSelector" name="pubType" <#if (disabledVal?length > 0)>disabled="${disabledVal}"</#if> >
|
||||||
<option value="" selected="selected">Select one</option>
|
<option value="" <#if (publicationTypeValue?length = 0)>selected="selected"</#if>>Select one</option>
|
||||||
<#list rangeOptionKeys as key>
|
<#list pubTypeLiteralOptions?keys as key>
|
||||||
<opton value="${key}"
|
<option value="${key}" <#if (publicationTypeValue = key)>selected="selected"</#if>>${pubTypeLiteralOptions[key]}</option>
|
||||||
<#if editConfiguration.objectUri?has_contant && editConfiguration.object.Uri = key>selected</#if>
|
|
||||||
</#list>
|
</#list>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="relatedIndLabel">Title ${requiredHint}</label>
|
<label for="relatedIndLabel">Title ${requiredHint}</label>
|
||||||
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="publicationLabel" disabled="${disabledVal}" value="${???}" />
|
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="title"
|
||||||
|
<#if (disabledVal?length > 0)>disabled="${disabledVal}"</#if> value="" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="acSelection">
|
<div class="acSelection">
|
||||||
|
@ -67,20 +80,21 @@
|
||||||
<span class="acSelectionInfo"></span>
|
<span class="acSelectionInfo"></span>
|
||||||
<a href="/vivo/individual?uri=" class="verifyMatch">(Verify this match)</a>
|
<a href="/vivo/individual?uri=" class="verifyMatch">(Verify this match)</a>
|
||||||
</p>
|
</p>
|
||||||
<input class="acUriReceiver" type="hidden" id="${roleActivityUri}" name="publication" value="" />
|
<input class="acUriReceiver" type="hidden" id="pubUri" name="pubUri" value="" />
|
||||||
|
|
||||||
<input class="acLabelReceiver" type="hidden" id="existingPublicationLabel" name="existingPublicationLabel" value="${grantLabel}" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<#--Commenting out as unclear whether this contains any dates to begin with
|
||||||
|
<#if htmlForElements?keys?seq_contains("dateField")>
|
||||||
|
<label class="dateTime" for="dateField">Publication Date ${yearHint}</label>
|
||||||
|
${htmlForElements["dateField"]} ${yearHint}
|
||||||
|
</#if>
|
||||||
|
-->
|
||||||
|
|
||||||
<label for="startField">Publication Date ${yearHint}</label>
|
|
||||||
|
|
||||||
<fieldset class="dateTime">
|
|
||||||
<input class="text-field" name="dateField-year" id="dateField-year" type="text" value="${dateTime}" size="4" maxlength="4" />
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<input type="hidden" name = "editKey" value="${???}"/>
|
<input type="hidden" name = "editKey" value="${editKey}"/>
|
||||||
<input type="submit" id="submit" value="editConfiguration.submitLabel"/><span class="or"> or </span><a class="cancel" href="${editConfiguration.cancelUrl}">Cancel</a>
|
<input type="submit" id="submit" value="${submitButtonText}"/><span class="or"> or </span><a class="cancel" href="${cancelUrl}">Cancel</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||||
|
@ -89,8 +103,6 @@
|
||||||
|
|
||||||
<#assign sparqlQueryUrl = "/ajax/sparqlQuery" >
|
<#assign sparqlQueryUrl = "/ajax/sparqlQuery" >
|
||||||
|
|
||||||
<#assign sparqlForAcFilter = "PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri . ?authorshipUri core:linkedInformationResource ?pubUri .}"
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var customFormData = {
|
var customFormData = {
|
||||||
sparqlForAcFilter: '${sparqlForAcFilter}',
|
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||||
|
@ -101,19 +113,19 @@
|
||||||
defaultTypeName: 'publication' // used in repair mode to generate button text
|
defaultTypeName: 'publication' // used in repair mode to generate button text
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
</#if>
|
||||||
|
|
||||||
<#/if>
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
||||||
|
|
||||||
|
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
||||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
|
||||||
|
|
||||||
|
|
||||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
|
|
||||||
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
||||||
|
|
||||||
|
<#-- '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
|
||||||
|
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
|
||||||
|
-->
|
|
@ -0,0 +1,66 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#--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>
|
||||||
|
|
||||||
|
<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter />
|
||||||
|
<#assign returnUrl = ""/>
|
||||||
|
|
||||||
|
<h2>Add Your Own Concept</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<form id="addUserDefinedConceptForm" class="editForm" action = "${submitUrl}" method="post">
|
||||||
|
<input type="hidden" name="editKey" id="editKey" value="${editKey}" role="input" />
|
||||||
|
<#--Autocomplete for looking up existing skos concepts -->
|
||||||
|
<p>
|
||||||
|
<label for="relatedIndLabel">Concept <span class='requiredHint'> *</span></label>
|
||||||
|
<input class="acSelector" size="50" type="text" id="relatedIndLabel" name="conceptLabel"
|
||||||
|
<#if (disabledVal?length > 0)>disabled="${disabledVal}"</#if> value="" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="acSelection">
|
||||||
|
<p class="inline">
|
||||||
|
<label>Selected Publication:</label>
|
||||||
|
<span class="acSelectionInfo"></span>
|
||||||
|
<a href="/vivo/individual?uri=" class="verifyMatch">(Verify this match)</a>
|
||||||
|
</p>
|
||||||
|
<input class="acUriReceiver" type="hidden" id="conceptNode" name="conceptNode" value="" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
<input type="hidden" name = "editKey" value="${editKey}"/>
|
||||||
|
<input type="submit" id="submit" value="Add Concept"/><span class="or"> or </span><a class="cancel" href="${returnUrl}">Return to Manage Concepts</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<#assign sparqlQueryUrl = "/ajax/sparqlQuery" >
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var customFormData = {
|
||||||
|
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||||
|
sparqlQueryUrl: '${sparqlQueryUrl}',
|
||||||
|
acUrl: '${urls.base}/autocomplete?tokenize=true',
|
||||||
|
submitButtonTextType: 'simple',
|
||||||
|
editMode: 'add',
|
||||||
|
defaultTypeName: 'concept' // used in repair mode to generate button text
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
|
||||||
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
||||||
|
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
|
||||||
|
|
||||||
|
|
||||||
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
|
||||||
|
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
|
||||||
|
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
|
||||||
|
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
|
|
@ -3,42 +3,48 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.N3Validator;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
|
||||||
public class PersonHasPublicationValidator implements N3Validator {
|
public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||||
|
|
||||||
private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type.";
|
private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type.";
|
||||||
private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title.";
|
private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title.";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfiguration editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
EditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
|
|
||||||
Map<String,String> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,Literal> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
// If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted.
|
// If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted.
|
||||||
String pubUri = urisFromForm.get("pubUri");
|
List<String> pubUriList = urisFromForm.get("pubUri");
|
||||||
|
//This method will return null if the list is null or empty, otherwise returns first element
|
||||||
|
//Assumption is that only one value for uri, type, or title will be sent back
|
||||||
|
String pubUri = (String) getFirstElement(pubUriList);
|
||||||
if (!StringUtils.isEmpty(pubUri)) {
|
if (!StringUtils.isEmpty(pubUri)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pubType = urisFromForm.get("pubType");
|
List<String> pubTypeList = urisFromForm.get("pubType");
|
||||||
|
String pubType = (String) getFirstElement(pubTypeList);
|
||||||
if ("".equals(pubType)) {
|
if ("".equals(pubType)) {
|
||||||
pubType = null;
|
pubType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Literal title = literalsFromForm.get("title");
|
List<Literal> titleList = literalsFromForm.get("title");
|
||||||
|
Literal title = (Literal) getFirstElement(titleList);
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
String titleValue = title.getLexicalForm();
|
String titleValue = title.getLexicalForm();
|
||||||
if (StringUtils.isEmpty(titleValue)) {
|
if (StringUtils.isEmpty(titleValue)) {
|
||||||
|
@ -55,5 +61,13 @@ public class PersonHasPublicationValidator implements N3Validator {
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
return errors.size() != 0 ? errors : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getFirstElement(List checkList) {
|
||||||
|
if(checkList == null || checkList.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return checkList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,30 +3,31 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.N3Validator;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
|
||||||
|
|
||||||
public class PublicationHasAuthorValidator implements N3Validator {
|
public class PublicationHasAuthorValidator implements N3ValidatorVTwo {
|
||||||
|
|
||||||
private static String MISSING_FIRST_NAME_ERROR = "Must specify the author's first name.";
|
private static String MISSING_FIRST_NAME_ERROR = "Must specify the author's first name.";
|
||||||
private static String MISSING_LAST_NAME_ERROR = "Must specify the author's last name.";
|
private static String MISSING_LAST_NAME_ERROR = "Must specify the author's last name.";
|
||||||
private static String MALFORMED_LAST_NAME_ERROR = "Last name may not contain a comma. Please enter first name in first name field.";
|
private static String MALFORMED_LAST_NAME_ERROR = "Last name may not contain a comma. Please enter first name in first name field.";
|
||||||
;
|
;
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> validate(EditConfiguration editConfig,
|
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||||
EditSubmission editSub) {
|
MultiValueEditSubmission editSub) {
|
||||||
Map<String,String> urisFromForm = editSub.getUrisFromForm();
|
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
|
||||||
Map<String,Literal> literalsFromForm = editSub.getLiteralsFromForm();
|
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
String personUri = urisFromForm.get("personUri");
|
List<String> personUri = urisFromForm.get("personUri");
|
||||||
if ("".equals(personUri)) {
|
if (allListElementsEmpty(personUri)) {
|
||||||
personUri = null;
|
personUri = null;
|
||||||
}
|
}
|
||||||
// If there's a personUri, then we're done. The firstName and lastName fields are
|
// If there's a personUri, then we're done. The firstName and lastName fields are
|
||||||
|
@ -35,11 +36,24 @@ public class PublicationHasAuthorValidator implements N3Validator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Literal firstName = literalsFromForm.get("firstName");
|
//Expecting only one first name in this case
|
||||||
if( firstName != null && firstName.getLexicalForm() != null && "".equals(firstName.getLexicalForm()) )
|
//To Do: update logic if multiple first names considered
|
||||||
|
Literal firstName = null;
|
||||||
|
List<Literal> firstNameList = literalsFromForm.get("firstName");
|
||||||
|
if(firstNameList != null && firstNameList.size() > 0) {
|
||||||
|
firstName = firstNameList.get(0);
|
||||||
|
}
|
||||||
|
if( firstName != null &&
|
||||||
|
firstName.getLexicalForm() != null &&
|
||||||
|
"".equals(firstName.getLexicalForm()) )
|
||||||
firstName = null;
|
firstName = null;
|
||||||
|
|
||||||
Literal lastName = literalsFromForm.get("lastName");
|
|
||||||
|
List<Literal> lastNameList = literalsFromForm.get("lastName");
|
||||||
|
Literal lastName = null;
|
||||||
|
if(lastNameList != null && lastNameList.size() > 0) {
|
||||||
|
lastName = lastNameList.get(0);
|
||||||
|
}
|
||||||
String lastNameValue = "";
|
String lastNameValue = "";
|
||||||
if (lastName != null) {
|
if (lastName != null) {
|
||||||
lastNameValue = lastName.getLexicalForm();
|
lastNameValue = lastName.getLexicalForm();
|
||||||
|
@ -61,5 +75,21 @@ public class PublicationHasAuthorValidator implements N3Validator {
|
||||||
|
|
||||||
return errors.size() != 0 ? errors : null;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
@ -354,9 +355,22 @@ public class AddAssociatedConceptGenerator extends VivoBaseGenerator implements
|
||||||
List<AssociatedConceptInfo> testInfo = new ArrayList<AssociatedConceptInfo>();
|
List<AssociatedConceptInfo> testInfo = new ArrayList<AssociatedConceptInfo>();
|
||||||
testInfo.add(new AssociatedConceptInfo("testLabel", "testURI", "testVocabURI", "testVocabLabel"));
|
testInfo.add(new AssociatedConceptInfo("testLabel", "testURI", "testVocabURI", "testVocabLabel"));
|
||||||
formSpecificData.put("existingConcepts", testInfo);
|
formSpecificData.put("existingConcepts", testInfo);
|
||||||
|
//Return url for adding user defined concept
|
||||||
|
formSpecificData.put("userDefinedConceptUrl", getUserDefinedConceptUrl(vreq));
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getUserDefinedConceptUrl(VitroRequest vreq) {
|
||||||
|
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
|
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
|
String generatorName = "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.AddUserDefinedConceptGenerator";
|
||||||
|
String editUrl = EditConfigurationUtils.getEditUrl(vreq);
|
||||||
|
|
||||||
|
return editUrl + "?subject=" + UrlBuilder.urlEncode(subjectUri) +
|
||||||
|
"&predicate=" + UrlBuilder.urlEncode(predicateUri) +
|
||||||
|
"&editForm=" + UrlBuilder.urlEncode(generatorName);
|
||||||
|
}
|
||||||
|
|
||||||
public class AssociatedConceptInfo {
|
public class AssociatedConceptInfo {
|
||||||
private String conceptLabel;
|
private String conceptLabel;
|
||||||
private String conceptURI;
|
private String conceptURI;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
|
@ -60,10 +61,11 @@ public class AddAuthorsToInformationResourceGenerator extends VivoBaseGenerator
|
||||||
|
|
||||||
//template file
|
//template file
|
||||||
editConfiguration.setTemplate("addAuthorsToInformationResource.ftl");
|
editConfiguration.setTemplate("addAuthorsToInformationResource.ftl");
|
||||||
//no validators or preprocessors
|
//add validators
|
||||||
|
editConfiguration.addValidator(new PublicationHasAuthorValidator());
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
return editConfiguration;
|
return editConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,12 +10,17 @@ import java.util.Map;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasPublicationValidator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||||
|
|
||||||
public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public class AddPublicationToPersonGenerator extends VivoBaseGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
|
||||||
|
@ -46,11 +52,12 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
setSparqlQueries(editConfiguration, vreq);
|
setSparqlQueries(editConfiguration, vreq);
|
||||||
|
|
||||||
//set fields
|
//set fields
|
||||||
setFields(editConfiguration, vreq, EditConfigurationUtils.getPredicateUri(vreq));
|
setFields(editConfiguration, vreq);
|
||||||
|
|
||||||
//template file
|
//template file
|
||||||
editConfiguration.setTemplate("addAuthorsToInformationResource.ftl");
|
editConfiguration.setTemplate("addPublicationToPerson.ftl");
|
||||||
//no validators or preprocessors
|
//adding person has publication validator
|
||||||
|
editConfiguration.addValidator(new PersonHasPublicationValidator());
|
||||||
|
|
||||||
//Adding additional data, specifically edit mode
|
//Adding additional data, specifically edit mode
|
||||||
addFormSpecificData(editConfiguration, vreq);
|
addFormSpecificData(editConfiguration, vreq);
|
||||||
|
@ -62,7 +69,7 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
|
|
||||||
|
|
||||||
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
private void setVarNames(EditConfigurationVTwo editConfiguration) {
|
||||||
editConfiguration.setVarNameForSubject("infoResource");
|
editConfiguration.setVarNameForSubject("person");
|
||||||
editConfiguration.setVarNameForPredicate("predicate");
|
editConfiguration.setVarNameForPredicate("predicate");
|
||||||
editConfiguration.setVarNameForObject("authorshipUri");
|
editConfiguration.setVarNameForObject("authorshipUri");
|
||||||
|
|
||||||
|
@ -77,14 +84,45 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
|
|
||||||
/***N3 strings both required and optional***/
|
/***N3 strings both required and optional***/
|
||||||
private List<String> generateN3Optional() {
|
private List<String> generateN3Optional() {
|
||||||
// TODO Auto-generated method stub
|
return list(getN3ForExistingPub(),
|
||||||
return null;
|
getN3ForNewPub(),
|
||||||
|
getN3NewPubNameAssertion(),
|
||||||
|
getN3NewPubTypeAssertion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<String> generateN3Required() {
|
private List<String> generateN3Required() {
|
||||||
// TODO Auto-generated method stub
|
return list(getAuthorshipN3());
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
private String getAuthorshipN3() {
|
||||||
|
return "@prefix core: <" + vivoCore + "> . " +
|
||||||
|
"?authorshipUri a core:Authorship ;" +
|
||||||
|
"core:linkedAuthor ?person ." +
|
||||||
|
"?person core:authorInAuthorship ?authorshipUri .";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getN3ForExistingPub() {
|
||||||
|
return "@prefix core: <" + vivoCore + "> ." +
|
||||||
|
"?authorshipUri core:linkedInformationResource ?pubUri ." +
|
||||||
|
"?pubUri core:informationResourceInAuthorship ?authorshipUri .";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getN3ForNewPub() {
|
||||||
|
return "@prefix core: <" + vivoCore + "> ." +
|
||||||
|
"?pubUri a ?pubType ;" +
|
||||||
|
"<" + label + "> ?title ." +
|
||||||
|
"?authorshipUri core:linkedInformationResource ?pubUri ." +
|
||||||
|
"?pubUri core:informationResourceInAuthorship ?authorshipUri .";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getN3NewPubNameAssertion() {
|
||||||
|
return "?pubUri <" + label + "> ?title .";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getN3NewPubTypeAssertion() {
|
||||||
|
return "?pubUri a ?pubType . ";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get new resources */
|
/** Get new resources */
|
||||||
|
@ -92,17 +130,18 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
String DEFAULT_NS_TOKEN=null; //null forces the default NS
|
||||||
|
|
||||||
HashMap<String, String> newResources = new HashMap<String, String>();
|
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||||
newResources.put("role", DEFAULT_NS_TOKEN);
|
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("roleActivity", DEFAULT_NS_TOKEN);
|
newResources.put("pubUri", DEFAULT_NS_TOKEN);
|
||||||
newResources.put("intervalNode", DEFAULT_NS_TOKEN);
|
|
||||||
newResources.put("startNode", DEFAULT_NS_TOKEN);
|
|
||||||
newResources.put("endNode", DEFAULT_NS_TOKEN);
|
|
||||||
return newResources;
|
return newResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set URIS and Literals In Scope and on form and supporting methods */
|
/** Set URIS and Literals In Scope and on form and supporting methods */
|
||||||
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsInScope(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
HashMap<String, List<String>> urisInScope = new HashMap<String, List<String>>();
|
||||||
|
urisInScope.put(editConfiguration.getVarNameForSubject(),
|
||||||
|
Arrays.asList(new String[]{editConfiguration.getSubjectUri()}));
|
||||||
|
urisInScope.put(editConfiguration.getVarNameForPredicate(),
|
||||||
|
Arrays.asList(new String[]{editConfiguration.getPredicateUri()}));
|
||||||
editConfiguration.setUrisInScope(urisInScope);
|
editConfiguration.setUrisInScope(urisInScope);
|
||||||
HashMap<String, List<Literal>> literalsInScope = new HashMap<String, List<Literal>>();
|
HashMap<String, List<Literal>> literalsInScope = new HashMap<String, List<Literal>>();
|
||||||
editConfiguration.setLiteralsInScope(literalsInScope);
|
editConfiguration.setLiteralsInScope(literalsInScope);
|
||||||
|
@ -112,26 +151,23 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
List<String> urisOnForm = new ArrayList<String>();
|
List<String> urisOnForm = new ArrayList<String>();
|
||||||
//add role activity and roleActivityType to uris on form
|
//add role activity and roleActivityType to uris on form
|
||||||
urisOnForm.add("roleActivity");
|
urisOnForm.add("pubUri");
|
||||||
urisOnForm.add("roleActivityType");
|
urisOnForm.add("pubType");
|
||||||
//Also adding the predicates
|
|
||||||
//TODO: Check how to override this in case of default parameter? Just write hidden input to form?
|
|
||||||
urisOnForm.add("roleToActivityPredicate");
|
|
||||||
urisOnForm.add("activityToRolePredicate");
|
|
||||||
editConfiguration.setUrisOnform(urisOnForm);
|
editConfiguration.setUrisOnform(urisOnForm);
|
||||||
|
|
||||||
//activity label and role label are literals on form
|
//activity label and role label are literals on form
|
||||||
List<String> literalsOnForm = new ArrayList<String>();
|
List<String> literalsOnForm = new ArrayList<String>();
|
||||||
literalsOnForm.add("activityLabel");
|
literalsOnForm.add("title");
|
||||||
literalsOnForm.add("roleLabel");
|
|
||||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set SPARQL Queries and supporting methods. */
|
/** Set SPARQL Queries and supporting methods. */
|
||||||
|
//In this case no queries for existing
|
||||||
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
private void setSparqlQueries(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
//Queries for activity label, role label, start Field value, end Field value
|
editConfiguration.setSparqlForExistingUris(new HashMap<String, String>());
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
editConfiguration.setSparqlForAdditionalLiteralsInScope(new HashMap<String, String>());
|
||||||
editConfiguration.setSparqlForExistingUris(map);
|
editConfiguration.setSparqlForAdditionalUrisInScope(new HashMap<String, String>());
|
||||||
|
editConfiguration.setSparqlForExistingLiterals(new HashMap<String, String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,15 +175,98 @@ public class AddPublicationToPersonGenerator extends BaseEditConfigurationGenera
|
||||||
* Set Fields and supporting methods
|
* Set Fields and supporting methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
|
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
|
setTitleField(editConfiguration);
|
||||||
|
setPubTypeField(editConfiguration);
|
||||||
|
setPubUriField(editConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Form specific data
|
private void setTitleField(EditConfigurationVTwo editConfiguration) {
|
||||||
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
String stringDatatypeUri = XSD.xstring.toString();
|
||||||
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
editConfiguration.addField(new FieldVTwo().
|
||||||
editConfiguration.setFormSpecificData(formSpecificData);
|
setName("title").
|
||||||
|
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||||
|
setRangeDatatypeUri(stringDatatypeUri));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setPubTypeField(EditConfigurationVTwo editConfiguration) {
|
||||||
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
setName("pubType").
|
||||||
|
setOptionsType("HARDCODED_LITERALS").
|
||||||
|
setLiteralOptions(getPublicationTypeLiteralOptions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setPubUriField(EditConfigurationVTwo editConfiguration) {
|
||||||
|
editConfiguration.addField(new FieldVTwo().
|
||||||
|
setName("pubUri").
|
||||||
|
setObjectClassUri(personClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<List<String>> getPublicationTypeLiteralOptions() {
|
||||||
|
List<List<String>> literalOptions = new ArrayList<List<String>>();
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/AcademicArticle", "Academic Article"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Article", "Article"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/AudioDocument", "Audio Document"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#BlogPosting", "Blog Posting"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Book", "Book"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#CaseStudy", "Case Study"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Catalog", "Catalog"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Chapter", "Chapter"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#ConferencePaper", "Conference Paper"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#ConferencePoster", "Conference Poster"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Database", "Database"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/EditedBook", "Edited Book"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#EditorialArticle", "Editorial Article"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Film", "Film"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Newsletter", "Newsletter"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#NewsRelease", "News Release"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Patent", "Patent"));
|
||||||
|
literalOptions.add(list("http://purl.obolibrary.org/obo/OBI_0000272", "Protocol"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Report", "Report"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#ResearchProposal", "Research Proposal"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Review", "Review"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Software", "Software"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Speech", "Speech"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Thesis", "Thesis"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#Video", "Video"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Webpage", "Webpage"));
|
||||||
|
literalOptions.add(list("http://purl.org/ontology/bibo/Website", "Website"));
|
||||||
|
literalOptions.add(list("http://vivoweb.org/ontology/core#WorkingPaper", "Working Paper"));
|
||||||
|
return literalOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Form specific data
|
||||||
|
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||||
|
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
|
||||||
|
formSpecificData.put("editMode", getEditMode(vreq).name().toLowerCase());
|
||||||
|
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
|
||||||
|
editConfiguration.setFormSpecificData(formSpecificData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSparqlForAcFilter(VitroRequest vreq) {
|
||||||
|
String subject = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
|
|
||||||
|
String query = "PREFIX core:<" + vivoCore + "> " +
|
||||||
|
"SELECT ?pubUri WHERE { " +
|
||||||
|
"<" + subject + "> core:authorInAuthorship ?authorshipUri ." +
|
||||||
|
"?authorshipUri core:linkedInformationResource ?pubUri . }";
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditMode getEditMode(VitroRequest vreq) {
|
||||||
|
return EditModeUtils.getEditMode(vreq, list("http://vivoweb.org/ontology/core#linkedInformationResource"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue