diff --git a/productMods/config/listViewConfig-educationalTraining.xml b/productMods/config/listViewConfig-educationalTraining.xml index d057ab66..76f0b612 100644 --- a/productMods/config/listViewConfig-educationalTraining.xml +++ b/productMods/config/listViewConfig-educationalTraining.xml @@ -13,12 +13,18 @@ SELECT DISTINCT ?subclass ?edTraining + ?trainingType + ?typeName ?org ?orgName ?degreeName ?degreeAbbr ?majorField ?deptOrSchool ?info ?dateTimeStart ?dateTimeEnd WHERE { - ?subject ?property ?edTraining + ?subject ?property ?edTraining + OPTIONAL {?edTraining vitro:mostSpecificType ?trainingType . + ?trainingType rdfs:subClassOf core:EducationalTraining . + ?trainingType rdfs:label ?typeName + } OPTIONAL { ?edTraining core:trainingAtOrganization ?org . ?org rdfs:label ?orgName @@ -92,6 +98,30 @@ } + + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX core: <http://vivoweb.org/ontology/core#> + PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> + CONSTRUCT { + ?subject ?property ?edTraining . + ?edTraining vitro:mostSpecificType ?trainingType . + ?trainingType rdfs:subClassOf core:EducationalTraining . + ?trainingType rdfs:label ?typeName + } WHERE { + { + ?subject ?property ?edTraining . + ?edTraining vitro:mostSpecificType ?trainingType . + ?trainingType rdfs:subClassOf core:EducationalTraining + } UNION + { + ?subject ?property ?edTraining . + ?edTraining vitro:mostSpecificType ?trainingType . + ?trainingType rdfs:subClassOf core:EducationalTraining . + ?trainingType rdfs:label ?typeName + } + } + + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX core: <http://vivoweb.org/ontology/core#> diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl index 9ea8e181..fd0165e8 100644 --- a/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl +++ b/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl @@ -24,6 +24,8 @@ <@s.join [ statement.degreeAbbr!statement.degreeName, statement.majorField! ], " in " /> --> ${statement.degreeAbbr!statement.degreeName} <#if statement.majorField??> in ${statement.majorField} + <#elseif statement.typeName??> + ${statement.typeName!} diff --git a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl index a2cdb017..cfddbef1 100644 --- a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl @@ -22,6 +22,7 @@ <#assign majorFieldValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "majorField") /> <#assign degreeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "degree") /> <#assign existingOrgValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "org") /> +<#assign trainingTypeValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "trainingType")/> <#--If edit submission exists, then retrieve validation errors if they exist--> <#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content> @@ -116,6 +117,14 @@ <@lvf.acSelection urls.base "org" "org" existingOrgValue/> + + <#assign trainingTypeOpts = editConfiguration.pageData.trainingType /> +

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 ea5bdb9d..6e2d7306 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 @@ -86,7 +86,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements conf.setVarNameForPredicate("predicate"); conf.setVarNameForObject("edTraining"); - conf.setN3Required( Arrays.asList( n3ForNewEdTraining, orgLabelAssertion, orgTypeAssertion ) ); + conf.setN3Required( Arrays.asList( n3ForNewEdTraining, orgLabelAssertion, orgTypeAssertion, trainingTypeAssertion ) ); conf.setN3Optional(Arrays.asList( n3ForEdTrainingToOrg, majorFieldAssertion, degreeAssertion, deptAssertion, infoAssertion, @@ -101,7 +101,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements //uris in scope: none //literals in scope: none - conf.setUrisOnform( Arrays.asList( "org", "orgType", "degree")); + conf.setUrisOnform( Arrays.asList( "org", "orgType", "degree", "trainingType")); conf.setLiteralsOnForm( Arrays.asList("orgLabel","majorField","dept","info")); conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery); @@ -112,8 +112,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery); - conf.addSparqlForExistingUris("org",orgQuery); - conf.addSparqlForExistingUris("orgType",orgTypeQuery); + conf.addSparqlForExistingUris("org", orgQuery); + conf.addSparqlForExistingUris("orgType", orgTypeQuery); + conf.addSparqlForExistingUris("trainingType", trainingTypeQuery); conf.addSparqlForExistingUris("degree", degreeQuery); conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery); conf.addSparqlForExistingUris("startNode", existingStartNodeQuery); @@ -151,6 +152,13 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements setValidators( list("nonempty"))); //setLiteralOptions( [ "Select one" ] ) + conf.addField( new FieldVTwo(). + setName("trainingType"). + setOptionsType(FieldVTwo.OptionsType.CHILD_VCLASSES_WITH_PARENT). + setObjectClassUri(trainingClass). + setValidators( list("nonempty") ) + ); + conf.addField( new FieldVTwo(). setName("dept"). setRangeDatatypeUri( XSD.xstring.toString() ). @@ -195,6 +203,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements final static String orgLabelAssertion = "?org <"+ label +"> ?orgLabel ."; + final static String trainingTypeAssertion = + "?edTraining a ?trainingType ."; + final static String degreeAssertion = "?edTraining <"+ degreeEarned +"> ?degree .\n"+ "?degree <"+ degreeOutcomeOf +"> ?edTraining ."; @@ -259,6 +270,11 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements "?existingOrgType rdfs:subClassOf <"+ orgClass +"> .\n"+ "}"; + final static String trainingTypeQuery = + "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + + "SELECT ?existingTrainingType WHERE { \n" + + " ?edTraining vitro:mostSpecificType ?existingTrainingType . }"; + final static String degreeQuery = "SELECT ?existingDegree WHERE {\n"+ "?edTraining <"+ degreeEarned +"> ?existingDegree . }"; diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java index 4820e2bb..ed54f664 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/PersonHasMailingAddressGenerator.java @@ -37,22 +37,7 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen final static String mailingAddressPred =vivoCore+"mailingAddress" ; public PersonHasMailingAddressGenerator() {} - - // There are 4 modes that this form can be in: - // 1. Add. There is a subject and a predicate but no position and - // nothing else. - // - // 2. Normal edit where everything should already be filled out. - // There is a subject, a object and an individual on - // the other end of the object's core:personInOrganization stmt. - // - // 3. Repair a bad role node. There is a subject, predicate and object - // but there is no individual on the other end of the object's - // core:personInOrganization stmt. This should be similar to an add - // but the form should be expanded. - // - // 4. Really bad node. multiple core:personInOrganization statements. - + @Override public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) { @@ -154,11 +139,12 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen return conf; } + /* N3 assertions */ + final static String n3ForNewAddress = "@prefix vivo: <" + vivoCore + "> . \n\n" + "?person vivo:mailingAddress ?address . \n" + "?address a vivo:Address . \n" + -// "?address a ?addressType . \n" + "?address vivo:mailingAddressFor ?person . \n" ; final static String addrLineOneAssertion = @@ -188,45 +174,40 @@ public class PersonHasMailingAddressGenerator extends VivoBaseGenerator implemen final static String addressTypeAssertion = "?address a ?addressType ."; + + /* Queries for editing an existing entry */ + final static String addrLabelQuery = "SELECT ?existingAddrLabel WHERE { \n" + -// " ?person <"+ mailingAddressPred +"> ?address . \n" + " ?address <" + label + "> ?existingAddrLabel . \n" + "}"; final static String addrLineOneQuery = "SELECT ?existingaddrLineOne WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ addrLine1Pred +"> ?existingaddrLineOne . }"; final static String addrLineTwoQuery = "SELECT ?existingaddrLineTwo WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ addrLine2Pred +"> ?existingaddrLineTwo . }"; final static String addrLineThreeQuery = "SELECT ?existingaddrLineThree WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ addrLine3Pred +"> ?existingaddrLineThree . }"; final static String cityQuery = "SELECT ?existingCity WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ cityPred +"> ?existingCity . }"; final static String stateQuery = "SELECT ?existingState WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ statePred +"> ?existingState . }"; final static String postalCodeQuery = "SELECT ?existingPostalCode WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ postalCodePred +"> ?existingPostalCode . }"; final static String countryQuery = "SELECT ?existingCountry WHERE {\n"+ -// "?person <"+ mailingAddressPred +"> ?address . \n" + "?address <"+ countryPred +"> ?existingCountry . }"; final static String addressTypeQuery = diff --git a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java index 52f6f0fd..1b39efda 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java +++ b/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/generators/VivoBaseGenerator.java @@ -17,6 +17,7 @@ public abstract class VivoBaseGenerator extends BaseEditConfigurationGenerator i final static String type =VitroVocabulary.RDF_TYPE ; final static String label =rdfs+"label" ; + final static String trainingClass = vivoCore+"EducationalTraining" ; final static String degreeClass =vivoCore+"AcademicDegree" ; final static String majorFieldPred =vivoCore+"majorField" ; final static String deptPred =vivoCore+"departmentOrSchool" ;