コード例 #1
0
ファイル: DriveController.java プロジェクト: npanane/helix
  @RequestMapping(value = "/deleteDrive", method = RequestMethod.GET)
  public @ResponseBody void deleteDrive(@RequestParam("rowId") Integer rowId) {

    try {
      Drive drive = driveService.getDrive(rowId);
      driveService.deleteDrive(drive);
    } catch (HelixServiceException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: DriveController.java プロジェクト: npanane/helix
 @RequestMapping(value = "/saveOrUpdateDriveInfo", method = RequestMethod.GET)
 public @ResponseBody String saveOrUpdateDriveInfo(
     @RequestParam("description") String description,
     @RequestParam("month") Integer month,
     @RequestParam("year") Integer year,
     @RequestParam("totalAmount") String totalAmount,
     @RequestParam("totalCount") String totalCount,
     @RequestParam("totalCCAmount") String totalCCAmount,
     @RequestParam("averageAmount") String averageAmount,
     @RequestParam("Response") String Response,
     @RequestParam("inProcess") String inProcess,
     @RequestParam("userName") String userName,
     @RequestParam("driveId") Integer driveId,
     HttpServletResponse response) {
   // set encoding explicitly
   response.setCharacterEncoding("UTF-8");
   try {
     User user = userService.getUser(userName);
     DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
     Date date = new Date();
     Date currentDate = dateFormat.parse(dateFormat.format(date));
     if (driveId != null) {
       // update drive info
       Drive drive = driveService.getDrive(driveId);
       drive.setDriveName(description);
       drive.setDriveMonth(month);
       drive.setDriveYear(year);
       drive.setFlInProcess(Boolean.valueOf(inProcess));
       drive.setIdUserLastUpdated(user);
       drive.setDateUpdated(currentDate);
       driveService.updateDrive(drive);
       return driveId.toString();
     } else {
       // add drive info
       Drive drive = new Drive();
       drive.setDriveName(description);
       drive.setDriveMonth(month);
       drive.setDriveYear(year);
       drive.setFlInProcess(Boolean.valueOf(inProcess));
       drive.setUser(user);
       drive.setDateCreated(currentDate);
       // set campaign
       drive.setCampaigns(buildCampaigns(drive));
       driveService.saveDrive(drive);
       String driveIdStr = driveService.getLastDriveId();
       return driveIdStr;
     }
   } catch (HelixServiceException e) {
     e.printStackTrace();
     return null;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
コード例 #3
0
ファイル: DriveController.java プロジェクト: npanane/helix
 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;
 }
コード例 #4
0
ファイル: DriveController.java プロジェクト: npanane/helix
  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;
  }
コード例 #5
0
ファイル: DriveController.java プロジェクト: npanane/helix
  @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;
  }