Beispiel #1
0
  /**
   * Generates portion of the query for subcapability WHERE
   *
   * @param sql already existing portion of the SQL, with SELECT and FROM clauses finished
   * @param capabilityAlias alias of the capability for which the condition is to be made
   * @param filter filter describing the condition
   * @param filterPath indexes into the capability lists up to the root starting from this
   *     capability filter. It is used to give MyBatis information where to look for parameter
   *     values
   */
  private void processCapabilityWhere(
      SimpleStringBuilder sql,
      String capabilityAlias,
      CapabilityFilter filter,
      List<Integer> filterPath) {
    sql.append("(", capabilityAlias, ".namespace = ");
    buildParameterValuePath(sql, filterPath, null, "namespace");
    processAttributesWhere(sql, filter.getAttributes(), filterPath, capabilityAlias);

    for (int i = 0; i < filter.getSubFilters().size(); i++) {
      List<Integer> path = new LinkedList<>(filterPath);
      path.add(i);

      sql.append(" AND ");

      processCapabilityWhere(sql, capabilityAlias + i, filter.getSubFilters().get(i), path);
    }
    sql.append(")");
  }
Beispiel #2
0
  /**
   * Generate JOIN clause related to a root capability filter
   *
   * @param sql existing sql
   * @param filter root capability filter
   * @param index index of the filter in the filters list
   */
  private void processRootCapabilityJoin(SQL sql, CapabilityFilter filter, int index) {
    String capabilityAlias = createRootCapabilityAlias(index);
    sql.JOIN(
        "capability "
            + capabilityAlias
            + " ON "
            + capabilityAlias
            + ".resource_id = r.resource_id");
    processAttributesJoin(sql, filter.getAttributes(), capabilityAlias);

    processSubCapabilitiesJoin(sql, filter, capabilityAlias);
  }
Beispiel #3
0
  /**
   * Generates portion of the query for subcapability JOIN
   *
   * @param sql already existing portion of the SQL, presumed to have at least SELECT and FROM
   *     clauses.
   * @param filter filter for the particular subcapability
   * @param parentCapabilityAlias alias of the subcapability's parent in the #sql query
   */
  private void processSubCapabilitiesJoin(
      SQL sql, CapabilityFilter filter, String parentCapabilityAlias) {
    String subAlias;
    CapabilityFilter subFilter;
    for (int k = 0; k < filter.getSubFilters().size(); k++) {
      subFilter = filter.getSubFilters().get(k);

      subAlias = parentCapabilityAlias + k;
      sql.INNER_JOIN(
          "capability "
              + subAlias
              + " ON "
              + parentCapabilityAlias
              + ".capability_id = "
              + subAlias
              + ".parent_capability_id");

      processAttributesJoin(sql, subFilter.getAttributes(), subAlias);

      processSubCapabilitiesJoin(sql, subFilter, subAlias);
    }
  }