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} + <#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.

- \ No newline at end of file + + +<#--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] > + + <#return ""> + + +<#--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] > + + <#return ""> + + +<#--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) /> + + <#return returnValue> + + + +<#--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] > + + <#return ""> + + +<#--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] > + + <#return ""> + + +<#--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) /> + + <#return returnValue> + + +<#--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)> + + <#return returnValue> + 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 predicates = getPossibleRoleToActivityPredicates(); - List addToQuery = new ArrayList(); - query += "SELECT ?existingActivity WHERE { \n" + - " ?role ?predicate ?existingActivity . \n "; - query += getFilterRoleToActivityPredicate("predicate"); - query += "}"; - } else { - - query += "SELECT ?existingActivity WHERE { ?role <" +roleToActivityPredicate + "> ?existingActivity . }"; - } - + List predicates = getPossibleRoleToActivityPredicates(); + List addToQuery = new ArrayList(); + query += "SELECT ?existingActivity WHERE { \n" + + " ?role ?predicate ?existingActivity . \n "; + query += getFilterRoleToActivityPredicate("predicate"); + query += "}"; return query; } @@ -658,20 +642,11 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat "PREFIX rdfs: <" + RDFS.getURI() + "> \n"; String roleToActivityPredicate = getRoleToActivityPredicate(vreq); - if(doAddFilterToRoleToActivityQuery(vreq)) { - - query += "SELECT ?existingTitle WHERE { \n" + - "?role ?predicate ?existingActivity . \n" + - "?existingActivity rdfs:label ?existingTitle . \n"; - query += getFilterRoleToActivityPredicate("predicate"); - query += "}"; - - } else { - query += "SELECT ?existingTitle WHERE { \n" + - "?role <" + roleToActivityPredicate + "> ?existingActivity . \n" + - "?existingActivity rdfs:label ?existingTitle . }"; - } - + query += "SELECT ?existingTitle WHERE { \n" + + "?role ?predicate ?existingActivity . \n" + + "?existingActivity rdfs:label ?existingTitle . \n"; + query += getFilterRoleToActivityPredicate("predicate"); + query += "}"; return query; } @@ -1055,7 +1030,6 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat public String getActivityToRolePredicate(VitroRequest vreq) { return getActivityToRolePlaceholder(); - //return getDefaultActivityToRolePredicate(); } //This has a default value, but note that even that will not be used @@ -1065,22 +1039,11 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat //placeholder value by default public String getRoleToActivityPredicate(VitroRequest vreq) { return getRoleToActivityPlaceholder(); - //return getDefaultRoleToActivityPredicate(); } //Ensure when overwritten that this includes the <> b/c otherwise the query won't work //Some values will have a default value - //activityToRolePredicate - public String getDefaultActivityToRolePredicate() { - return "http://vivoweb.org/ontology/core#relatedRole"; - } - - //roleToActivityPredicate - public String getDefaultRoleToActivityPredicate() { - return "http://vivoweb.org/ontology/core#roleIn"; - - } - + public List getPossibleRoleToActivityPredicates() { return ModelUtils.getPossiblePropertiesForRole(); } @@ -1173,15 +1136,6 @@ public abstract class AddRoleToPersonTwoStageGenerator implements EditConfigurat editConfiguration.setFormSpecificData(formSpecificData); } - //Do add filter fo rroel to activity or activity to role predicates - public boolean doAddFilterToRoleToActivityQuery(VitroRequest vreq) { - return (getRoleToActivityPredicate(vreq) == getRoleToActivityPlaceholder()); - } - - public boolean doAddFilterToActivityToRoleQuery(VitroRequest vreq) { - return (getActivityToRolePredicate(vreq) == getActivityToRolePlaceholder()); - } - public String getFilterRoleToActivityPredicate(String predicateVar) { String addFilter = "FILTER ("; diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/RoleToPredicatePreprocessor.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/RoleToPredicatePreprocessor.java index 68ca1df8..02769c57 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/RoleToPredicatePreprocessor.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/RoleToPredicatePreprocessor.java @@ -66,13 +66,13 @@ public abstract class RoleToPredicatePreprocessor extends BaseEditSubmissionPrep Map> urisFromForm = submission.getUrisFromForm(); if(type != null) { ObjectProperty roleToItemProperty = getCorrectProperty(type, wadf); - String roleToItemPredicate = roleToItemProperty.getURI(); - String itemToRolePredicate = roleToItemProperty.getURIInverse(); + String roleToItemPredicateURI = roleToItemProperty.getURI(); + String itemToRolePredicateURI = roleToItemProperty.getURIInverse(); List predicates = new ArrayList(); - predicates.add(roleToItemPredicate); + predicates.add(roleToItemPredicateURI); List inversePredicates = new ArrayList(); - inversePredicates.add(itemToRolePredicate); + inversePredicates.add(itemToRolePredicateURI); //Populate the two fields in edit submission if(urisFromForm.containsKey(roleToItemPredicate)) { urisFromForm.remove(roleToItemPredicate); diff --git a/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/UMLSConceptSearch.java b/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/UMLSConceptSearch.java index cc8cf90a..d43e634f 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/UMLSConceptSearch.java +++ b/src/edu/cornell/mannlib/vitro/webapp/utils/ConceptSearchService/UMLSConceptSearch.java @@ -11,6 +11,7 @@ import javax.servlet.ServletOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; import org.json.JSONObject; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -58,7 +59,16 @@ public class UMLSConceptSearch extends AbstractConceptSearch{ } if(json.has("BestMatch")) { - + JSONArray bestMatchArray = json.getJSONArray("BestMatch"); + int len = bestMatchArray.length(); + int i; + for(i = 0; i < len; i++) { + JSONObject o = bestMatchArray.getJSONObject(i); + String definition = o.getString("definition"); + String label = o.getString("label"); + String CUI = o.getString("CUI"); + String type = o.getString("type"); + } } } catch(Exception ex) { log.error("Error making json object out of output");