コード例 #1
0
ファイル: QueryValidator.java プロジェクト: molgenis/molgenis
  private static Attribute getQueryRuleAttribute(QueryRule queryRule, EntityType entityType) {
    String queryRuleField = queryRule.getField();
    if (queryRuleField == null) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "Query rule with operator [%s] is missing required field",
                  queryRule.getOperator().toString())));
    }

    Attribute attr = entityType.getAttribute(queryRuleField);
    if (attr == null) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "Query rule field [%s] refers to unknown attribute in entity type [%s]",
                  queryRuleField, entityType.getName())));
    }
    return attr;
  }