From fbf2c4b65157b3cee9f6400cb4c9454884895ef8 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 10 Sep 2013 11:33:20 -0400 Subject: [PATCH] VIVO-112: more updates for educational training and a change for organizationHasPositionHistory --- .../listViewConfig-educationalTraining.xml | 27 +++++---- .../listViewConfig-hasInvestigatorRole.xml | 30 +++++----- ...listViewConfig-organizationForPosition.xml | 23 +++++-- .../forms/personHasEducationalTraining.ftl | 4 +- ...ganizationHasPositionHistoryGenerator.java | 16 ++--- .../PersonHasEducationalTraining.java | 60 ++++++++++++------- 6 files changed, 97 insertions(+), 63 deletions(-) diff --git a/productMods/config/listViewConfig-educationalTraining.xml b/productMods/config/listViewConfig-educationalTraining.xml index 810c1e95..5334d50d 100644 --- a/productMods/config/listViewConfig-educationalTraining.xml +++ b/productMods/config/listViewConfig-educationalTraining.xml @@ -26,7 +26,13 @@ ?trainingType rdfs:subClassOf core:EducationalProcess . ?trainingType rdfs:label ?typeName } - OPTIONAL { ?edTraining core:relates ?org . + OPTIONAL { ?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . + ?awardedDegree core:relates ?degree . + ?degree a core:AcademicDegree + OPTIONAL { ?degree rdfs:label ?degreeName } + OPTIONAL { ?degree core:abbreviation ?degreeAbbr } + } + OPTIONAL { ?awardedDegree core:assignedBy ?org . ?org rdfs:label ?orgName OPTIONAL { ?org vitro:mostSpecificType ?subclass . @@ -34,12 +40,6 @@ } } - OPTIONAL { ?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . - ?awardedDegree core:relates ?degree . - ?degree a core:AcademicDegree - OPTIONAL { ?degree rdfs:label ?degreeName } - OPTIONAL { ?degree core:abbreviation ?degreeAbbr } - } OPTIONAL { ?edTraining core:majorField ?majorField } OPTIONAL { ?edTraining core:departmentOrSchool ?deptOrSchool } OPTIONAL { ?edTraining core:supplementalInformation ?info } @@ -74,9 +74,9 @@ ?subject ?property ?edTraining . ?edTraining a core:EducationalProcess . ?edTraining ?edTrainingProp ?edTrainingValue . - ?edTraining core:relates ?org . - ?org rdfs:label ?orgName . ?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . + ?awardedDegree core:assignedBy ?org . + ?org rdfs:label ?orgName . ?awardedDegree core:relates ?degree . ?edTraining core:dateTimeInterval ?dateTimeInterval } WHERE { @@ -92,14 +92,15 @@ UNION { ?subject ?property ?edTraining . ?edTraining a core:EducationalProcess . - ?edTraining core:relates ?org . - ?org rdfs:label ?orgName - } + ?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . + } UNION { ?subject ?property ?edTraining . ?edTraining a core:EducationalProcess . ?edTraining <http://purl.obolibrary.org/obo/RO_0002234> ?awardedDegree . - } + ?awardedDegree core:assignedBy ?org . + ?org rdfs:label ?orgName + } UNION { ?subject ?property ?edTraining . ?edTraining a core:EducationalProcess . diff --git a/productMods/config/listViewConfig-hasInvestigatorRole.xml b/productMods/config/listViewConfig-hasInvestigatorRole.xml index 98344214..b8da33ce 100644 --- a/productMods/config/listViewConfig-hasInvestigatorRole.xml +++ b/productMods/config/listViewConfig-hasInvestigatorRole.xml @@ -31,7 +31,7 @@ LET (?activityName := afn:localname(?activity)) OPTIONAL { ?activity rdfs:label ?activityLabel } } - OPTIONAL { ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity + OPTIONAL { ?role <http://vivoweb.org/ontology/core#relates> ?activity LET (?activityName := afn:localname(?activity)) OPTIONAL { ?activity rdfs:label ?activityLabel } } @@ -49,7 +49,7 @@ ?dateTimeEndValueRole core:dateTime ?dateTimeEndRole } } - OPTIONAL { ?role <http://vivoweb.org/ontology/core#relatedBy> ?grant . + OPTIONAL { ?role <http://vivoweb.org/ontology/core#relates> ?grant . ?grant core:dateTimeInterval ?dateTimeIntervalGrant OPTIONAL { ?dateTimeIntervalGrant core:start ?dateTimeStartValueGrant . ?dateTimeStartValueGrant core:dateTime ?dateTimeStartGrant @@ -77,7 +77,7 @@ { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity + ?role <http://vivoweb.org/ontology/core#relates> ?activity } UNION { ?subject ?property ?role . @@ -96,18 +96,18 @@ CONSTRUCT { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity rdfs:label ?activityLabel } WHERE { { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity + ?role <http://vivoweb.org/ontology/core#relates> ?activity } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity rdfs:label ?activityLabel } } @@ -135,7 +135,7 @@ } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity rdfs:label ?activityName } UNION { ?subject ?property ?role . @@ -145,23 +145,23 @@ } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity core:grantAwardedBy ?awardedBy } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity core:grantAwardedBy ?awardedBy . ?awardedBy rdfs:label ?awardedByLabel } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity core:administeredBy ?adminedBy } UNION { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?activity . + ?role <http://vivoweb.org/ontology/core#relates> ?activity . ?activity core:administeredBy ?adminedBy . ?adminedBy rdfs:label ?adminedByLabel } @@ -206,14 +206,14 @@ CONSTRUCT { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?grant . + ?role <http://vivoweb.org/ontology/core#relates> ?grant . ?grant core:dateTimeInterval ?dateTimeIntervalGrant . ?dateTimeIntervalGrant core:start ?dateTimeStartValueGrant . ?dateTimeStartValueGrant core:dateTime ?dateTimeStartGrant } WHERE { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?grant . + ?role <http://vivoweb.org/ontology/core#relates> ?grant . ?grant core:dateTimeInterval ?dateTimeIntervalGrant . ?dateTimeIntervalGrant core:start ?dateTimeStartValueGrant . ?dateTimeStartValueGrant core:dateTime ?dateTimeStartGrant @@ -225,14 +225,14 @@ CONSTRUCT { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?grant . + ?role <http://vivoweb.org/ontology/core#relates> ?grant . ?grant core:dateTimeInterval ?dateTimeIntervalGrant . ?dateTimeIntervalGrant core:end ?dateTimeEndValueGrant . ?dateTimeEndValueGrant core:dateTime ?dateTimeEndGrant } WHERE { ?subject ?property ?role . ?role a ?objectType . - ?role <http://vivoweb.org/ontology/core#relatedBy> ?grant . + ?role <http://vivoweb.org/ontology/core#relates> ?grant . ?grant core:dateTimeInterval ?dateTimeIntervalGrant . ?dateTimeIntervalGrant core:end ?dateTimeEndValueGrant . ?dateTimeEndValueGrant core:dateTime ?dateTimeEndGrant diff --git a/productMods/config/listViewConfig-organizationForPosition.xml b/productMods/config/listViewConfig-organizationForPosition.xml index 9416110d..a49f0889 100644 --- a/productMods/config/listViewConfig-organizationForPosition.xml +++ b/productMods/config/listViewConfig-organizationForPosition.xml @@ -9,6 +9,7 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> + PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?subclass ?position @@ -19,6 +20,7 @@ WHERE { ?subject ?property ?position OPTIONAL { ?position core:relates ?person . + ?person a foaf:Person . ?person rdfs:label ?personName } @@ -51,29 +53,38 @@ PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> CONSTRUCT { ?subject ?property ?position . + ?position a core:Position . ?position vitro:mostSpecificType ?subclass } WHERE { ?subject ?property ?position . + ?position a core:Position . ?position vitro:mostSpecificType ?subclass } PREFIX core: <http://vivoweb.org/ontology/core#> - PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?subject ?property ?position . + ?position a core:Position . ?position ?positionProperty ?positionValue . + ?position core:relates ?person . + ?person a foaf:Person . ?person rdfs:label ?personName } WHERE { { - ?subject ?property ?position + ?subject ?property ?position . + ?position a core:Position . } UNION { ?subject ?property ?position . + ?position a core:Position . ?position ?positionProperty ?positionValue } UNION { ?subject ?property ?position . - ?position core:positionForPerson ?person . + ?position core:relates ?person . + ?person a foaf:Person . ?person rdfs:label ?personName } } @@ -83,11 +94,13 @@ PREFIX core: <http://vivoweb.org/ontology/core#> CONSTRUCT { ?subject ?property ?position . + ?position a core:Position . ?position core:dateTimeInterval ?dateTimeInterval . ?dateTimeInterval core:start ?dateTimeStartValue . ?dateTimeStartValue core:dateTime ?dateTimeStart } WHERE { - ?subject ?property ?position . + ?subject ?property ?position . + ?position a core:Position . ?position core:dateTimeInterval ?dateTimeInterval . ?dateTimeInterval core:start ?dateTimeStartValue . ?dateTimeStartValue core:dateTime ?dateTimeStart @@ -98,11 +111,13 @@ PREFIX core: <http://vivoweb.org/ontology/core#> CONSTRUCT { ?subject ?property ?position . + ?position a core:Position . ?position core:dateTimeInterval ?dateTimeInterval . ?dateTimeInterval core:end ?dateTimeEndValue . ?dateTimeEndValue core:dateTime ?dateTimeEnd } WHERE { ?subject ?property ?position . + ?position a core:Position . ?position core:dateTimeInterval ?dateTimeInterval . ?dateTimeInterval core:end ?dateTimeEndValue . ?dateTimeEndValue core:dateTime ?dateTimeEnd diff --git a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl index b514b188..d7ab5d20 100644 --- a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl @@ -44,7 +44,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o <#assign submissionErrors = editSubmission.validationErrors/> -<#if editMode == "edit"> +<#if editMode == "edit" || editMode == "repair"> <#assign titleVerb="${i18n().edit_capitalized}"> <#assign submitButtonText="${i18n().save_changes}"> <#assign disabledVal="disabled"> @@ -164,7 +164,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o - <#if editMode == "edit"> + <#if editMode == "edit" || editMode == "repair"> <#else> diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/OrganizationHasPositionHistoryGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/OrganizationHasPositionHistoryGenerator.java index 6364b3cc..ac562d48 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/OrganizationHasPositionHistoryGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/OrganizationHasPositionHistoryGenerator.java @@ -43,13 +43,13 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator + "PREFIX core: \n" + "PREFIX rdfs: \n" + "SELECT ?existingPerson WHERE { \n" - + " ?position core:positionForPerson ?existingPerson .}"; + + " ?position core:relates ?existingPerson .}"; private static final String QUERY_EXISTING_PERSON_LABEL = "" + "PREFIX core: \n" + "PREFIX rdfs: \n" + "SELECT ?existingPersonLabel WHERE { \n" - + " ?position core:positionForPerson ?existingPerson . \n" + + " ?position core:relates ?existingPerson . \n" + " ?existingPerson rdfs:label ?existingPersonLabel . }"; private static final String QUERY_EXISTING_INTERVAL_NODE = "" @@ -113,18 +113,18 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator private static final String N3_NEW_POSITION = "" + "@prefix core: . \n" + "@prefix rdfs: . \n" - + "?organization core:organizationForPosition ?position . \n" + + "?organization core:relatedBy ?position . \n" + "?position a core:Position . \n" + "?position a ?positionType . \n" + "?position rdfs:label ?positionTitle . \n" - + "?position core:positionInOrganization ?organization . "; + + "?position core:relates ?organization . "; private static final String N3_NEW_PERSON = "" + "@prefix core: . \n" + "@prefix rdfs: . \n" + "@prefix foaf: . \n" - + "?position core:positionForPerson ?person . \n" - + "?person core:personInPosition ?position . \n" + + "?position core:relates ?person . \n" + + "?person core:relatedBy ?position . \n" + "?person a foaf:Person . \n" + "?person rdfs:label ?personLabel . "; @@ -138,8 +138,8 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator private static final String N3_EXISTING_PERSON = "" + "@prefix core: . \n" - + "?position core:positionForPerson ?existingPerson . \n" - + "?existingPerson core:personInPosition ?position . \n"; + + "?position core:relates ?existingPerson . \n" + + "?existingPerson core:relatedBy ?position . \n"; private static final String N3_NEW_START_NODE = "" + "@prefix core: . \n" diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java index 762ff407..880dd0f8 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasEducationalTraining.java @@ -90,8 +90,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) ); conf.setN3Optional(Arrays.asList( - n3ForNewOrg, n3ForExistingOrg, n3ForNewAwardedDegree, - majorFieldAssertion, + n3ForNewOrgExistingAwardedDegree, n3ForExistingOrgExistingAwardedDegree, n3ForNewAwardedDegreeNewOrg, + majorFieldAssertion, n3ForNewAwardedDegreeExistingOrg, //existingDegreeTypeAssertion, existingAwardedDegreeLabel, deptAssertion, infoAssertion, n3ForStart, n3ForEnd )); @@ -229,15 +229,30 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements final static String trainingTypeAssertion = "?edTraining a ?trainingType ."; - final static String n3ForNewAwardedDegree = + final static String n3ForNewAwardedDegreeNewOrg = "@prefix core: <"+ vivoCore +"> .\n"+ "?edTraining ?newAwardedDegree . \n" + "?newAwardedDegree ?edTraining . \n" + "?newAwardedDegree ?person . \n" + "?person ?newAwardedDegree . \n" + "?newAwardedDegree <"+ label +"> ?awardedDegreeLabel . \n" + - "?newOrg ?newAwardedDegree . \n" + "?newAwardedDegree ?newOrg . \n" + + "?newOrg ?newAwardedDegree . \n" + + "?newOrg a ?orgType . \n" + + "?newOrg <"+ label +"> ?orgLabel . \n" + + "?newAwardedDegree ?degreeType .\n"+ + "?degreeType ?newAwardedDegree . \n"+ + "?newAwardedDegree a core:AwardedDegree ."; + + final static String n3ForNewAwardedDegreeExistingOrg = + "@prefix core: <"+ vivoCore +"> .\n"+ + "?edTraining ?newAwardedDegree . \n" + + "?newAwardedDegree ?edTraining . \n" + + "?newAwardedDegree ?person . \n" + + "?person ?newAwardedDegree . \n" + + "?newAwardedDegree <"+ label +"> ?awardedDegreeLabel . \n" + + "?existingOrg ?newAwardedDegree . \n" + + "?newAwardedDegree ?existingOrg . \n" + "?newAwardedDegree ?degreeType .\n"+ "?degreeType ?newAwardedDegree . \n"+ "?newAwardedDegree a core:AwardedDegree ."; @@ -249,15 +264,15 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements "?degreeType ?existingAwardedDegree . \n"+ "?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel . " ; - final static String n3ForNewOrg = - "?edTraining ?newOrg . \n" + - "?newOrg ?edTraining . \n" + + final static String n3ForNewOrgExistingAwardedDegree = + "?existingAwardedDegree ?newOrg . \n" + + "?newOrg ?existingAwardedDegree . \n" + "?newOrg <"+ label +"> ?orgLabel . \n" + "?newOrg a ?orgType ."; - final static String n3ForExistingOrg = - "?edTraining ?existingOrg . \n" + - "?existingOrg ?edTraining . \n" + + final static String n3ForExistingOrgExistingAwardedDegree = + "?existingAwardedDegree ?existingOrg . \n" + + "?existingOrg ?existingAwardedDegree . \n" + "?existingOrg a ?orgType . "; final static String majorFieldAssertion = @@ -287,16 +302,6 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements /* Queries for editing an existing educational training entry */ - final static String existingOrgQuery = - "SELECT ?existingOrg WHERE {\n"+ - "?edTraining ?existingOrg . }\n"; - - final static String orgLabelQuery = - "SELECT ?existingOrgLabel WHERE {\n"+ - "?edTraining ?existingOrg .\n"+ - "?existingOrg <"+ label +"> ?existingOrgLabel .\n"+ - "}"; - final static String existingAwardedDegreeQuery = "SELECT ?existingAwardedDegree WHERE {\n"+ "?edTraining ?existingAwardedDegree . }\n"; @@ -306,12 +311,25 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements "?edTraining ?existingAwardedDegree . \n" + "?existingAwardedDegree <"+ label +"> ?existingAwardedDegreeLabel }\n"; + final static String existingOrgQuery = + "SELECT ?existingOrg WHERE {\n"+ + "?edTraining ?existingAwardedDegree . \n" + + "?existingAwardedDegree ?existingOrg . }\n"; + + final static String orgLabelQuery = + "SELECT ?existingOrgLabel WHERE {\n"+ + "?edTraining ?existingAwardedDegree . \n" + + "?existingAwardedDegree ?existingOrg .\n"+ + "?existingOrg <"+ label +"> ?existingOrgLabel .\n"+ + "}"; + /* Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another type is returned and we don't get a match to the select element options. */ final static String orgTypeQuery = "PREFIX rdfs: <"+ rdfs +"> \n"+ "SELECT ?existingOrgType WHERE {\n"+ - "?edTraining ?existingOrg .\n"+ + "?edTraining ?existingAwardedDegree . \n" + + "?existingAwardedDegree ?existingOrg .\n"+ "?existingOrg a ?existingOrgType .\n"+ "?existingOrgType rdfs:subClassOf <"+ orgClass +"> .\n"+ "}";