This commit is contained in:
parent
b51bb4b5fc
commit
9f7a059213
7 changed files with 64 additions and 41 deletions
|
@ -1,7 +1,6 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for adding a grant role, such as principal investigator, to a foaf:Persons -->
|
||||
<#import "lib-vivo-form.ftl" as lvf>
|
||||
<#--Retrieve certain edit configuration information-->
|
||||
<#assign editMode = editConfiguration.pageData.editMode />
|
||||
<#assign literalValues = editConfiguration.existingLiteralValues />
|
||||
|
@ -40,10 +39,8 @@
|
|||
|
||||
<#--Get selected activity type value if it exists, this is alternative to below-->
|
||||
|
||||
<#assign grantLabel = ""/>
|
||||
<#if literalValues?keys?seq_contains("grantLabel") && (literalValues.grantLabel?size > 0)>
|
||||
<#assign grantLabel = literalValues.grantLabel[0] />
|
||||
</#if>
|
||||
<#assign grantLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")/>
|
||||
|
||||
|
||||
<#--Get existing grant label value-->
|
||||
<#assign existingGrantLabel = "" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#import "lib-vivo-form.ftl" as lvf>
|
||||
|
||||
<#--Retrieve certain edit configuration information-->
|
||||
<#assign editMode = editConfiguration.pageData.editMode />
|
||||
|
@ -6,6 +7,10 @@
|
|||
<#assign uriValues = editConfiguration.existingUriValues />
|
||||
<#assign htmlForElements = editConfiguration.pageData.htmlForElements />
|
||||
<#assign showRoleLabelField = editConfiguration.pageData.showRoleLabelField />
|
||||
<#--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>
|
||||
<#--Freemarker variables with default values that can be overridden by specific forms-->
|
||||
|
||||
|
||||
|
@ -44,22 +49,15 @@
|
|||
|
||||
|
||||
<#--Get selected activity type value if it exists, this is alternative to below-->
|
||||
<#assign activityTypeValue = ""/>
|
||||
<#if uriValues?keys?seq_contains("roleActivityType") && (uriValues.roleActivityType?size > 0)>
|
||||
<#assign activityTypeValue = uriValues.roleActivityType[0] />
|
||||
</#if>
|
||||
<#assign activityTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "roleActivityType")/>
|
||||
|
||||
<#--Get activity label value-->
|
||||
<#assign activityLabelValue = "" />
|
||||
<#if literalValues?keys?seq_contains("activityLabel") && (literalValues.activityLabel?size > 0)>
|
||||
<#assign activityLabelValue = literalValues.activityLabel[0] />
|
||||
</#if>
|
||||
<#assign activityLabelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "activityLabel") />
|
||||
|
||||
|
||||
<#--Get role label-->
|
||||
<#assign roleLabel = "" />
|
||||
<#if literalValues?keys?seq_contains("roleLabel") && (literalValues.roleLabel?size > 0) >
|
||||
<#assign roleLabel = literalValues.roleLabel[0] />
|
||||
</#if>
|
||||
<#assign roleLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "roleLabel") />
|
||||
|
||||
|
||||
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
|
||||
<#assign yearHint = "<span class='hint'>(YYYY)</span>" />
|
||||
|
@ -67,18 +65,26 @@
|
|||
<h2>${titleVerb} ${roleDescriptor} entry for ${editConfiguration.subjectName}</h2>
|
||||
|
||||
<#--Display error messages if any-->
|
||||
<#if errorNameFieldIsEmpty??>
|
||||
<#assign errorMessage = "Enter a name for the ." />
|
||||
</#if>
|
||||
|
||||
<#if errorRoleFieldIsEmpty??>
|
||||
<#assign errorMessage = "Specify a role for this ." />
|
||||
</#if>
|
||||
|
||||
<#if errorMessage?has_content>
|
||||
<#if submissionErrors?has_content>
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>${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]}
|
||||
<br/>
|
||||
</#list>
|
||||
<#--Checking if role field is empty-->
|
||||
<#if lvf.submissionErrorExists(editSubmission, "roleLabel")>
|
||||
Specify a role for this activity.
|
||||
</#if>
|
||||
<#if lvf.submissionErrorExists(editSubmission, "activityLabel")>
|
||||
Enter a name for the activity.
|
||||
</#if>
|
||||
|
||||
</p>
|
||||
</section>
|
||||
</#if>
|
||||
|
||||
|
@ -108,7 +114,6 @@
|
|||
</p>
|
||||
|
||||
|
||||
|
||||
<div class="fullViewOnly">
|
||||
<p>
|
||||
<label for="relatedIndLabel">### Name ${requiredHint}</label>
|
||||
|
|
|
@ -55,7 +55,7 @@ return - returns empty string if no value found-->
|
|||
</#function>
|
||||
|
||||
|
||||
<#--Given edit submission object find values->
|
||||
<#--Given edit submission object find values-->
|
||||
<#function getEditSubmissionLiteralValue submission varName>
|
||||
<#local literalValues = submission.literalsFromForm >
|
||||
<#if (literalValues?keys?seq_contains(varName)) && (literalValues[varName]?size > 0)>
|
||||
|
@ -79,7 +79,7 @@ return - returns empty string if no value found-->
|
|||
<#local returnValue = getEditSubmissionUriValue(submission, varName) />
|
||||
<#if (returnValue?length = 0)>
|
||||
<#local returnValue = getEditSubmissionLiteralValue(submission, varName) />
|
||||
</#if>
|
||||
</#if>
|
||||
<#return returnValue>
|
||||
</#function>
|
||||
|
||||
|
@ -93,3 +93,13 @@ return - returns empty string if no value found-->
|
|||
</#if>
|
||||
<#return returnValue>
|
||||
</#function>
|
||||
|
||||
<#--Check if submission error exists for a field name-->
|
||||
<#function submissionErrorExists editSubmission fieldName>
|
||||
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
|
||||
<#if editSubmission.validationErrors?keys?seq_contains(fieldName)>
|
||||
<#return true>
|
||||
</#if>
|
||||
</#if>
|
||||
<#return false>
|
||||
</#function>
|
||||
|
|
|
@ -129,7 +129,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//There will be specialized parameters as well, we may include them here or in a
|
||||
//separate method
|
||||
private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
String formUrl = EditConfigurationUtils.getFormUrl(vreq);
|
||||
String formUrl = EditConfigurationUtils.getFormUrlWithoutContext(vreq);
|
||||
|
||||
subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||
predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||
|
|
|
@ -172,7 +172,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
}
|
||||
|
||||
private void initProcessParameters(VitroRequest vreq, HttpSession session, EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.setFormUrl(EditConfigurationUtils.getFormUrl(vreq));
|
||||
editConfiguration.setFormUrl(EditConfigurationUtils.getFormUrlWithoutContext(vreq));
|
||||
editConfiguration.setEntityToReturnTo(EditConfigurationUtils.getSubjectUri(vreq));
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Replacement should only happen when we have an actual predicate
|
||||
|
||||
String replaceRoleToActivityPredicate = getRoleToActivityPredicate(vreq);
|
||||
activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "predicate", replaceRoleToActivityPredicate);
|
||||
activityTypeQuery = QueryUtils.replaceQueryVar(activityTypeQuery, "predicate", getRoleToActivityPlaceholderName());
|
||||
log.debug("Activity type query: " + activityTypeQuery);
|
||||
|
||||
return activityTypeQuery;
|
||||
|
@ -886,9 +886,14 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
}
|
||||
|
||||
private String getRoleToActivityPlaceholder() {
|
||||
return "?roleToActivityPredicate";
|
||||
return "?" + getRoleToActivityPlaceholderName();
|
||||
}
|
||||
|
||||
private String getRoleToActivityPlaceholderName() {
|
||||
return "roleToActivityPredicate";
|
||||
}
|
||||
|
||||
|
||||
private String getActivityToRolePlaceholder() {
|
||||
return "?activityToRolePredicate";
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
|
|||
//This combines the first and last name into the rdfs:label
|
||||
config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
|
||||
|
||||
String formUrl = EditConfigurationUtils.getFormUrl(vreq);
|
||||
String formUrl = EditConfigurationUtils.getFormUrlWithoutContext(vreq);
|
||||
config.setFormUrl(formUrl);
|
||||
|
||||
//Note, the spaces are important - they were added by ProcessRdfFormController earlier
|
||||
|
|
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -102,6 +103,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.addSparqlForExistingLiteral("dept", deptQuery);
|
||||
conf.addSparqlForExistingLiteral("info", infoQuery);
|
||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||
|
||||
|
||||
conf.addSparqlForExistingUris("org",orgQuery);
|
||||
conf.addSparqlForExistingUris("orgType",orgTypeQuery);
|
||||
|
@ -148,20 +151,23 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
setName("info").
|
||||
setRangeDatatypeUri( XSD.xstring.toString() ));
|
||||
|
||||
conf.addField(new FieldVTwo().
|
||||
setName("startField").
|
||||
FieldVTwo startField = new FieldVTwo().
|
||||
setName("startField");
|
||||
conf.addField(startField.
|
||||
setEditElement(
|
||||
new DateTimeWithPrecisionVTwo(null,
|
||||
new DateTimeWithPrecisionVTwo(startField,
|
||||
VitroVocabulary.Precision.YEAR.uri(),
|
||||
VitroVocabulary.Precision.NONE.uri())));
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("endField").
|
||||
|
||||
FieldVTwo endField = new FieldVTwo().
|
||||
setName("endField");
|
||||
conf.addField( endField.
|
||||
setEditElement(
|
||||
new DateTimeWithPrecisionVTwo(null,
|
||||
new DateTimeWithPrecisionVTwo(endField,
|
||||
VitroVocabulary.Precision.YEAR.uri(),
|
||||
VitroVocabulary.Precision.NONE.uri())));
|
||||
|
||||
//Add validator
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue