@RequestMapping(value = "/update.action", method = RequestMethod.POST) @ResponseBody public Map<String, Object> update(AidrCollection collection) throws Exception { logger.info("Updating AidrCollection into Database having id " + collection.getId()); try { AidrCollection dbCollection = collectionService.findById(collection.getId()); collection.setStartDate(dbCollection.getStartDate()); collection.setUser(dbCollection.getUser()); collection.setCreatedDate(dbCollection.getCreatedDate()); collectionService.update(collection); return getUIWrapper(true); } catch (Exception e) { logger.error("Error while Updating AidrCollection Info into database", e); return getUIWrapper(false); } }
@RequestMapping( value = "/save.action", method = {RequestMethod.POST}) @ResponseBody public Map<String, Object> save(AidrCollection collection) throws Exception { logger.info("Save AidrCollection to Database having code : " + collection.getCode()); try { UserEntity entity = getAuthenticatedUser(); collection.setUser(entity); collection.setStatus(CollectionStatus.NOT_RUNNING); Calendar now = Calendar.getInstance(); collection.setCreatedDate(now.getTime()); collectionService.create(collection); return getUIWrapper(true); } catch (Exception e) { logger.error("Error while saving AidrCollection Info to database", e); return getUIWrapper(false); } }