updates related to autocomplete changes
This commit is contained in:
parent
0eafc20767
commit
f0ccf65ddd
9 changed files with 321 additions and 116 deletions
|
@ -26,7 +26,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
|
|||
|
||||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
List<String> adviseeUri = urisFromForm.get("advisee");
|
||||
List<String> adviseeUri = urisFromForm.get("existingAdvisee");
|
||||
if (allListElementsEmpty(adviseeUri)) {
|
||||
adviseeUri = null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* $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 PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
|
||||
|
||||
private static String MISSING_AWARD_LABEL_ERROR = "You must select an existing award or type the name of a new award.";
|
||||
;
|
||||
@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> awardUri = urisFromForm.get("existingAward");
|
||||
if (allListElementsEmpty(awardUri)) {
|
||||
awardUri = null;
|
||||
}
|
||||
// If there's an awardUri, then we're done. If not, check to see if the label exists.
|
||||
// If that's null, too, it's an error.
|
||||
if (awardUri != null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
List<String> awardLabel = urisFromForm.get("awardLabel");
|
||||
if (allListElementsEmpty(awardLabel)) {
|
||||
awardLabel = null;
|
||||
}
|
||||
if (awardLabel != null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
errors.put("awardLabel", MISSING_AWARD_LABEL_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -67,8 +67,8 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
conf.setN3Required( Arrays.asList( n3ForNewAdvisingRelationship,
|
||||
advisingRelLabelAssertion,
|
||||
advisingRelTypeAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForAdviseeAssertion,
|
||||
adviseeLabelAssertion,
|
||||
conf.setN3Optional( Arrays.asList( n3ForNewAdviseeAssertion,
|
||||
n3ForExistingAdviseeAssertion,
|
||||
degreeAssertion,
|
||||
firstNameAssertion,
|
||||
lastNameAssertion,
|
||||
|
@ -78,7 +78,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
n3ForEnd ) );
|
||||
|
||||
conf.addNewResource("advisingRelationship", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("advisee", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("newAdvisee", 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);
|
||||
|
@ -87,21 +87,18 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "advisee"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName" ));
|
||||
conf.setUrisOnform(Arrays.asList("advisingRelType", "existingSubjArea", "degree", "existingAdvisee"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("advisingRelLabel", "subjAreaLabel", "adviseeLabel", "firstName", "lastName", "subjAreaLabelDisplay", "adviseeLabelDisplay" ));
|
||||
|
||||
conf.addSparqlForExistingLiteral("advisingRelLabel", advisingRelLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("adviseeLabel", adviseeLabelQuery);
|
||||
// may not need these two because in edit mode the display will be an acSelection div
|
||||
// conf.addSparqlForExistingLiteral("firstName", firstNameQuery);
|
||||
// conf.addSparqlForExistingLiteral("lastName", lastNameQuery);
|
||||
conf.addSparqlForExistingLiteral("subjAreaLabel", subjAreaLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||
|
||||
conf.addSparqlForExistingUris("advisingRelType", advisingRelTypeQuery);
|
||||
conf.addSparqlForExistingUris("existingSubjArea", subjAreaQuery);
|
||||
conf.addSparqlForExistingUris("advisee", adviseeQuery);
|
||||
conf.addSparqlForExistingUris("existingAdvisee", adviseeQuery);
|
||||
conf.addSparqlForExistingUris("degree", degreeQuery);
|
||||
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
|
||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||
|
@ -153,7 +150,7 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("advisee").
|
||||
setName("existingAdvisee").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri( adviseeClass )
|
||||
);
|
||||
|
@ -164,6 +161,18 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
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("adviseeLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().setName("startField").
|
||||
setEditElement(
|
||||
new DateTimeWithPrecisionVTwo(null,
|
||||
|
@ -203,27 +212,27 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
final static String advisingRelTypeAssertion =
|
||||
"?advisingRelationship a ?advisingRelType .";
|
||||
|
||||
final static String n3ForAdviseeAssertion =
|
||||
"?advisingRelationship <" + adviseePred + "> ?advisee . \n" +
|
||||
"?advisee <" + adviseeInPred + "> ?advisingRelationship . ";
|
||||
final static String n3ForNewAdviseeAssertion =
|
||||
"?advisingRelationship <" + adviseePred + "> ?newAdvisee . \n" +
|
||||
"?newAdvisee <" + adviseeInPred + "> ?advisingRelationship . \n" +
|
||||
"?newAdvisee <" + label + "> ?adviseeLabel . \n" +
|
||||
"?newAdvisee a <" + adviseeClass + "> . ";
|
||||
|
||||
final static String adviseeLabelAssertion =
|
||||
"?advisee <" + label + "> ?adviseeLabel .";
|
||||
final static String n3ForExistingAdviseeAssertion =
|
||||
"?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
|
||||
"?existingAdvisee <" + adviseeInPred + "> ?advisingRelationship . ";
|
||||
|
||||
final static String firstNameAssertion =
|
||||
"@prefix foaf: <" + foaf + "> . \n" +
|
||||
"?advisee foaf:firstName ?firstName .";
|
||||
"?newAdvisee foaf:firstName ?firstName .";
|
||||
|
||||
final static String lastNameAssertion =
|
||||
"@prefix foaf: <" + foaf + "> . \n" +
|
||||
"?advisee foaf:lastName ?lastName .";
|
||||
"?newAdvisee foaf:lastName ?lastName .";
|
||||
|
||||
final static String degreeAssertion =
|
||||
"?advisingRelationship <"+ degreePred +"> ?degree .";
|
||||
|
||||
final static String n3ForSubjAreaType =
|
||||
"?subjArea a <" + subjAreaClass + "> . ";
|
||||
|
||||
//This is for an existing subject area
|
||||
//Where we only need the existing subject area label
|
||||
final static String n3ForExistingSubjAreaAssertion =
|
||||
|
@ -273,21 +282,6 @@ public class PersonHasAdvisingRelationshipGenerator extends VivoBaseGenerator im
|
|||
" ?existingAdvisee <" + label + "> ?existingAdviseeLabel . \n" +
|
||||
"}";
|
||||
|
||||
/* May not need these
|
||||
final static String firstNameQuery =
|
||||
"prefix foaf: <" + foaf + "> \n" +
|
||||
"SELECT ?existingFirstName WHERE { \n" +
|
||||
" ?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
|
||||
" ?existingAdvisee foaf:firstName ?existingFirstName . \n" +
|
||||
"}";
|
||||
|
||||
final static String lastNameQuery =
|
||||
"prefix foaf: <" + foaf + "> \n" +
|
||||
"SELECT ?existingLastName WHERE { \n" +
|
||||
" ?advisingRelationship <" + adviseePred + "> ?existingAdvisee . \n" +
|
||||
" ?existingAdvisee foaf:lastName ?existingLastName . \n" +
|
||||
"}";
|
||||
*/
|
||||
final static String subjAreaQuery =
|
||||
"SELECT ?existingSubjArea WHERE { \n" +
|
||||
" ?advisingRelationship <" + subjAreaPred + "> ?existingSubjArea . \n" +
|
||||
|
|
|
@ -22,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.
|
|||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasAwardOrHonorValidator;
|
||||
|
||||
public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||
EditConfigurationGenerator {
|
||||
|
@ -65,18 +66,20 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewAwardReceipt,
|
||||
awardReceiptLabelAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForReceiptToAward,
|
||||
n3ForAwardToReceipt,
|
||||
conf.setN3Optional( Arrays.asList( n3ForNewAwardAssertion,
|
||||
n3ForExistingAwardAssertion,
|
||||
descriptionAssertion,
|
||||
n3ForOrgAssertion,
|
||||
awardLabelAssertion,
|
||||
n3ForNewOrgNewAwardAssertion,
|
||||
n3ForExistingOrgNewAwardAssertion,
|
||||
n3ForNewOrgExistingAwardAssertion,
|
||||
n3ForExistingOrgExistingAwardAssertion,
|
||||
n3ForYearAwarded,
|
||||
n3ForStart,
|
||||
n3ForEnd ) );
|
||||
|
||||
conf.addNewResource("award", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("awardReceipt", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("org", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("newOrg", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("yearAwardedNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
@ -85,8 +88,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("award", "org"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel" ));
|
||||
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
|
||||
|
||||
conf.addSparqlForExistingLiteral("awardReceiptLabel", awardReceiptLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("awardLabel", awardLabelQuery);
|
||||
|
@ -96,8 +99,8 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
conf.addSparqlForExistingLiteral("startField-value", existingStartDateQuery);
|
||||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||
|
||||
conf.addSparqlForExistingUris("award", awardQuery);
|
||||
conf.addSparqlForExistingUris("org", orgQuery);
|
||||
conf.addSparqlForExistingUris("existingAward", existingAwardQuery);
|
||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||
conf.addSparqlForExistingUris("yearAwardedNode",existingYearAwardedNodeQuery);
|
||||
conf.addSparqlForExistingUris("intervalNode",existingIntervalNodeQuery);
|
||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||
|
@ -113,13 +116,13 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("org").
|
||||
setName("existingOrg").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri( orgClass )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("award").
|
||||
setName("existingAward").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri( awardClass )
|
||||
);
|
||||
|
@ -139,7 +142,25 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
conf.addField( new FieldVTwo().
|
||||
setName("awardLabel").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("nonempty") )
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()))
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("yearAwardedDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()))
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()))
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("awardLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()))
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().setName("yearAwarded").
|
||||
|
@ -168,7 +189,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
|
||||
conf.addValidator(new PersonHasAwardOrHonorValidator());
|
||||
prepare(vreq, conf);
|
||||
return conf;
|
||||
}
|
||||
|
@ -179,30 +200,43 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
"@prefix vivo: <" + vivoCore + "> . \n\n" +
|
||||
"?person <" + awardReceiptPred + "> ?awardReceipt . \n" +
|
||||
"?awardReceipt a <" + awardReceiptClass + "> . \n" +
|
||||
"?awardReceipt <" + awardForPred + "> ?person . \n" +
|
||||
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
|
||||
"?award a <" + awardClass + "> . " ;
|
||||
"?awardReceipt <" + awardForPred + "> ?person . " ;
|
||||
|
||||
final static String awardReceiptLabelAssertion =
|
||||
"?awardReceipt <"+ label + "> ?awardReceiptLabel .";
|
||||
|
||||
final static String n3ForReceiptToAward =
|
||||
"?awardReceipt <" + receiptOfPred + "> ?award .";
|
||||
|
||||
final static String awardLabelAssertion =
|
||||
final static String n3ForNewAwardAssertion =
|
||||
"?awardReceipt <" + receiptOfPred + "> ?award . \n" +
|
||||
"?award a <" + awardClass + "> . \n" +
|
||||
"?award <" + receiptPred + "> ?awardReceipt . \n" +
|
||||
"?award <"+ label + "> ?awardLabel .";
|
||||
|
||||
final static String n3ForAwardToReceipt =
|
||||
"?award <" + receiptPred + "> ?awardReceipt .";
|
||||
final static String n3ForExistingAwardAssertion =
|
||||
"?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
|
||||
"?existingAward <" + receiptPred + "> ?awardReceipt . " ;
|
||||
|
||||
final static String descriptionAssertion =
|
||||
"?awardReceipt <"+ descriptionPred +"> ?description .";
|
||||
|
||||
final static String n3ForOrgAssertion =
|
||||
"?award <" + awardConferredByPred +"> ?org . \n" +
|
||||
"?org a <" + orgClass + "> . \n" +
|
||||
"?org <" + awardConferredPred + "> ?award . \n" +
|
||||
"?org <"+ label + "> ?orgLabel .";
|
||||
final static String n3ForExistingOrgNewAwardAssertion =
|
||||
"?award <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||
"?existingOrg <" + awardConferredPred + "> ?award . ";
|
||||
|
||||
final static String n3ForExistingOrgExistingAwardAssertion =
|
||||
"?existingAward <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||
"?existingOrg <" + awardConferredPred + "> ?existingAward . ";
|
||||
|
||||
final static String n3ForNewOrgNewAwardAssertion =
|
||||
"?newOrg a <" + orgClass + "> . \n" +
|
||||
"?award <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||
"?newOrg <" + awardConferredPred + "> ?award . \n" +
|
||||
"?newOrg <"+ label + "> ?orgLabel .";
|
||||
|
||||
final static String n3ForNewOrgExistingAwardAssertion =
|
||||
"?newOrg a <" + orgClass + "> . \n" +
|
||||
"?existingAward <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||
"?newOrg <" + awardConferredPred + "> ?existingAward . \n" +
|
||||
"?newOrg <"+ label + "> ?orgLabel .";
|
||||
|
||||
final static String n3ForYearAwarded =
|
||||
"?awardReceipt <" + yearAwardedPred + "> ?yearAwardedNode . \n" +
|
||||
|
@ -228,15 +262,16 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
|
||||
/* Queries for editing an existing entry */
|
||||
|
||||
final static String awardQuery =
|
||||
final static String existingAwardQuery =
|
||||
"SELECT ?existingAward WHERE { \n" +
|
||||
" ?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
|
||||
"}";
|
||||
|
||||
final static String orgQuery =
|
||||
final static String existingOrgQuery =
|
||||
"SELECT ?existingOrg WHERE { \n" +
|
||||
" ?award <" + awardConferredByPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg <" + awardConferredPred + "> ?award . }";
|
||||
" ?awardReceipt <" + receiptOfPred + "> ?existingAward . \n" +
|
||||
" ?existingAward<" + awardConferredByPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg <" + awardConferredPred + "> ?existingAward . }";
|
||||
|
||||
final static String awardReceiptLabelQuery =
|
||||
"SELECT ?existingAwardReceiptLabel WHERE { \n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue