public void updateParam(DbSession dbSession, ActiveRuleParamDto activeRuleParam) { Preconditions.checkNotNull(activeRuleParam.getId(), ACTIVE_RULE_PARAM_IS_NOT_PERSISTED); mapper(dbSession).updateParameter(activeRuleParam); }
@Override public void accept(@Nonnull ActiveRuleParamDto activeRuleParamDto) { if (activeRuleParamDto.getKey().equals(key)) { dbClient.activeRuleDao().deleteParamById(dbSession, activeRuleParamDto.getId()); } } }
public ActiveRuleParamDto insertParam(DbSession dbSession, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { checkArgument(activeRule.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED); checkArgument(activeRuleParam.getId() == null, ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED); Preconditions.checkNotNull(activeRuleParam.getRulesParameterId(), RULE_PARAM_IS_NOT_PERSISTED); activeRuleParam.setActiveRuleId(activeRule.getId()); mapper(dbSession).insertParameter(activeRuleParam); return activeRuleParam; }
@Test public void insertParam() { ActiveRuleDto activeRule = createFor(profile1, rule1).setSeverity(Severity.CRITICAL); underTest.insert(dbSession, activeRule); ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(rule1Param1).setValue("foo"); underTest.insertParam(dbSession, activeRule, activeRuleParam); List<ActiveRuleParamDto> reloaded = underTest.selectParamsByActiveRuleId(dbSession, activeRule.getId()); assertThat(reloaded).hasSize(1); assertThat(reloaded.get(0)) .matches(p -> Objects.equals(p.getId(), activeRuleParam.getId())) .matches(p -> p.getKey().equals(activeRuleParam.getKey())) .matches(p -> p.getActiveRuleId().equals(activeRule.getId())) .matches(p -> p.getRulesParameterId().equals(rule1Param1.getId())) .matches(p -> p.getValue().equals("foo")); }
@Test public void updateParam() { ActiveRuleDto activeRule = createFor(profile1, rule1).setSeverity(Severity.CRITICAL); underTest.insert(dbSession, activeRule); ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(rule1Param1).setValue("foo"); underTest.insertParam(dbSession, activeRule, activeRuleParam); underTest.updateParam(dbSession, activeRuleParam.setValue("bar")); List<ActiveRuleParamDto> reloaded = underTest.selectParamsByActiveRuleId(dbSession, activeRule.getId()); assertThat(reloaded).hasSize(1); assertThat(reloaded.get(0)) .matches(p -> Objects.equals(p.getId(), activeRuleParam.getId())) .matches(p -> p.getKey().equals(activeRuleParam.getKey())) .matches(p -> p.getActiveRuleId().equals(activeRule.getId())) .matches(p -> p.getRulesParameterId().equals(rule1Param1.getId())) .matches(p -> p.getValue().equals("bar")); }
public void deleteParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { Preconditions.checkNotNull(activeRule.getId(), ACTIVE_RULE_IS_NOT_PERSISTED); Preconditions.checkNotNull(activeRuleParam.getId(), ACTIVE_RULE_PARAM_IS_NOT_PERSISTED); deleteParamById(session, activeRuleParam.getId()); }
public void updateParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { Preconditions.checkNotNull(activeRule.getId(), ACTIVE_RULE_IS_NOT_PERSISTED); Preconditions.checkNotNull(activeRuleParam.getId(), ACTIVE_RULE_PARAM_IS_NOT_PERSISTED); mapper(session).updateParameter(activeRuleParam); }
@Override public void accept(@Nonnull ActiveRuleParamDto activeRuleParamDto) { if (activeRuleParamDto.getKey().equals(key)) { dbClient.activeRuleDao().deleteParamById(dbSession, activeRuleParamDto.getId()); } } }
public ActiveRuleParamDto insertParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { Preconditions.checkArgument(activeRule.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED); Preconditions.checkArgument(activeRuleParam.getId() == null, ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED); Preconditions.checkNotNull(activeRuleParam.getRulesParameterId(), RULE_PARAM_IS_NOT_PERSISTED); activeRuleParam.setActiveRuleId(activeRule.getId()); mapper(session).insertParameter(activeRuleParam); return activeRuleParam; }
public void deleteParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) { // TODO SQL rewrite to delete by key Optional<ActiveRuleDto> activeRule = selectByKey(session, key); if (activeRule.isPresent()) { ActiveRuleParamDto activeRuleParam = mapper(session).selectParamByActiveRuleAndKey(activeRule.get().getId(), param); if (activeRuleParam != null) { mapper(session).deleteParameter(activeRuleParam.getId()); } } }