Package org.jayasoft.woj.portal.model

Examples of org.jayasoft.woj.portal.model.SpecialOffer


    public List addLicense(Order order) throws ServiceException, RegistrationException {
        LOGGER.info("adding licenses to order:" + order.getId());
      List newLicense = new ArrayList();
      User u = order.getBuyer();
      Price price = order.getPrice();
      SpecialOffer so = order.getSpecialOffer();
      int nb = order.getSubscribedUsers();
      int duration = order.getSubscribedYears();
      UserDao userDao = DaoFactory.getUserDao();
      LicenseDao licenseDao = DaoFactory.getLicenseDao();
      try {
            ClufImpl cluf = getActiveCluf();
           
        userDao.fetch(u);
        UserImpl user = (UserImpl)userDao.findUser(u.getLogin());
        userDao.fetch(user);

            if ((user.getLastAcceptedCluf() == null) || !cluf.getVersion().equals(user.getLastAcceptedCluf().getVersion())) {
                user.setLastAcceptedCluf(cluf);
            }

            for (int i = 0; i < nb; i++) {
          License l = (License) licenseDao.newHandledObject();
          l.setBuyer(user);
          l.setPrice(price);
          l.setSpecialOffer(so);
          long validUntil = getValidUntil(duration);
        l.setValidUntil(validUntil);
          user.getBuyedLicenses().add(l);
          newLicense.add(l);
          //counter increment
          price.getCounter().increment();
          if(so != null) {
            so.getCounter().increment();
          }
        }
        ServiceFactory.getUserService().update(user);
           
            upgradeLicenses(user, newLicense);
View Full Code Here


    }
  }
 
  private void privateUpdate(UserImpl buyer, Purchaser p, String productCode, int users, int years, Order order) {
    Price price = getPrice(productCode, users, years);
    SpecialOffer specialOffer = getSpecialOffer(price);
    order.setPrice(price);
    order.setSpecialOffer(specialOffer);
    order.setSubscribedUsers(users);
    order.setSubscribedYears(years);
        order.setCost(computeTotal(price, specialOffer, users, years));
View Full Code Here

    }
   
    public int computePrice(String productCode, int nbUsers, int nbYears, boolean withSpecialOffer) {
        Price price = DaoFactory.getPricingDao().getPrice(productCode, nbUsers, nbYears);
        if(price != null) {
          SpecialOffer specialOffer = null;
          if(withSpecialOffer) {
            specialOffer = getSpecialOffer(price);
          }
          return computeTotal(price, specialOffer, nbUsers, nbYears);
        }
View Full Code Here

    List l = Portal.getInstance().getPricingService().getAllPriceForProduct(productCode);
    List offers = Portal.getInstance().getPricingService().getAllSpecialOfferForProduct(productCode);
    Map offerByPrice = new HashMap();
    //just to avoid to many fetch on special offer we prepare a map
    for (Iterator iter = offers.iterator(); iter.hasNext();) {
      SpecialOffer so = (SpecialOffer) iter.next();
      offerByPrice.put(String.valueOf(so.getRelatedPrice().getId()), so);
    }
    int nbYear = 3;
    Collections.sort(l, new Comparator() {
      public int compare(Object o1, Object o2) {
        Price p1 = (Price) o1;
        Price p2 = (Price) o2;
        if (p1.getMinimunUser() < p2.getMinimunUser()) {
          return Integer.MIN_VALUE;
        }
        if (p1.getMinimunUser() == p2.getMinimunUser()) {
          return p1.getDurationInYear() - p2.getDurationInYear();
        }
        return Integer.MAX_VALUE;
      }
    });
        String[][] table =  new String[l.size()/nbYear][];
        Iterator iterator = l.iterator();
    for (int i=0; i<table.length; i++) {
      String[] row = new String[nbYear+1];
      table[i] = row;
      for (int j = 0; j < row.length; j++) {
        Price p = null;
        if(iterator.hasNext()) {
          p = (Price) iterator.next();
        }
        if(p!=null) {
          if(j == 0) {
            row[j++] = p.getMinimunUser() +" - "+ p.getMaximunUser();
          }
          // To many fetch slow down the page
//          SpecialOffer so = Portal.getInstance().getPricingService().getSpecialOffer(p);
          SpecialOffer so = (SpecialOffer) offerByPrice.get(String.valueOf(p.getId()));
          if(so != null) {
            row[j] = "<strike>"+p.getPriceByYear() +"</strike> &euro;"+"<br/>" + specialOfferMsg +" "+so.getNewPrice()+" &euro;";
          } else {
            row[j] = p.getPriceByYear() +" &euro;";
          }
        } else {
          row[j] = "";
View Full Code Here

 
    /* (non-Javadoc)
     * @see org.jayasoft.woj.portal.data.dao.hibernate.DefaultHibernateWOJDao#newHandledObject()
     */
    public WOJObject newHandledObject() {
        return new SpecialOffer();
    }
View Full Code Here

                    ActionsHelper.rememberContext(request, "homepage");

                    List actualSO = Portal.getInstance().getPricingService().getAllSpecialOffer();
                    List offersKey = new ArrayList(actualSO.size());
                    for (Iterator itSO = actualSO.iterator(); itSO.hasNext();) {
                        SpecialOffer so = (SpecialOffer)itSO.next();
                        offersKey.add("so-"+so.getId());
                    }
                    addOffersToShow(request, offersKey, false);
                   
                    return null;
                }
View Full Code Here

                        request.setAttribute("ENTERPRISE", buildArray("ENTERPRISE", spoText));
                       
                        List actualSO = Portal.getInstance().getPricingService().getAllSpecialOffer();
                        List offersKey = new ArrayList(actualSO.size());
                        for (Iterator itSO = actualSO.iterator(); itSO.hasNext();) {
                            SpecialOffer so = (SpecialOffer)itSO.next();
                            offersKey.add("so-"+so.getId());
                        }
                       
                        addOffersToShow(request, offersKey, true);
                       
                        return null;
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.portal.model.SpecialOffer

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.