Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.JpaGroup


        group.setMemberIds(members);
    }

    @Test
    public void testNoConversion() {
        JpaGroup group = new JpaGroup();
        assertThat(converter.convert(group), is(sameInstance(group)));
    }
View Full Code Here


        assertThat(converter.convert(category), is(nullValue()));
    }

    @Test
    public void testConvertGroupToJpaGroup() {
        JpaGroup jpaGroup = converter.convert(group);

        assertThat(jpaGroup, is(not(sameInstance(group))));
        assertThat(jpaGroup, is(instanceOf(JpaGroup.class)));
        assertEquals(description, jpaGroup.getDescription());
        assertEquals(title, jpaGroup.getTitle());
        assertEquals(ownerId, jpaGroup.getOwnerId());
        assertEquals(members.size(), jpaGroup.getMemberIds().size());
    }
View Full Code Here

    public JpaGroup convert(Group source) {
        return source instanceof JpaGroup ? (JpaGroup) source : createEntity(source);
    }

    private JpaGroup createEntity(Group source) {
        JpaGroup converted = null;
        if (source != null) {
            TypedQuery<JpaGroup> query = manager.createNamedQuery(JpaGroup.FIND_BY_TITLE, JpaGroup.class);
            query.setParameter(JpaGroup.GROUP_TITLE_PARAM, source.getTitle());
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaGroup();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

        return CollectionUtils.<Group>toBaseTypedList(query.getResultList());
    }

    @Override
    public Group save(Group item) {
        JpaGroup converted = converter.convert(item);
        return saveOrUpdate(converted.getEntityId(), manager, converted);
    }
View Full Code Here

        assertEquals(2, list.size());
    }

    @Test
    public void createGroup() {
        JpaGroup newGroup = new JpaGroup();
        newGroup.setTitle("TEST GROUP");
        newGroup.setDescription("TEST GROUP");
        newGroup.setOwnerId("1");
        newGroup.setMemberIds(Arrays.asList(new String[] {"1", "5"}));

        Group savedGroup = repository.save(newGroup);

        assertThat(savedGroup.getId(), notNullValue());
        assertThat(savedGroup.getTitle(), equalTo("TEST GROUP"));
View Full Code Here

        assertThat(savedGroup.getMemberIds().size(), equalTo(2));
    }

    @Test
    public void deleteGroup() {
        JpaGroup newGroup = new JpaGroup();
        newGroup.setTitle("TEST GROUP");
        newGroup.setDescription("TEST GROUP");
        newGroup.setOwnerId("1");
        newGroup.setMemberIds(Arrays.asList(new String[] {"1", "5"}));

        Group savedGroup = repository.save(newGroup);

        String id = savedGroup.getId();
View Full Code Here

    public JpaGroup convert(Group source) {
        return source instanceof JpaGroup ? (JpaGroup) source : createEntity(source);
    }

    private JpaGroup createEntity(Group source) {
        JpaGroup converted = null;
        if (source != null) {
            TypedQuery<JpaGroup> query = manager.createNamedQuery(JpaGroup.FIND_BY_TITLE, JpaGroup.class);
            query.setParameter(JpaGroup.GROUP_ID_PARAM, source.getTitle());
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaGroup();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

    @Override
    public List<Person> findByGroup(String groupId) {
        TypedQuery<JpaGroup> query = manager.createNamedQuery(JpaGroup.FIND_BY_TITLE, JpaGroup.class);
        query.setParameter(JpaGroup.GROUP_ID_PARAM, groupId);
        JpaGroup result = getSingleResult(query.getResultList());
        return result == null ? new ArrayList<Person>() : CollectionUtils.<Person>toBaseTypedList(result.getMembers());
    }
View Full Code Here

    @Override
    public List<Person> findByGroup(String groupId) {
        TypedQuery<JpaGroup> query = manager.createNamedQuery(JpaGroup.FIND_BY_TITLE, JpaGroup.class);
        query.setParameter(JpaGroup.GROUP_ID_PARAM, groupId);
        JpaGroup result = getSingleResult(query.getResultList());
        return result == null ? new ArrayList<Person>() : CollectionUtils.<Person>toBaseTypedList(result.getMembers());
    }
View Full Code Here

        group.setMembers(members);
    }

    @Test
    public void testNoConversion() {
        JpaGroup group = new JpaGroup();
        assertThat(converter.convert(group), is(sameInstance(group)));
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.JpaGroup

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.