Пример #1
0
  @Override
  protected void validateThis(
      final ValidationContext context, final ResponseDeclaration responseDeclaration) {
    final int maxChoices = getMaxChoices();
    final int minChoices = getMinChoices();

    if (maxChoices != 0 && minChoices > maxChoices) {
      context.fireValidationError(
          this, "Minimum number of choices can't be bigger than maximum number");
    }

    if (responseDeclaration != null) {
      if (responseDeclaration.getBaseType() != null
          && !responseDeclaration.getBaseType().isIdentifier()) {
        context.fireValidationError(this, "Response variable must have identifier base type");
      }

      if (getMaxChoices() == 1
          && !responseDeclaration.getCardinality().isSingle()
          && !responseDeclaration.getCardinality().isMultiple()) {
        context.fireValidationError(
            this, "Response variable must have single or multiple cardinality");
      }

      if (getMaxChoices() != 1 && !responseDeclaration.getCardinality().isMultiple()) {
        context.fireValidationError(this, "Response variable must have multiple cardinality");
      }
    }
  }
Пример #2
0
  @Override
  public void validateThis(
      final ValidationContext context, final ResponseDeclaration responseDeclaration) {
    final Integer minChoices = getMinChoices();
    final Integer maxChoices = getMaxChoices();

    if (minChoices != null && minChoices.intValue() < 1) {
      context.fireValidationError(this, "Minimum number of choices can't be less than one");
    }

    if (maxChoices != null && minChoices != null && maxChoices.intValue() < minChoices.intValue()) {
      context.fireValidationError(
          this, "Maximum number of choices must be greater or equal to minimum number of choices");
    }

    if (maxChoices != null && maxChoices.intValue() > getHotspotChoices().size()) {
      context.fireValidationError(
          this, "Maximum number of choices cannot be larger than the number of choice children");
    }

    if (responseDeclaration != null) {
      if (responseDeclaration.getBaseType() != null
          && !responseDeclaration.getBaseType().isIdentifier()) {
        context.fireValidationError(this, "Response variable must have identifier base type");
      }

      if (!responseDeclaration.getCardinality().isOrdered()) {
        context.fireValidationError(this, "Response variable must have ordered cardinality");
      }
    }
  }