Package net.stinfoservices.pacifiq.server.model

Examples of net.stinfoservices.pacifiq.server.model.Profile


    @Override
    @Transactional(readOnly = false)
    public Long saveProfile(ProfileDTO dto) throws Exception {
        // not allowed profileDAO.getEntityManager().getTransaction().begin();
        Profile profile = profileDAO.find(dto.getId());
        if (profile == null) {
            profile = new Profile();
            // version 0 or 1 ? do use constant ?
            profile.setVersion(0);
        }
        applyDiffProfile(profile, dto);
        profile = profileDAO.save(profile);
        // not allowed profileDAO.getEntityManager().getTransaction().commit();
        return profile.getId();
    }
View Full Code Here


            if ((user.getProgramsWithConsultationRights() != null) && !user.getProgramsWithConsultationRights().isEmpty()) {
                authorities.add(new SimpleGrantedAuthority(ProfileHelper.SPECIFIC_PROGRAMS_CONSULTATION));
            }

            try {
                final Profile profile = profileDAO.findByUzer(user);
                authorities.addAll(ProfileHelper.getAuthorities(profile));
            } catch (EmptyResultDataAccessException noRes) {
                return authorities;
            }
            return authorities;
View Full Code Here

    @Test
    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFind() throws Exception {
        Profile profile = profileDAO.find(1L);
        Profile profilec = new Profile();

        profilec.setId(1L);
        profilec.setAdministrator(true);
        profilec.setLicensesConsultation(true);
        profilec.setLicensesEdition(true);
        profilec.setProgramsConsultation(true);
        profilec.setProgramsEdition(true);
        profilec.setName(ADMINISTRATOR_PROFILE_NAME);
        profilec.setVersion(2);
        assertNotNull(profile);
        assertEquals(ADMINISTRATOR_PROFILE_NAME, profile.getName());
        assertTrue(profile.getAdministrator());
        assertTrue(profile.getLicensesConsultation());
        assertTrue(profile.getLicensesEdition());
View Full Code Here

    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFindAll() throws Exception {
        List<Profile> profiles = profileDAO.findAll();
        Profile profilec = new Profile();
        Profile profile;

        profilec.setId(1L);
        profilec.setAdministrator(true);
        profilec.setLicensesConsultation(true);
        profilec.setLicensesEdition(true);
View Full Code Here

    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFindEntries() throws Exception {
        List<Profile> profiles = profileDAO.findEntries(0, 1);
        Profile profile = profiles.get(0);
        Profile profilec = new Profile();

        profilec.setId(1L);
        profilec.setAdministrator(true);
        profilec.setLicensesConsultation(true);
        profilec.setLicensesEdition(true);
        profilec.setProgramsConsultation(true);
        profilec.setProgramsEdition(true);
        profilec.setName(ADMINISTRATOR_PROFILE_NAME);
        profilec.setVersion(2);
        assertSame(1, profiles.size());
        assertNotNull(profile);
        assertEquals(profile, profilec);
        profiles = profileDAO.findEntries(0, 0);
        assertSame(0, profiles.size());
View Full Code Here

    public void testSave() throws Exception {
        try {
            DatabaseConnection connection = new DatabaseConnection(dataSource.getConnection());
            IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(this.getClass().getResource("/dbunit/dao/admin/profile-create_no-id.xml")
                    .openStream());
            Profile profile = new Profile();
            Profile nprofile;

            profile.setAdministrator(false);
            profile.setLicensesConsultation(false);
            profile.setLicensesEdition(false);
            profile.setProgramsConsultation(false);
            profile.setProgramsEdition(false);
            profile.setName(DEFAULT_PROFILE_NAME);
            profile.setVersion(1);
            nprofile = profileDAO.save(profile);
            assertNotNull(nprofile);
            assertEquals(nprofile.getName(), profile.getName());
            assertEquals(nprofile.getAdministrator(), profile.getAdministrator());
            assertEquals(nprofile.getLicensesConsultation(), profile.getLicensesConsultation());
            assertEquals(nprofile.getLicensesEdition(), profile.getLicensesEdition());
            assertEquals(nprofile.getProgramsConsultation(), profile.getProgramsConsultation());
            assertEquals(nprofile.getProgramsEdition(), profile.getProgramsEdition());
            entityManager.getTransaction().commit();
            DatabaseAssertionMode.NON_STRICT.getDatabaseAssertion().assertEquals(expectedDataSet,
                    connection.createDataSet(expectedDataSet.getTableNames()));
            connection.close();
        } catch (DatabaseUnitException e) {
View Full Code Here

    public void testSave2() throws Exception {
        try {
            DatabaseConnection connection = new DatabaseConnection(dataSource.getConnection());
            IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(this.getClass()
                    .getResource("/dbunit/dao/admin/profile-update_aftersave.xml").openStream());
            Profile profile = new Profile();
            Profile nprofile;

            profile.setId(1L);
            profile.setAdministrator(true);
            profile.setLicensesConsultation(true);
            profile.setLicensesEdition(true);
            profile.setProgramsConsultation(true);
            profile.setProgramsEdition(true);
            profile.setName(ADMINISTRATOR_PROFILE_NAME);
            profile.setVersion(1);
            nprofile = profileDAO.save(profile);
            assertNotNull(nprofile);
            assertEquals(nprofile.getName(), profile.getName());
            assertEquals(nprofile.getAdministrator(), profile.getAdministrator());
            assertEquals(nprofile.getLicensesConsultation(), profile.getLicensesConsultation());
            assertEquals(nprofile.getLicensesEdition(), profile.getLicensesEdition());
            assertEquals(nprofile.getProgramsConsultation(), profile.getProgramsConsultation());
            assertEquals(nprofile.getProgramsEdition(), profile.getProgramsEdition());
            entityManager.getTransaction().commit();
            DatabaseAssertionMode.NON_STRICT.getDatabaseAssertion().assertEquals(expectedDataSet,
                    connection.createDataSet(expectedDataSet.getTableNames()));
            connection.close();
        } catch (DatabaseUnitException e) {
View Full Code Here

    @DatabaseSetup(value = CREATE_DATASET)
    @ExpectedDatabase(value = EMPTY_DATASET, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = EMPTY_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testRemove() throws Exception {
        Profile profile = new Profile();

        profile.setId(1L);
        profile.setAdministrator(false);
        profile.setLicensesConsultation(false);
        profile.setLicensesEdition(false);
        profile.setProgramsConsultation(false);
        profile.setProgramsEdition(false);
        profile.setName(DEFAULT_PROFILE_NAME);
        profile.setVersion(1);
        profileDAO.remove(profile);
    }
View Full Code Here

    @Test
    @DatabaseSetup(value = UPDATE_DATASET)
    @ExpectedDatabase(value = EMPTY_DATASET, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = EMPTY_DATASET, type = DatabaseOperation.DELETE)
    public void testRemove2() throws Exception {
        Profile profile = new Profile();

        profile.setId(1L);
        profile.setAdministrator(true);
        profile.setLicensesConsultation(true);
        profile.setLicensesEdition(true);
        profile.setProgramsConsultation(true);
        profile.setProgramsEdition(true);
        profile.setName(ADMINISTRATOR_PROFILE_NAME);
        profile.setVersion(2);
        profileDAO.remove(profile);
    }
View Full Code Here

        if (profile == null) {
            return (null);
        }

        try {
            Profile p = entityManager.merge(profile);

            entityManager.persist(p);
            p = entityManager.find(Profile.class, p.getId());
            LOGGER.info(MessageFormat.format(ResourceBundle.getBundle("system").getString("OBJECT_SAVED"), this.getClass().getSimpleName(),
                    p.getId()));

            return (p);
        } catch (Exception ex) {
            throw new CustomException(ex);
        }
View Full Code Here

TOP

Related Classes of net.stinfoservices.pacifiq.server.model.Profile

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.