public Document buildGetDriveInfoResponseXML(Integer driveId) throws HelixServiceException { Document document = DocumentHelper.createDocument(); Element root = document.addElement("drive"); Drive drive = driveService.getDrive(driveId); Element element = root.addElement("details"); element.addAttribute("driveId", String.valueOf(drive.getIdDrive())); element.addAttribute("description", drive.getDriveName()); if (drive.getDriveMonth() != null) { element.addAttribute("month", String.valueOf(drive.getDriveMonth())); } if (drive.getDriveYear() != null) { element.addAttribute("year", String.valueOf(drive.getDriveYear())); } element.addAttribute("inProcess", String.valueOf(drive.getFlInProcess())); return document; }
@RequestMapping(value = "/print", method = RequestMethod.GET) public ModelAndView print(ModelAndView modelAndView) { List<DriveReport> driveReportList = new ArrayList<DriveReport>(); List<Drive> driveList = null; try { driveList = driveService.getDrives(); } catch (HelixServiceException e) { e.printStackTrace(); } for (Drive drive : driveList) { DriveReport driveReport = new DriveReport(); driveReport.setName(drive.getDriveName()); if (drive.getDriveMonth() != null) { driveReport.setMonth(drive.getDriveMonth().toString()); } if (drive.getDriveYear() != null) { driveReport.setYear(drive.getDriveYear().toString()); } driveReportList.add(driveReport); } JRDataSource ds = new JRBeanCollectionDataSource(driveReportList); // In order to use Spring's built-in Jasper support, // We are required to pass our datasource as a map parameter // parameterMap is the Model of our application Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("datasource", ds); // pdfReport is the View of our application // This is declared inside the /WEB-INF/jasper-views.xml modelAndView = new ModelAndView("pdfReportDrive", parameterMap); // Return the View and the Model combined return modelAndView; }
private List<Campaign> buildCampaigns(Drive drive) { List<Campaign> campaigns = new ArrayList<Campaign>(); try { List<Client> clients = clientService.getClients(); for (Client client : clients) { Campaign campaign = new Campaign(); campaign.setDrive(drive); campaign.setClient(client); campaign.setCampaignYear(String.valueOf(drive.getDriveYear())); campaigns.add(campaign); } } catch (HelixServiceException e) { e.printStackTrace(); } return campaigns; }