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" ;