NIHVIVO-3709: updates to support editable autocomplete fields
This commit is contained in:
parent
5e13309e8a
commit
028d367461
18 changed files with 519 additions and 187 deletions
|
@ -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 OrganizationHasPositionValidator 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> personUri = urisFromForm.get("existingPerson");
|
||||
if (allListElementsEmpty(personUri) || personUri.contains(">SUBMITTED VALUE WAS BLANK<")) {
|
||||
personUri = null;
|
||||
}
|
||||
// If there's an adviseeUri, then we're done. The firstName and lastName fields are
|
||||
// disabled and so don't get submitted.
|
||||
if (personUri != 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
|
||||
|
@ -16,6 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
|||
|
||||
public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
||||
|
||||
private Log log = LogFactory.getLog(PersonHasPublicationValidator.class);
|
||||
|
||||
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.";
|
||||
|
@ -29,35 +33,25 @@ 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> 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 editorUri = (String) getFirstElement(editorUriList);
|
||||
if (StringUtils.isEmpty(editorUri) || editorUri.equals(">SUBMITTED VALUE WAS BLANK<")) {
|
||||
editorUri = null;
|
||||
}
|
||||
if ( editorUri != null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// The Editor field is optional for all publication subclasses. Validation is only necessary if the user only enters a
|
||||
// last name or only enters a first name
|
||||
|
||||
//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");
|
||||
Literal firstName = null;
|
||||
if(firstNameList != null && firstNameList.size() > 0) {
|
||||
firstName = firstNameList.get(0);
|
||||
firstName = firstNameList.get(0);
|
||||
}
|
||||
if( firstName != null &&
|
||||
firstName.getLexicalForm() != null &&
|
||||
"".equals(firstName.getLexicalForm()) )
|
||||
firstName = 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);
|
||||
lastName = lastNameList.get(0);
|
||||
}
|
||||
String lastNameValue = "";
|
||||
if (lastName != null) {
|
||||
|
@ -67,15 +61,18 @@ public class PersonHasPublicationValidator implements N3ValidatorVTwo {
|
|||
}
|
||||
}
|
||||
|
||||
if (lastName == null) {
|
||||
if ( lastName == null && firstName != null ) {
|
||||
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||
// Don't reject space in the last name: de Vries, etc.
|
||||
} else if (lastNameValue.contains(",")) {
|
||||
// Don't reject space in the last name: de Vries, etc.
|
||||
}
|
||||
else if ( firstName == null && lastName != null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
}
|
||||
else if (lastNameValue.contains(",")) {
|
||||
errors.put("lastName", MALFORMED_LAST_NAME_ERROR);
|
||||
}
|
||||
|
||||
if (firstName == null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return errors.size() != 0 ? errors : null;
|
||||
|
|
|
@ -34,6 +34,8 @@ 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.AutocompleteRequiredInputValidator;
|
||||
|
||||
/**
|
||||
* Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole
|
||||
and hasPrincipalInvestigatorRole.
|
||||
|
@ -109,7 +111,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Add validators
|
||||
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
|
||||
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingGrant","grantLabel"));
|
||||
//no preprocessors required here
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(editConfiguration, vreq);
|
||||
|
@ -183,8 +185,10 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
|
||||
private List<String> generateN3Optional(VitroRequest vreq) {
|
||||
List<String> n3Optional = new ArrayList<String>();
|
||||
//n3 for grant label
|
||||
n3Optional.add(getN3ForGrantLabel(vreq));
|
||||
//n3 for new grant
|
||||
n3Optional.add(getN3ForNewGrant(vreq));
|
||||
//n3 for existing grant
|
||||
n3Optional.add(getN3ForExistingGrant(vreq));
|
||||
//n3 for inverse
|
||||
n3Optional.add("?role ?inverseRolePredicate ?person .");
|
||||
//N3ForStart
|
||||
|
@ -198,17 +202,25 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
String editString = getPrefixesString();
|
||||
editString += "?person ?rolePredicate ?role .";
|
||||
editString += "?role a <" + getRoleType(vreq) + "> .";
|
||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
|
||||
editString += "?grant a core:Grant ;" +
|
||||
"<" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||
return editString;
|
||||
}
|
||||
|
||||
public String getN3ForGrantLabel(VitroRequest vreq) {
|
||||
return "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
|
||||
|
||||
public String getN3ForNewGrant(VitroRequest vreq) {
|
||||
String editString = getPrefixesString();
|
||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?grant .";
|
||||
editString += "?grant a core:Grant . ";
|
||||
editString += "?grant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||
editString += "?grant <" + RDFS.label.getURI() + "> ?grantLabel .";
|
||||
return editString;
|
||||
}
|
||||
|
||||
|
||||
public String getN3ForExistingGrant(VitroRequest vreq) {
|
||||
String editString = getPrefixesString();
|
||||
editString += "?role <" + getRoleToGrantPredicate(vreq) + "> ?existingGrant . ";
|
||||
editString += "?existingGrant <" + getGrantToRolePredicate(vreq) + "> ?role .";
|
||||
return editString;
|
||||
}
|
||||
|
||||
//Method b/c used in two locations, n3 optional and n3 assertions
|
||||
private List<String> getN3ForStart() {
|
||||
List<String> n3ForStart = new ArrayList<String>();
|
||||
|
@ -248,9 +260,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
newResources.put("endNode", defaultNamespace + "individual");
|
||||
return newResources;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set URIS and Literals In Scope and on form and supporting methods
|
||||
|
@ -295,10 +304,11 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
//add role activity and roleActivityType to uris on form
|
||||
urisOnForm.add("grant");
|
||||
urisOnForm.add("existingGrant");
|
||||
editConfiguration.setUrisOnform(urisOnForm);
|
||||
//activity label and role label are literals on form
|
||||
literalsOnForm.add("grantLabel");
|
||||
literalsOnForm.add("existingGrantLabel");
|
||||
literalsOnForm.add("grantLabelDisplay");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
||||
|
@ -324,7 +334,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
private HashMap<String, String> generateSparqlForExistingUris(VitroRequest vreq) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
//Queries for role activity, activity type query, interval node, start node, end node, start field precision, endfield precision
|
||||
map.put("grant", getGrantQuery(vreq));
|
||||
map.put("existingGrant", getExistingGrantQuery(vreq));
|
||||
map.put("intervalNode", getIntervalNodeQuery(vreq));
|
||||
map.put("startNode", getStartNodeQuery(vreq));
|
||||
map.put("endNode", getEndNodeQuery(vreq));
|
||||
|
@ -390,7 +400,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
map.put("endField-value", getExistingEndDateQuery(vreq));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private String getGrantLabelQuery(VitroRequest vreq) {
|
||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||
|
@ -404,7 +413,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
return query;
|
||||
}
|
||||
|
||||
private String getGrantQuery(VitroRequest vreq) {
|
||||
private String getExistingGrantQuery(VitroRequest vreq) {
|
||||
String query = "PREFIX core: <" + getVivoCoreNamespace() + ">" +
|
||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n";
|
||||
|
||||
|
@ -445,7 +454,8 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Multiple fields
|
||||
getGrantField(editConfiguration, vreq, fields);
|
||||
getGrantLabelField(editConfiguration, vreq, fields);
|
||||
getExistingGrantLabelField(editConfiguration, vreq, fields);
|
||||
getGrantLabelDisplayField(editConfiguration, vreq, fields);
|
||||
getExistingGrantField(editConfiguration, vreq, fields);
|
||||
getStartField(editConfiguration, vreq, fields);
|
||||
getEndField(editConfiguration, vreq, fields);
|
||||
editConfiguration.setFields(fields);
|
||||
|
@ -489,9 +499,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
//Not really interested in validators here
|
||||
List<String> validators = new ArrayList<String>();
|
||||
validators.add("datatype:" + stringDatatypeUri);
|
||||
if(isAddMode(vreq) || isRepairMode(vreq)) {
|
||||
validators.add("nonempty");
|
||||
}
|
||||
field.setValidators(validators);
|
||||
|
||||
//subjectUri and subjectClassUri are not being used in Field
|
||||
|
@ -508,11 +515,34 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
|
||||
}
|
||||
|
||||
private void getGrantLabelDisplayField(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "grantLabelDisplay";
|
||||
//get range data type uri and range language
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName(fieldName);
|
||||
//queryForExisting is not being used anywhere in Field
|
||||
|
||||
//subjectUri and subjectClassUri are not being used in Field
|
||||
|
||||
field.setOptionsType("UNDEFINED");
|
||||
//why isn't predicate uri set for data properties?
|
||||
field.setPredicateUri(null);
|
||||
field.setObjectClassUri(null);
|
||||
field.setRangeDatatypeUri(null);
|
||||
|
||||
field.setLiteralOptions(new ArrayList<List<String>>());
|
||||
|
||||
fields.put(field.getName(), field);
|
||||
|
||||
}
|
||||
//Need if returning from an invalid submission
|
||||
private void getExistingGrantLabelField(
|
||||
private void getExistingGrantField(
|
||||
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
||||
Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "existingGrantLabel";
|
||||
String fieldName = "existingGrant";
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName(fieldName);
|
||||
|
@ -634,9 +664,7 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
private boolean isRepairMode(VitroRequest vreq) {
|
||||
return EditModeUtils.isRepairMode(getEditMode(vreq));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Methods that are REQUIRED to be implemented in subclasses
|
||||
**/
|
||||
|
@ -668,10 +696,6 @@ public class AddGrantRoleToPersonGenerator implements EditConfigurationGenerator
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Methods with default values that may be overwritten when required by a subclass
|
||||
* Both Default value and method that can be overwritten are included below
|
||||
|
|
|
@ -153,6 +153,8 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
getN3ForConference(),
|
||||
getN3ForEvent(),
|
||||
getN3ForEditor(),
|
||||
getN3FirstNameAssertion(),
|
||||
getN3LastNameAssertion(),
|
||||
getN3ForPublisher(),
|
||||
getN3ForLocaleAssertion(),
|
||||
getN3ForVolumeAssertion(),
|
||||
|
@ -273,6 +275,16 @@ public class AddPublicationToPersonGenerator extends VivoBaseGenerator implement
|
|||
"?editorUri vivo:editorOf ?pubUri . ";
|
||||
}
|
||||
|
||||
private String getN3FirstNameAssertion() {
|
||||
return "@prefix foaf: <" + foaf + "> . \n" +
|
||||
"?newEditor foaf:firstName ?firstName .";
|
||||
}
|
||||
|
||||
private String getN3LastNameAssertion() {
|
||||
return "@prefix foaf: <" + foaf + "> . \n" +
|
||||
"?newEditor foaf:lastName ?lastName .";
|
||||
}
|
||||
|
||||
private String getN3ForNewPublisher() {
|
||||
return "@prefix vivo: <" + vivoCore + "> . \n" +
|
||||
"?pubUri vivo:publisher ?newPublisher . \n" +
|
||||
|
|
|
@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocesso
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.AntiXssValidation;
|
||||
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;
|
||||
/**
|
||||
* Generates the edit configuration for adding a Role to a Person.
|
||||
|
||||
|
@ -128,7 +129,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
editConfiguration.setN3Required(list(
|
||||
N3_PREFIX + "\n" +
|
||||
"?person ?rolePredicate ?role .\n" +
|
||||
"?role a ?roleType .\n"
|
||||
"?role a ?roleType .\n" +
|
||||
"?role ?inverseRolePredicate ?person ."
|
||||
));
|
||||
|
||||
// Optional N3
|
||||
|
@ -140,10 +142,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//independently evaluated and passed back with substitutions even if the other strings are not
|
||||
//substituted correctly.
|
||||
editConfiguration.setN3Optional( list(
|
||||
"?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+
|
||||
"?roleActivity " + getActivityToRolePlaceholder() + " ?role .",
|
||||
"?role ?inverseRolePredicate ?person .",
|
||||
getN3ForActivityLabel(),
|
||||
getN3ForNewRoleActivity(),
|
||||
getN3ForExistingRoleActivity(),
|
||||
getN3ForActivityType(),
|
||||
getN3RoleLabelAssertion(),
|
||||
getN3ForStart(),
|
||||
|
@ -173,6 +173,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Add validator
|
||||
editConfiguration.addValidator(new DateTimeIntervalValidationVTwo("startField","endField") );
|
||||
editConfiguration.addValidator(new AntiXssValidation());
|
||||
editConfiguration.addValidator(new AutocompleteRequiredInputValidator("existingRoleActivity", "activityLabel"));
|
||||
|
||||
//Add preprocessors
|
||||
addPreprocessors(editConfiguration, vreq.getWebappDaoFactory());
|
||||
|
@ -191,8 +192,19 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
|
||||
/* N3 Required and Optional Generators as well as supporting methods */
|
||||
|
||||
private String getN3ForActivityLabel() {
|
||||
return "?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel .";
|
||||
private List<String> getN3ForNewRoleActivity() {
|
||||
List<String> n3ForNewRoleActivity = new ArrayList<String>();
|
||||
n3ForNewRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?roleActivity .\n"+
|
||||
"?roleActivity " + getActivityToRolePlaceholder() + " ?role . \n" +
|
||||
"?roleActivity <" + RDFS.label.getURI() + "> ?activityLabel .");
|
||||
return n3ForNewRoleActivity;
|
||||
}
|
||||
|
||||
private List<String> getN3ForExistingRoleActivity() {
|
||||
List<String> n3ForExistingRoleActivity = new ArrayList<String>();
|
||||
n3ForExistingRoleActivity.add("?role " + getRoleToActivityPlaceholder() + " ?existingRoleActivity .\n"+
|
||||
"?existingRoleActivity " + getActivityToRolePlaceholder() + " ?role . ");
|
||||
return n3ForExistingRoleActivity;
|
||||
}
|
||||
|
||||
private String getN3ForActivityType() {
|
||||
|
@ -266,7 +278,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo editConfiguration, VitroRequest vreq) {
|
||||
List<String> urisOnForm = new ArrayList<String>();
|
||||
//add role activity and roleActivityType to uris on form
|
||||
urisOnForm.add("roleActivity");
|
||||
urisOnForm.add("existingRoleActivity");
|
||||
urisOnForm.add("roleActivityType");
|
||||
//Also adding the predicates
|
||||
//TODO: Check how to override this in case of default parameter? Just write hidden input to form?
|
||||
|
@ -277,6 +289,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//activity label and role label are literals on form
|
||||
List<String> literalsOnForm = new ArrayList<String>();
|
||||
literalsOnForm.add("activityLabel");
|
||||
literalsOnForm.add("activityLabelDisplay");
|
||||
literalsOnForm.add("roleLabel");
|
||||
editConfiguration.setLiteralsOnForm(literalsOnForm);
|
||||
}
|
||||
|
@ -295,7 +308,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Queries for role activity, activity type query, interval node,
|
||||
// start node, end node, start field precision, endfield precision
|
||||
map = new HashMap<String, String>();
|
||||
map.put("roleActivity", getRoleActivityQuery(vreq));
|
||||
map.put("existingRoleActivity", getExistingRoleActivityQuery(vreq));
|
||||
map.put("roleActivityType", getActivityTypeQuery(vreq));
|
||||
map.put("intervalNode", getIntervalNodeQuery(vreq));
|
||||
map.put("startNode", getStartNodeQuery(vreq));
|
||||
|
@ -495,7 +508,7 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
}
|
||||
|
||||
|
||||
private String getRoleActivityQuery(VitroRequest vreq) {
|
||||
private String getExistingRoleActivityQuery(VitroRequest vreq) {
|
||||
//If role to activity predicate is the default query, then we need to replace with a union
|
||||
//of both realizedIn and the other
|
||||
String query = "PREFIX core: <" + VIVO_NS + ">";
|
||||
|
@ -503,8 +516,8 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//Portion below for multiple possible predicates
|
||||
List<String> predicates = getPossibleRoleToActivityPredicates();
|
||||
List<String> addToQuery = new ArrayList<String>();
|
||||
query += "SELECT ?existingActivity WHERE { \n" +
|
||||
" ?role ?predicate ?existingActivity . \n ";
|
||||
query += "SELECT ?existingRoleActivity WHERE { \n" +
|
||||
" ?role ?predicate ?existingRoleActivity . \n ";
|
||||
query += getFilterRoleToActivityPredicate("predicate");
|
||||
query += "}";
|
||||
return query;
|
||||
|
@ -558,8 +571,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
|
||||
//Multiple fields
|
||||
getActivityLabelField(editConfiguration, vreq, fields);
|
||||
getActivityLabelDisplayField(editConfiguration, vreq, fields);
|
||||
getRoleActivityTypeField(editConfiguration, vreq, fields);
|
||||
getRoleActivityField(editConfiguration, vreq, fields);
|
||||
getExistingRoleActivityField(editConfiguration, vreq, fields);
|
||||
getRoleLabelField(editConfiguration, vreq, fields);
|
||||
getStartField(editConfiguration, vreq, fields);
|
||||
getEndField(editConfiguration, vreq, fields);
|
||||
|
@ -638,10 +652,6 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
//queryForExisting is not being used anywhere in Field
|
||||
|
||||
List<String> validators = new ArrayList<String>();
|
||||
//If add mode or repair, etc. need to add label required validator
|
||||
if(isAddMode(vreq) || isRepairMode(vreq)) {
|
||||
validators.add("nonempty");
|
||||
}
|
||||
validators.add("datatype:" + stringDatatypeUri);
|
||||
field.setValidators(validators);
|
||||
|
||||
|
@ -658,6 +668,29 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
fields.put(field.getName(), field);
|
||||
}
|
||||
|
||||
private void getActivityLabelDisplayField(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "activityLabelDisplay";
|
||||
//get range data type uri and range language
|
||||
String stringDatatypeUri = XSD.xstring.toString();
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
field.setName(fieldName);
|
||||
//queryForExisting is not being used anywhere in Field
|
||||
|
||||
//subjectUri and subjectClassUri are not being used in Field
|
||||
|
||||
field.setOptionsType("UNDEFINED");
|
||||
//why isn't predicate uri set for data properties?
|
||||
field.setPredicateUri(null);
|
||||
field.setObjectClassUri(null);
|
||||
field.setRangeDatatypeUri(stringDatatypeUri);
|
||||
|
||||
field.setLiteralOptions(new ArrayList<List<String>>());
|
||||
|
||||
fields.put(field.getName(), field);
|
||||
}
|
||||
|
||||
//type of "right side" of role, i.e. type of activity from role roleIn activity
|
||||
private void getRoleActivityTypeField(
|
||||
EditConfigurationVTwo editConfiguration, VitroRequest vreq,
|
||||
|
@ -699,9 +732,9 @@ public abstract class AddRoleToPersonTwoStageGenerator extends BaseEditConfigura
|
|||
}
|
||||
|
||||
//Assuming URI for activity for role?
|
||||
private void getRoleActivityField(EditConfigurationVTwo editConfiguration,
|
||||
private void getExistingRoleActivityField(EditConfigurationVTwo editConfiguration,
|
||||
VitroRequest vreq, Map<String, FieldVTwo> fields) {
|
||||
String fieldName = "roleActivity";
|
||||
String fieldName = "existingRoleActivity";
|
||||
//get range data type uri and range language
|
||||
|
||||
FieldVTwo field = new FieldVTwo();
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.edit.n3editing.OrganizationHasPositionValidator;
|
||||
|
||||
public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
||||
implements EditConfigurationGenerator {
|
||||
|
@ -115,11 +116,33 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
+ "\n" //
|
||||
+ "?position a core:Position , ?positionType ; \n"
|
||||
+ " rdfs:label ?positionTitle ; \n"
|
||||
+ " core:positionInOrganization ?organization ; \n"
|
||||
+ " core:positionForPerson ?person . \n" //
|
||||
+ "\n" //
|
||||
+ "?person core:personInPosition ?position ;"
|
||||
+ " rdfs:label ?personLabel";
|
||||
+ " core:positionInOrganization ?organization ; ";
|
||||
|
||||
private static final String N3_NEW_PERSON = ""
|
||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||
+ "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"
|
||||
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
|
||||
+ "\n" //
|
||||
+ "?position core:positionForPerson ?person . \n" //
|
||||
+ "?person core:personInPosition ?position . \n"
|
||||
+ "?person a foaf:Person . \n"
|
||||
+ "?person rdfs:label ?personLabel";
|
||||
|
||||
private static final String N3_NEW_FIRST_NAME = ""
|
||||
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
|
||||
+ "\n" //
|
||||
+ "?person foaf:firstName ?firstName .";
|
||||
|
||||
private static final String N3_NEW_LAST_NAME = ""
|
||||
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
|
||||
+ "\n" //
|
||||
+ "?person foaf:lastName ?lastName .";
|
||||
|
||||
private static final String N3_EXISTING_PERSON = ""
|
||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||
+ "\n" //
|
||||
+ "?position core:positionForPerson ?existingPerson . \n" //
|
||||
+ "?existingPerson core:personInPosition ?position . ";
|
||||
|
||||
private static final String N3_NEW_START_NODE = ""
|
||||
+ "@prefix core: <http://vivoweb.org/ontology/core#> . \n"
|
||||
|
@ -161,7 +184,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.setTemplate("organizationHasPositionHistory.ftl");
|
||||
|
||||
conf.setN3Required(Arrays.asList(N3_NEW_POSITION));
|
||||
conf.setN3Optional(Arrays.asList(N3_NEW_START_NODE, N3_NEW_END_NODE));
|
||||
conf.setN3Optional(Arrays.asList(N3_NEW_PERSON, N3_EXISTING_PERSON, N3_NEW_START_NODE, N3_NEW_END_NODE, N3_NEW_FIRST_NAME, N3_NEW_LAST_NAME));
|
||||
|
||||
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("person", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
@ -169,7 +192,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.addNewResource("startNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("person", "position", "positionType"));
|
||||
conf.setUrisOnform(Arrays.asList("existingPerson", "position", "positionType"));
|
||||
conf.addSparqlForExistingUris("positionType",
|
||||
QUERY_EXISTING_POSITION_TYPE);
|
||||
conf.addSparqlForExistingUris("person", QUERY_EXISTING_PERSON);
|
||||
|
@ -179,12 +202,13 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.addSparqlForExistingUris("startNode", QUERY_EXISTING_START_NODE);
|
||||
conf.addSparqlForExistingUris("endNode", QUERY_EXISTING_END_NODE);
|
||||
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "personLabel"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "personLabelDisplay", "personLabel", "firstName", "lastName"));
|
||||
conf.addSparqlForExistingLiteral("positionTitle",
|
||||
QUERY_EXISTING_POSITION_TITLE);
|
||||
conf.addSparqlForExistingLiteral("personLabel",
|
||||
QUERY_EXISTING_PERSON_LABEL);
|
||||
|
||||
conf.addSparqlForExistingUris("existingPerson",
|
||||
QUERY_EXISTING_PERSON);
|
||||
conf.addSparqlForExistingLiteral("startField-value",
|
||||
QUERY_EXISTING_START_VALUE);
|
||||
conf.addSparqlForExistingUris("startField-precision",
|
||||
|
@ -205,13 +229,25 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
.setRangeDatatypeUri(XSD.xstring.toString())
|
||||
.setValidators(list("nonempty")));
|
||||
|
||||
conf.addField(new FieldVTwo().setName("person")
|
||||
conf.addField(new FieldVTwo().setName("existingPerson")
|
||||
.setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS)
|
||||
.setObjectClassUri(personClass));
|
||||
|
||||
conf.addField(new FieldVTwo().setName("personLabel")
|
||||
.setRangeDatatypeUri(XSD.xstring.toString())
|
||||
.setValidators(list("nonempty")));
|
||||
.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().setName("personLabelDisplay")
|
||||
.setRangeDatatypeUri(XSD.xstring.toString())
|
||||
.setValidators( list("datatype:" + XSD.xstring.toString()) ));
|
||||
|
||||
FieldVTwo startField = new FieldVTwo().setName("startField");
|
||||
conf.addField(startField.setEditElement(new DateTimeWithPrecisionVTwo(
|
||||
|
@ -221,6 +257,7 @@ public class OrganizationHasPositionHistoryGenerator extends VivoBaseGenerator
|
|||
conf.addField(endField.setEditElement(new DateTimeWithPrecisionVTwo(
|
||||
endField, URI_PRECISION_YEAR, URI_PRECISION_NONE)));
|
||||
|
||||
conf.addValidator(new OrganizationHasPositionValidator());
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField",
|
||||
"endField"));
|
||||
|
|
|
@ -86,7 +86,7 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
|||
conf.addNewResource("endNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
||||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("existingAward", "existingOrg"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("description", "awardReceiptLabel", "awardLabel", "orgLabel", "yearAwardedDisplay", "orgLabelDisplay", "awardLabelDisplay" ));
|
||||
|
|
|
@ -20,6 +20,7 @@ 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.EditMode;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
|
||||
|
||||
/**
|
||||
Form for adding an educational attainment to an individual
|
||||
|
@ -86,14 +87,13 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.setVarNameForPredicate("predicate");
|
||||
conf.setVarNameForObject("edTraining");
|
||||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, orgLabelAssertion, orgTypeAssertion, trainingTypeAssertion ) );
|
||||
conf.setN3Required( Arrays.asList( n3ForNewEdTraining, trainingTypeAssertion ) );
|
||||
conf.setN3Optional(Arrays.asList(
|
||||
n3ForEdTrainingToOrg, majorFieldAssertion, degreeAssertion,
|
||||
deptAssertion, infoAssertion,
|
||||
n3ForStart, n3ForEnd, n3ForOrgToEdTraining ));
|
||||
n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, majorFieldAssertion, degreeAssertion,
|
||||
deptAssertion, infoAssertion, n3ForStart, n3ForEnd ));
|
||||
|
||||
conf.addNewResource("edTraining", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("org",DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("newOrg",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);
|
||||
|
@ -101,8 +101,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform( Arrays.asList( "org", "orgType", "degree", "trainingType"));
|
||||
conf.setLiteralsOnForm( Arrays.asList("orgLabel","majorField","dept","info"));
|
||||
conf.setUrisOnform( Arrays.asList( "existingOrg", "orgType", "degree", "trainingType"));
|
||||
conf.setLiteralsOnForm( Arrays.asList("orgLabel", "orgLabelDisplay", "majorField", "dept", "info"));
|
||||
|
||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("majorField", majorFieldQuery);
|
||||
|
@ -112,7 +112,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.addSparqlForExistingLiteral("endField-value", existingEndDateQuery);
|
||||
|
||||
|
||||
conf.addSparqlForExistingUris("org", orgQuery);
|
||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||
conf.addSparqlForExistingUris("trainingType", trainingTypeQuery);
|
||||
conf.addSparqlForExistingUris("degree", degreeQuery);
|
||||
|
@ -135,7 +135,7 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
setValidators(list("datatype:" + XSD.xstring.toString())));
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("org").
|
||||
setName("existingOrg").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri( orgClass ));
|
||||
//setLiteralOptions( [ "Select One" } )
|
||||
|
@ -143,7 +143,11 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabel").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("nonempty") ));
|
||||
setValidators( list("datatype:" + XSD.xstring.toString())));
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ));
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("orgType").
|
||||
|
@ -197,14 +201,26 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
|
||||
/* N3 assertions for working with educational training */
|
||||
|
||||
final static String orgTypeAssertion =
|
||||
"?org a ?orgType .";
|
||||
|
||||
final static String orgLabelAssertion =
|
||||
"?org <"+ label +"> ?orgLabel .";
|
||||
final static String n3ForNewEdTraining =
|
||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||
"?person core:educationalTraining ?edTraining .\n" +
|
||||
"?edTraining a core:EducationalTraining .\n" +
|
||||
"?edTraining core:educationalTrainingOf ?person .";
|
||||
|
||||
final static String trainingTypeAssertion =
|
||||
"?edTraining a ?trainingType .";
|
||||
|
||||
final static String n3ForNewOrg =
|
||||
"?edTraining <"+ trainingAtOrg +"> ?newOrg . \n" +
|
||||
"?newOrg ?inverseTrainingAtOrg ?edTraining .\n" +
|
||||
"?newOrg <"+ label +"> ?orgLabel .";
|
||||
|
||||
final static String n3ForExistingOrg =
|
||||
"?edTraining <"+ trainingAtOrg +"> ?existingOrg . \n" +
|
||||
"?existingOrg ?inverseTrainingAtOrg ?edTraining . ";
|
||||
|
||||
final static String orgTypeAssertion =
|
||||
"?newOrg a ?orgType .";
|
||||
|
||||
final static String degreeAssertion =
|
||||
"?edTraining <"+ degreeEarned +"> ?degree .\n"+
|
||||
|
@ -235,22 +251,9 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
|||
final static String infoAssertion =
|
||||
"?edTraining <"+ infoPred +"> ?info .";
|
||||
|
||||
final static String n3ForNewEdTraining =
|
||||
"@prefix core: <"+ vivoCore +"> .\n"+
|
||||
"?person core:educationalTraining ?edTraining .\n"+
|
||||
"?edTraining a core:EducationalTraining ;\n"+
|
||||
"core:educationalTrainingOf ?person ;\n"+
|
||||
"<"+ trainingAtOrg +"> ?org .\n";
|
||||
|
||||
final static String n3ForEdTrainingToOrg =
|
||||
"?edTraining <"+ trainingAtOrg +"> ?org .";
|
||||
|
||||
//The inverse of the above
|
||||
final static String n3ForOrgToEdTraining =
|
||||
"?org ?inverseTrainingAtOrg ?edTraining .";
|
||||
/* Queries for editing an existing educational training entry */
|
||||
|
||||
final static String orgQuery =
|
||||
final static String existingOrgQuery =
|
||||
"SELECT ?existingOrg WHERE {\n"+
|
||||
"?edTraining <"+ trainingAtOrg +"> ?existingOrg . }\n";
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ 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.EditMode;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.AutocompleteRequiredInputValidator;
|
||||
|
||||
public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator implements
|
||||
EditConfigurationGenerator {
|
||||
|
@ -72,13 +73,11 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
|
||||
conf.setN3Required( Arrays.asList( n3ForNewPosition,
|
||||
positionTitleAssertion,
|
||||
positionTypeAssertion,
|
||||
orgLabelAssertion,
|
||||
orgTypeAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForStart, n3ForEnd ) );
|
||||
positionTypeAssertion ) );
|
||||
conf.setN3Optional( Arrays.asList( n3ForNewOrg, n3ForExistingOrg, orgTypeAssertion, n3ForStart, n3ForEnd ) );
|
||||
|
||||
conf.addNewResource("position", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("org", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
conf.addNewResource("newOrg", 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);
|
||||
|
@ -86,8 +85,8 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
//uris in scope: none
|
||||
//literals in scope: none
|
||||
|
||||
conf.setUrisOnform(Arrays.asList("org", "orgType", "positionType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel"));
|
||||
conf.setUrisOnform(Arrays.asList("existingOrg", "orgType", "positionType"));
|
||||
conf.setLiteralsOnForm(Arrays.asList("positionTitle", "orgLabel", "orgLabelDisplay"));
|
||||
|
||||
conf.addSparqlForExistingLiteral("orgLabel", orgLabelQuery);
|
||||
conf.addSparqlForExistingLiteral("positionTitle", positionTitleQuery);
|
||||
|
@ -96,7 +95,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
conf.addSparqlForExistingLiteral(
|
||||
"endField-value", existingEndDateQuery);
|
||||
|
||||
conf.addSparqlForExistingUris("org", orgQuery);
|
||||
conf.addSparqlForExistingUris("existingOrg", existingOrgQuery);
|
||||
conf.addSparqlForExistingUris("orgType", orgTypeQuery);
|
||||
conf.addSparqlForExistingUris("positionType", positionTypeQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
|
@ -122,7 +121,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("org").
|
||||
setName("existingOrg").
|
||||
setOptionsType(FieldVTwo.OptionsType.INDIVIDUALS_VIA_VCLASS).
|
||||
setObjectClassUri(orgClass)
|
||||
);
|
||||
|
@ -130,7 +129,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabel").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() ).
|
||||
setValidators( list("nonempty") )
|
||||
setValidators( list("datatype:" + XSD.xstring.toString()) )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
setName("orgLabelDisplay").
|
||||
setRangeDatatypeUri(XSD.xstring.toString() )
|
||||
);
|
||||
|
||||
conf.addField( new FieldVTwo().
|
||||
|
@ -157,6 +161,7 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
|
||||
conf.addValidator(new DateTimeIntervalValidationVTwo("startField","endField"));
|
||||
conf.addValidator(new AntiXssValidation());
|
||||
conf.addValidator(new AutocompleteRequiredInputValidator("existingOrg", "orgLabel"));
|
||||
|
||||
//Adding additional data, specifically edit mode
|
||||
addFormSpecificData(conf, vreq);
|
||||
|
@ -165,24 +170,28 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
}
|
||||
|
||||
final static String n3ForNewPosition =
|
||||
"@prefix core: <" + vivoCore + "> . \n\n" +
|
||||
"@prefix core: <" + vivoCore + "> . \n" +
|
||||
"?person core:personInPosition ?position . \n" +
|
||||
"?position a ?positionType ; \n" +
|
||||
" core:positionForPerson ?person ; \n" +
|
||||
" <" + positionInOrgPred + "> ?org . \n" +
|
||||
"?org <" + orgForPositionPred + "> ?position .";
|
||||
"?position a ?positionType . \n" +
|
||||
"?position core:positionForPerson ?person ; ";
|
||||
|
||||
final static String positionTitleAssertion =
|
||||
"?position <" + RDFS.label.getURI() + "> ?positionTitle .";
|
||||
"?position <" + label + "> ?positionTitle .";
|
||||
|
||||
final static String positionTypeAssertion =
|
||||
"?position a ?positionType .";
|
||||
|
||||
final static String orgLabelAssertion =
|
||||
"?org <" + RDFS.label.getURI() + "> ?orgLabel .";
|
||||
"?position a ?positionType .";
|
||||
|
||||
final static String n3ForNewOrg =
|
||||
"?position <" + positionInOrgPred + "> ?newOrg . \n" +
|
||||
"?newOrg <" + orgForPositionPred + "> ?position . \n" +
|
||||
"?newOrg <" + label + "> ?orgLabel .";
|
||||
|
||||
final static String n3ForExistingOrg =
|
||||
"?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||
"?existingOrg <" + orgForPositionPred + "> ?position . " ;
|
||||
|
||||
final static String orgTypeAssertion =
|
||||
"?org a ?orgType .";
|
||||
"?newOrg a ?orgType .";
|
||||
|
||||
final static String n3ForStart =
|
||||
"?position <" + positionToInterval + "> ?intervalNode . \n" +
|
||||
|
@ -203,12 +212,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
final static String orgLabelQuery =
|
||||
"SELECT ?existingOrgLabel WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg <" + RDFS.label.getURI() + "> ?existingOrgLabel . \n" +
|
||||
" ?existingOrg <" + label + "> ?existingOrgLabel . \n" +
|
||||
"}";
|
||||
|
||||
final static String positionTitleQuery =
|
||||
"SELECT ?existingPositionTitle WHERE { \n" +
|
||||
"?position <" + RDFS.label.getURI() + "> ?existingPositionTitle . }";
|
||||
"?position <" + label + "> ?existingPositionTitle . }";
|
||||
|
||||
final static String existingStartDateQuery =
|
||||
"SELECT ?existingDateStart WHERE { \n" +
|
||||
|
@ -226,12 +235,12 @@ public class PersonHasPositionHistoryGenerator extends VivoBaseGenerator impleme
|
|||
" ?endNode a <" + dateTimeValueType + "> . \n" +
|
||||
" ?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||
|
||||
final static String orgQuery =
|
||||
final static String existingOrgQuery =
|
||||
"SELECT ?existingOrg WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . }";
|
||||
|
||||
final static String orgTypeQuery =
|
||||
"PREFIX rdfs: <" + RDFS.getURI() + "> \n" +
|
||||
"PREFIX rdfs: <" + rdfs + "> \n" +
|
||||
"SELECT ?existingOrgType WHERE { \n" +
|
||||
" ?position <" + positionInOrgPred + "> ?existingOrg . \n" +
|
||||
" ?existingOrg a ?existingOrgType . \n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue