Package org.jayasoft.woj.portal.model

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


    }

  public void unlinkLicense(Long userId) throws ServiceException {
        try {
            LOGGER.info("unlinking license for " + userId);
            UserImpl user = (UserImpl) DaoFactory.getUserDao().find(userId);
            if (user!=null) {
                License l = user.getLicenseUsed();
                user.setLicenseUsed(null);
//                user.setGroup(null);
                ServiceFactory.getUserService().update(user);
                ServiceFactory.getLicenseService().saveLicense(l);
                NotificationService.updateUsers(new User[] {user});
                LOGGER.info("unlink done.");
View Full Code Here


            ClufImpl cluf = ServiceFactory.getLicenseService().getActiveCluf();
            License l = licenseDao.createTrial();
           
            Group group = (Group) groupDao.find(groupId);
//            l.setHostId(hostId); No Host
            UserImpl user = (UserImpl)userDao.findUser(userLogged.getLogin());
            userDao.fetch(user);
            if ((user.getLastAcceptedCluf() == null) ||
                cluf.getVersion().equals(user.getLastAcceptedCluf().getVersion())) {
                user.setLastAcceptedCluf(cluf);
            }
            user.getBuyedLicenses().add(l);
            l.setValidUntil(user.getLicenseUsed().getValidUntil());
            l.setBuyer(user);
            l.setCluf(cluf);
            l.setGroup(group);
//            DaoFactory.getLicenseDao().save(l);
            ServiceFactory.getUserService().update(user);
View Full Code Here

    public void inviteUser(User userLogged, Long groupId, String userMail) throws ServiceException {
        if (userMail==null || !EmailHelper.doEmailSeemsValid(userMail)) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.no.mail", new Object[] {userMail}));
        }
        UserImpl u = (UserImpl)DaoFactory.getUserDao().findUserByEmail(userMail);
        Group g;
        try {
            g = (Group)DaoFactory.getGroupDao().find(groupId);
        } catch (DaoException e) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.group.not.found", new Object[] {groupId}));
        }
        if (u==null) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.no.user.by.mail", new Object[] {userMail}));
        }
   
        License l = u.getLicenseUsed();
        if (l==null || !u.isLicenseValid()) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.user.no.license.valid", new Object[] {userMail}));
        }
        if (!ServiceFactory.getLicenseService().isGroupable(l)) {
            throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.error.invite.user.license.non.groupable", new Object[] {userMail}));
        }
View Full Code Here

     * @param u
     * @return a non null list of FidelityOffer
     */
    public List getFidelityOffers(User u) {
        if (u instanceof UserImpl) {
            UserImpl user = (UserImpl)ServiceFactory.getUserService().getUser(u.getLogin());
            UserPoint up = DaoFactory.getUserPointDao().getLast(user);
            return DaoFactory.getFidelityOfferDao().getAccessible((up==null)?0:up.getPoints());
        }
        LOGGER.warn("cannot get fidelity offers for a non UserImpl object:" + u);
        return Collections.EMPTY_LIST;
View Full Code Here

        }
    }
   
    public void addUserLicenseToGroup(Long userID, Long grpID) throws ServiceException {
        try {
            UserImpl user = (UserImpl)DaoFactory.getUserDao().find(userID);
            Group group = (Group)DaoFactory.getGroupDao().find(grpID);
           
            License l = user.getLicenseUsed();
            if (!ServiceFactory.getLicenseService().isGroupable(l)) {
                throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.accepted.error.bad.license", null));
            }
            if (!user.isLicenseValid()) {
                throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.admin.user.group.accept.invite.accepted.error.license.expired", null));
            }
            if (l.getGroup() != null) {
                removeLicense(new Long(l.getGroup().getId()), new Long(l.getId()));
            }
View Full Code Here

                        LOGGER.info("order " + pendingOrder.getId() + " payed...");
                        DaoFactory.getOrderDao().save(pendingOrder);
                       
            LOGGER.info("creating licence...");
            List lic = ServiceFactory.getLicenseService().addLicense(pendingOrder);
                        UserImpl buyer = pendingOrder.getBuyer();
                       
                       
                        // We modify user for fidelity
                        Product p = pendingOrder.getPrice().getProduct();
                        int years = pendingOrder.getSubscribedYears();
View Full Code Here

    }

    public void buy(User buyer, Product p, int years, int subscribedUsers) {
        if (buyer instanceof UserImpl) {
            try {
                UserImpl godson = (UserImpl)buyer;
                UserDao uDao = DaoFactory.getUserDao();
                ProductPointDao ppDao = DaoFactory.getProductPointDao();
                UserPointDao upDao = DaoFactory.getUserPointDao();
               
                UserImpl godfather = (UserImpl)uDao.findUser(godson.getGodfather());
                if (godfather != null) {
                    ProductPoint pp = ppDao.get(p, years, ProductPoint.GODSON);
                    if (pp.getPoints()!=0) {
                        UserPoint oldGFUP = getUserPoint(godfather);
                        UserPoint gfUP = UserPointFactory.godson(godfather, oldGFUP, godson, p, subscribedUsers, pp);
                        upDao.save(gfUP);
                        ServiceFactory.getRegistrationService().sendFidelityAccountPointEarnedByGodSonBuyMail(godfather, godson, p, subscribedUsers, years, gfUP.getEarnedPoints(), gfUP.getPoints());
                        LOGGER.info("adding " + pp.getPoints() + " to user: " + godfather.getId() + ", his godson: " + godson.getId() + " bought " + p.getCode() + " for " + years + " years");
                    }
                } else {
                    LOGGER.info("user: " + buyer.getId() + " does not have a godfather");
                }
                ProductPoint pp = ppDao.get(p, years, ProductPoint.PURCHASE);
View Full Code Here

    }
   
    public void renew(User buyer, Product p, int years) {
        if (buyer instanceof UserImpl) {
            try {
                UserImpl godson = (UserImpl)buyer;
                UserPointDao upDao = DaoFactory.getUserPointDao();
                ProductPointDao ppDao = DaoFactory.getProductPointDao();
               
                ProductPoint pp = ppDao.get(p, years, ProductPoint.RENEWAL);
                if (pp.getPoints()!=0) {
                    UserPoint oldGSUP = getUserPoint(godson);
                    UserPoint gsUP = UserPointFactory.renew(godson, oldGSUP, p, pp);
                    upDao.save(gsUP);
                    ServiceFactory.getRegistrationService().sendFidelityAccountPointEarnedBySelfRenewMail(godson, p, years, gsUP.getEarnedPoints(), gsUP.getPoints());
                    LOGGER.info("adding " + pp.getPoints() + " to user: " + godson.getId() + ", he renews " + p.getCode() + " for " + years + " years");
                }
            } catch (DaoException e) {
                LOGGER.warn("cannot add fidelity points to user: " + buyer.getId(), e);
            }
        } else {
View Full Code Here

    }
   
    public void orderGift(User u, Long giftId) throws ServiceException {
        if (u instanceof UserImpl) {
            try {
                UserImpl user = (UserImpl)u;
                UserPointDao upDao = DaoFactory.getUserPointDao();
                FidelityOfferDao foDao = DaoFactory.getFidelityOfferDao();
                FidelityOffer fo = (FidelityOffer)foDao.find(giftId);
                if (fo != null) {
                    UserPoint oldUP = getUserPoint(user);
                    if (oldUP.getPoints() < fo.getNeededPoints()) {
                        throw new ServiceException(RessourceBundleApplicationMessage.error("woj.page.fidelity.offers.not.enough.points", null));
                    }
                    UserPoint up = UserPointFactory.orderGift(u, oldUP, fo);
                    upDao.save(up);
                    ServiceFactory.getRegistrationService().sendOrderGiftMail(user, Messages.DEFAULT.getString(fo.getKey()), fo.getNeededPoints(), up.getPoints());
                    LOGGER.info("removing " + fo.getNeededPoints() + " from user: " + user.getId() + ", he ordered: " + fo.getKey());
                } else {
                    LOGGER.warn("gift " + giftId + " not found on db");
                }
            } catch (DaoException e) {
                LOGGER.warn("cannot order gift " + giftId + " for user: " + u.getId(), e);
View Full Code Here

    }
   
    public void promotion(User u, String moduleName) {
        if (u instanceof UserImpl) {
            try {
                UserImpl user = (UserImpl)u;
                UserPointDao upDao = DaoFactory.getUserPointDao();
                Integer points = new Integer(Messages.DEFAULT.getString("woj.page.fidelity.offers.program.module.array.value"));
               
                if (points.intValue()>0) {
                    UserPoint oldUP = getUserPoint(user);
                    UserPoint up = UserPointFactory.promotion(u, oldUP, moduleName, points.intValue());
                    upDao.save(up);
                    ServiceFactory.getRegistrationService().sendFidelityAccountPointEarnedByUploadMail(user, moduleName, up.getEarnedPoints(), up.getPoints());                   
                    LOGGER.info("adding " + points + " to user: " + user.getId() + ", module: " + moduleName + " has been promoted");
                }
            } catch (DaoException e) {
                LOGGER.warn("cannot give fidelity points for promotion of " + moduleName + " for user " + u.getLogin() , e);
            }
        } else {
View Full Code Here

TOP

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

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.