예제 #1
0
 public Document buildDriveResponseXML() throws HelixServiceException {
   Document document = DocumentHelper.createDocument();
   Element root = document.addElement("drives");
   List<Drive> drives = driveService.getDrives();
   if (drives != null) {
     for (Drive drive : drives) {
       Element element = root.addElement("drive");
       element.addAttribute("driveId", String.valueOf(drive.getIdDrive()));
       element.addAttribute("name", drive.getDriveName());
     }
   }
   return document;
 }
예제 #2
0
  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;
  }
예제 #3
0
  @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;
  }