@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_ADD}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.POST, value = {"/{id}/item"}) public ModelAndView createTaskResourceAssociation( HttpServletRequest request, @PathVariable(ID) String gooruOid, @RequestBody String data, HttpServletResponse response) throws Exception { User user = (User) request.getAttribute(Constants.USER); JSONObject json = requestData(data); ActionResponseDTO<TaskResourceAssoc> task = getTaskService() .createTaskResourceAssociation( this.buildTaskResourceFromInputParameters(getValue(TASK_RESOURCE_ASSOC, json)), user, gooruOid); if (task.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { response.setStatus(HttpServletResponse.SC_CREATED); } String[] includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null; String includes[] = (String[]) ArrayUtils.addAll( includeFields == null ? TASK_CREATE_RESOURCE_ASSOC_INCLUDES : includeFields, ERROR_INCLUDE); includes = (String[]) ArrayUtils.addAll(includes, RESOURCE_INCLUDE_FIELDS); SessionContextSupport.putLogParameter(EVENTNAME, CREATE_TASK_RESOURCE_ASSOCIATION); SessionContextSupport.putLogParameter( TASK_ASSOCIATED_DATE, task.getModel().getAssociationDate()); SessionContextSupport.putLogParameter( TASK_RESOURCE_ASSOCIATOR, task.getModel().getAssociatedBy() != null ? task.getModel().getAssociatedBy().getPartyUid() : null); SessionContextSupport.putLogParameter( TASK_RESOURCE_UID, task.getModel().getTaskResourceAssocUid()); SessionContextSupport.putLogParameter(RESOURCE, task.getModel().getResource().getGooruOid()); return toModelAndViewWithIoFilter( task.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_ADD}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.POST, value = {"/{id}/associate"}) public ModelAndView createTaskAssoc( @PathVariable(ID) String taskId, @RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(PREDICATE, "task.create_task_assoc"); User user = (User) request.getAttribute(Constants.USER); JSONObject json = requestData(data); ActionResponseDTO<TaskAssoc> responseDTO = getTaskService() .createTaskAssoc( this.buildTaskAssocFromInputParameters(getValue(TASK_ASSOC, json)), taskId, user); if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { response.setStatus(HttpServletResponse.SC_CREATED); } String[] includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null; String includes[] = (String[]) ArrayUtils.addAll( includeFields == null ? TASK_ASSOC_INCLUDES : includeFields, ERROR_INCLUDE); SessionContextSupport.putLogParameter(EVENTNAME, CREATE_TASK_ASSOC); SessionContextSupport.putLogParameter(TASK_ASSOC_UID, responseDTO.getModel().getTaskAssocUid()); SessionContextSupport.putLogParameter( TASK_DESCENDANT_ID, responseDTO.getModel().getTaskDescendant() != null ? responseDTO.getModel().getTaskDescendant().getGooruOid() : null); SessionContextSupport.putLogParameter( TASK_PARENT_ID, responseDTO.getModel().getTaskParent() != null ? responseDTO.getModel().getTaskParent().getGooruOid() : null); return toModelAndViewWithIoFilter( responseDTO.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_DELETE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.DELETE, value = {"/{id}"}) public void deleteTask( @PathVariable(ID) String gooruOid, HttpServletRequest request, HttpServletResponse response) throws Exception { this.getTaskService().deleteTask(gooruOid); SessionContextSupport.putLogParameter(EVENTNAME, DELETE_TASK); SessionContextSupport.putLogParameter(GOORU_OID, gooruOid); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_READ}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.GET, value = {"/{id}/taskhistory"}) public ModelAndView getTaskHistory( @PathVariable(ID) String taskUid, @RequestParam(value = DATA_OBJECT, required = false) String data, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(PREDICATE, "task.get_task_history"); List<TaskHistoryItem> taskHistoryItems = this.getTaskService().getTaskHistory(taskUid); String[] includeFields = null; if (data != null && !data.isEmpty()) { JSONObject json = requestData(data); includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null; } String[] includes = (String[]) ArrayUtils.addAll( includeFields == null ? TASK_HISTORY_ITEM_INCLUDES : includeFields, ERROR_INCLUDE); SessionContextSupport.putLogParameter(GOORU_OID, taskUid); return toModelAndViewWithIoFilter( taskHistoryItems, RESPONSE_FORMAT_JSON, EXCLUDE_ALL, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_DELETE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.DELETE, value = {"/associate/{id}"}) public void deleteTaskAssoc( @PathVariable(ID) String taskAssocUid, HttpServletRequest request, HttpServletResponse response) { this.getTaskService().deleteTaskAssoc(taskAssocUid); SessionContextSupport.putLogParameter(EVENTNAME, DELETE_TASK_ASSOC); SessionContextSupport.putLogParameter(TASK_ASSOC_UID, taskAssocUid); response.setStatus(HttpServletResponse.SC_NO_CONTENT); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_UPDATE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.PUT, value = {"/{id}"}) public ModelAndView updateTask( HttpServletRequest request, @PathVariable(ID) String gooruOid, @RequestBody String data, HttpServletResponse response) throws Exception { request.setAttribute(PREDICATE, "task.update_task"); User user = (User) request.getAttribute(Constants.USER); JSONObject json = requestData(data); ActionResponseDTO<Task> task = getTaskService() .updateTask( gooruOid, this.buildTaskFromInputParameters(getValue(TASK, json)), getValue(PLANNED_END_DATE, json) != null ? getValue(PLANNED_END_DATE, json) : null, user); if (task.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } String[] includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null; String includes[] = (String[]) ArrayUtils.addAll(includeFields == null ? TASK_INCLUDES : includeFields, ERROR_INCLUDE); SessionContextSupport.putLogParameter(EVENTNAME, UPDATE_TASK); SessionContextSupport.putLogParameter(TASK_UID, task.getModel().getGooruOid()); SessionContextSupport.putLogParameter( MODIFIED_USER, task.getModel().getLastUpdatedUserUid() != null ? task.getModel().getLastUpdatedUserUid() : null); SessionContextSupport.putLogParameter(LAST_MODIFIED_DATE, task.getModel().getLastModified()); return toModelAndViewWithIoFilter( task.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_FEEDBACK_UPDATE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping(method = RequestMethod.PUT, value = "/{id}") public ModelAndView updateFeedback( @RequestBody String data, @PathVariable(value = ID) String feedbackId, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = (User) request.getAttribute(Constants.USER); List<Feedback> feedbacks = getFeedbackService() .updateFeedback(feedbackId, this.buildFeedbackFromInputParameters(data, request)); Feedback feedback = feedbacks.get(0); // To capture activity log SessionContextSupport.putLogParameter( EVENT_NAME, "update-" + feedback.getCategory().getValue()); SessionContextSupport.putLogParameter(FEEDBACK_ID, feedback.getGooruOid()); SessionContextSupport.putLogParameter(FEEDBACK_GOORU_OID, feedback.getAssocGooruOid()); SessionContextSupport.putLogParameter(FEEDBACK_GOORU_UID, feedback.getAssocUserUid()); SessionContextSupport.putLogParameter(GOORU_UID, user.getPartyUid()); SessionContextSupport.putLogParameter(SCORE, feedback.getScore()); SessionContextSupport.putLogParameter(CONTEXT, feedback.getContext()); String includes[] = (String[]) ArrayUtils.addAll(FEEDBACK_INCLUDE_FIELDS, ERROR_INCLUDE); return toModelAndViewWithIoFilter(feedbacks, RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_DELETE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.DELETE, value = {"/{tid}/item/{id}"}) public void deleteTaskResourceAssociatedItem( @PathVariable(TID) String taskUid, @PathVariable(ID) String resourceId, HttpServletRequest request, HttpServletResponse response) throws Exception { getTaskService().deleteTaskResourceAssocItem(taskUid, resourceId); SessionContextSupport.putLogParameter(EVENTNAME, DELETE_TASK_RESOURCE_ASSOCIATED_ITEM); SessionContextSupport.putLogParameter(TASK_UID, taskUid); SessionContextSupport.putLogParameter(RESOURCE_ASSOC_UID, resourceId); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_ADD}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( value = {""}, method = RequestMethod.POST) public ModelAndView createTask( HttpServletRequest request, @RequestBody String data, HttpServletResponse response) throws Exception { request.setAttribute(PREDICATE, "task.create_task"); User user = (User) request.getAttribute(Constants.USER); JSONObject json = requestData(data); ActionResponseDTO<Task> task = getTaskService() .createTask( this.buildTaskFromInputParameters(getValue(TASK, json)), getValue(PLANNED_END_DATE, json) != null ? getValue(PLANNED_END_DATE, json) : null, user, this.buildAttachFromInputParameters(getValue(ATTACH_TO, json))); if (task.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { response.setStatus(HttpServletResponse.SC_CREATED); } String[] includeFields = getValue(FIELDS, json) != null ? getFields(getValue(FIELDS, json)) : null; String includes[] = (String[]) ArrayUtils.addAll(includeFields == null ? TASK_INCLUDES : includeFields, ERROR_INCLUDE); SessionContextSupport.putLogParameter(EVENTNAME, CREATE_TASK); SessionContextSupport.putLogParameter(TASK_UID, task.getModel().getGooruOid()); SessionContextSupport.putLogParameter( CREATOR_UID, task.getModel().getCreatedOn() != null ? task.getModel().getCreator().getPartyUid() : null); SessionContextSupport.putLogParameter(TASK_CREATED_DATE, task.getModel().getCreatedOn()); SessionContextSupport.putLogParameter(TASK_TITLE, task.getModel().getTitle()); return toModelAndViewWithIoFilter( task.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, includes); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_FEEDBACK_DELETE}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") public void deleteFeedback( @PathVariable(value = ID) String feedbackId, @RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = (User) request.getAttribute(Constants.USER); if (data != null && data.length() > 0) { Feedback feedback = this.buildFeedbackFromInputParameters(data, request); SessionContextSupport.putLogParameter(CONTEXT, feedback.getContext()); } this.getFeedbackService().deleteFeedback(feedbackId, user.getPartyUid()); SessionContextSupport.putLogParameter(EVENT_NAME, "delete-" + getFeedbackCategory(request)); SessionContextSupport.putLogParameter(FEEDBACK_ID, feedbackId); response.setStatus(HttpServletResponse.SC_NO_CONTENT); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_TASK_MANAGEMENT_ADD}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping( method = RequestMethod.POST, value = {"/{id}/associate/user/{uid}"}) public ModelAndView createTaskUserAssoc( @PathVariable(ID) String gooruOid, @PathVariable(UID) String gooruUid, @RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = requestData(data); List<TaskUserAssoc> taskUserAssocList = getTaskService() .createTaskUserAssoc( gooruOid, gooruUid, json != null ? getValue(ASSOCIATION_TYPE, json) : null); if (taskUserAssocList.size() < 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { for (TaskUserAssoc taskUserAssoc : taskUserAssocList) { SessionContextSupport.putLogParameter(EVENTNAME, CREATE_TASK_USER_ASSOC); SessionContextSupport.putLogParameter( USER_UID, taskUserAssoc.getTask().getUser().getGooruUId()); SessionContextSupport.putLogParameter(GOORU_OID, taskUserAssoc.getTask().getGooruOid()); SessionContextSupport.putLogParameter( CREATOR_UID, taskUserAssoc.getTask().getCreator() != null ? taskUserAssoc.getTask().getCreator().getPartyUid() : null); SessionContextSupport.putLogParameter(ASSOCIATION_TYPE, taskUserAssoc.getAssociationType()); SessionContextSupport.putLogParameter( TASK_CREATED_DATE, taskUserAssoc.getTask().getCreatedOn()); } } return toModelAndViewWithIoFilter( taskUserAssocList, RESPONSE_FORMAT_JSON, EXCLUDE_ALL, TASK_USER_ASSOC_INCLUDES); }
@AuthorizeOperations(operations = {GooruOperationConstants.OPERATION_FEEDBACK_ADD}) @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @RequestMapping(method = RequestMethod.POST, value = "") public ModelAndView createFeedback( @RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = (User) request.getAttribute(Constants.USER); Feedback newFeedback = this.buildFeedbackFromInputParameters(data, request); boolean list = newFeedback.getTypes() != null ? true : false; List<Feedback> feedbacks = getFeedbackService().createFeedbacks(newFeedback, user); Feedback feedback = feedbacks.get(0); response.setStatus(HttpServletResponse.SC_CREATED); // To capture activity log SessionContextSupport.putLogParameter(TARGET_TYPE, feedback.getTarget().getValue()); SessionContextSupport.putLogParameter(FEEDBACK_GOORU_OID, feedback.getAssocGooruOid()); SessionContextSupport.putLogParameter(FEEDBACK_GOORU_UID, feedback.getAssocUserUid()); SessionContextSupport.putLogParameter(FEEDBACK_ID, feedback.getGooruOid()); SessionContextSupport.putLogParameter(GOORU_UID, user.getPartyUid()); SessionContextSupport.putLogParameter(SCORE, feedback.getScore()); ContextDTO contextDTO = null; if (newFeedback.getContext() != null) { contextDTO = buildContextInputParam(newFeedback.getContext()); } String eventName = "create-" + feedback.getCategory().getValue(); if (contextDTO != null) { SessionContextSupport.putLogParameter("parentGooruId", contextDTO.getCollectionGooruId()); SessionContextSupport.putLogParameter("contentGooruId", contextDTO.getResourceGooruId()); if (contextDTO.getEventName() != null) { eventName = contextDTO.getEventName(); } } else { SessionContextSupport.putLogParameter("parentGooruId", null); SessionContextSupport.putLogParameter("contentGooruId", null); } SessionContextSupport.putLogParameter(EVENT_NAME, eventName); String includes[] = (String[]) ArrayUtils.addAll(FEEDBACK_INCLUDE_FIELDS, ERROR_INCLUDE); return toModelAndViewWithIoFilter( list ? feedbacks : feedback, RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }