Package org.apache.rave.portal.model

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


    }

    @Test
    @Rollback(true)
    public void save_newEntity() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(sameInstance(regionWidget)));
        assertThat(saved.getId(), is(notNullValue()));
View Full Code Here


    }

    @Test
    @Rollback(true)
    public void save_existingEntity() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setId(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(not(sameInstance(regionWidget))));
        assertThat(saved.getId(), is(equalTo(regionWidget.getId())));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        RegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(null, null, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();

        assertThat(saved.getPreferences().size(), is(equalTo(1)));
View Full Code Here

    @Test
    @Rollback(true)
    public void save_cascadeMerge() {
        long VALID_PREFERENCE_ID = addPreferenceToRegionWidget(VALID_REGION_WIDGET_ID);

        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setId(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        JpaRegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(VALID_PREFERENCE_ID,
                VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME, VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();

        assertThat(saved.getPreferences().size(), is(equalTo(1)));
View Full Code Here

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

    @Override
    public RegionWidget save(RegionWidget item) {
        JpaRegionWidget region = regionWidgetConverter.convert(item);
        return saveOrUpdate(region.getEntityId(), manager, region);
    }
View Full Code Here

    public JpaRegionWidget convert(RegionWidget source) {
        return source instanceof JpaRegionWidget ? (JpaRegionWidget) source : createEntity(source);
    }

    private JpaRegionWidget createEntity(RegionWidget source) {
        JpaRegionWidget converted = null;
        if (source != null) {
            TypedQuery<JpaRegionWidget> query = manager.createNamedQuery(JpaRegionWidget.FIND_BY_ID, JpaRegionWidget.class);
            query.setParameter(JpaRegionWidget.PARAM_WIDGET_ID, source.getId());
            converted = getSingleResult(query.getResultList());

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

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        JpaRegion region = new JpaRegion();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget();
        region.getRegionWidgets().add(regionWidget);

        JpaRegion saved = (JpaRegion)repository.save(region);
        manager.flush();
View Full Code Here

    public void save_cascadeMerge() {

        JpaRegion region = new JpaRegion();
        region.setEntityId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setId(1L);
        region.getRegionWidgets().add(regionWidget);

        Region saved = repository.save(region);
        manager.flush();
View Full Code Here

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        JpaRegion region = new JpaRegion();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget();
        region.getRegionWidgets().add(regionWidget);

        JpaRegion saved = (JpaRegion)repository.save(region);
        manager.flush();
View Full Code Here

    public void save_cascadeMerge() {

        JpaRegion region = new JpaRegion(1L);
        region.setEntityId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget(1L);
        region.getRegionWidgets().add(regionWidget);

        System.out.println(region.toString());

        Region saved = repository.save(region);
View Full Code Here

TOP

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

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.