Esempio n. 1
0
  public JwSqlSelect getUserAirportAndRolesAndRoleGroupsSelect(
      String airportCode, String roleOrRoleGroup) {
    boolean isRole = AcRoleEnum.getFromCode(roleOrRoleGroup) != null;
    String roleCode = isRole ? roleOrRoleGroup : null;
    String roleGroupCode = isRole ? null : roleOrRoleGroup;

    AcUserAirportDb ua = null;
    String x = "x";
    String roles = "roles";
    String roleGroups = "roleGroups";
    String airports = "airports";

    JwSqlSelect st = createSelect();
    st.selectString(x, LOGIN);
    st.selectString(x, FIRST_NAME);
    st.selectString(x, LAST_NAME);
    st.selectString(x, roles);
    st.selectString(x, roleGroups);
    st.selectGroupConcat(ua.ALIAS, ua.AIRPORT_CODE, null, "1", null, airports);
    st.from(getUserRolesAndRoleGroupsSelect(roles, roleGroups), x);
    st.fromLeftOuterJoin(null, x, ua.TABLE, ua.ALIAS, LOGIN, ua.LOGIN);
    st.groupBy(1, 2, 3, 4, 5);
    if (JwUtility.hasValue(airportCode)) st.having().contains(null, airports, airportCode);
    if (JwUtility.hasValue(roleCode)) st.having().contains(null, roles, roleCode);
    if (JwUtility.hasValue(roleGroupCode)) st.having().contains(null, roleGroups, roleGroupCode);
    return st;
  }
  public JwList<AcDomesticNominatedRouteSummaryVo> groupSummaryByCreatedUtcTsOnOrAfter(
      JwTimestamp startUtcTs) {
    JwList<AcDomesticNominatedRouteSummaryVo> v = new JwList<AcDomesticNominatedRouteSummaryVo>();

    JwSqlSelect st = createSelect();
    st.selectDate(ALIAS, NORMALIZED_BEGIN_UTC_DT);
    st.selectDate(ALIAS, NORMALIZED_END_UTC_DT);
    st.selectMinimumTimestamp(ALIAS, CREATED_UTC_TS);
    st.selectCount();
    st.from(TABLE, ALIAS);
    st.where().isGreaterThanOrEqualTo(ALIAS, CREATED_UTC_TS, startUtcTs);
    st.where().isEqual(ALIAS, STATUS, AcDomesticNominatedRouteStatusEnum.NEW.getCode());
    st.groupBy(ALIAS, NORMALIZED_BEGIN_UTC_DT);
    st.groupBy(ALIAS, NORMALIZED_END_UTC_DT);
    AcDbUtility.processResults(
        getAccess(), st, getReadNominatedRouteSummaryVoListResultSetProcessor(v));
    return v;
  }
  public JwList<AcDomesticCandidateRouteSummaryVo> groupSummaryByNormalizedBeginUtcDtBetween(
      JwDate startUtcDt, JwDate endUtcDt) {
    // select c.normalizedBeginUtcDt, c.normalizedEndUtcDt, count(distinct c.id),
    // group_concat(distinct c.status)
    // from domesticNominatedRoute c
    // where c.normalizedBeginUtcDt >= startUtcDt and c.normalizedBeginUtcDt <= endUtcDt
    // group by c.normalizedBeginUtcDt, c.normalizedEndUtcDt
    JwList<AcDomesticCandidateRouteSummaryVo> v = new JwList<AcDomesticCandidateRouteSummaryVo>();

    JwSqlSelect st = createSelect();
    st.selectDate(ALIAS, NORMALIZED_BEGIN_UTC_DT);
    st.selectDate(ALIAS, NORMALIZED_END_UTC_DT);
    st.selectCountDistinct(ALIAS, ID);
    st.selectGroupConcatDistinct(ALIAS, STATUS);
    st.from(TABLE, ALIAS);
    st.where().isGreaterThanOrEqualTo(ALIAS, NORMALIZED_BEGIN_UTC_DT, startUtcDt);
    st.where().isLessThanOrEqualTo(ALIAS, NORMALIZED_BEGIN_UTC_DT, endUtcDt);
    st.groupBy(ALIAS, NORMALIZED_BEGIN_UTC_DT);
    st.groupBy(ALIAS, NORMALIZED_END_UTC_DT);
    AcDbUtility.processResults(getAccess(), st, getReadSummaryVoListResultSetProcessor(v));
    return v;
  }
Esempio n. 4
0
  private JwSqlSelect getUserRolesAndRoleGroupsSelect(String roles, String roleGroups) {
    AcUserRoleDb ur = null;
    String x = "x";
    String isRoleGroup = "isRoleGroup";
    String groupRoleRoles = "groupRoleRoles";

    JwSqlAdaptor adaptor = getAccess().getAdaptor();
    JwSqlSimpleExprValue nullExpr = null;
    JwSqlSimpleExprLiteral openParenExpr = new JwSqlSimpleExprLiteral(adaptor, "'('");
    JwSqlSimpleExprLiteral closeParenExpr = new JwSqlSimpleExprLiteral(adaptor, "')'");
    JwSqlSimpleExprColumn boolExpr = new JwSqlSimpleExprColumn(adaptor, isRoleGroup);
    JwSqlSimpleExprColumn roleExpr = new JwSqlSimpleExprColumn(adaptor, null, ur.ROLE);
    JwSqlSimpleExprColumn groupRoleRolesExpr =
        new JwSqlSimpleExprColumn(adaptor, null, groupRoleRoles);

    JwSqlSimpleExprFunctionConcat concat = new JwSqlSimpleExprFunctionConcat(adaptor);
    concat.addExpression(roleExpr);
    concat.addExpression(openParenExpr);
    concat.addExpression(groupRoleRolesExpr);
    concat.addExpression(closeParenExpr);

    JwSqlSimpleExprFunctionIf roleCond;
    roleCond = new JwSqlSimpleExprFunctionIf(boolExpr, nullExpr, roleExpr);
    JwSqlSimpleExprFunctionGroupConcat roleConcat;
    roleConcat = new JwSqlSimpleExprFunctionGroupConcat(roleCond, false);
    roleConcat.setOrderBy(1, true);

    JwSqlSimpleExprFunctionIf groupCond;
    groupCond = new JwSqlSimpleExprFunctionIf(boolExpr, concat, nullExpr);
    JwSqlSimpleExprFunctionGroupConcat groupRoleConcat;
    groupRoleConcat = new JwSqlSimpleExprFunctionGroupConcat(groupCond, false);
    groupRoleConcat.setOrderBy(1, true);

    JwSqlSelect st = createSelect();
    st.selectString(x, LOGIN);
    st.selectString(x, FIRST_NAME);
    st.selectString(x, LAST_NAME);
    st.addExpression(
        roleConcat, roles); // group_concat(if(isRoleGroup,null,role) order by 1) as roles
    st.addExpression(
        groupRoleConcat,
        roleGroups); // group_concat(if(isRoleGroup,concat(role,'(',groupRoleRoles,')'),null) order
                     // by 1) as roleGroups
    st.from(getUserRoleGroupsSelect(isRoleGroup, groupRoleRoles), x);
    st.groupBy(1, 2, 3);
    return st;
  }
Esempio n. 5
0
  private JwSqlSelect getUserRoleGroupsSelect(String isRoleGroup, String groupRoleRoles) {
    AcUserRoleDb ur = null;
    AcRoleGroupRoleDb rgr = null;

    JwSqlSimpleExprColumn c =
        new JwSqlSimpleExprColumn(_access.getAdaptor(), rgr.ALIAS, rgr.ROLE_GROUP_CODE);
    JwSqlBooleanPrimaryIs isRoleGroupExpr = new JwSqlBooleanPrimaryIs(c, true);

    JwSqlSelect st = createSelect();
    st.selectString(ALIAS, LOGIN);
    st.selectString(ALIAS, FIRST_NAME);
    st.selectString(ALIAS, LAST_NAME);
    st.selectString(ur.ALIAS, ur.ROLE);
    st.addExpression(isRoleGroupExpr, isRoleGroup);
    st.selectGroupConcat(rgr.ALIAS, rgr.ROLE, null, "1", null, groupRoleRoles);
    st.from(TABLE, ALIAS);
    st.from(ur.TABLE, ur.ALIAS);
    st.fromLeftOuterJoin(null, ur.ALIAS, rgr.TABLE, rgr.ALIAS, ur.ROLE, rgr.ROLE_GROUP_CODE);
    st.where().isTrue(ALIAS, ACTIVE);
    st.where().isEqualColumn(ALIAS, LOGIN, ur.ALIAS, ur.LOGIN);
    st.groupBy(1, 2, 3, 4, 5);
    return st;
  }