/** * Utility function to determine if a Page layout adjustment is needed * which comparing the existing and new PageLayout objects * * @param newLayout the new PageLayout to be applied to the Page * @param curLayout the existing PageLayout of the Page * @return true if the Page Regions need to be adjusted up or down */ private boolean isLayoutAdjustmentNeeded(PageLayout newLayout, PageLayout curLayout) { return newLayout != null && !curLayout.equals(newLayout) && !curLayout.getNumberOfRegions().equals(newLayout.getNumberOfRegions()); }
public PageLayout(org.apache.rave.model.PageLayout source) { this.code = source.getCode(); this.numberOfRegions = source.getNumberOfRegions(); this.renderSequence = source.getRenderSequence(); this.userSelectable = source.isUserSelectable(); }
@Override @Transactional public Page updatePage(String pageId, String name, String pageLayoutCode, Map<String, Object> properties) { Page page = pageRepository.get(pageId); PageLayout newLayout = pageLayoutRepository.getByPageLayoutCode(pageLayoutCode); PageLayout curLayout = page.getPageLayout(); //if the region lengths of the layouts do not match then adjust the new layout if (isLayoutAdjustmentNeeded(newLayout, curLayout)) { //if the new layout has fewer regions than the previous layout the widgets from the //deleted regions need to be appended to the last valid region in the new layout if (curLayout.getNumberOfRegions() > newLayout.getNumberOfRegions()) { reduceRegionsForPage(page, newLayout.getNumberOfRegions()); } //otherwise the new layout has more regions that the previous layout and //new regions need to be added to the page else { long numberOfNewRegionsToAdd = newLayout.getNumberOfRegions() - curLayout.getNumberOfRegions(); createAdditionalRegionsForPage(page, numberOfNewRegionsToAdd); } } //save the new page properties page.setName(name); page.setPageLayout(newLayout); //Forces callers to send an empty map rather than a null value to clear properties if(properties != null) { page.setProperties(properties); } return pageRepository.save(page); }
private void updateProperties(PageLayout source, JpaPageLayout converted) { converted.setCode(source.getCode()); converted.setNumberOfRegions(source.getNumberOfRegions()); converted.setRenderSequence(source.getRenderSequence()); converted.setUserSelectable(source.isUserSelectable()); } }
List<Page> parentsSubPages = new ArrayList<Page>(); int regionCount; for (regionCount = 0; regionCount < pageLayout.getNumberOfRegions(); regionCount++) { Region region = new RegionImpl(); region.setRenderOrder(regionCount);
for (regionCount = 0; regionCount < pageLayout.getNumberOfRegions(); regionCount++) { Region region = new RegionImpl(); region.setRenderOrder(regionCount);