@RequestMapping(value = "/findById.action", method = RequestMethod.GET) @ResponseBody public AidrCollection findById(Integer id) throws Exception { logger.info("Fetch AidrCollection for Id " + id); AidrCollection collection = collectionService.findById(id); System.out.println("-----------Collection :" + collection.getLangFilters()); return collection; }
@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); } }
@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 = "/delete.action", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Map<String, Object> delete(AidrCollection collection) throws Exception { logger.info("Deleting AidrCollection Info from Database having id " + collection.getId()); try { collectionService.delete(collection); return getUIWrapper(true); } catch (Exception e) { logger.error("Error while deleting AIDR Collection Info from database", e); return getUIWrapper(false); } }