VIVO-340 new custom form et al for advisee in and a refactored form for the advisor side

This commit is contained in:
tworrall 2013-10-10 10:14:55 -04:00
parent 2876b4d21d
commit db6e2dd358
16 changed files with 1357 additions and 104 deletions

View file

@ -0,0 +1,95 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.hp.hpl.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3ValidatorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
public class PersonHasAdvisorsValidator implements N3ValidatorVTwo {
private static String MISSING_FIRST_NAME_ERROR = "You must enter a value in the First Name field.";
private static String MISSING_LAST_NAME_ERROR = "You must enter a value in the Last Name field.";
private static String MALFORMED_LAST_NAME_ERROR = "The last name field may not contain a comma. Please enter first name in First Name field.";
@Override
public Map<String, String> validate(EditConfigurationVTwo editConfig,
MultiValueEditSubmission editSub) {
Map<String,List<String>> urisFromForm = editSub.getUrisFromForm();
Map<String,List<Literal>> literalsFromForm = editSub.getLiteralsFromForm();
Map<String,String> errors = new HashMap<String,String>();
List<String> adviseeUri = urisFromForm.get("existingAdvisor");
if (allListElementsEmpty(adviseeUri) || adviseeUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
adviseeUri = null;
}
// If there's an adviseeUri, then we're done. The firstName and lastName fields are
// disabled and so don't get submitted.
if (adviseeUri != null) {
return null;
}
//Expecting only one first name in this case
//To Do: update logic if multiple first names considered
Literal firstName = null;
List<Literal> firstNameList = literalsFromForm.get("firstName");
if(firstNameList != null && firstNameList.size() > 0) {
firstName = firstNameList.get(0);
}
if( firstName != null &&
firstName.getLexicalForm() != null &&
"".equals(firstName.getLexicalForm()) )
firstName = null;
List<Literal> lastNameList = literalsFromForm.get("lastName");
Literal lastName = null;
if(lastNameList != null && lastNameList.size() > 0) {
lastName = lastNameList.get(0);
}
String lastNameValue = "";
if (lastName != null) {
lastNameValue = lastName.getLexicalForm();
if( "".equals(lastNameValue) ) {
lastName = null;
}
}
if (lastName == null) {
errors.put("lastName", MISSING_LAST_NAME_ERROR);
// Don't reject space in the last name: de Vries, etc.
} else if (lastNameValue.contains(",")) {
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
}
if (firstName == null) {
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
}
return errors.size() != 0 ? errors : null;
}
private boolean allListElementsEmpty(List<String> checkList) {
if(checkList == null)
return true;
if(checkList.isEmpty()) {
return true;
}
boolean allEmpty = true;
for(String s: checkList) {
if(s.length() != 0){
allEmpty = false;
break;
}
}
return allEmpty;
}
}

View file

@ -0,0 +1,417 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.Arrays;
import java.util.HashMap;
import javax.servlet.http.HttpSession;
import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasAdvisorsValidator;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeIntervalValidationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasAdviseeRelationshipGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
final static String advisingRelClass = vivoCore + "AdvisingRelationship";
final static String subjAreaClass = "http://www.w3.org/2004/02/skos/core#Concept";
final static String degreeClass = vivoCore+"AcademicDegree";
final static String advisorClass = foaf + "Person";
final static String advisorRoleClass = "http://vivoweb.org/ontology/core#AdvisorRole";
final static String adviseeRoleClass = "http://vivoweb.org/ontology/core#AdviseeRole";
final static String advisingRelToInterval = vivoCore + "dateTimeInterval";
final static String intervalType = vivoCore + "DateTimeInterval";
final static String intervalToStart = vivoCore + "start";
final static String intervalToEnd = vivoCore + "end";
final static String dateTimeValueType = vivoCore + "DateTimeValue";
final static String dateTimeValue = vivoCore + "dateTime";
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
public PersonHasAdviseeRelationshipGenerator() {}
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
HttpSession session) throws Exception {
EditConfigurationVTwo conf = new EditConfigurationVTwo();
initBasics(conf, vreq);
initPropertyParameters(vreq, session, conf);
initObjectPropForm(conf, vreq);
conf.setTemplate("personHasAdviseeRelationship.ftl");
conf.setVarNameForSubject("person");
conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("adviseeRole");
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
advisingRelLabelAssertion,
advisingRelTypeAssertion ) );
conf.setN3Optional( Arrays.asList( n3ForNewAdvisorAssertion,
n3ForExistingAdvisorAssertion,
degreeAssertion,
firstNameAssertion,
lastNameAssertion,
n3ForExistingSubjAreaAssertion, //relationship to existing subject area
n3ForNewSubjAreaAssertion, //this will include all the new information that needs to be captured
n3ForStart,
n3ForEnd ) );
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("vcardAdvisor", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("vcardName", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("adviseeRole", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("advisorRole", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("newSubjArea", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
//uris in scope: none
//literals in scope: none
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisor"));
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "advisorLabel", "firstName", "lastName", "subjAreaLabelDisplay", "advisorLabelDisplay" ));
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
conf.addSparqlForExistingLiteral("advisorLabel", advisorLabelQuery);
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
conf.addSparqlForExistingUris("adviseeRole", existingAdviseeRoleQuery);
conf.addSparqlForExistingUris("advisorRole", existingAdvisorRoleQuery);
conf.addSparqlForExistingUris("existingSubjArea", subjAreaQuery);
conf.addSparqlForExistingUris("existingAdvisor", advisorQuery);
conf.addSparqlForExistingUris("degree", degreeQuery);
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
conf.addSparqlForExistingUris("startField-precision", existingStartPrecisionQuery);
conf.addSparqlForExistingUris("endField-precision", existingEndPrecisionQuery);
conf.addField( new FieldVTwo().
setName("advisingRelType").
setValidators( list("nonempty") ).
setOptions( new ChildVClassesWithParent(advisingRelClass))
);
conf.addField( new FieldVTwo().
setName("advisingRelLabel").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("firstName").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("lastName").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo(). // options set by auto complete JS
setName("existingSubjArea")
);
conf.addField( new FieldVTwo().
setName("subjAreaLabel").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("degree").
setOptions(
new IndividualsViaVClassOptions(degreeClass))
);
conf.addField( new FieldVTwo(). // options set by auto complete JS
setName("existingAdvisor")
);
conf.addField( new FieldVTwo().
setName("advisorLabel").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("subjAreaLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().
setName("advisorLabelDisplay").
setRangeDatatypeUri(XSD.xstring.toString() ).
setValidators( list("datatype:" + XSD.xstring.toString()) )
);
conf.addField( new FieldVTwo().setName("startField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri())
)
);
conf.addField( new FieldVTwo().setName("endField").
setEditElement(
new DateTimeWithPrecisionVTwo(null,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri())
)
);
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
conf.addValidator(new AntiXssValidation());
conf.addValidator(new PersonHasAdvisorsValidator());
addFormSpecificData(conf, vreq);
prepare(vreq, conf);
return conf;
}
/* N3 assertions */
final static String n3ForNewAdvisingRelationship =
"@prefix vivo: <" + vivoCore + "> . \n\n" +
"?person <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
"?advisingRelationship a <" + advisingRelClass + "> . \n" +
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?person . \n" +
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
"?adviseeRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
"?person <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole . \n" +
"?adviseeRole <http://purl.obolibrary.org/obo/RO_0000052> ?person . ";
final static String advisingRelLabelAssertion =
"?advisingRelationship <"+ label + "> ?advisingRelLabel .";
final static String advisingRelTypeAssertion =
"?advisingRelationship a ?advisingRelType .";
final static String n3ForNewAdvisorAssertion =
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newAdvisor . \n" +
"?newAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
"?newAdvisor <" + label + "> ?advisorLabel . \n" +
"?newAdvisor a <" + advisorClass + "> . \n" +
"?newAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?newAdvisor . \n" +
"?advisorRole a <" + advisorRoleClass + "> . \n" +
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
final static String n3ForExistingAdvisorAssertion =
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisor . \n" +
"?existingAdvisor <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
"?existingAdvisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole . \n" +
"?advisorRole <http://purl.obolibrary.org/obo/RO_0000052> ?existingAdvisor . \n" +
"?advisorRole a <" + advisorRoleClass + "> . \n" +
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
"?advisorRole <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
final static String firstNameAssertion =
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
"?vcardName vcard:givenName ?firstName .";
final static String lastNameAssertion =
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . \n" +
"?newAdvisor <http://purl.obolibrary.org/obo/ARG_2000028> ?vcardAdvisor . \n" +
"?vcardAdvisor <http://purl.obolibrary.org/obo/ARG_2000029> ?newAdvisor . \n" +
"?vcardAdvisor a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
"?vcardAdvisor vcard:hasName ?vcardName . \n" +
"?vcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
"?vcardName vcard:familyName ?lastName .";
final static String degreeAssertion =
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?degree . \n" +
"?degree <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
//This is for an existing subject area
//Where we only need the existing subject area label
final static String n3ForExistingSubjAreaAssertion =
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingSubjArea . \n" +
"?existingSubjArea <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . ";
//For new subject area, we include all new information
//new subject area should always be a new resource
//and the following should only get evaluated
//when there is something in the label
final static String n3ForNewSubjAreaAssertion =
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?newSubjArea . \n" +
"?newSubjArea <http://vivoweb.org/ontology/core#relatedBy> ?advisingRelationship . \n" +
"?newSubjArea <"+ label + "> ?subjAreaLabel . \n" +
"?newSubjArea a <" + subjAreaClass + "> . ";
final static String n3ForStart =
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
"?intervalNode a <" + intervalType + "> . \n" +
"?intervalNode <" + intervalToStart + "> ?startNode . \n" +
"?startNode a <" + dateTimeValueType + "> . \n" +
"?startNode <" + dateTimeValue + "> ?startField-value . \n" +
"?startNode <" + dateTimePrecision + "> ?startField-precision . \n";
final static String n3ForEnd =
"?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
"?intervalNode a <" + intervalType + "> . \n" +
"?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
"?endNode a <" + dateTimeValueType + "> . \n" +
"?endNode <" + dateTimeValue + "> ?endField-value . \n" +
"?endNode <" + dateTimePrecision + "> ?endField-precision . \n";
/* Queries for editing an existing entry */
final static String advisingRelTypeQuery =
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?advisingRelType WHERE { \n" +
" ?advisingRelationship vitro:mostSpecificType ?advisingRelType . \n" +
"}";
final static String advisorQuery =
"SELECT ?existingAdvisor WHERE { \n" +
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisor . \n" +
" ?existingAdvisor a <" + advisorClass + "> . \n" +
" FILTER (?person != ?existingAdvisor) . \n" +
"}";
final static String existingAdviseeRoleQuery =
"SELECT ?adviseeRole WHERE { \n" +
"?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?adviseeRole . \n" +
"?adviseeRole a <" + adviseeRoleClass + "> . \n" +
"}";
final static String existingAdvisorRoleQuery =
"SELECT ?advisorRole WHERE { \n" +
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?advisorRole . \n" +
" ?advisorRole a <" + advisorRoleClass + "> . \n" +
"}";
final static String advisorLabelQuery =
"SELECT ?existingAdvisorLabel WHERE { \n" +
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingAdvisor . \n" +
" ?existingAdvisor a <" + advisorClass + "> . \n" +
" ?existingAdvisor <" + label + "> ?existingAdvisorLabel . \n" +
" FILTER (?person != ?existingAdvisor) . \n" +
"}";
final static String subjAreaQuery =
"SELECT ?existingSubjArea WHERE { \n" +
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingSubjArea . \n" +
" ?existingSubjArea a <http://www.w3.org/2004/02/skos/core#Concept> . \n" +
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
" FILTER (?type != <http://vivoweb.org/ontology/core#AcademicDegree>) . \n" +
"}";
final static String subjAreaLabelQuery =
"SELECT ?existingSubjAreaLabel WHERE { \n" +
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingSubjArea . \n" +
" ?existingSubjArea a <http://www.w3.org/2004/02/skos/core#Concept> . \n" +
" ?existingSubjArea <" + label + "> ?existingSubjAreaLabel . \n" +
" ?existingSubjArea <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> ?type \n" +
" FILTER (?type != <http://vivoweb.org/ontology/core#AcademicDegree>) . \n" +
"}";
final static String advisingRelLabelQuery =
"SELECT ?existingAdvisingRelLabel WHERE { \n" +
" ?advisingRelationship <" + label + "> ?existingAdvisingRelLabel . \n" +
"}";
final static String degreeQuery =
"SELECT ?existingDegree WHERE {\n"+
" ?advisingRelationship <http://vivoweb.org/ontology/core#relates> ?existingDegree . \n" +
" ?existingDegree a <" + degreeClass + "> . \n" +
"}";
final static String existingStartDateQuery =
"SELECT ?existingDateStart WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
" ?startNode a <" + dateTimeValueType +"> . \n" +
" ?startNode <" + dateTimeValue + "> ?existingDateStart . }";
final static String existingEndDateQuery =
"SELECT ?existingEndDate WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n " +
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
" ?endNode a <" + dateTimeValueType + "> . \n" +
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
final static String existingIntervalNodeQuery =
"SELECT ?existingIntervalNode WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?existingIntervalNode . \n" +
" ?existingIntervalNode a <" + intervalType + "> . }";
final static String existingStartNodeQuery =
"SELECT ?existingStartNode WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?existingStartNode . \n" +
" ?existingStartNode a <" + dateTimeValueType + "> .} ";
final static String existingEndNodeQuery =
"SELECT ?existingEndNode WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToEnd + "> ?existingEndNode . \n" +
" ?existingEndNode a <" + dateTimeValueType + "> } ";
final static String existingStartPrecisionQuery =
"SELECT ?existingStartPrecision WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToStart + "> ?startNode . \n" +
" ?startNode a <" + dateTimeValueType + "> . \n" +
" ?startNode <" + dateTimePrecision + "> ?existingStartPrecision . }";
final static String existingEndPrecisionQuery =
"SELECT ?existingEndPrecision WHERE { \n" +
" ?advisingRelationship <" + advisingRelToInterval + "> ?intervalNode . \n" +
" ?intervalNode a <" + intervalType + "> . \n" +
" ?intervalNode <" + intervalToEnd + "> ?endNode . \n" +
" ?endNode a <" + dateTimeValueType + "> . \n" +
" ?endNode <" + dateTimePrecision + "> ?existingEndPrecision . }";
public void addFormSpecificData(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
HashMap<String, Object> formSpecificData = new HashMap<String, Object>();
formSpecificData.put("sparqlForAcFilter", getSparqlForAcFilter(vreq));
editConfiguration.setFormSpecificData(formSpecificData);
}
public String getSparqlForAcFilter(VitroRequest vreq) {
String subject = EditConfigurationUtils.getSubjectUri(vreq);
String predicate = EditConfigurationUtils.getPredicateUri(vreq);
//Get all objects for existing predicate, filters out results from addition and edit
String query = "SELECT ?objectVar WHERE { " +
"<" + subject + "> <" + predicate + "> ?objectVar .} ";
return query;
}
}

View file

@ -21,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaVClassOptions;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator implements
public class PersonHasAdvisorRelationshipGenerator extends VivoBaseGenerator implements
EditConfigurationGenerator {
final static String advisingRelClass = vivoCore + "AdvisingRelationship";
@ -38,7 +38,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
final static String dateTimeValue = vivoCore + "dateTime";
final static String dateTimePrecision = vivoCore + "dateTimePrecision";
public PersonHasAdvisingRelationshipGenerator() {}
public PersonHasAdvisorRelationshipGenerator() {}
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
@ -50,11 +50,11 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
initPropertyParameters(vreq, session, conf);
initObjectPropForm(conf, vreq);
conf.setTemplate("personHasAdvisingRelationship.ftl");
conf.setTemplate("personHasAdvisorRelationship.ftl");
conf.setVarNameForSubject("person");
conf.setVarNameForPredicate("predicate");
conf.setVarNameForObject("advisingRelationship");
conf.setVarNameForObject("advisorRole");
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
advisingRelLabelAssertion,