Package org.libreplan.business.users.entities

Examples of org.libreplan.business.users.entities.User


            }
        }
    }

    private static Locale getUserLocale() {
        User user = UserUtil.getUserFromSession();
        if (user != null) {
            return user.getApplicationLanguage().getLocale();
        }
        return null;
    }
View Full Code Here


        return transactionService
                .runOnAnotherTransaction(new IOnTransaction<User>() {

                    @Override
                    public User execute() {
                        User user = User.create("login" + UUID.randomUUID(),
                                "password", "");
                        userDAO.save(user);
                        user.dontPoseAsTransientObjectAnymore();
                        return user;
                    }
                });
    }
View Full Code Here

    }

    @Test(expected = ValidationException.class)
    @Transactional
    public void testWorkerBoundToUserAlreadyBound() {
        final User user = givenStoredUser();

        transactionService.runOnAnotherTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                Worker worker1 = givenValidWorker();
View Full Code Here

        resource.add(user.getWorker());
        return resource;
    }

    public static Resource getBoundResourceFromSession() {
        User user = UserUtil.getUserFromSession();
        if (user.isBound()) {
            return user.getWorker();
        }
        return null;
    }
View Full Code Here

        assertEquals(previous + 1, externalCompanyDAO.list(ExternalCompany.class).size());
    }

    @Test
    public void testRelationWithUser() throws InstanceNotFoundException {
        final User user = createValidUser();
        final ExternalCompany externalCompany = createValidExternalCompany();
        externalCompany.setCompanyUser(user);

        IOnTransaction<Void> saveEntities = new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                userDAO.save(user);
                externalCompanyDAO.save(externalCompany);
                return null;
            }
        };
        transactionService.runOnTransaction(saveEntities);

        IOnTransaction<Void> retrieveEntitiesInOtherTransaction = new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try{
                    ExternalCompany retrievedCompany = externalCompanyDAO.find(externalCompany.getId());
                    assertEquals(user.getLoginName(), retrievedCompany.getCompanyUser().getLoginName());
                }
                catch (InstanceNotFoundException e) {
                    fail("Unexpected InstanceNotFoundException");
                }
                return null;
View Full Code Here

    }

    @Override
    public List<Order> getOrdersByReadAuthorizationByScenario(String username,
            Scenario scenario) {
        User user;
        try {
            user = userDAO.findByLoginName(username);
        } catch (InstanceNotFoundException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    @Override
    public List<Order> getOrdersByReadAuthorizationBetweenDatesByLabelsCriteriaCustomerAndState(
            String username, Scenario scenario, Date startDate, Date endDate,
            List<Label> labels, List<Criterion> criteria,
            ExternalCompany customer, OrderStatusEnum state) {
        User user;
        try {
            user = userDAO.findByLoginName(username);
        } catch (InstanceNotFoundException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

                UserRole.ROLE_READ_ALL_PROJECTS,
                UserRole.ROLE_EDIT_ALL_PROJECTS)) {
            return true;
        }
        try {
            User user = userDAO.findByLoginName(loginName);
            for (OrderAuthorization authorization : orderAuthorizationDAO
                    .listByOrderUserAndItsProfiles(order, user)) {
                if (authorization.getAuthorizationType() == OrderAuthorizationType.READ_AUTHORIZATION
                        || authorization.getAuthorizationType() == OrderAuthorizationType.WRITE_AUTHORIZATION) {
                    return true;
View Full Code Here

   }

    @Test
    @Transactional
    public void testNavigateFromOrderAuthorizationToUser() {
        User user = createValidUser();
        userDAO.save(user);
        UserOrderAuthorization userOrderAuthorization = createValidUserOrderAuthorization();
        userOrderAuthorization.setUser(user);
        orderAuthorizationDAO.save(userOrderAuthorization);
        assertEquals(user.getId(), userOrderAuthorization.getUser().getId());
    }
View Full Code Here

    public User findByLoginName(String loginName)
        throws InstanceNotFoundException {

        Criteria c = getSession().createCriteria(User.class);
        c.add(Restrictions.eq("loginName", loginName).ignoreCase());
        User user = (User) c.uniqueResult();

        if (user == null) {
            throw new InstanceNotFoundException(loginName,
                User.class.getName());
        } else {
View Full Code Here

TOP

Related Classes of org.libreplan.business.users.entities.User

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.