Package org.jayasoft.woj.portal.model

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


        Order o = new Order();
        o.setTotalCost(50.0d);
        Invoice i = new Invoice();
        PaymentInfo pi = new PaymentInfo();
        License l = new License();
        Price p = new Price();
        p.setPriceByYear(50);
        l.setPrice(p);
        pi.setLicenses(Collections.singleton(l));
        o.setPayments(Collections.singleton(pi));
        o.setInvoice(i);
        Purchaser pur = getPurchaser();
View Full Code Here


   
    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);
View Full Code Here

                return TrialLicense.getAllowedSpace();
            } else {
                return 0;
            }
    }
    Price p = lic.getPrice();
    if (p == null) {
      return 0;
    } else {
      String code = p.getProduct().getCode();
      if (code != null && code.startsWith(PROFESSIONAL_CODE_PREFIX)) {
                String sizeCode = code.substring(PROFESSIONAL_CODE_PREFIX.length());
                Integer realSize = (Integer)LICENSES_SIZE_GROUP.get(sizeCode);
        return (realSize==null)?0:realSize.intValue() * 1024;
      } else {
View Full Code Here

      throw new RuntimeException("Unable to save order:"+order, e);
    }
  }
 
  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);
View Full Code Here

    public Price getPrice(String productCode, int nbUsers, int nbYears) {
    return DaoFactory.getPricingDao().getPrice(productCode, nbUsers, nbYears);
    }
   
    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);
          }
View Full Code Here

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

      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

TOP

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

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.