diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-hasEditReviewRole.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-hasEditReviewRole.ftl index f8112949..4fb68898 100644 --- a/productMods/templates/freemarker/body/partials/individual/propStatement-hasEditReviewRole.ftl +++ b/productMods/templates/freemarker/body/partials/individual/propStatement-hasEditReviewRole.ftl @@ -15,7 +15,9 @@ next statement --> <#macro showRole statement property> <#local linkedIndividual> - ${statement.activityLabel!statement.activityName} + <#if statement?has_content && statement.activity?has_content> + ${statement.activityLabel!statement.activityName} + #if> #local> <#local dateTime> diff --git a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl index bee68305..816ebcf7 100644 --- a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl @@ -39,6 +39,8 @@ <#--Get selected activity type value if it exists, this is alternative to below--> +Test grant label: ${lvf.getFormFieldValue(editSubmission, editConfiguration, "grantLabel")} End Test + <#assign grantLabel = ""/> <#if literalValues?keys?seq_contains("grantLabel") && (literalValues.grantLabel?size > 0)> <#assign grantLabel = literalValues.grantLabel[0] /> diff --git a/productMods/templates/freemarker/lib/lib-vivo-form.ftl b/productMods/templates/freemarker/lib/lib-vivo-form.ftl index acbbe8d0..8ab155bc 100644 --- a/productMods/templates/freemarker/lib/lib-vivo-form.ftl +++ b/productMods/templates/freemarker/lib/lib-vivo-form.ftl @@ -21,4 +21,75 @@ switch to another browser, such as FireFox.
-#macro> \ No newline at end of file +#macro> + +<#--Given an edit configuration template object, get the current value for a uri field using the field name--> + + +<#function getEditConfigLiteralValue config varName> + <#local literalValues = config.existingLiteralValues > + <#if (literalValues?keys?seq_contains(varName)) && (literalValues[varName]?size > 0)> + <#return literalValues[varName][0] > + #if> + <#return ""> +#function> + +<#--Given an edit configuration template object, get the current value for a literal field using the field name--> + +<#function getEditConfigUriValue config varName> + <#local uriValues = config.existingUriValues /> + <#if (uriValues?keys?seq_contains(varName)) && (uriValues[varName]?size > 0)> + <#return uriValues[varName][0] > + #if> + <#return ""> +#function> + +<#--Now check whether a given value returns either a uri or a literal value, if one empty then use other and +return - returns empty string if no value found--> +<#function getEditConfigValue config varName> + <#local returnValue = getEditConfigUriValue(config, varName) /> + <#if (returnValue?length = 0)> + <#local returnValue = getEditConfigLiteralValue(config, varName) /> + #if> + <#return returnValue> +#function> + + +<#--Given edit submission object find values-> +<#function getEditSubmissionLiteralValue submission varName> + <#local literalValues = submission.literalsFromForm > + <#if (literalValues?keys?seq_contains(varName)) && (literalValues[varName]?size > 0)> + <#return literalValues[varName][0] > + #if> + <#return ""> +#function> + +<#--Given an edit configuration template object, get the current value for a literal field using the field name--> + +<#function getEditSubmissionUriValue submission varName> + <#local uriValues = submission.urisFromForm /> + <#if (uriValues?keys?seq_contains(varName)) && (uriValues[varName]?size > 0)> + <#return uriValues[varName][0] > + #if> + <#return ""> +#function> + +<#--Get edit submission value for either literal or uri--> +<#function getEditSubmissionValue submission varName> + <#local returnValue = getEditSubmissionUriValue(submission, varName) /> + <#if (returnValue?length = 0)> + <#local returnValue = getEditSubmissionLiteralValue(submission, varName) /> + #if> + <#return returnValue> +#function> + +<#--Get the value for the form field, checking edit submission first and then edit configuration--> +<#function getFormFieldValue submission config varName> + <#local returnValue = ""> + <#if submission?has_content && submission.submissionExists = true> + <#local returnValue = getEditSubmissionValue(submission varName)> + <#else> + <#local returnValue = getEditConfigValue(config varName)> + #if> + <#return returnValue> +#function> diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java index 59c2c149..acfbf779 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddEditorRoleToPersonGenerator.java @@ -85,17 +85,6 @@ public class AddEditorRoleToPersonGenerator extends AddRoleToPersonTwoStageGener editConfiguration.setTemplate(template); } - - //The default activityToRolePredicate and roleToActivityPredicates are - //correct for this subclass so they don't need to be overwritten - public String getActivityToRolePredicate(VitroRequest vreq) { - return "http://vivoweb.org/ontology/core#linkedRole"; - } - - public String getRoleToActivityPredicate(VitroRequest vreq) { - return "http://vivoweb.org/ontology/core#forInformationResource"; - } - //role type will always be set based on particular form public String getRoleType(VitroRequest vreq) { //TODO: Get dynamic way of including vivoweb ontology diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java index 28eaeb35..af5e7aa7 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/AddRoleToPersonTwoStageGenerator.java @@ -540,11 +540,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat //Replacement should only happen when we have an actual predicate String replaceRoleToActivityPredicate = getRoleToActivityPredicate(vreq); - //if no filters to add, this means an actual parameter exists for the role to activity predicate and that should be utilized - //as the replacement - if(!doAddFilterToRoleToActivityQuery(vreq)) { - activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "predicate", replaceRoleToActivityPredicate); - } + activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "predicate", replaceRoleToActivityPredicate); log.debug("Activity type query: " + activityTypeQuery); return activityTypeQuery; @@ -557,9 +553,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat "SELECT ?existingActivityType WHERE { \n" + " ?role ?predicate ?existingActivity . \n" + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n"; - if(doAddFilterToRoleToActivityQuery(vreq)) { - query += getFilterRoleToActivityPredicate("predicate"); - } + query += getFilterRoleToActivityPredicate("predicate"); query+= "}"; return query; } @@ -572,9 +566,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat " ?role ?predicate ?existingActivity . \n" + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + " ?existingActivityType rdfs:subClassOf ?objectClassUri . \n"; - if(doAddFilterToRoleToActivityQuery(vreq)) { - query += getFilterRoleToActivityPredicate("predicate"); - } + query += getFilterRoleToActivityPredicate("predicate"); query+= "}"; return query; } @@ -586,9 +578,7 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat " ?role ?predicate ?existingActivity . \n" + " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + " ?existingActivityType vitro:inClassGroup ?classgroup . \n"; - if(doAddFilterToRoleToActivityQuery(vreq)) { - query += getFilterRoleToActivityPredicate("predicate"); - } + query += getFilterRoleToActivityPredicate("predicate"); query+= "}"; return query; } @@ -601,18 +591,12 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat String roleToActivityPredicate = getRoleToActivityPredicate(vreq); //Portion below for multiple possible predicates - if(doAddFilterToRoleToActivityQuery(vreq)) { - List