private BornTransmissionLog prepareLog() { BornTransmissionLog log = new BornTransmissionLog(); log.setFilename(filenameStart); log.setSubmitDateTime(new Date()); logDao.persist(log); return log; }
private String getFileSuffix(Integer logId) { long num = logDao.getSeqNoToday(filenameStart, logId); String tmp = String.valueOf(num); while (tmp.length() < 3) { tmp = "0" + tmp; } return tmp; }
private void uploadToBorn( Integer demographicNo, Integer rourkeFdid, Integer nddsFdid, Integer report18mFdid) { byte[] born18mXml = generateXml(demographicNo, rourkeFdid, nddsFdid, report18mFdid); if (born18mXml == null) return; BornTransmissionLog log = prepareLog(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String dt = sdf.format(new Date()); String filename = filenameStart + "_" + dt + "_" + getFileSuffix(log.getId()) + ".xml"; boolean uploadOk = uploadToBORN(born18mXml, filename); if (uploadOk) recordFormSent(demographicNo, rourkeFdid, nddsFdid, report18mFdid); // update log filename and status (success=true/false) log.setFilename(filename); log.setSuccess(uploadOk); logDao.merge(log); logger.info("Uploaded [" + filename + "]"); return; }