Package org.apache.rave.portal.model

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


        return RegionImpl.class;
    }

    @Override
    public Region get(String  id) {
        Page page = getPageByRegionId(id);
        for(Region region : page.getRegions()) {
            if(region.getId().equals(id)) {
                return region;
            }
        }
        return null;
View Full Code Here


        return null;
    }

    @Override
    public Region save(Region item) {
        Page page;
        int index;

        if(item.getId() == null) {
            page = getPageFromRepository(item);
            page.getRegions().add(item);
            index = page.getRegions().size()-1;
        } else {
            page = getPageByRegionId(item.getId());
            index = replaceRegion(page, item);
        }
        Page saved = template.save(page);
        return saved.getRegions().get(index);
    }
View Full Code Here

        return saved.getRegions().get(index);
    }

    @Override
    public void delete(Region item) {
        Page page;

        if(item.getId() == null) {
            throw new IllegalStateException("Unidentifiable region (null id)");
        } else {
            page = getPageByRegionId(item.getId());
View Full Code Here

        return RegionWidgetImpl.class;
    }

    @Override
    public RegionWidget get(String id) {
        Page page = getPageByRegionWidgetId(id);
        return getRegionWidgetById(page, id);
    }
View Full Code Here

        return item.getId() == null ? addNewRegionWidget(item) : updateRegionWidget(item);
    }

    @Override
    public void delete(RegionWidget item) {
        Page page = getPageByRegionWidgetId(item.getId());
        replaceOrRemoveWidget(page, item, false);
        template.save(page);
    }
View Full Code Here

        template.save(page);
    }

    private RegionWidget updateRegionWidget(RegionWidget item) {
        RegionWidget savedWidget;
        Page page = getPageByRegionWidgetId(item.getId());
        replaceOrRemoveWidget(page, item, true);
        Page saved = template.save(page);
        savedWidget = getRegionWidgetById(saved, item.getId());
        return savedWidget;
    }
View Full Code Here

        savedWidget = getRegionWidgetById(saved, item.getId());
        return savedWidget;
    }

    private RegionWidget addNewRegionWidget(RegionWidget item) {
        Page page = getPageFromRepository(item);
        Region parent = getRegionById(item.getRegion().getId(), page.getRegions());
        if(parent == null) throw new IllegalStateException("Unable to find parent for page");
        parent.getRegionWidgets().add(item);
        Page saved = template.save(page);
        return getRegionById(parent.getId(), saved.getRegions()).getRegionWidgets().get(parent.getRegionWidgets().size() -1);
    }
View Full Code Here

    }

    @Test
    public void get(){
        String id = "1111L";
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region region = new RegionImpl(id);
        regions.add(region);
        page.setRegions(regions);

        expect( template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is(id))))).andReturn(page);
        replay(template);

        Region result = repo.get(id);
View Full Code Here

    }

    @Test
    public void get_null(){
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region region = new RegionImpl("1111L");
        regions.add(region);
        page.setRegions(regions);

        expect(template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is("2222L"))))).andReturn(page);
        replay(template);

        Region result = repo.get("2222L");
View Full Code Here

    }

    @Test
    public void save(){
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region item = new RegionImpl("1111L");
        regions.add(item);
        page.setRegions(regions);

        expect(template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is("1111L"))))).andReturn(page);
        expect(template.save(isA(Page.class))).andReturn(page);
        replay(template);
View Full Code Here

TOP

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

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.