Example #1
0
  private RuleTypeDTO createRuleTypeDTO(Violation violation)
      throws RuleInstantionException, LanguageNotFoundException, RuleTypeNotFoundException {
    try {
      if (violationtypeFactory == null) {
        throw new LanguageNotFoundException();
      }
      ViolationType violationtype =
          violationtypeFactory.createViolationType(violation.getViolationtypeKey());
      RuleType rule = ruleFactory.generateRuleType(violation.getRuletypeKey());

      RuleTypeDTO ruleDTO = ruleAssembler.createRuleTypeDTO(rule, violationtype);
      return ruleDTO;
    } catch (ViolationTypeNotFoundException e) {
      throw new ViolationTypeNotFoundException();
    }
  }
Example #2
0
  public List<ViolationDTO> createViolationDTO(List<Violation> violations) {
    List<ViolationDTO> violationDTOList = new ArrayList<ViolationDTO>();

    for (Violation violation : violations) {
      try {
        ViolationDTO violationDTO = createViolationDTO(violation);
        violationDTOList.add(violationDTO);
      } catch (ViolationTypeNotFoundException e) {
        logger.warn(
            String.format(
                "ViolationtypeKey: %s not found in violation", violation.getViolationtypeKey()));
      } catch (LanguageNotFoundException e) {
        logger.warn(e.getMessage());
      } catch (RuleTypeNotFoundException e) {
        logger.warn(e.getMessage());
      } catch (RuleInstantionException e) {
        logger.warn(e.getMessage());
      }
    }
    return violationDTOList;
  }