custom form changes to support editable autocomplete fields; new validator classes
This commit is contained in:
parent
6695832257
commit
5e13309e8a
14 changed files with 462 additions and 157 deletions
|
@ -12,10 +12,18 @@ 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 {
|
||||
public class AutocompleteRequiredInputValidator implements N3ValidatorVTwo {
|
||||
|
||||
private static String MISSING_AWARD_LABEL_ERROR = "You must select an existing award or type the name of a new award.";
|
||||
;
|
||||
private static String MISSING_LABEL_ERROR = "Please select an existing value or enter a new value in the Name field.";
|
||||
|
||||
private String uriReceiver;
|
||||
private String labelInput;
|
||||
|
||||
public AutocompleteRequiredInputValidator(String uriReceiver, String labelInput) {
|
||||
this.uriReceiver = uriReceiver;
|
||||
this.labelInput = labelInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> validate(EditConfigurationVTwo editConfig,
|
||||
MultiValueEditSubmission editSub) {
|
||||
|
@ -24,25 +32,23 @@ public class PersonHasAwardOrHonorValidator implements N3ValidatorVTwo {
|
|||
|
||||
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.
|
||||
List<String> selectedUri = urisFromForm.get(uriReceiver);
|
||||
|
||||
// If there's a presentationUri, 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) {
|
||||
if (allListElementsEmpty(selectedUri) || selectedUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
||||
selectedUri = null;
|
||||
}
|
||||
if (selectedUri != null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
List<String> awardLabel = urisFromForm.get("awardLabel");
|
||||
if (allListElementsEmpty(awardLabel)) {
|
||||
awardLabel = null;
|
||||
}
|
||||
if (awardLabel != null) {
|
||||
List<Literal> specifiedLabel = literalsFromForm.get(labelInput);
|
||||
if (specifiedLabel != null && specifiedLabel.size() > 0) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
errors.put("awardLabel", MISSING_AWARD_LABEL_ERROR);
|
||||
errors.put(labelInput, MISSING_LABEL_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public class PersonHasAdviseesValidator 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) {
|
||||
|
@ -27,7 +27,7 @@ public class PersonHasAdviseesValidator implements N3ValidatorVTwo {
|
|||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
List<String> adviseeUri = urisFromForm.get("existingAdvisee");
|
||||
if (allListElementsEmpty(adviseeUri)) {
|
||||
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
|
||||
|
|
|
@ -16,8 +16,9 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
|||
|
||||
public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||
|
||||
private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type.";
|
||||
private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title.";
|
||||
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,
|
||||
|
@ -29,35 +30,53 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
|||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
// If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted.
|
||||
List<String> pubUriList = urisFromForm.get("pubUri");
|
||||
List<String> editorUriList = urisFromForm.get("editorUri");
|
||||
//This method will return null if the list is null or empty, otherwise returns first element
|
||||
//Assumption is that only one value for uri, type, or title will be sent back
|
||||
String pubUri = (String) getFirstElement(pubUriList);
|
||||
if (!StringUtils.isEmpty(pubUri)) {
|
||||
String editorUri = (String) getFirstElement(editorUriList);
|
||||
if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
|
||||
editorUri = null;
|
||||
}
|
||||
if ( editorUri != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> pubTypeList = urisFromForm.get("pubType");
|
||||
String pubType = (String) getFirstElement(pubTypeList);
|
||||
if ("".equals(pubType)) {
|
||||
pubType = 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);
|
||||
}
|
||||
|
||||
List<Literal> titleList = literalsFromForm.get("title");
|
||||
Literal title = (Literal) getFirstElement(titleList);
|
||||
if (title != null) {
|
||||
String titleValue = title.getLexicalForm();
|
||||
if (StringUtils.isEmpty(titleValue)) {
|
||||
title = null;
|
||||
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 (pubType == null) {
|
||||
errors.put("pubType", MISSING_PUB_TYPE_ERROR);
|
||||
}
|
||||
if (title == null) {
|
||||
errors.put("title", MISSING_PUB_TITLE_ERROR);
|
||||
}
|
||||
if (firstName == null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
}
|
||||
|
||||
return errors.size() != 0 ? errors : null;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,10 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisio
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.FieldVTwo;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||
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.AutocompleteRequiredInputValidator;
|
||||
|
||||
public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator implements
|
||||
EditConfigurationGenerator {
|
||||
|
@ -61,13 +63,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
conf.setVarNameForObject("role");
|
||||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewRole,
|
||||
roleLabelAssertion,
|
||||
presTypeAssertion,
|
||||
presLabelAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForConference, n3ForStart, n3ForEnd ) );
|
||||
roleLabelAssertion) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForNewPresentation, presTypeAssertion, n3ForExistingPresentation, n3ForNewConference, n3ForExistingConference, n3ForStart, n3ForEnd ) );
|
||||
|
||||
conf.addNewResource("presentation", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("conference", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("newConference", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("role", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("intervalNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
@ -76,14 +76,14 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("presentation", "conference", "role", "presentationType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "conferenceLabel", "roleLabel"));
|
||||
conf.setUrisOnform(Arrays.asList("existingPresentation", "existingConference", "presentationType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("presentationLabel", "presentationLabelDisplay", "conferenceLabel", "conferenceLabelDisplay", "roleLabel"));
|
||||
|
||||
conf.addSparqlForExistingLiteral("presentationLabel", presentationLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("conferenceLabel", conferenceLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("roleLabel", roleLabelQuery);
|
||||
conf.addSparqlForExistingUris("presentation", presentationQuery);
|
||||
conf.addSparqlForExistingUris("conference", conferenceQuery);
|
||||
conf.addSparqlForExistingUris("existingPresentation", presentationQuery);
|
||||
conf.addSparqlForExistingUris("existingConference", existingConferenceQuery);
|
||||
conf.addSparqlForExistingUris("presentationType", presentationTypeQuery);
|
||||
conf.addSparqlForExistingLiteral(
|
||||
"startField-value", existingStartDateQuery);
|
||||
|
@ -99,15 +99,21 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
existingEndPrecisionQuery);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("presentation").
|
||||
setName("existingPresentation").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri(presentationClass)
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("presentationLabelDisplay")
|
||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("presentationLabel")
|
||||
.setRangeDatatypeUri( XSD.xstring.toString() ).
|
||||
setValidators( list("nonempty") )
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
|
@ -124,7 +130,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("conference").
|
||||
setName("existingConference").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri(conferenceClass)
|
||||
);
|
||||
|
@ -134,6 +140,11 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
setRangeDatatypeUri(XSD.xstring.toString() )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("conferenceLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().setName("startField").
|
||||
setEditElement(
|
||||
new DateTimeWithPrecisionVTwo(null,
|
||||
|
@ -152,7 +163,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
|
||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingPresentation", "presentationLabel"));
|
||||
prepare(vreq, conf);
|
||||
return conf;
|
||||
}
|
||||
|
@ -162,24 +173,33 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
"@prefix core: <" + vivoCore + "> . \n\n" +
|
||||
"?person <" + hasRolePred + "> ?role . \n" +
|
||||
"?role a <" + roleClass + "> . \n" +
|
||||
"?role <" + roleOfPred + "> ?person . \n" +
|
||||
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
|
||||
"?presentation <" + realizedRolePred + "> ?role .";
|
||||
|
||||
"?role <" + roleOfPred + "> ?person . ";
|
||||
|
||||
final static String roleLabelAssertion =
|
||||
"?role <" + label + "> ?roleLabel .";
|
||||
|
||||
final static String presLabelAssertion =
|
||||
final static String n3ForNewPresentation =
|
||||
"?role <" + roleRealizedInPred + "> ?presentation . \n" +
|
||||
"?presentation <" + realizedRolePred + "> ?role . \n" +
|
||||
"?presentation <" + label + "> ?presentationLabel .";
|
||||
|
||||
final static String n3ForExistingPresentation =
|
||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . \n" +
|
||||
"?existingPresentation <" + realizedRolePred + "> ?role . ";
|
||||
|
||||
final static String presTypeAssertion =
|
||||
"?presentation a ?presentationType .";
|
||||
|
||||
final static String n3ForConference =
|
||||
"?conference a <" + conferenceClass + "> . \n" +
|
||||
"?conference <" + includesEventPred + "> ?presentation . \n" +
|
||||
"?presentation <" + eventWithinPred + "> ?conference . \n" +
|
||||
"?conference <" + label + "> ?conferenceLabel .";
|
||||
final static String n3ForNewConference =
|
||||
"?presentation <" + eventWithinPred + "> ?newConference . \n" +
|
||||
"?newConference <" + includesEventPred + "> ?presentation . \n" +
|
||||
"?newConference a <" + conferenceClass + "> . \n" +
|
||||
"?newConference <" + label + "> ?conferenceLabel .";
|
||||
|
||||
final static String n3ForExistingConference =
|
||||
"?existingConference a <" + conferenceClass + "> . \n" +
|
||||
"?existingConference <" + includesEventPred + "> ?presentation . \n" +
|
||||
"?presentation <" + eventWithinPred + "> ?existingConference . ";
|
||||
|
||||
final static String n3ForStart =
|
||||
"?role <" + roleToInterval + "> ?intervalNode . \n" +
|
||||
|
@ -217,7 +237,7 @@ public class AddPresenterRoleToPersonGenerator extends VivoBaseGenerator impleme
|
|||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||
"?existingPresentation vitro:mostSpecificType ?existingPresentationType . }";
|
||||
|
||||
final static String conferenceQuery =
|
||||
final static String existingConferenceQuery =
|
||||
"SELECT ?existingConference WHERE { \n" +
|
||||
"?role <" + roleRealizedInPred + "> ?existingPresentation . " +
|
||||
"?existingPresentation <" + eventWithinPred + "> ?existingConference . }";
|
||||
|
|
|
@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||
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.AutocompleteRequiredInputValidator;
|
||||
|
||||
/**
|
||||
* On an add/new, this will show a form, on an edit/update this will skip to the
|
||||
|
@ -112,8 +113,9 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
// template file
|
||||
editConfiguration.setTemplate("addPublicationToPerson.ftl");
|
||||
// adding person has publication validator
|
||||
editConfiguration.addValidator(new PersonHasPublicationValidator());
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("pubUri", "title"));
|
||||
editConfiguration.addValidator(new PersonHasPublicationValidator());
|
||||
|
||||
// Adding additional data, specifically edit mode
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
|
@ -140,29 +142,35 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
|
||||
/***N3 strings both required and optional***/
|
||||
private List<String> generateN3Optional() {
|
||||
return list(getN3ForExistingPub(),
|
||||
getN3ForNewPub(),
|
||||
getN3NewPubNameAssertion(),
|
||||
getN3NewPubTypeAssertion(),
|
||||
getN3ForCollection(),
|
||||
getN3ForBook(),
|
||||
getN3ForConference(),
|
||||
getN3ForEvent(),
|
||||
getN3ForEditor(),
|
||||
getN3ForPublisher(),
|
||||
getN3ForLocaleAssertion(),
|
||||
getN3ForVolumeAssertion(),
|
||||
getN3ForNumberAssertion(),
|
||||
getN3ForIssueAssertion(),
|
||||
getN3ForStartPageAssertion(),
|
||||
getN3ForEndPageAssertion(),
|
||||
getN3ForDateTimeAssertion()
|
||||
return list(getN3ForNewCollection(),
|
||||
getN3ForNewBook(),
|
||||
getN3ForNewConference(),
|
||||
getN3ForNewEvent(),
|
||||
getN3ForNewEditor(),
|
||||
getN3ForNewPublisher(),
|
||||
getN3ForCollection(),
|
||||
getN3ForBook(),
|
||||
getN3ForConference(),
|
||||
getN3ForEvent(),
|
||||
getN3ForEditor(),
|
||||
getN3ForPublisher(),
|
||||
getN3ForLocaleAssertion(),
|
||||
getN3ForVolumeAssertion(),
|
||||
getN3ForNumberAssertion(),
|
||||
getN3ForIssueAssertion(),
|
||||
getN3ForStartPageAssertion(),
|
||||
getN3ForEndPageAssertion(),
|
||||
getN3ForDateTimeAssertion()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private List<String> generateN3Required() {
|
||||
return list(getAuthorshipN3());
|
||||
return list(getAuthorshipN3(),
|
||||
getN3ForNewPub(),
|
||||
getN3NewPubNameAssertion(),
|
||||
getN3NewPubTypeAssertion()
|
||||
);
|
||||
}
|
||||
|
||||
private String getAuthorshipN3() {
|
||||
|
@ -195,52 +203,88 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
|
||||
}
|
||||
|
||||
private String getN3ForNewCollection() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:hasPublicationVenue ?newCollection . \n" +
|
||||
"?newCollection a <" + collectionClass + "> . \n" +
|
||||
"?newCollection vivo:publicationVenueFor ?pubUri . \n" +
|
||||
"?newCollection <" + label + "> ?collection .";
|
||||
}
|
||||
|
||||
private String getN3ForCollection() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:hasPublicationVenue ?collectionUri . \n" +
|
||||
"?collectionUri a <" + collectionClass + "> . \n" +
|
||||
"?collectionUri vivo:publicationVenueFor ?pubUri . \n" +
|
||||
"?collectionUri <" + label + "> ?collection .";
|
||||
"?collectionUri vivo:publicationVenueFor ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForNewBook() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:hasPublicationVenue ?newBook . \n" +
|
||||
"?newBook a <" + bookClass + "> . \n" +
|
||||
"?newBook vivo:publicationVenueFor ?pubUri . \n " +
|
||||
"?newBook <" + label + "> ?book .";
|
||||
}
|
||||
|
||||
private String getN3ForBook() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:hasPublicationVenue ?bookUri . \n" +
|
||||
"?bookUri a <" + bookClass + "> . \n" +
|
||||
"?bookUri vivo:publicationVenueFor ?pubUri . \n " +
|
||||
"?bookUri <" + label + "> ?book .";
|
||||
"?bookUri vivo:publicationVenueFor ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForNewConference() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri <" + presentedAtPred + "> ?newConference . \n" +
|
||||
"?newConference a <" + conferenceClass + "> . \n" +
|
||||
"?newConference vivo:includesEvent ?pubUri . \n" +
|
||||
"?newConference <" + label + "> ?conference .";
|
||||
}
|
||||
|
||||
private String getN3ForConference() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri <" + presentedAtPred + "> ?conferenceUri . \n" +
|
||||
"?conferenceUri a <" + conferenceClass + "> . \n" +
|
||||
"?conferenceUri vivo:includesEvent ?pubUri . \n" +
|
||||
"?conferenceUri <" + label + "> ?conference .";
|
||||
"?conferenceUri vivo:includesEvent ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForNewEvent() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:proceedingsOf ?newEvent . \n" +
|
||||
"?newEvent a <" + conferenceClass + "> . \n" +
|
||||
"?newEvent vivo:hasProceedings ?pubUri . \n" +
|
||||
"?newEvent <" + label + "> ?event .";
|
||||
}
|
||||
|
||||
private String getN3ForEvent() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:proceedingsOf ?eventUri . \n" +
|
||||
"?eventUri a <" + conferenceClass + "> . \n" +
|
||||
"?eventUri vivo:hasProceedings ?pubUri . \n" +
|
||||
"?eventUri <" + label + "> ?event .";
|
||||
"?eventUri vivo:hasProceedings ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForNewEditor() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:editor ?newEditor . \n" +
|
||||
"?newEditor a <" + editorClass + "> . \n" +
|
||||
"?newEditor vivo:editorOf ?pubUri . \n" +
|
||||
"?newEditor <" + label + "> ?editor .";
|
||||
}
|
||||
|
||||
private String getN3ForEditor() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:editor ?editorUri . \n" +
|
||||
"?editorUri a <" + editorClass + "> . \n" +
|
||||
"?editorUri vivo:editorOf ?pubUri . \n" +
|
||||
"?editorUri <" + label + "> ?editor .";
|
||||
"?editorUri vivo:editorOf ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForNewPublisher() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:publisher ?newPublisher . \n" +
|
||||
"?newPublisher a <" + publisherClass + "> . \n" +
|
||||
"?newPublisher vivo:publisherOf ?pubUri . \n" +
|
||||
"?newPublisher <" + label + "> ?publisher .";
|
||||
}
|
||||
|
||||
private String getN3ForPublisher() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:publisher ?publisherUri . \n" +
|
||||
"?publisherUri a <" + publisherClass + "> . \n" +
|
||||
"?publisherUri vivo:publisherOf ?pubUri . \n" +
|
||||
"?publisherUri <" + label + "> ?publisher .";
|
||||
"?publisherUri vivo:publisherOf ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3ForLocaleAssertion() {
|
||||
|
@ -288,12 +332,12 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
HashMap<String, String> newResources = new HashMap<String, String>();
|
||||
newResources.put("authorshipUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("pubUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("collectionUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("bookUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("conferenceUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("eventUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("editorUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("publisherUri", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newCollection", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newBook", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newConference", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newEvent", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newEditor", DEFAULT_NS_TOKEN);
|
||||
newResources.put("newPublisher", DEFAULT_NS_TOKEN);
|
||||
newResources.put("dateTimeNode", DEFAULT_NS_TOKEN);
|
||||
return newResources;
|
||||
}
|
||||
|
@ -314,7 +358,6 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//add role activity and roleActivityType to uris on form
|
||||
urisOnForm.add("pubUri");
|
||||
urisOnForm.add("pubType");
|
||||
urisOnForm.add("collectionUri");
|
||||
urisOnForm.add("bookUri");
|
||||
|
@ -333,12 +376,20 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
literalsOnForm.add("event");
|
||||
literalsOnForm.add("editor");
|
||||
literalsOnForm.add("publisher");
|
||||
literalsOnForm.add("collectionDisplay");
|
||||
literalsOnForm.add("bookDisplay");
|
||||
literalsOnForm.add("conferenceDisplay");
|
||||
literalsOnForm.add("eventDisplay");
|
||||
literalsOnForm.add("editorDisplay");
|
||||
literalsOnForm.add("publisherDisplay");
|
||||
literalsOnForm.add("locale");
|
||||
literalsOnForm.add("volume");
|
||||
literalsOnForm.add("number");
|
||||
literalsOnForm.add("issue");
|
||||
literalsOnForm.add("startPage");
|
||||
literalsOnForm.add("endPage");
|
||||
literalsOnForm.add("firstName");
|
||||
literalsOnForm.add("lastName");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
|
@ -361,16 +412,24 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setPubTypeField(editConfiguration);
|
||||
setPubUriField(editConfiguration);
|
||||
setCollectionLabelField(editConfiguration);
|
||||
setCollectionDisplayField(editConfiguration);
|
||||
setCollectionUriField(editConfiguration);
|
||||
setBookLabelField(editConfiguration);
|
||||
setBookDisplayField(editConfiguration);
|
||||
setBookUriField(editConfiguration);
|
||||
setConferenceLabelField(editConfiguration);
|
||||
setConferenceDisplayField(editConfiguration);
|
||||
setConferenceUriField(editConfiguration);
|
||||
setEventLabelField(editConfiguration);
|
||||
setEventDisplayField(editConfiguration);
|
||||
setEventUriField(editConfiguration);
|
||||
setEditorLabelField(editConfiguration);
|
||||
setEditorDisplayField(editConfiguration);
|
||||
setFirstNameField(editConfiguration);
|
||||
setLastNameField(editConfiguration);
|
||||
setEditorUriField(editConfiguration);
|
||||
setPublisherLabelField(editConfiguration);
|
||||
setPublisherDisplayField(editConfiguration);
|
||||
setPublisherUriField(editConfiguration);
|
||||
setLocaleField(editConfiguration);
|
||||
setVolumeField(editConfiguration);
|
||||
|
@ -393,7 +452,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("pubType").
|
||||
setOptionsType("HARDCODED_LITERALS").
|
||||
setLiteralOptions(getPublicationTypeLiteralOptions()));
|
||||
setLiteralOptions(getPublicationTypeLiteralOptions()).
|
||||
setValidators( list("nonempty") ));
|
||||
}
|
||||
|
||||
private void setPubUriField(EditConfigurationVTwo editConfiguration) {
|
||||
|
@ -410,6 +470,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setCollectionDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("collectionDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setCollectionUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("collectionUri").
|
||||
|
@ -423,6 +491,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setBookDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("bookDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setBookUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
|
@ -437,6 +513,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setConferenceDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("conferenceDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setConferenceUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
|
@ -451,7 +535,31 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setEventDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("eventDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
|
||||
private void setFirstNameField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("firstName").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setLastNameField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("lastName").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
private void setEventUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("eventUri").
|
||||
|
@ -465,6 +573,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setEditorDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("editorDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setEditorUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
|
@ -479,6 +595,14 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setPublisherDisplayField(EditConfigurationVTwo editConfiguration) {
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
setName("publisherDisplay").
|
||||
setValidators(list("datatype:" + stringDatatypeUri)).
|
||||
setRangeDatatypeUri(stringDatatypeUri));
|
||||
}
|
||||
|
||||
private void setPublisherUriField(EditConfigurationVTwo editConfiguration) {
|
||||
editConfiguration.addField(new FieldVTwo().
|
||||
|
|
|
@ -22,7 +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;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
|
||||
|
||||
public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||
EditConfigurationGenerator {
|
||||
|
@ -189,7 +189,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
conf.addValidator(new PersonHasAwardOrHonorValidator());
|
||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingAward", "awardLabel"));
|
||||
prepare(vreq, conf);
|
||||
return conf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue