Examples of SpecialOffer


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

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

    }
  }
 
  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

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

    }
   
    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

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

    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

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

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

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

                    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

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

                        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

Examples of org.plugtree.training.handsonlabs.model.SpecialOffer

     
      StockItem sonyLCDTV1 = new StockItem(ItemType.LCD_TV,"Sony");
      StockItem sonyLCDTV2 = new StockItem(ItemType.LCD_TV,"Sony");
     
      //PROMOTIONAL PRICES
      SpecialOffer samsungLCDSpecialOffer = new SpecialOffer(ItemType.LCD_TV, "Samsung", 300d);
     
      SpecialOffer sonyLEDSpecialOffer = new SpecialOffer(ItemType.LED_TV, "Sony", 850d);
     
      //Insert promotional prices as globals
      ksession.setGlobal("samsung_led_price", samsung_led_price);
      ksession.setGlobal("samsung_lcd_price", samsung_lcd_price);
      ksession.setGlobal("samsung_tube_price", samsung_tube_price);
      ksession.setGlobal("sony_led_price", sony_led_price);
      ksession.setGlobal("sony_lcd_price", sony_lcd_price);
       
      //Insert Special prices as facts
      ksession.insert(samsungLCDSpecialOffer);
      ksession.insert(sonyLEDSpecialOffer);
     
      //Insert items as facts
        ksession.insert(samsungLEDTV1);
        ksession.insert(samsungLEDTV2);
        ksession.insert(samsungLCDTV1);
        ksession.insert(samsungTUBETV1);
        ksession.insert(sonyLEDTV1);
        ksession.insert(sonyLCDTV1);
        ksession.insert(sonyLCDTV2);
       
        //fire all rules
        ksession.fireAllRules();
       
       
        //Control
       
        //SAMSUNG
        Assert.assertEquals("",samsung_led_price.doubleValue(), samsungLEDTV1.getPrice(),0.1);
        Assert.assertEquals("",samsung_led_price.doubleValue(), samsungLEDTV2.getPrice(),0.1);

        Assert.assertEquals("",samsungLCDSpecialOffer.getPrice(), samsungLCDTV1.getPrice(),0.1);
       
        Assert.assertEquals("",samsung_tube_price.doubleValue(), samsungTUBETV1.getPrice(),0.1);
       
        //SONY
        Assert.assertEquals("",sonyLEDSpecialOffer.getPrice(), sonyLEDTV1.getPrice(),0.1);
       
        Assert.assertEquals("",sony_lcd_price.doubleValue(), sonyLCDTV1.getPrice(),0.1);
        Assert.assertEquals("",sony_lcd_price.doubleValue(), sonyLCDTV2.getPrice(),0.1);
       
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.