public void processRecord(Object record) throws Exception { CreateSelectiveServiceRecordImpl ssRecord = (CreateSelectiveServiceRecordImpl) record; ssRecord.appendDebug( "Started Processing Record with Applicant ID = " + ssRecord.getApplicant().getId()); Applicant applicant = null; try { applicant = applicantDao.findByIdBasicInfoForCreateSelectiveService(ssRecord.getApplicant().getId()); } catch (DataAccessException e) { String msg = "DB Error: Failure to retrieve applicant with id: " + applicant.getId(); throw getBaseExceptionType(msg, e, logger, LOG_DEBUG); } if (applicant != null) { ssRecord.setApplicant(applicant); ssRecord.setAuditValues(); } else { return; } try { OtherInfo otherInfo = applicant.getOtherInfo(); applicantDao.updateSelectiveServiceStatus( otherInfo, DLRConstants.SELECTIVE_SERVICE_STATUS_SENT_TO_USSS); applicantDao.updateSelectiveServiceSentFlag(otherInfo, new Boolean(true)); ssRecord.appendDebug("After Update Selective Service Status & SentFlag"); } catch (DataAccessException e) { String msg = "DB Error: Failure to update Selective Service Status " + "for applicant with id " + applicant.getId(); throw getBaseExceptionType(msg, e, logger, LOG_DEBUG); } }
protected void writeRecord(IBaseRecord record) throws Exception { CreateSelectiveServiceRecordImpl ssRecord = (CreateSelectiveServiceRecordImpl) record; Applicant applicant = ssRecord.getApplicant(); IssuanceDoc dl = applicant.getLicense(); IssuanceDoc unl = applicant.getUNL(); IssuanceDoc id = applicant.getStateID(); IssuanceDoc issuanceDoc = null; if (dl != null) { issuanceDoc = dl; } else if (unl != null) { issuanceDoc = unl; } else { issuanceDoc = id; } if (issuanceDoc == null) throw new RuntimeException("unable to find an issuance doc for the current applicant"); String dlIdUnl = HandlerUtil.padding(issuanceDoc.getDlIdUnlNumber(), 10); String lastName = HandlerUtil.padding(applicant.getLastName(), 40); String firstName = HandlerUtil.padding(applicant.getFirstName(), 40); String middleName = HandlerUtil.padding(applicant.getMiddleName(), 40); String suffix = HandlerUtil.padding(convertSuffix(applicant.getSuffix()), 5); String physicalStreet1 = HandlerUtil.padding(applicant.getPhysicalAddress().getStreet1(), 32); String physicalStreet2 = HandlerUtil.padding(applicant.getPhysicalAddress().getStreet2(), 32); String physicalCity = HandlerUtil.padding(applicant.getPhysicalAddress().getCity(), 33); String physicalState = HandlerUtil.padding(applicant.getPhysicalAddress().getState(), 2); String physicalZipCode = HandlerUtil.padding(applicant.getPhysicalAddress().getZip(), 5); String physicalZipCodeExt = HandlerUtil.padding(applicant.getPhysicalAddress().getZipExt(), 4); if (physicalZipCode == null || (physicalZipCodeExt != null && physicalZipCodeExt.trim().length() == 0)) { physicalZipCodeExt = "0000"; } String formatedDob = DateUtil.formatDate("MMddyyyy", applicant.getPlaceOfBirthInfo().getBrthDob()); String dateOfBirth = HandlerUtil.padding(formatedDob, 8); String ssn = HandlerUtil.padding(applicant.getSsn(), 9); String formatedAppDate = DateUtil.formatDate("MMddyyyy", new Date()); String applicationDate = HandlerUtil.padding(formatedAppDate, 8); String errorFlag = convertErrDelFlag(applicant.getErrDelFlag()); String output = new StringBuffer() .append(dlIdUnl) .append(lastName) .append(firstName) .append(middleName) .append(suffix) .append(physicalStreet1) .append(physicalStreet2) .append(physicalCity) .append(physicalState) .append(physicalZipCode) .append(physicalZipCodeExt) .append(dateOfBirth) .append(ssn) .append(applicationDate) .append(errorFlag) .toString(); writer.write(output + "\r\n"); }