// Method throw the appropriate message (For buttons) FIXME: I don't like this throwing private void throwMessage(FacesContext facesContext, String message, AbstractPerson person) { if (message.equalsIgnoreCase("WARN")) { facesContext.addMessage( null, new FacesMessage( FacesMessage.SEVERITY_WARN, "You haven't choosen a Person to delete", "Choose one")); } else if (message.equalsIgnoreCase("ERROR")) { facesContext.addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Person can't be deleted", "He's assosiated with the project")); } else if (message.equalsIgnoreCase("INFO")) { facesContext.addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "Person " + person.getFirstName() + " " + person.getLastName() + " was successfully removed", "from the dataBase")); } else if (message.equals("EMAIL")) { facesContext.addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Duplicates Error !", "The same EMAIL already exists!")); } }
/** * Method is checking email for uniqueness * * @param ejb - SessionBean PersonFacade * @param person - Person instance (Worker, Partner, LeadTc..) * @return true if new email isn't unique (The same email exists in the db) * @return false if new email is unique. */ private boolean isSameEmailExists(AbstractFacade ejb, AbstractPerson person) { String email = person.getEmail(); // Get AbstractPerson.email from the instance boolean isExist = ejb.isFieldExist(email); // Check if the same email exists return isExist; }
/** * Auxiliary method for checking, if the selected person is already using in the project (erid). * * @return true, if the same person exist in the ERID table */ private boolean isWorkerBusy(AbstractPerson person) { if (person.getEridCollection().isEmpty()) { return false; } return true; }