Example #1
0
  @Override
  protected LinkedList<RT> doInBackground(Object... params) {
    String url = null;

    // Only cache
    if (!query.isIgnoreCache()) {
      try {
        url = query.createUrl();
      } catch (Exception e) {
        JLog.wtf("Trying to get query url", e);
      }

      synchronized (cachedQueries) {
        Object result = cachedQueries.get(url);
        if (result != null) {
          JLog.v("Cached query returned: " + url);
          return (LinkedList<RT>) result;
        }
      }
    }

    try {
      LinkedList<RT> result = query.get(header, clazz);
      if (result != null && url != null) {
        synchronized (cachedQueries) {
          cachedQueries.put(url, result);
        }
      }
      return result;
    } catch (Exception e) {
      JLog.e(query.getClass().getSimpleName() + ".get()", e);
    }
    return null;
  }
Example #2
0
 static JCompanyCache newInstance(Connection con) {
   JCompanyCache cache = new JCompanyCache();
   try {
     cache.init(con);
   } catch (Throwable e) {
     JLog.getLogger().error("", e);
   }
   return cache;
 }
Example #3
0
  public JCompany getCompanyById(String com_id) {
    if (com_id == null || com_id.length() == 0) return null;

    if (JUnit.getUnit(com_id) == null) {
      Exception e = new Exception("部门没找到 com_id=" + com_id);
      JLog.getLogger().error("", e);
      return null;
    }
    String code = JUnit.getUnit(com_id).getUnit_code();

    if (mapCompany.get(code) == null) {
      try {
        loadCompany(code);
      } catch (Exception e) {
        JLog.getLogger().error("", e);
      }
    }
    return mapCompany.get(code);
  }
Example #4
0
 public void loadCompany(String unit_code) throws Exception {
   Connection con = null;
   try {
     con = com.gemway.igo.JDatabase.getJDatabase().getConnection();
     loadCompany(con, unit_code);
   } catch (Exception e) {
     JLog.getLogger().error("", e);
   } finally {
     if (con != null)
       try {
         con.close();
       } catch (Exception e) {
       }
   }
 }
Example #5
0
  public JCompany getCompanyByCode(String code) throws Exception {
    JCompany obj = mapCompany.get(code.toUpperCase());
    if (obj == null) JLog.getLogger().info("公司没找到code=" + code);

    return obj;
  }