Package org.apache.rave.portal.model

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


    }

    @Test
    public void renderOpenSocial() {
        Page page = new Page(1L, new User(VALID_USER_ID, VALID_USER_NAME));
        Region region = new Region(1L, page, 1);
        page.setRegions(Arrays.asList(region));

        Widget w = new Widget();
        w.setType("OpenSocial");
        w.setEntityId(1L);
        w.setTitle("Gadget Title");
        w.setUrl("http://www.example.com/gadget.xml");

        RegionWidget rw = new RegionWidget(1L, w, region);
        region.setRegionWidgets(Arrays.asList(rw));

        RenderContext context = new RenderContext();
        context.setProperties(new HashMap());
        String rendered = service.render(rw, context);
        assertThat(rendered, is(notNullValue()));
View Full Code Here


    }

    // returns a trusted Region object, either from the RegionRepository, or the
    // cached container list
    private Region getTrustedRegion(long regionId, List<Region> trustedRegionContainer) {
        Region region = null;
        if (trustedRegionContainer.isEmpty()) {
            region = regionRepository.get(regionId);
            trustedRegionContainer.add(region);
        } else {
            region = trustedRegionContainer.get(0);
View Full Code Here

    // checks to see if the Authentication object principal is the owner of the supplied region object
    // if trustedDomainObject is false, pull the entity from the database first to ensure
    // the model object is trusted and hasn't been modified
    private boolean isRegionOwner(Authentication authentication, Region region, List<Region> trustedRegionContainer, boolean trustedDomainObject) {
        Region trustedRegion = null;
        if (trustedDomainObject) {
            trustedRegion = region;
        } else {
            trustedRegion = getTrustedRegion(region.getEntityId(), trustedRegionContainer);
        }
        return isRegionOwnerByUsername(authentication, trustedRegion.getPage().getOwner().getUsername());
    }
View Full Code Here

        Widget w = new Widget();
        w.setEntityId(1L);
        w.setType(Constants.WIDGET_TYPE);
        w.setUrl(VALID_GADGET_URL);
        Region region = new Region(1L);
        RegionWidget rw = new RegionWidget();
        rw.setEntityId(1L);
        rw.setCollapsed(VALID_COLLAPSED);
        rw.setWidget(w);
        rw.setRegion(region);
View Full Code Here

    @Test
    public void render_null() {
        Widget w = new Widget();
        w.setType(Constants.WIDGET_TYPE);
        Region region = new Region(1L);
        RegionWidget rw = new RegionWidget();
        rw.setWidget(w);
        rw.setRegion(region);

        final String markup =
View Full Code Here

    }

    @Test
    public void deleteWidget_validParams() {
        final long WIDGET_ID = 3;
        expect(pageService.removeWidgetFromPage(WIDGET_ID)).andReturn(new Region());
        replay(pageService);

        RpcResult<Region> result = pageApi.removeWidgetFromPage(WIDGET_ID);
        verify(pageService);
        assertThat(result, is(notNullValue()));
View Full Code Here

    }   
   
    @Override
    @Transactional
    public RegionWidget moveRegionWidget(long regionWidgetId, int newPosition, long toRegion, long fromRegion) {
        Region target = getFromRepository(toRegion, regionRepository);
        if (toRegion == fromRegion) {
            moveWithinRegion(regionWidgetId, newPosition, target);
        } else {
            moveBetweenRegions(regionWidgetId, newPosition, fromRegion, target);
        }
        target = regionRepository.save(target);
        return findRegionWidgetById(regionWidgetId, target.getRegionWidgets());
    }
View Full Code Here

    @Override
    @Transactional
    public RegionWidget addWidgetToPage(long pageId, long widgetId) {
        Page page = getFromRepository(pageId, pageRepository);
        Widget widget = getFromRepository(widgetId, widgetRepository);
        Region region = page.getRegions().get(0);
        return createWidgetInstance(widget, region, 0);
    }
View Full Code Here

        List<Region> regions = page.getRegions();
        int lastRegionRenderOrder = regions.get(regions.size()-1).getRenderOrder() + 1;

        //add as many missing regions as the new layout requires
        for (int i=0; i < numberOfNewRegionsToAdd; i++) {
            Region newRegion = new Region();
            newRegion.setPage(page);
            newRegion.setRenderOrder(lastRegionRenderOrder++);
            regions.add(newRegion);
        }
    }
View Full Code Here

     * @param page the Page to remove Regions from
     * @param newLayout the new PageLayout which will be applied to the Page
     */
    private void reduceRegionsForPage(Page page, long numberOfRegionsInNewLayout) {
        List<Region> regions = page.getRegions();
        Region lastValidRegion = regions.get((int) (numberOfRegionsInNewLayout-1));
       
        //remove all of the extra regions for this new layout and append the widgets
        while (regions.size() > numberOfRegionsInNewLayout) {
            Region deletedRegion = regions.remove(regions.size()-1);

            //append the regions widgets to to last valid region in the new layout
            for (RegionWidget widget : deletedRegion.getRegionWidgets()) {
                moveRegionWidgetToNewRegion(widget, lastValidRegion);
            }
            regionRepository.delete(deletedRegion);
        }
        regionRepository.save(lastValidRegion);
View Full Code Here

TOP

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

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.