Esempio n. 1
0
 public static MInfoWindow get(String tableName, String trxName) {
   Query query =
       new Query(
           Env.getCtx(),
           MTable.get(Env.getCtx(), MInfoWindow.Table_ID),
           MInfoWindow.COLUMNNAME_AD_Table_ID + "=? AND IsValid='Y' ",
           null);
   MTable table = MTable.get(Env.getCtx(), tableName);
   if (table != null) {
     List<MInfoWindow> iws =
         query
             .setParameters(table.getAD_Table_ID())
             .setOrderBy(
                 "AD_Client_ID Desc, AD_Org_ID Desc, IsDefault Desc, AD_InfoWindow_ID Desc")
             .setOnlyActiveRecords(true)
             .setApplyAccessFilter(true)
             .list();
     // verify role has access and return the first with access / IDEMPIERE-893
     for (MInfoWindow iw : iws) {
       Boolean access = MRole.getDefault().getInfoAccess(iw.getAD_InfoWindow_ID());
       if (access != null && access.booleanValue()) return iw;
     }
   }
   return null;
 }
Esempio n. 2
0
  @Override
  protected boolean beforeSave(boolean newRecord) {
    AccessSqlParser parser = new AccessSqlParser("SELECT * FROM " + getFromClause());
    TableInfo[] tableInfos = parser.getTableInfo(0);
    if (tableInfos == null || tableInfos.length == 0) {
      log.saveError("ParseFromClauseError", "Failed to parse from clause");
      return false;
    }

    // only one default per table
    if (newRecord || is_ValueChanged("IsDefault")) {
      if (isDefault()) {
        if (newRecord) {
          Query query =
              new Query(
                  getCtx(),
                  MTable.get(getCtx(), Table_ID),
                  "AD_Table_ID=? AND IsDefault='Y' AND AD_Client_ID=?",
                  get_TrxName());
          List<MInfoWindow> list = query.setParameters(getAD_Table_ID(), getAD_Client_ID()).list();
          for (MInfoWindow iw : list) {
            iw.setIsDefault(false);
            iw.saveEx();
          }
        } else {
          Query query =
              new Query(
                  getCtx(),
                  MTable.get(getCtx(), Table_ID),
                  "AD_InfoWindow_ID<>? AND AD_Table_ID=? AND IsDefault='Y' AND AD_Client_ID=?",
                  get_TrxName());
          List<MInfoWindow> list =
              query
                  .setParameters(getAD_InfoWindow_ID(), getAD_Table_ID(), getAD_Client_ID())
                  .list();
          for (MInfoWindow iw : list) {
            iw.setIsDefault(false);
            iw.saveEx();
          }
        }
      }
    }

    // evaluate need valid
    boolean isNeedValid =
        is_new()
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_AD_Table_ID)
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_WhereClause)
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_FromClause)
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_OrderByClause)
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_OtherClause)
            || is_ValueChanged(I_AD_InfoWindow.COLUMNNAME_IsDistinct);

    // valid config
    if (isNeedValid) {
      validate();
    }

    return true;
  }
Esempio n. 3
0
 /**
  * return true if the current role can access to the specified info window ; otherwise return null
  */
 public static MInfoWindow get(int infoWindowID, String trxName) {
   MInfoWindow iw = new MInfoWindow(Env.getCtx(), infoWindowID, null);
   Boolean access = MRole.getDefault().getInfoAccess(iw.getAD_InfoWindow_ID());
   if (access != null && access.booleanValue()) return iw;
   return null;
 }