Package com.centraview.marketing

Examples of com.centraview.marketing.PromotionList


    int startat = startATparam.intValue();
    int endat = EndAtparam.intValue();
    int begainindex = Math.max(startat - 100, 1);
    int endindex = endat + 100;

    PromotionList DL = new PromotionList();
    DL.setSortMember(sortmem);
    CVDal cvdl = new CVDal(dataSource);

    if (searchString == null)
      searchString = "";

    String appendStr = "";
    String strSQL = "";
    String sortType = "";
    if (sorttype == 'D') {
      sortType = " DESC ";
    }

    strSQL = "select e.Promotionid promotionid, e.title, description,startdate ,enddate, status, 0 as ordercount from `promotion` e order by "
        + sortmem + sortType + " LIMIT " + (begainindex - 1) + " , " + (endindex + 1) + ";";

    if (searchString.startsWith("SIMPLE :")) {
      searchString = searchString.substring(8);
      appendStr = " where  (e.Promotionid like '%" + searchString + "%' OR e.title like '%"
          + searchString + "%' OR description like  '%" + searchString
          + "%'   OR startdate like  '%" + searchString + "%' OR enddate like  '%" + searchString
          + "%' OR status like  '%" + searchString + "%' ) order by  ";
      strSQL = strSQL.replaceFirst("order by", appendStr);
    }

    if ((null != searchString) && (searchString.startsWith("ADVANCE:"))) {
      int searchIndex = (searchString.toUpperCase()).indexOf("WHERE");
      strSQL = "select promotion.Promotionid promotionid, promotion.title, description,startdate ,enddate,"
          + "status, 0 as ordercount from `promotion`  where "
          + searchString.substring((searchIndex + 5), searchString.length())
          + " order by "
          + sortmem + sortType + " LIMIT " + (begainindex - 1) + " , " + (endindex + 1) + ";";
    }

    cvdl.setSqlQuery(strSQL);
    Collection v = cvdl.executeQuery();
    cvdl.clearParameters();
    cvdl.destroy();

    Iterator it = v.iterator();
    TimeZone tz = TimeZone.getTimeZone("EST");
    int i = 0;

    while (it.hasNext()) {
      i++;
      HashMap hm = (HashMap)it.next();

      int ID = ((Long)hm.get("promotionid")).intValue();
      IntMember promotionid = new IntMember("promotionid", ID, 10, "", 'T', false, 10);
      StringMember title = new StringMember("title", (String)hm.get("title"), 10, "", 'T', true);
      StringMember description = new StringMember("description", (String)hm.get("description"), 10,
          "", 'T', false);
      DateMember startdate = new DateMember("startdate", (java.util.Date)hm.get("startdate"), 10,
          "URL", 'T', false, 100, "EST");
      DateMember enddate = new DateMember("enddate", (java.util.Date)hm.get("enddate"), 10, "URL",
          'T', false, 100, "EST");
      StringMember status = new StringMember("status", (String)hm.get("status"), 10, "", 'T', false);
      // int nooforder = ((Long)hm.get("nooforder")).intValue();
      int nooforder = Integer.parseInt(hm.get("ordercount").toString());
      IntMember nooforders = new IntMember("nooforders", nooforder, 10, "", 'T', false, 10);

      PromotionListElement ele = new PromotionListElement(ID);

      ele.put("promotionid", promotionid);
      ele.put("title", title);
      ele.put("description", description);
      ele.put("startdate", startdate);
      ele.put("enddate", enddate);
      ele.put("status", status);
      ele.put("nooforders", nooforders);

      // added by Sameer for generating fixed length sort key from i
      StringBuffer sb = new StringBuffer("00000000000");
      sb.setLength(11);
      String str = (new Integer(i)).toString();

      sb.replace((sb.length() - str.length()), (sb.length()), str);
      String newOrd = sb.toString();

      DL.put(newOrd, ele);
      DL.setTotalNoOfRecords(DL.size());
      DL.setListType("Promotion");
      DL.setBeginIndex(begainindex);
      DL.setEndIndex(endindex);

    }

    return DL;
View Full Code Here


      throws AuthorizationFailedException
  {
    if (!CVUtility.isModuleVisible("Promotion", userId, this.dataSource))
      throw new AuthorizationFailedException("Promotion - getPromotionList");

    PromotionList promotionlist = null;
    try {
      InitialContext ic = CVUtility.getInitialContext();
      MarketingListLocalHome home = (MarketingListLocalHome)ic.lookup("local/MarketingList");
      MarketingListLocal local = home.create();
      local.setDataSource(this.dataSource);
View Full Code Here

  public PromotionList getPromotionList(int userID, int startATparam, int EndAtparam,
      String searchString, String sortColumn) throws CommunicationException, NamingException
  {
    if ((searchString != null) && ((searchString.trim()).length() > 0)) {
      PromotionList dl = new PromotionList();
      dl.setStartAT(startATparam);
      dl.setEndAT(EndAtparam);
      dl.setSortMember(sortColumn);
      dl.setSortType('A');
      dl.setSearchString(searchString);
      dl.setListType("Promotion");

      long currentListID = this.getNextListID();
      dl.setListID(currentListID);

      displayLists.put(new Long(currentListID), dl);

      return this.getPromotionList(userID, dl);

    } else {
      PromotionList returnDL = null;
      try {
        HashMap hm = new HashMap();
        hm.put("startATparam", new Integer(startATparam));
        hm.put("EndAtparam", new Integer(EndAtparam));
        hm.put("searchString", searchString);
        hm.put("sortmem", sortColumn);
        hm.put("sortType", new Character('A'));
        HashMap listMap = null;
        MarketingFacadeHome aa = (MarketingFacadeHome)CVUtility.getHomeObject(
            "com.centraview.marketing.marketingfacade.MarketingFacadeHome", "MarketingFacade");
        try {
          MarketingFacade remote = (MarketingFacade)aa.create();
          remote.setDataSource(this.dataSource);
          returnDL = remote.getPromotionList(userID, hm);
        } catch (Exception e) {
          System.out.println("[Exception] ListGenerator.getPromotionList: " + e.toString());
          // e.printStackTrace();
        }

        returnDL.setListType("Promotion");
        returnDL.setTotalNoOfRecords(returnDL.size());

        long currentListID = this.getNextListID();
        returnDL.setListID(currentListID);
        returnDL.setStartAT(startATparam);
        returnDL.setEndAT(EndAtparam);

        PromotionList emptyDL = createEmptyObject(returnDL);
        emptyDL.setTotalNoOfRecords(returnDL.getTotalNoOfRecords());
        emptyDL.setListID(currentListID);
        emptyDL.setListType("Promotion");
        emptyDL.setStartAT(returnDL.getStartAT());
        emptyDL.setEndAT(returnDL.getEndAT());

        displayLists.put(new Long(currentListID), emptyDL);
      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here

  public PromotionList getPromotionList(int userid, DisplayList DLparam)
      throws CommunicationException, NamingException
  {

    PromotionList returnDL = null;
    PromotionList paramDL = (PromotionList)DLparam;

    int listSize = paramDL.getTotalNoOfRecords();
    int startAT = paramDL.getStartAT();
    int EndAt = paramDL.getEndAT();

    String searchString = paramDL.getSearchString();
    String sortColumn = paramDL.getSortMember();

    HashMap hm = new HashMap();
    hm.put("startATparam", new Integer(Math.max(startAT - 100, 1)));
    hm.put("EndAtparam", new Integer(Math.min(EndAt + 100, listSize)));
    hm.put("searchString", searchString);
    hm.put("sortmem", paramDL.getSortMember());
    hm.put("sortType", new Character(paramDL.getSortType()));

    MarketingFacadeHome aa = (MarketingFacadeHome)CVUtility.getHomeObject(
        "com.centraview.marketing.marketingfacade.MarketingFacadeHome", "MarketingFacade");
    try {
      MarketingFacade remote = (MarketingFacade)aa.create();
      remote.setDataSource(this.dataSource);
      returnDL = remote.getPromotionList(userid, hm);
    } catch (Exception e) {
      System.out.println("[Exception] ListGenerator.getPromotionList: " + e.toString());
      // e.printStackTrace();
    }

    returnDL.setListType("Promotion");
    returnDL.setTotalNoOfRecords(returnDL.size());
    returnDL.setListID(paramDL.getListID());
    returnDL.setStartAT(paramDL.getStartAT());
    returnDL.setEndAT(paramDL.getEndAT());
    returnDL.setSortType(paramDL.getSortType());
    returnDL.setSearchString(searchString);
    return returnDL;
  }
View Full Code Here

  /**
   * this method creates empty Object
   */
  public PromotionList createEmptyObject(PromotionList list)
  {
    PromotionList dummy = new PromotionList();
    dummy.setListType(list.getListType());
    dummy.setPrimaryMemberType(list.getPrimaryMemberType());
    dummy.setPrimaryTable(list.getPrimaryTable());
    dummy.setSortMember(list.getSortMember());
    dummy.setSortType(list.getSortType());
    dummy.setPrimaryMember(list.getPrimaryMember());
    dummy.setStartAT(list.getStartAT());
    dummy.setEndAT(list.getEndAT());
    dummy.setBeginIndex(0);
    dummy.setEndIndex(0);
    return dummy;
  }
View Full Code Here

TOP

Related Classes of com.centraview.marketing.PromotionList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.