NIHVIVO-646 Adding an existing person as an author on the add authors to publications form
This commit is contained in:
parent
e92bea31bf
commit
218d3dfa3c
2 changed files with 46 additions and 4 deletions
|
@ -30,10 +30,6 @@ public class PersonHasPositionValidator implements N3Validator {
|
||||||
if( "".equals(organizationUri))
|
if( "".equals(organizationUri))
|
||||||
organizationUri = null;
|
organizationUri = null;
|
||||||
|
|
||||||
// System.out.println("newOrgName " + newOrgName);
|
|
||||||
// System.out.println("newOrgType " + newOrgType);
|
|
||||||
// System.out.println("organizationUri " + organizationUri);
|
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
if( organizationUri != null && (newOrgName != null || newOrgType != null) ){
|
if( organizationUri != null && (newOrgName != null || newOrgType != null) ){
|
||||||
errors.put("newOrgName", DUPLICATE_ERROR);
|
errors.put("newOrgName", DUPLICATE_ERROR);
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
|
public class PublicationHasAuthorValidator implements N3Validator {
|
||||||
|
|
||||||
|
private static String MISSING_AUTHOR_ERROR = "Must specify a new or existing author.";
|
||||||
|
private static String MISSING_FIRST_NAME_ERROR = "Must specify the author's first name.";
|
||||||
|
private static String MISSING_LAST_NAME_ERROR = "Must specify the author's last name.";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> validate(EditConfiguration editConfig,
|
||||||
|
EditSubmission editSub) {
|
||||||
|
Map<String,String> urisFromForm = editSub.getUrisFromForm();
|
||||||
|
Map<String,Literal> literalsFromForm = editSub.getLiteralsFromForm();
|
||||||
|
|
||||||
|
Literal firstName = literalsFromForm.get("firstName");
|
||||||
|
if( firstName.getLexicalForm() != null && "".equals(firstName.getLexicalForm()) )
|
||||||
|
firstName = null;
|
||||||
|
|
||||||
|
Literal lastName = literalsFromForm.get("lastName");
|
||||||
|
if( lastName.getLexicalForm() != null && "".equals(lastName.getLexicalForm()) )
|
||||||
|
lastName = null;
|
||||||
|
|
||||||
|
String personUri = urisFromForm.get("personUri");
|
||||||
|
if ("".equals(personUri)) {
|
||||||
|
personUri = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,String> errors = new HashMap<String,String>();
|
||||||
|
|
||||||
|
if (personUri == null && lastName == null && firstName == null) {
|
||||||
|
errors.put("lastName", MISSING_AUTHOR_ERROR);
|
||||||
|
} else if (lastName != null && firstName == null) {
|
||||||
|
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||||
|
} else if (lastName == null && firstName != null) {
|
||||||
|
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.size() != 0 ? errors : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue