private boolean _staffValidation(Staff staff) throws RepeatAttendException,
RepeatCompanyEmailException, RepeatLicenseException,
RepeatIdentityCardException, IncompleteStaffException,
InvalidStaffProperty {
String method = "_staffValidation";
if (null == staff) {
return false;
}
// Required properties validation
String attend = staff.getAttend();
String password = staff.getPassword();
String name = staff.getName();
String corpMail = staff.getCorpMail();
String idCard = staff.getIdCard();
Integer education = staff.getEducation();
Integer jobs = staff.getJobs();
Integer exp = staff.getExp();
Integer department = staff.getDepartment();
Integer state = staff.getState();
Date dateEn = staff.getDateEn();
_logger.debug(method, "attend=" + attend);
_logger.debug(method, "password=" + password);
_logger.debug(method, "name=" + name);
_logger.debug(method, "corpMail=" + corpMail);
_logger.debug(method, "idCard=" + idCard);
_logger.debug(method, "education=" + education);
_logger.debug(method, "jobs=" + jobs);
_logger.debug(method, "exp=" + exp);
_logger.debug(method, "department=" + department);
_logger.debug(method, "state=" + state);
_logger.debug(method, "dateEn=" + dateEn);
// Null properties check
if (null == attend) {
throw new IncompleteStaffException(1);
}
if (null == password) {
throw new IncompleteStaffException(2);
}
if (null == name) {
throw new IncompleteStaffException(3);
}
if (null == corpMail) {
throw new IncompleteStaffException(4);
}
if (null == idCard) {
throw new IncompleteStaffException(5);
}
if (null == education) {
throw new IncompleteStaffException(6);
}
if (null == jobs) {
throw new IncompleteStaffException(7);
}
if (null == exp) {
throw new IncompleteStaffException(8);
}
if (null == department) {
throw new IncompleteStaffException(9);
}
if (null == state) {
throw new IncompleteStaffException(10);
}
if (null == dateEn) {
throw new IncompleteStaffException(11);
}
// Properties validation
if (!ValidatorUtil.isAttend(attend)) {
throw new InvalidStaffProperty(1);
}
if (!ValidatorUtil.isPassword(password)) {
throw new InvalidStaffProperty(2);
}
if (!ValidatorUtil.isName(name)) {
throw new InvalidStaffProperty(3);
}
if (!ValidatorUtil.isEmail(corpMail)) {
throw new InvalidStaffProperty(4);
}
if (!ValidatorUtil.isIdentityCard(idCard)) {
throw new InvalidStaffProperty(5);
}
//exp must between after has been born 15years later and dateEn
int dateEnYear = Integer.parseInt(DateUtil.parseString(dateEn).substring(0, 4));
int afterBirth15 = Integer.parseInt(idCard.substring(6, 10)) + 15;
if (exp < afterBirth15 || exp > dateEnYear) {
throw new InvalidStaffProperty(6);
}
if (!corpMail.endsWith("@cn.ufinity.com")) {
throw new InvalidStaffProperty(7);
}
boolean bool = _notRequiredPropertiesValidation(staff);
if (bool) {
_repeatStaffProperties(staff);
} else {
_logger.debug(method,
"Validation failure, Not required properties invalid!");
return false;
}
return true;
}
[该贴被xuezhongde于2009-01-19 17:15修改过]