Package org.apache.rave.portal.model

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


        expect(addressConverter.convert(isA(AddressImpl.class))).andReturn(new JpaAddress());
        replay(addressConverter);

        ModelConverter pageLayoutConverter = createMock(ModelConverter.class);
        expect(pageLayoutConverter.getSourceType()).andReturn(Address.class).anyTimes();
        expect(pageLayoutConverter.convert(isA(PageLayout.class))).andReturn(new JpaPageLayout());
        replay(pageLayoutConverter);

        List<ModelConverter> converters = new ArrayList<ModelConverter>();
        converters.add(personConverter);
        converters.add(addressConverter);
View Full Code Here


        assertEquals(repository.getType(), JpaPageLayout.class);
    }

    @Test
    public void get() {
        JpaPageLayout p = (JpaPageLayout) repository.get(VALID_ID.toString());
        assertThat(p.getEntityId(), is(VALID_ID));
        assertThat(p.getCode(), is(VALID_LAYOUT_CODE));
    }
View Full Code Here

        }
    }

    @Test
    public void getByPageLayoutCode() {
        JpaPageLayout pageLayout = (JpaPageLayout)repository.getByPageLayoutCode(VALID_LAYOUT_CODE);
        assertThat(pageLayout.getCode(), is(VALID_LAYOUT_CODE));
        assertThat(pageLayout.getNumberOfRegions(), is(2L));
        assertThat(pageLayout.getEntityId(), is(notNullValue(Long.class)));
    }
View Full Code Here

        final Long newNumRegions = 3L;
        final String newCode = "new_code";
        final Long newRenderSeq = 22L;
        final boolean newUserSelectable = true;

        JpaPageLayout pageLayout = new JpaPageLayout();
        pageLayout.setNumberOfRegions(newNumRegions);
        pageLayout.setCode(newCode);
        pageLayout.setRenderSequence(newRenderSeq);
        pageLayout.setUserSelectable(newUserSelectable);

        assertThat(pageLayout.getEntityId(), is(nullValue()));
        repository.save(pageLayout);
        Long newId = pageLayout.getEntityId();
        assertThat(newId > 0, is(true));
        PageLayout newLayout = repository.get(newId.toString());
        assertThat(newLayout.getCode(), is(newCode));
        assertThat(newLayout.getRenderSequence(), is(newRenderSeq));
        assertThat(newLayout.getNumberOfRegions(), is(newNumRegions));
View Full Code Here

    public JpaPageLayout convert(PageLayout source) {
        return source instanceof JpaPageLayout ? (JpaPageLayout) source : createEntity(source);
    }

    private JpaPageLayout createEntity(PageLayout source) {
        JpaPageLayout converted = null;
        if (source != null) {
            TypedQuery<JpaPageLayout> query = manager.createNamedQuery(JpaPageLayout.PAGELAYOUT_GET_BY_LAYOUT_CODE, JpaPageLayout.class);
            query.setParameter(JpaPageLayout.CODE_PARAM, source.getCode());
            converted = getSingleResult(query.getResultList());

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

        return manager.find(JpaPageLayout.class, Long.parseLong(id));
    }

    @Override
    public PageLayout save(PageLayout item) {
        JpaPageLayout layout = converter.convert(item);
        return saveOrUpdate(layout.getEntityId(), manager, layout);
    }
View Full Code Here

        return manager.find(JpaPageLayout.class, id);
    }

    @Override
    public PageLayout save(PageLayout item) {
        JpaPageLayout layout = converter.convert(item);
        return saveOrUpdate(layout.getEntityId(), manager, layout);
    }
View Full Code Here

        assertEquals(repository.getType(), JpaPageLayout.class);
    }

    @Test
    public void get() {
        JpaPageLayout p = (JpaPageLayout) repository.get(VALID_ID);
        assertThat(p.getEntityId(), is(VALID_ID));
        assertThat(p.getCode(), is(VALID_LAYOUT_CODE));
    }
View Full Code Here

        }
    }

    @Test
    public void getByPageLayoutCode() {
        JpaPageLayout pageLayout = (JpaPageLayout)repository.getByPageLayoutCode(VALID_LAYOUT_CODE);
        assertThat(pageLayout.getCode(), is(VALID_LAYOUT_CODE));
        assertThat(pageLayout.getNumberOfRegions(), is(2L));
        assertThat(pageLayout.getEntityId(), is(notNullValue(Long.class)));
    }
View Full Code Here

        final Long newNumRegions = 3L;
        final String newCode = "new_code";
        final Long newRenderSeq = 22L;
        final boolean newUserSelectable = true;

        JpaPageLayout pageLayout = new JpaPageLayout();
        pageLayout.setNumberOfRegions(newNumRegions);
        pageLayout.setCode(newCode);
        pageLayout.setRenderSequence(newRenderSeq);
        pageLayout.setUserSelectable(newUserSelectable);

        assertThat(pageLayout.getEntityId(), is(nullValue()));
        repository.save(pageLayout);
        long newId = pageLayout.getEntityId();
        assertThat(newId > 0, is(true));
        PageLayout newLayout = repository.get(newId);
        assertThat(newLayout.getCode(), is(newCode));
        assertThat(newLayout.getRenderSequence(), is(newRenderSeq));
        assertThat(newLayout.getNumberOfRegions(), is(newNumRegions));
View Full Code Here

TOP

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

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.