@Test @Sql(scripts = { "/sql/clearRole.sql", "/sql/clearAction.sql", "/sql/insertRoleData.sql", "/sql/insertActionData.sql" }) public void testShouldCreateRoleActions() { RoleActionsRequest roleRequest = new RoleActionsRequest(); Role role = Role.builder().code("CITIZEN").build(); Action action1 = new Action(); action1.setName("Get all ReceivingMode"); Action action2 = new Action(); action2.setName("Get ComplaintType by type,count and tenantId"); List<Action> actions = new ArrayList<Action>(); actions.add(action1); actions.add(action2); roleRequest.setRole(role); roleRequest.setActions(actions); roleRequest.setTenantId("default"); roleRequest.setRequestInfo(getRequestInfo()); List<RoleAction> roleActions = roleActionRepository.createRoleActions(roleRequest); assertThat(roleActions.size()).isEqualTo(2); assertThat(roleActions.get(0).getRoleCode().equals("CITIZEN")); assertThat(roleActions.get(1).getRoleCode().equals("CITIZEN")); assertThat(roleActions.get(1).getRoleCode().equals("default")); }
public List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest) { LOGGER.info("Create Role Actions Repository::" + actionRequest); final String roleActionsInsert = "insert into eg_roleaction(rolecode,actionid,tenantid) values (:rolecode,:actionid,:tenantid)"; List<Integer> actionList = getActionsBasedOnIds(actionRequest); Role role = actionRequest.getRole(); List<RoleAction> roleActionList = new ArrayList<RoleAction>(); List<Map<String, Object>> batchValues = new ArrayList<>(actionList.size()); for (Integer actionid : actionList) { batchValues.add(new MapSqlParameterSource("rolecode", role.getCode()).addValue("actionid", actionid) .addValue("tenantid", actionRequest.getTenantId()).getValues()); RoleAction roleAction = new RoleAction(); roleAction.setActionId(actionid); roleAction.setRoleCode(role.getCode()); roleAction.setTenantId(actionRequest.getTenantId()); roleActionList.add(roleAction); } namedParameterJdbcTemplate.batchUpdate(roleActionsInsert, batchValues.toArray(new Map[actionList.size()])); return roleActionList; }
RoleActionRepository { public List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest) { LOGGER.info("Create Role Actions Repository::" + actionRequest); final String roleActionsInsert = "insert into eg_roleaction(rolecode,actionid,tenantid) values (:rolecode,:actionid,:tenantid)"; List<Integer> actionList = getActionsBasedOnIds(actionRequest); Role role = actionRequest.getRole(); List<RoleAction> roleActionList = new ArrayList<RoleAction>(); List<Map<String, Object>> batchValues = new ArrayList<>(actionList.size()); for (Integer actionid : actionList) { batchValues.add(new MapSqlParameterSource("rolecode", role.getCode()).addValue("actionid", actionid) .addValue("tenantid", actionRequest.getTenantId()).getValues()); RoleAction roleAction = new RoleAction(); roleAction.setActionId(actionid); roleAction.setRoleCode(role.getCode()); roleAction.setTenantId(actionRequest.getTenantId()); roleActionList.add(roleAction); } namedParameterJdbcTemplate.batchUpdate(roleActionsInsert, batchValues.toArray(new Map[actionList.size()])); return roleActionList; } }
RoleActionRepository { public List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest) { LOGGER.info("Create Role Actions Repository::" + actionRequest); final String roleActionsInsert = "insert into eg_roleaction(rolecode,actionid,tenantid) values (:rolecode,:actionid,:tenantid)"; List<Integer> actionList = getActionsBasedOnIds(actionRequest); Role role = actionRequest.getRole(); List<RoleAction> roleActionList = new ArrayList<RoleAction>(); List<Map<String, Object>> batchValues = new ArrayList<>(actionList.size()); for (Integer actionid : actionList) { batchValues.add(new MapSqlParameterSource("rolecode", role.getCode()).addValue("actionid", actionid) .addValue("tenantid", actionRequest.getTenantId()).getValues()); RoleAction roleAction = new RoleAction(); roleAction.setActionId(actionid); roleAction.setRoleCode(role.getCode()); roleAction.setTenantId(actionRequest.getTenantId()); roleActionList.add(roleAction); } namedParameterJdbcTemplate.batchUpdate(roleActionsInsert, batchValues.toArray(new Map[actionList.size()])); return roleActionList; }  }
RoleActionRepository { public List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest) { LOGGER.info("Create Role Actions Repository::" + actionRequest); final String roleActionsInsert = "insert into eg_roleaction(rolecode,actionid,tenantid) values (:rolecode,:actionid,:tenantid)"; List<Integer> actionList = getActionsBasedOnIds(actionRequest); Role role = actionRequest.getRole(); List<RoleAction> roleActionList = new ArrayList<RoleAction>(); List<Map<String, Object>> batchValues = new ArrayList<>(actionList.size()); for (Integer actionid : actionList) { batchValues.add(new MapSqlParameterSource("rolecode", role.getCode()).addValue("actionid", actionid) .addValue("tenantid", actionRequest.getTenantId()).getValues()); RoleAction roleAction = new RoleAction(); roleAction.setActionId(actionid); roleAction.setRoleCode(role.getCode()); roleAction.setTenantId(actionRequest.getTenantId()); roleActionList.add(roleAction); } namedParameterJdbcTemplate.batchUpdate(roleActionsInsert, batchValues.toArray(new Map[actionList.size()])); return roleActionList; }  List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest); boolean checkActionNamesAreExistOrNot(final RoleActionsRequest actionRequest); boolean addUniqueValidationForTenantAndRoleAndAction(final RoleActionsRequest actionRequest); }
RoleActionRepository { public List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest) { LOGGER.info("Create Role Actions Repository::" + actionRequest); final String roleActionsInsert = "insert into eg_roleaction(rolecode,actionid,tenantid) values (:rolecode,:actionid,:tenantid)"; List<Integer> actionList = getActionsBasedOnIds(actionRequest); Role role = actionRequest.getRole(); List<RoleAction> roleActionList = new ArrayList<RoleAction>(); List<Map<String, Object>> batchValues = new ArrayList<>(actionList.size()); for (Integer actionid : actionList) { batchValues.add(new MapSqlParameterSource("rolecode", role.getCode()).addValue("actionid", actionid) .addValue("tenantid", actionRequest.getTenantId()).getValues()); RoleAction roleAction = new RoleAction(); roleAction.setActionId(actionid); roleAction.setRoleCode(role.getCode()); roleAction.setTenantId(actionRequest.getTenantId()); roleActionList.add(roleAction); } namedParameterJdbcTemplate.batchUpdate(roleActionsInsert, batchValues.toArray(new Map[actionList.size()])); return roleActionList; }  List<RoleAction> createRoleActions(final RoleActionsRequest actionRequest); boolean checkActionNamesAreExistOrNot(final RoleActionsRequest actionRequest); boolean addUniqueValidationForTenantAndRoleAndAction(final RoleActionsRequest actionRequest); static final Logger LOGGER; }