@RequestMapping( method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE}, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}) @ResponseBody public EntityModel saveFlow( @RequestBody FlowForm flowForm, BindingResult bindingResult, HttpSession session) { LoginForm loginForm = (LoginForm) session.getAttribute("loginForm"); EntityModel selectedEntity = loginForm.getSelectedEntity(); List<FlowModel> flowList = this.getAllFlowsOfSelectedEntity(selectedEntity); flowForm.validate(flowList); FlowModel flowModel = flowManagerService.createFlow( flowForm.getEntityName(), flowForm.getFlowName(), flowForm.getFlowType(), flowForm.getPluginFormat(), flowForm.getDataFormat()); if (flowForm.getFlowType().equals(FlowType.HARMONIZE)) { selectedEntity.getHarmonizeFlows().add(flowModel); } else { selectedEntity.getInputFlows().add(flowModel); } return selectedEntity; }
private List<FlowModel> getAllFlowsOfSelectedEntity(EntityModel selectedEntity) { List<FlowModel> flowList = new ArrayList<>(); flowList.addAll(selectedEntity.getInputFlows()); flowList.addAll(selectedEntity.getHarmonizeFlows()); return flowList; }