Esempio n. 1
0
 @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;
   }
 }