コード例 #1
0
  /**
   * Get Model Validation Script Rules for a table/event
   *
   * @param ctx context
   * @param table_id AD_Table_ID
   * @param event Event
   * @return array of MTableScriptValidator or null if error or no validators found
   */
  public static List<MTableScriptValidator> getModelValidatorRules(
      Properties ctx, int ad_table_id, String event) {
    // Try cache
    final MultiKey key = new MultiKey(ad_table_id, event);
    List<MTableScriptValidator> mvrs = s_cacheTableEvent.get(key);
    if (mvrs != null) {
      if (mvrs.size() > 0) return mvrs;
      else return null;
    }
    //
    // Fetch now
    final String whereClause = "AD_Table_ID=? AND EventModelValidator=?";
    mvrs =
        new Query(ctx, Table_Name, whereClause, null)
            .setParameters(ad_table_id, event)
            .setOnlyActiveRecords(true)
            .setOrderBy(COLUMNNAME_SeqNo)
            .list();
    // Store to cache
    for (MTableScriptValidator rule : mvrs) {
      s_cache.put(rule.get_ID(), rule);
    }

    // Store to cache
    if (mvrs != null) s_cacheTableEvent.put(key, mvrs);
    //
    if (mvrs != null && mvrs.size() > 0) return mvrs;
    else return null;
  } //	getModelValidatorRules
コード例 #2
0
 /**
  * Get table script validator from cache
  *
  * @param ctx context
  * @param AD_Table_ScriptValidator_ID id
  * @return MTableScriptValidator
  */
 public static MTableScriptValidator get(Properties ctx, int AD_Table_ScriptValidator_ID) {
   final Integer key = AD_Table_ScriptValidator_ID;
   MTableScriptValidator retValue = (MTableScriptValidator) s_cache.get(key);
   if (retValue != null) return retValue;
   retValue = new MTableScriptValidator(ctx, AD_Table_ScriptValidator_ID, null);
   if (retValue.get_ID() != 0) s_cache.put(key, retValue);
   return retValue;
 } //	get