private void createReportItems( Document aggregateDoc, List<ReportExternalImport> insertableImportReports, List<ReportExternalImport> updatableImportReports) { String sendingSiteId = (String) aggregateDoc.getRootElement().element("site-id").getData(); Set<String> eventDateSet = new HashSet<String>(); // to make sure no // duplicates for (Object reportObj : aggregateDoc.getRootElement().elements("reports")) { Element report = (Element) reportObj; String eventDate = (String) report.element("event-date").getData(); eventDate = eventDate.split(" ")[0]; if (!eventDateSet.contains(eventDate)) { eventDateSet.add(eventDate); String data = (String) report.element("data").getData(); ReportExternalImport importReport = createReportExternalImport(sendingSiteId, eventDate, data); if (importReport.getId() == null) { insertableImportReports.add(importReport); } else { updatableImportReports.add(importReport); } } } }
private ReportExternalImport createReportExternalImport( String sendingSiteId, String eventDate, String data) { ReportExternalImport importReport = new ReportExternalImport(); importReport.setEventDate( DateUtil.convertStringDateToTimestampWithPatternNoLocale(eventDate, DATE_PATTERN)); importReport.setSendingSite(sendingSiteId); importReport.setReportType("testIndicators"); ReportExternalImport rei = reportImportDAO.getReportByEventDateSiteType(importReport); if (rei != null) { importReport = rei; } importReport.setData(data); importReport.setSysUserId("1"); importReport.setRecievedDate(DateUtil.getTimestampAtMidnightForDaysAgo(0)); return importReport; }