コード例 #1
0
  public static Object getJavaObject(HttpServletRequest pRequest, String pFullClassName)
      throws Exception {
    HttpSession session = pRequest.getSession();
    CleanwiseUser appUser = (CleanwiseUser) session.getAttribute(Constants.APP_USER);
    StoreData storeD = appUser.getUserStore();
    AccountData accountD = appUser.getUserAccount();
    int storeId = 0;
    int accountId = 0;
    if (storeD != null) storeId = storeD.getBusEntity().getBusEntityId();
    if (accountD != null) accountId = accountD.getBusEntity().getBusEntityId();
    String key = storeId + "@" + accountId + "@" + pFullClassName;
    Object javaObj = session.getAttribute(key);
    if (javaObj == null) {
      ArrayList prefAL = new ArrayList();
      String path = "";
      PropertyData storePrefixPD = storeD.getPrefix();
      if (storePrefixPD != null) {
        path = Utility.strNN(storePrefixPD.getValue());
      }
      String accountDir = accountD.getPropertyValue(RefCodeNames.PROPERTY_TYPE_CD.ACCOUNT_FOLDER);
      if (Utility.isSet(accountDir)) {
        path += "/" + accountDir;
      }
      path = path.replace('\\', '/').toLowerCase();
      String[] pathDirA = Utility.parseStringToArray(path, "/");
      String pathInc = null;
      for (int ii = 0; ii < pathDirA.length; ii++) {
        String ss = pathDirA[ii];
        if (Utility.isSet(ss)) {
          if (pathInc == null) {
            pathInc = "." + ss;
          } else {
            pathInc += "." + ss;
          }
          pathDirA[ii] = pathInc;
        } else {
          pathDirA[ii] = null;
        }
      }

      int ll = pFullClassName.lastIndexOf(".");
      String defaultPath = pFullClassName.substring(0, ll);
      String className = pFullClassName.substring(ll);
      Class clazz = null;
      for (int ii = pathDirA.length - 1; ii >= 0; ii--) {
        if (pathDirA[ii] != null) {
          String fullClassNameTest = defaultPath + pathDirA[ii] + className;
          try {
            clazz = Class.forName(fullClassNameTest);
            if (clazz != null) {
              break;
            }
          } catch (Exception exc) {
          }
        }
      }
      if (clazz == null) {
        clazz = Class.forName(pFullClassName);
      }
      if (clazz != null) {
        javaObj = clazz.newInstance();
        session.setAttribute(key, javaObj);
      }
    }
    return javaObj;
  }
コード例 #2
0
  /**
   * <code>getAccountsUIByCriteria</code> returns a vector of AccountUIView's meeting the criteria
   * of the BusEntitySearchCriteria.
   *
   * @param pCrit a <code>BusEntitySearchCriteria</code> value the criteria
   * @return a <code>AccountUIViewVector</code> value
   * @exception SQLException if an error occurs
   */
  public AccountUIViewVector getAccountsUIByCriteria(BusEntitySearchCriteria pCrit)
      throws RemoteException {
    Connection conn = null;
    AccountUIViewVector acctVec = new AccountUIViewVector();
    try {
      // USER FILTER ==========================================================//
      Integer userId = null;
      String userFilterForAccounts = "";
      if (pCrit.getUserIds() != null && pCrit.getUserIds().size() > 0) {
        userId = (Integer) pCrit.getUserIds().get(0);
        userFilterForAccounts = getUserFilterForAccounts(userId.intValue());
      }
      // STORE FILTER===========================================================//
      Integer storeId = null;
      if (pCrit.getStoreBusEntityIds() != null && pCrit.getStoreBusEntityIds().size() > 0) {
        storeId = (Integer) pCrit.getStoreBusEntityIds().get(0);
      } else {
        throw new RemoteException("Store ID can't be null. ");
      }
      String storeFilter =
          "(select STORE_DIM_ID from DW_STORE_DIM \n" + "  where STORE_ID = " + storeId + " ) \n";

      String storeFilterForAccounts = getStoreFilterForAccounts(storeId.intValue());

      // ACCOUNT NAMES FILTER==================================================//
      String accountNameFilter =
          getSearchSqlByFilterName(
              "JD_ACCOUNT_NAME", pCrit.getSearchName(), pCrit.getSearchNameType());
      String accountIdFilter =
          (Utility.isSet(pCrit.getSearchId())) ? " and JD_ACCOUNT_ID = " + pCrit.getSearchId() : "";
      // ========================================================================//
      conn = getReportConnection();
      String sql =
          "select  \n "
              + " wm_concat(ACCOUNT_DIM_ID) ACCOUNT_DIM_IDS, \n"
              + " ACCOUNT_ID,  \n"
              + " JD_ACCOUNT_NAME, JD_ACCOUNT_ID, \n"
              + " JD_ACCOUNT_CITY, JD_ACCOUNT_STATE, \n"
              + " JD_MARKET, JD_ACCOUNT_STATUS_CD \n"
              + "from DW_ACCOUNT_DIM where \n"
              + "   STORE_DIM_ID = "
              + storeFilter
              + " \n"
              +
              /*            " and  account_ID in ( " + storeFilterForAccounts +") \n"
               */
              userFilterForAccounts
              + accountIdFilter
              + accountNameFilter
              + " group by  \n "
              + "    ACCOUNT_ID,  \n"
              + "    JD_ACCOUNT_NAME, JD_ACCOUNT_ID, \n"
              + "    JD_ACCOUNT_CITY, JD_ACCOUNT_STATE,  \n"
              + "    JD_MARKET, JD_ACCOUNT_STATUS_CD \n"
              + " order by JD_ACCOUNT_NAME ";

      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery(sql);
      if (pCrit.getResultLimit() != QueryRequest.UNLIMITED) {
        stmt.setMaxRows(2000);
      }
      int rowId = 0;
      while (rs.next()) {
        AccountUIView aui = AccountUIView.createValue();
        rowId--;
        String accountDimIds =
            (rs.getString("ACCOUNT_DIM_IDS") != null) ? rs.getString("ACCOUNT_DIM_IDS") : "";

        BusEntityData be = new BusEntityData();
        be.setBusEntityId(rowId);
        be.setShortDesc(
            (rs.getString("JD_ACCOUNT_NAME") != null) ? rs.getString("JD_ACCOUNT_NAME") : "");
        be.setBusEntityStatusCd(
            (rs.getString("JD_ACCOUNT_STATUS_CD") != null)
                ? rs.getString("JD_ACCOUNT_STATUS_CD")
                : "");

        PropertyData pd = new PropertyData();
        pd.setValue((rs.getString("JD_MARKET") != null) ? rs.getString("JD_MARKET") : "");

        AddressData ad = new AddressData();
        ad.setAddress1("");
        ad.setCity(
            (rs.getString("JD_ACCOUNT_CITY") != null) ? rs.getString("JD_ACCOUNT_CITY") : "");
        ad.setStateProvinceCd(
            (rs.getString("JD_ACCOUNT_STATE") != null) ? rs.getString("JD_ACCOUNT_STATE") : "");

        aui.setAccountDimIds(accountDimIds);
        aui.setBusEntity(be);
        aui.setAccountType(pd);
        aui.setPrimaryAddress(ad);
        acctVec.add(aui);
      }
      stmt.close();
    } catch (Exception exc) {
      exc.printStackTrace();
      throw processException(exc);
    } finally {
      closeConnection(conn);
    }
    return acctVec;
  }