diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPositionValidator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPositionValidator.java deleted file mode 100644 index 6d41b3bb5..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPositionValidator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* $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.Map; - -import com.hp.hpl.jena.rdf.model.Literal; - -public class PersonHasPositionValidator implements N3Validator { - - private static String DUPLICATE_ERROR = "Must select an existing organization or create a new one, not both."; - private static String MISSING_ORG_ERROR = "Must either select an existing organization or create a new one."; - private static String MISSING_ORG_TYPE_ERROR = "Must select a type for the new organization."; - private static String MISSING_ORG_NAME_ERROR = "Must specify a name for the new organization."; - - public Map validate(EditConfiguration editConfig, EditSubmission editSub){ -// Map existingUris = editConfig.getUrisInScope(); -// Map existingLiterals = editConfig.getLiteralsInScope(); - Map urisFromForm = editSub.getUrisFromForm(); - Map literalsFromForm = editSub.getLiteralsFromForm(); - - Literal newOrgName = literalsFromForm.get("newOrgName"); - if( newOrgName.getLexicalForm() != null && "".equals(newOrgName.getLexicalForm()) ) - newOrgName = null; - String newOrgType = urisFromForm.get("newOrgType"); - if( "".equals(newOrgType ) ) - newOrgType = null; - String organizationUri = urisFromForm.get("organizationUri"); - if( "".equals(organizationUri)) - organizationUri = null; - - Map errors = new HashMap(); - if( organizationUri != null && (newOrgName != null || newOrgType != null) ){ - errors.put("newOrgName", DUPLICATE_ERROR); - errors.put("organizationUri", DUPLICATE_ERROR); - } else if ( organizationUri == null && newOrgName == null && newOrgType == null) { - errors.put("newOrgName", MISSING_ORG_ERROR); - errors.put("organizationUri", MISSING_ORG_ERROR); - }else if( organizationUri == null && newOrgName != null && newOrgType == null) { - errors.put("newOrgType", MISSING_ORG_TYPE_ERROR); - }else if( organizationUri == null && newOrgName == null && newOrgType != null) { - errors.put("newOrgName", MISSING_ORG_NAME_ERROR); - } - - if( errors.size() != 0 ) - return errors; - else - return null; - } -} \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPublicationValidator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPublicationValidator.java deleted file mode 100644 index 2ed3b613e..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PersonHasPublicationValidator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* $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.Map; - -import com.hp.hpl.jena.rdf.model.Literal; - -import edu.cornell.mannlib.vitro.webapp.utils.StringUtils; - -public class PersonHasPublicationValidator implements N3Validator { - - private static String MISSING_PUB_TYPE_ERROR = "Must specify a publication type."; - private static String MISSING_PUB_TITLE_ERROR = "Must specify a publication title."; - - @Override - public Map validate(EditConfiguration editConfig, - EditSubmission editSub) { - - Map urisFromForm = editSub.getUrisFromForm(); - Map literalsFromForm = editSub.getLiteralsFromForm(); - - Map errors = new HashMap(); - - // If there's a pubUri, then we're done. The other fields are disabled and so don't get submitted. - String pubUri = urisFromForm.get("pubUri"); - if (!StringUtils.isEmpty(pubUri)) { - return null; - } - - String pubType = urisFromForm.get("pubType"); - if ("".equals(pubType)) { - pubType = null; - } - - Literal title = literalsFromForm.get("title"); - if (title != null) { - String titleValue = title.getLexicalForm(); - if (StringUtils.isEmpty(titleValue)) { - title = null; - } - } - - if (pubType == null) { - errors.put("pubType", MISSING_PUB_TYPE_ERROR); - } - if (title == null) { - errors.put("title", MISSING_PUB_TITLE_ERROR); - } - - return errors.size() != 0 ? errors : null; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PublicationHasAuthorValidator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PublicationHasAuthorValidator.java deleted file mode 100644 index 41a448216..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/PublicationHasAuthorValidator.java +++ /dev/null @@ -1,62 +0,0 @@ -/* $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.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."; - private static String MALFORMED_LAST_NAME_ERROR = "Last name may not contain a comma. Please enter first name in first name field."; -; - @Override - public Map validate(EditConfiguration editConfig, - EditSubmission editSub) { - Map urisFromForm = editSub.getUrisFromForm(); - Map literalsFromForm = editSub.getLiteralsFromForm(); - - Map errors = new HashMap(); - - String personUri = urisFromForm.get("personUri"); - if ("".equals(personUri)) { - personUri = null; - } - // If there's a personUri, then we're done. The firstName and lastName fields are - // disabled and so don't get submitted. - if (personUri != null) { - return null; - } - - Literal firstName = literalsFromForm.get("firstName"); - if( firstName != null && firstName.getLexicalForm() != null && "".equals(firstName.getLexicalForm()) ) - firstName = null; - - Literal lastName = literalsFromForm.get("lastName"); - 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; - } - -}