rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlu...@apache.org
Subject svn commit: r1215251 - in /incubator/rave/trunk: rave-components/rave-core/src/main/java/org/apache/rave/portal/model/ rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/ rave-components/rave-core/src/main/java/org/apache/rave/po...
Date Fri, 16 Dec 2011 19:48:39 GMT
Author: carlucci
Date: Fri Dec 16 19:48:38 2011
New Revision: 1215251

URL: http://svn.apache.org/viewvc?rev=1215251&view=rev
Log:
RAVE-390: pull and render the list of available page layouts from the database instead of hardcoding the list in the jsp.  Subtask code in support of RAVE-97: support dynamic layouts

Added:
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepositoryTest.java
      - copied, changed from r1214390, incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageRepositoryTest.java
    incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageLayoutServiceTest.java
      - copied, changed from r1214390, incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageServiceTest.java
Modified:
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PageLayout.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
    incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql
    incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp
    incubator/rave/trunk/rave-portal/src/test/resources/test-data.sql

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PageLayout.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PageLayout.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PageLayout.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PageLayout.java Fri Dec 16 19:48:38 2011
@@ -39,12 +39,17 @@ import java.io.Serializable;
 @Entity
 @Table(name="page_layout")
 @NamedQueries({
-    @NamedQuery(name="PageLayout.getByLayoutCode", query = "select pl from PageLayout pl where pl.code = :code")
+    @NamedQuery(name=PageLayout.PAGELAYOUT_GET_BY_LAYOUT_CODE, query = "select pl from PageLayout pl where pl.code = :code"),
+    @NamedQuery(name=PageLayout.PAGELAYOUT_GET_ALL, query="select pl from PageLayout pl order by pl.renderSequence")
 })
 
 public class PageLayout implements BasicEntity, Serializable {
     private static final long serialVersionUID = 1L;
 
+    // static string identifiers for JPA queries
+    public static final String PAGELAYOUT_GET_BY_LAYOUT_CODE = "PageLayout.getByLayoutCode";
+    public static final String PAGELAYOUT_GET_ALL = "PageLayout.getAll";
+    
     @Id @Column(name="entity_id")
     @GeneratedValue(strategy = GenerationType.TABLE, generator = "pageLayoutIdGenerator")
     @TableGenerator(name = "pageLayoutIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName = "SEQ_NAME",
@@ -57,6 +62,9 @@ public class PageLayout implements Basic
     @Basic @Column(name="number_of_regions")
     private Long numberOfRegions;
 
+    @Basic(optional=false) @Column(name="render_sequence")
+    private Long renderSequence;
+
     /**
      * Gets the persistence unique identifier
      *
@@ -98,6 +106,14 @@ public class PageLayout implements Basic
         this.numberOfRegions = numberOfRegions;
     }
 
+    public Long getRenderSequence() {
+        return renderSequence;
+    }
+
+    public void setRenderSequence(Long renderSequence) {
+        this.renderSequence = renderSequence;
+    }
+
     @Override
     public boolean equals(Object obj) {
         if (obj == null) {

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageLayoutRepository.java Fri Dec 16 19:48:38 2011
@@ -21,6 +21,9 @@ package org.apache.rave.portal.repositor
 import org.apache.rave.persistence.Repository;
 import org.apache.rave.portal.model.PageLayout;
 
+import java.util.List;
+
 public interface PageLayoutRepository extends Repository<PageLayout> {
-	 PageLayout getByPageLayoutCode(String codename);
+    PageLayout getByPageLayoutCode(String codename);
+    List<PageLayout> getAll();
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepository.java Fri Dec 16 19:48:38 2011
@@ -26,6 +26,8 @@ import org.springframework.stereotype.Re
 
 import javax.persistence.TypedQuery;
 
+import java.util.List;
+
 import static org.apache.rave.persistence.jpa.util.JpaUtil.getSingleResult;
 
 
@@ -40,9 +42,14 @@ public class JpaPageLayoutRepository ext
 
 	 @Override
 	 public PageLayout getByPageLayoutCode(String codename){
-		  TypedQuery<PageLayout>query = manager.createNamedQuery("PageLayout.getByLayoutCode",PageLayout.class);
+		  TypedQuery<PageLayout>query = manager.createNamedQuery(PageLayout.PAGELAYOUT_GET_BY_LAYOUT_CODE,PageLayout.class);
 		  query.setParameter("code",codename);
 		  return getSingleResult(query.getResultList());
 	 }
 
+    @Override
+    public List<PageLayout> getAll() {
+        return manager.createNamedQuery(PageLayout.PAGELAYOUT_GET_ALL, PageLayout.class).getResultList();
+    }
+
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PageLayoutService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PageLayoutService.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PageLayoutService.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/PageLayoutService.java Fri Dec 16 19:48:38 2011
@@ -20,6 +20,9 @@ package org.apache.rave.portal.service;
 
 import org.apache.rave.portal.model.PageLayout;
 
+import java.util.List;
+
 public interface PageLayoutService {
-	 public PageLayout getPageLayoutByCode(String code);
+	PageLayout getPageLayoutByCode(String code);
+    List<PageLayout> getAll();
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultPageLayoutService.java Fri Dec 16 19:48:38 2011
@@ -25,18 +25,25 @@ import org.apache.rave.portal.service.Pa
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class DefaultPageLayoutService implements PageLayoutService {
-	 private final PageLayoutRepository pageLayoutRepository;
+    private final PageLayoutRepository pageLayoutRepository;
+
+    @Autowired
+    public DefaultPageLayoutService(PageLayoutRepository pageLayoutRepository) {
+        this.pageLayoutRepository = pageLayoutRepository;
+    }
+
+    @Override
+    public PageLayout getPageLayoutByCode(String code) {
+        return pageLayoutRepository.getByPageLayoutCode(code);
+    }
 
-	 @Autowired
-	 public DefaultPageLayoutService(PageLayoutRepository pageLayoutRepository) {
-		  this.pageLayoutRepository=pageLayoutRepository;
-	 }
-
-	 @Override
-	 public PageLayout getPageLayoutByCode(String code) {
-		  return pageLayoutRepository.getByPageLayoutCode(code);
-	 }
+    @Override
+    public List<PageLayout> getAll() {
+        return pageLayoutRepository.getAll();
+    }
 }
 

Copied: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepositoryTest.java (from r1214390, incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageRepositoryTest.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepositoryTest.java?p2=incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepositoryTest.java&p1=incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageRepositoryTest.java&r1=1214390&r2=1215251&rev=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/repository/impl/JpaPageLayoutRepositoryTest.java Fri Dec 16 19:48:38 2011
@@ -18,7 +18,8 @@
  */
 package org.apache.rave.portal.repository.impl;
 
-import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.PageLayout;
+import org.apache.rave.portal.repository.PageLayoutRepository;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,68 +31,47 @@ import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import java.util.List;
 
-import org.apache.rave.portal.repository.PageRepository;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 @Transactional
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:test-dataContext.xml", "classpath:test-applicationContext.xml"})
-public class JpaPageRepositoryTest {
+public class JpaPageLayoutRepositoryTest {
 
-    private static final Long USER_ID = 1L;
-    private static final Long INVALID_USER = -1L;
-    private static final String WIDGET_URL = "http://www.widget-dico.com/wikipedia/google/wikipedia.xml";
+    private static final String VALID_LAYOUT_CODE = "columns_2";
+    private static final String INVALID_LAYOUT_CODE = "invalid_layout";
 
     @PersistenceContext
     private EntityManager manager;
 
     @Autowired
-    private PageRepository repository;
+    private PageLayoutRepository repository;        
 
     @Test
-    public void getAllPages_validUser_validPageSet() {
-        List<Page> pages = repository.getAllPages(USER_ID);
-        assertThat(pages, is(notNullValue()));
-        assertThat(pages.size(), equalTo(2));
-        assertThat(pages.get(0).getRegions().size(), equalTo(2));
-        assertThat(pages.get(0).getRegions().get(0).getRegionWidgets().size(), equalTo(2));
-        assertThat(pages.get(0).getRegions().get(0).getRegionWidgets().get(0).getWidget().getUrl(), equalTo(WIDGET_URL));
+    public void getAll() {
+        List<PageLayout> pageLayouts = repository.getAll();
+        assertThat(pageLayouts.isEmpty(), is(false));
         
         // test that the query returns the pages in proper render sequence order
         Long lastRenderSequence = -1L;
-        for (Page p : pages) {
-            Long currentRenderSequence = p.getRenderSequence();
+        for (PageLayout pl : pageLayouts) {
+            Long currentRenderSequence = pl.getRenderSequence();
             assertThat(currentRenderSequence > lastRenderSequence, is(true));
             lastRenderSequence = currentRenderSequence;
         }
     }
+    
     @Test
-    public void getAllPages_invalidUser_emptySet() {
-        List<Page> pages = repository.getAllPages(INVALID_USER);
-        assertThat(pages.isEmpty(), is(true));
-    }
-    @Test
-    public void getAllPages_nullUser_emptySet() {
-        List<Page> pages = repository.getAllPages(null);
-        assertThat(pages.isEmpty(), is(true));
-    }
-
-    @Test
-    public void getById_valid() {
-        Page p = repository.get(1L);
-        assertThat(p, is(notNullValue()));
-        assertThat(p.getEntityId(), is(equalTo(1L)));
+    public void getByPageLayoutCode() {
+        PageLayout pageLayout = repository.getByPageLayoutCode(VALID_LAYOUT_CODE);
+        assertThat(pageLayout.getCode(), is(VALID_LAYOUT_CODE));
+        assertThat(pageLayout.getNumberOfRegions(), is(2L));
+        assertThat(pageLayout.getEntityId(), is(notNullValue(Long.class)));
     }
 
     @Test
-    public void getById_invalid() {
-        Page p = repository.get(-1L);
-        assertThat(p, is(nullValue()));
-    }
-
-
+    public void getByPageLayoutCode_invalidCode() {
+        assertThat(repository.getByPageLayoutCode(INVALID_LAYOUT_CODE), is(nullValue(PageLayout.class))); 
+    }    
 }

Copied: incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageLayoutServiceTest.java (from r1214390, incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageServiceTest.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageLayoutServiceTest.java?p2=incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageLayoutServiceTest.java&p1=incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageServiceTest.java&r1=1214390&r2=1215251&rev=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageServiceTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/java/org/apache/rave/portal/service/impl/DefaultPageLayoutServiceTest.java Fri Dec 16 19:48:38 2011
@@ -19,869 +19,63 @@
 
 package org.apache.rave.portal.service.impl;
 
-import org.apache.rave.portal.model.Page;
 import org.apache.rave.portal.model.PageLayout;
-import org.apache.rave.portal.model.Region;
-import org.apache.rave.portal.model.RegionWidget;
-import org.apache.rave.portal.model.User;
-import org.apache.rave.portal.model.Widget;
 import org.apache.rave.portal.repository.PageLayoutRepository;
-import org.apache.rave.portal.repository.PageRepository;
-import org.apache.rave.portal.repository.RegionRepository;
-import org.apache.rave.portal.repository.RegionWidgetRepository;
-import org.apache.rave.portal.repository.WidgetRepository;
-import org.apache.rave.portal.service.impl.DefaultPageService;
-import org.hamcrest.CoreMatchers;
+import org.apache.rave.portal.service.PageLayoutService;
 import org.junit.Before;
 import org.junit.Test;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.rave.portal.service.PageService;
-import org.apache.rave.portal.service.UserService;
 import static org.easymock.EasyMock.*;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.junit.Assert.assertThat;
 
-public class DefaultPageServiceTest {
-    private PageService pageService;
-
-    private PageRepository pageRepository;
-    private RegionRepository regionRepository;
-    private WidgetRepository widgetRepository;
-    private RegionWidgetRepository regionWidgetRepository;
+public class DefaultPageLayoutServiceTest {
+    private PageLayoutService pageLayoutService;
     private PageLayoutRepository pageLayoutRepository;
-    private UserService userService;
-
-    private final long REGION_WIDGET_ID = 5L;
-    private final long TO_REGION_ID = 1L;
-    private final long FROM_REGION_ID = 2L;
-    private final String PAGE_LAYOUT_CODE = "layout1";
-    private final long PAGE_ID = 1L;
-    private final long INVALID_PAGE_ID = -1L;
-
-    final Long VALID_REGION_WIDGET_ID = 1L;
-    final Long INVALID_REGION_WIDGET_ID = 100L;
-            
-    private Region targetRegion;
-    private Region originalRegion;
-    private Widget validWidget;
-    private User user;
-    private PageLayout pageLayout;
-    private String defaultPageName = "Main";
-    private Page page, page2;
-    private List<Page> pageList;
+    
+    private final String VALID_LAYOUT_CODE = "columns_1";
+    private final String INVALID_LAYOUT_CODE = "qqqqqq";
+    private PageLayout validPageLayout;                        
 
     @Before
     public void setup() {
-
-        pageRepository = createMock(PageRepository.class);
-        regionRepository = createMock(RegionRepository.class);
-        widgetRepository = createMock(WidgetRepository.class);
-        regionWidgetRepository = createMock(RegionWidgetRepository.class);
-        pageLayoutRepository = createMock(PageLayoutRepository.class);
-        userService = createMock(UserService.class);
-        pageService = new DefaultPageService(pageRepository, regionRepository, widgetRepository, regionWidgetRepository, pageLayoutRepository, userService, defaultPageName);
-
-        validWidget = new Widget(1L, "http://dummy.apache.org/widgets/widget.xml");
-        
-        targetRegion = new Region();
-        targetRegion.setEntityId(2L);
-        targetRegion.setRegionWidgets(new ArrayList<RegionWidget>());
-        targetRegion.getRegionWidgets().add(new RegionWidget(1L, validWidget, targetRegion, 0));
-        targetRegion.getRegionWidgets().add(new RegionWidget(2L, validWidget, targetRegion, 1));
-        targetRegion.getRegionWidgets().add(new RegionWidget(3L, validWidget, targetRegion, 2));
-
-        originalRegion = new Region();
-        originalRegion.setEntityId(1L);
-        originalRegion.setRegionWidgets(new ArrayList<RegionWidget>());
-        originalRegion.getRegionWidgets().add(new RegionWidget(4L, validWidget, targetRegion, 0));
-        originalRegion.getRegionWidgets().add(new RegionWidget(5L, validWidget, targetRegion, 1));
-        originalRegion.getRegionWidgets().add(new RegionWidget(6L, validWidget, targetRegion, 2));
-        
-        pageLayout = new PageLayout();
-        pageLayout.setEntityId(1L);
-        pageLayout.setCode(PAGE_LAYOUT_CODE);
-        pageLayout.setNumberOfRegions(3L);
+        pageLayoutRepository = createMock(PageLayoutRepository.class);      
+        pageLayoutService = new DefaultPageLayoutService(pageLayoutRepository);
         
-        user = new User();
-        user.setEntityId(1L);
-        user.setUsername("acarlucci"); 
-        user.setDefaultPageLayout(pageLayout);                
-        
-        page = new Page(PAGE_ID, user);
-        page.setRenderSequence(1L);
-        page2 = new Page(99L, user);
-        page2.setRenderSequence(2L);
-        
-        pageList = new ArrayList<Page>();        
-        pageList.add(page2);
-        pageList.add(page);
+        validPageLayout = new PageLayout();
+        validPageLayout.setCode(VALID_LAYOUT_CODE);
     }
 
     @Test
-    public void getAllPages() {
-        final Long VALID_USER_ID = 1L;
-        final List<Page> VALID_PAGES = new ArrayList<Page>();
-
-        expect(pageRepository.getAllPages(VALID_USER_ID)).andReturn(VALID_PAGES);
-        replay(pageRepository);
+    public void getAll() {
+        final List<PageLayout> VALID_PAGE_LAYOUTS = new ArrayList<PageLayout>();
 
-        assertThat(pageService.getAllPages(VALID_USER_ID), CoreMatchers.sameInstance(VALID_PAGES));
-    }
-
-    @Test
-    public void addNewPage_noExistingPages() {
-        final String PAGE_NAME = "my new page";
-        final Long EXPECTED_RENDER_SEQUENCE = 1L;
-                      
-        Page expectedPage = new Page();
-        expectedPage.setName(PAGE_NAME);       
-        expectedPage.setOwner(user);
-        expectedPage.setPageLayout(pageLayout);
-        expectedPage.setRenderSequence(EXPECTED_RENDER_SEQUENCE);
-        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));    
-                
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
-        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(new ArrayList<Page>());
-        replay(userService);
+        expect(pageLayoutRepository.getAll()).andReturn(VALID_PAGE_LAYOUTS);
         replay(pageLayoutRepository);
-        replay(pageRepository);             
 
-        Page newPage = pageService.addNewPage(PAGE_NAME, PAGE_LAYOUT_CODE);                
-        assertThat(newPage.getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
-        assertThat(newPage.getName(), is(PAGE_NAME));
-        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
-        
-        verify(userService);
+        assertThat(pageLayoutService.getAll(), sameInstance(VALID_PAGE_LAYOUTS));
+
         verify(pageLayoutRepository);
-        verify(pageRepository);
     }
     
     @Test
-    public void addNewPage_existingPages() {
-        final String PAGE_NAME = "my new page";
-        final Long EXPECTED_RENDER_SEQUENCE = 2L;
-        List<Page> existingPages = new ArrayList<Page>();
-        existingPages.add(new Page());
-                      
-        Page expectedPage = new Page();
-        expectedPage.setName(PAGE_NAME);       
-        expectedPage.setOwner(user);
-        expectedPage.setPageLayout(pageLayout);
-        expectedPage.setRenderSequence(EXPECTED_RENDER_SEQUENCE);
-        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));    
-                
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
-        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(existingPages);
-        replay(userService);
+    public void getPageLayoutByCode() {
+        expect(pageLayoutRepository.getByPageLayoutCode(VALID_LAYOUT_CODE)).andReturn(validPageLayout);
         replay(pageLayoutRepository);
-        replay(pageRepository);             
-
-        Page newPage = pageService.addNewPage(PAGE_NAME, PAGE_LAYOUT_CODE);                
-        assertThat(newPage.getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
-        assertThat(newPage.getName(), is(PAGE_NAME));
-        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
-        
-        verify(userService);
+        assertThat(pageLayoutService.getPageLayoutByCode(VALID_LAYOUT_CODE), sameInstance(validPageLayout));
         verify(pageLayoutRepository);
-        verify(pageRepository);
-    }    
-   
-    @Test
-    public void addNewDefaultPage() {
-        final Long EXPECTED_RENDER_SEQUENCE = 1L;
-                      
-        Page expectedPage = new Page();
-        expectedPage.setName(defaultPageName);       
-        expectedPage.setOwner(user);
-        expectedPage.setPageLayout(pageLayout);
-        expectedPage.setRenderSequence(EXPECTED_RENDER_SEQUENCE);
-        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));    
-                
-        expect(userService.getUserById(user.getEntityId())).andReturn(user);
-        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
-        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(new ArrayList<Page>());
-        replay(userService, pageLayoutRepository, pageRepository);             
-
-        Page newPage = pageService.addNewDefaultPage(user.getEntityId());                
-        assertThat(newPage.getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
-        assertThat(newPage.getName(), is(defaultPageName));
-        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
-        
-        verify(pageLayoutRepository, pageRepository);
-    }
-    
-    @Test
-    public void getDefaultPageName() {
-        assertThat(pageService.getDefaultPageName(), is(defaultPageName));
-    }
-  
-    @Test
-    public void deletePage() {
-        List<Page> pageListAfterDelete = new ArrayList<Page>(pageList);
-        pageListAfterDelete.remove(page);
-        
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(PAGE_ID)).andReturn(page);
-        pageRepository.delete(page);
-        expectLastCall();
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageListAfterDelete);
-        expect(pageRepository.save(page2)).andReturn(page2);
-        replay(userService);
-        replay(pageRepository);
-        pageService.deletePage(PAGE_ID);
-        verify(userService);
-        verify(pageRepository);
     }
-    
-    @Test
-    public void deletePage_invalidId() {               
-        final long INVALID_PAGE_ID = -999L;
-        
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(INVALID_PAGE_ID)).andReturn(page);
-        pageRepository.delete(page);
-        expectLastCall();
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageList);
-        expect(pageRepository.save(page2)).andReturn(page2);
-        expect(pageRepository.save(page)).andReturn(page);
-        replay(userService);
-        replay(pageRepository);
-        pageService.deletePage(INVALID_PAGE_ID);
-        verify(userService);
-        verify(pageRepository);
-    }    
-    
-    @Test
-    public void moveRegionWidget_validMiddle() {
-        final int newPosition = 0;
-        createMoveBetweenRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, TO_REGION_ID, FROM_REGION_ID);
 
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, false);
-    }
-
-    @Test
-    public void moveRegionWidget_validStart() {
-        final int newPosition = 1;
-        createMoveBetweenRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, TO_REGION_ID, FROM_REGION_ID);
-
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, false);
-    }
-
-    @Test
-    public void moveRegionWidget_validEnd() {
-        final int newPosition = 2;
-        createMoveBetweenRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, TO_REGION_ID, FROM_REGION_ID);
-
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, false);
-    }
-
-    @Test
-    public void moveRegionWidget_validMiddle_sameRegion() {
-        final int newPosition = 0;
-        createMoveWithinRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, FROM_REGION_ID, FROM_REGION_ID);
-
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, true);
-    }
-
-    @Test
-    public void moveRegionWidget_validStart_sameRegion() {
-        final int newPosition = 1;
-        createMoveWithinRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, FROM_REGION_ID, FROM_REGION_ID);
-
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, true);
-    }
-
-    @Test
-    public void moveRegionWidget_validEnd_sameRegion() {
-        final int newPosition = 2;
-        createMoveWithinRegionsExpectations();
-
-        RegionWidget widget = pageService.moveRegionWidget(REGION_WIDGET_ID, newPosition, FROM_REGION_ID, FROM_REGION_ID);
-
-        verify(regionRepository);
-        verifyPositions(newPosition, widget, true);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void moveRegionWidget_invalidWidget() {
-        createMoveBetweenRegionsExpectations();
-        pageService.moveRegionWidget(-1L, 0, 1L, 2L);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void moveRegionWidget_invalidWidget_sameRegion() {
-        createMoveBetweenRegionsExpectations();
-        pageService.moveRegionWidget(-1L, 0, 1L, 1L);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void moveRegionWidget_invalidTarget() {       
-        pageService.moveRegionWidget(-1L, 0, 5L, 6L);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void moveRegionWidget_invalidTarget_sameRegion() {       
-        pageService.moveRegionWidget(-1L, 0, 5L, 5L);
-    }
-
-    @Test
-    public void addWigetToPage_valid() {
-        final long WIDGET_ID = 1L;
-
-        Page value = new Page();
-        value.setRegions(new ArrayList<Region>());
-        value.getRegions().add(originalRegion);
-        value.getRegions().add(targetRegion);
-        Widget widget = new Widget();
-
-        expect(pageRepository.get(PAGE_ID)).andReturn(value);
-        expect(widgetRepository.get(WIDGET_ID)).andReturn(widget);
-        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
-        replay(pageRepository);
-        replay(regionRepository);
-        replay(widgetRepository);
-
-        RegionWidget instance = pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);
-
-        verify(pageRepository);
-        verify(regionRepository);
-        verify(widgetRepository);
-
-        verifyPositions(0, instance, true);
-        assertThat(originalRegion.getRegionWidgets().get(0), is(sameInstance(instance)));
-        assertThat(instance.getWidget(), is(sameInstance(widget)));
-
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void addWidgetToPage_invalidWidget() {
-        long WIDGET_ID = -1L;
-        expect(pageRepository.get(PAGE_ID)).andReturn(new Page());
-        expect(widgetRepository.get(WIDGET_ID)).andReturn(null);
-        replay(pageRepository);
-        replay(regionRepository);
-        replay(widgetRepository);
-
-        pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void addWidgetToPage_invalidPage() {
-        long WIDGET_ID = -1L;
-        expect(pageRepository.get(PAGE_ID)).andReturn(null);
-        expect(widgetRepository.get(WIDGET_ID)).andReturn(new Widget());
-        replay(pageRepository);
-        replay(regionRepository);
-        replay(widgetRepository);
-
-        pageService.addWidgetToPage(PAGE_ID, WIDGET_ID);
-    }
-
-    @Test
-    public void removeWidgetFromPage_validWidget() {
-        long WIDGET_ID = 1L;
-        long REGION_ID = 2L;
-        RegionWidget widget = new RegionWidget(WIDGET_ID);
-        widget.setRegion(new Region(REGION_ID));
-        Region region = new Region();
-
-        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(widget);
-        regionWidgetRepository.delete(widget);
-        expectLastCall();
-        replay(regionWidgetRepository);
-        expect(regionRepository.get(REGION_ID)).andReturn(region);
-        replay(regionRepository);
-
-        Region result = pageService.removeWidgetFromPage(WIDGET_ID);
-        verify(regionWidgetRepository);
-        verify(regionRepository);
-        assertThat(result, is(sameInstance(region)));
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void removeWidgetFromPage_invalidWidget() {
-        long WIDGET_ID = -1L;
-        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(null);
-        replay(regionWidgetRepository);
-        replay(regionRepository);
-
-        pageService.removeWidgetFromPage(WIDGET_ID);
-    }
-    
-    @Test
-    public void getPage() {
-        expect(pageRepository.get(PAGE_ID)).andReturn(page);
-        replay(pageRepository);
-          
-        assertThat(pageService.getPage(PAGE_ID), is(page));
-        
-        verify(pageRepository);
-    }
-    
-    @Test
-    public void getPageFromList() {
-        assertThat(pageService.getPageFromList(PAGE_ID, pageList), is(page));
-    }
-
-    @Test
-    public void getPageFromList_invalidId() {
-        assertThat(pageService.getPageFromList(INVALID_PAGE_ID, pageList), is(nullValue(Page.class)));
-    }
-    
-    @Test
-    public void getDefaultPageFromList_validList() {
-        assertThat(pageService.getDefaultPageFromList(pageList), is(page2));
-    }   
-    
-    @Test
-    public void getDefaultPageFromList_emptyList() {
-        assertThat(pageService.getDefaultPageFromList(new ArrayList<Page>()), is(nullValue(Page.class)));
-    }   
-    
-    @Test
-    public void getDefaultPageFromList_nullList() {
-        assertThat(pageService.getDefaultPageFromList(null), is(nullValue(Page.class)));
-    }      
-    
     @Test
-    public void movePage() {               
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(PAGE_ID)).andReturn(page);
-        expect(pageRepository.get(page2.getEntityId())).andReturn(page2);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageList);
-        expect(pageRepository.save(page2)).andReturn(page2);
-        expect(pageRepository.save(page)).andReturn(page);        
-        replay(userService);
-        replay(pageRepository);
-                          
-        assertThat(pageService.movePage(PAGE_ID, page2.getEntityId()).getRenderSequence(), is(2L));
-        assertThat(page2.getRenderSequence(), is(1L));        
-      
-        verify(userService);        
-        verify(pageRepository);
-    }
-    
-    @Test(expected=RuntimeException.class)
-    public void movePage_invalidPageId() {               
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(INVALID_PAGE_ID)).andReturn(null);
-        expect(pageRepository.get(page2.getEntityId())).andReturn(page2);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageList);
-        replay(userService);
-        replay(pageRepository);
-                          
-        pageService.movePage(INVALID_PAGE_ID, page2.getEntityId());
-      
-        verify(userService);        
-        verify(pageRepository);
-    }    
-  
-    @Test
-    public void movePageToDefault() {               
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(page2.getEntityId())).andReturn(page2);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageList);
-        expect(pageRepository.save(page)).andReturn(page);
-        expect(pageRepository.save(page2)).andReturn(page2);        
-        replay(userService);
-        replay(pageRepository);
-                          
-        assertThat(pageService.movePageToDefault(page2.getEntityId()).getRenderSequence(), is(1L));
-        assertThat(page.getRenderSequence(), is(2L));        
-      
-        verify(userService);        
-        verify(pageRepository);
-    }    
-    
-    @Test(expected=RuntimeException.class)
-    public void movePageToDefault_invalidPageId() {               
-        expect(userService.getAuthenticatedUser()).andReturn(user);
-        expect(pageRepository.get(INVALID_PAGE_ID)).andReturn(null);
-        expect(pageRepository.getAllPages(user.getEntityId())).andReturn(pageList);
-        replay(userService);
-        replay(pageRepository);
-                          
-        pageService.movePageToDefault(INVALID_PAGE_ID);     
-      
-        verify(userService);        
-        verify(pageRepository);
-    }
-    
-    @Test
-    public void updatePage_nameUpdate() {
-        String newName = "new page name";
-        String layoutName = "layout name";
-        
-        PageLayout layout = createStrictMock(PageLayout.class);
-        expect(layout.getNumberOfRegions()).andReturn(new Long(2)).anyTimes();
-//        expect(layout.equals(layout)).andReturn((boolean) true);
-        replay(layout);
-        
-        //create a strict mock that ensures that the appropriate setters are
-        //called, rather than checking the return value from the function
-        Page curPage = createStrictMock(Page.class);
-        expect(curPage.getPageLayout()).andReturn(layout);
-        curPage.setName(newName);
-        curPage.setPageLayout(layout);
-        replay(curPage);
-        
-        expect(pageRepository.get(PAGE_ID)).andReturn(curPage);
-        expect(pageRepository.save(curPage)).andReturn(curPage);
-        replay(pageRepository);
-        
-        
-        expect(pageLayoutRepository.getByPageLayoutCode(layoutName)).andReturn(layout);
+    public void getPageLayoutByCode_invalidPageLayout() {
+        expect(pageLayoutRepository.getByPageLayoutCode(INVALID_LAYOUT_CODE)).andReturn(null);
         replay(pageLayoutRepository);
-        
-        pageService.updatePage(PAGE_ID, newName, layoutName);
-        
-        verify(curPage);
-    }
-    
-    
-    @Test
-    public void updatePage_addRegion() {
-        String newName = "new page name";
-        String layoutName = "layout name";
-        
-        List<Region> regions = new ArrayList<Region>();
-        Region region = createStrictMock(Region.class);
-        expect(region.getRenderOrder()).andReturn(1);
-        replay(region);
-        regions.add(new Region());
-        regions.add(region);
-        
-        PageLayout prevLayout = createStrictMock(PageLayout.class);
-        expect(prevLayout.getNumberOfRegions()).andReturn(new Long(2)).anyTimes();
-        replay(prevLayout);
-        
-        PageLayout layout = createStrictMock(PageLayout.class);
-        expect(layout.getNumberOfRegions()).andReturn(new Long(3)).anyTimes();
-//        expect(layout.equals(layout)).andReturn((boolean) true);
-        replay(layout);
-        
-        //create a strict mock that ensures that the appropriate setters are
-        //called, rather than checking the return value from the function
-        Page curPage = createStrictMock(Page.class);
-        expect(curPage.getPageLayout()).andReturn(prevLayout);
-        expect(curPage.getRegions()).andReturn(regions);
-        curPage.setName(newName);
-        curPage.setPageLayout(layout);
-        replay(curPage);
-        
-        expect(pageRepository.get(PAGE_ID)).andReturn(curPage);
-        expect(pageRepository.save(curPage)).andReturn(curPage);
-        replay(pageRepository);
-        
-        expect(pageLayoutRepository.getByPageLayoutCode(layoutName)).andReturn(layout);
-        replay(pageLayoutRepository);
-        
-        pageService.updatePage(PAGE_ID, newName, layoutName);
-        assertThat(regions.size(), is(3));
-        assertThat(regions.get(regions.size()-1).getPage(), is(curPage));
-        
-        verify(curPage);
-    }
-    
-    
-    @Test
-    public void updatePage_removeRegion_noWidgets() {
-        String newName = "new page name";
-        String layoutName = "layout name";
-        
-        List<Region> regions = new ArrayList<Region>();
-        Region region = createStrictMock(Region.class);
-        expect(region.getRegionWidgets()).andReturn(new ArrayList<RegionWidget>());
-        expect(region.getRenderOrder()).andReturn(1);
-        replay(region);
-        regions.add(region);
-        
-        Region deletedRegion = createStrictMock(Region.class);
-        expect(deletedRegion.getRegionWidgets()).andReturn(new ArrayList<RegionWidget>());
-        replay(deletedRegion);
-        regions.add(deletedRegion);
-        
-        PageLayout prevLayout = createStrictMock(PageLayout.class);
-        expect(prevLayout.getNumberOfRegions()).andReturn(new Long(2)).anyTimes();
-        replay(prevLayout);
-        
-        PageLayout layout = createStrictMock(PageLayout.class);
-        expect(layout.getNumberOfRegions()).andReturn(new Long(1)).anyTimes();
-        replay(layout);
-        
-        regionRepository.delete(deletedRegion);
-        expect(regionRepository.save(region)).andReturn(region);
-        replay(regionRepository);
-        
-        //create a strict mock that ensures that the appropriate setters are
-        //called, rather than checking the return value from the function
-        Page curPage = createStrictMock(Page.class);
-        expect(curPage.getPageLayout()).andReturn(prevLayout);
-        expect(curPage.getRegions()).andReturn(regions);
-        curPage.setName(newName);
-        curPage.setPageLayout(layout);
-        replay(curPage);
-        
-        expect(pageRepository.get(PAGE_ID)).andReturn(curPage);
-        expect(pageRepository.save(curPage)).andReturn(curPage);
-        replay(pageRepository);
-        
-        expect(pageLayoutRepository.getByPageLayoutCode(layoutName)).andReturn(layout);
-        replay(pageLayoutRepository);
-        
-        pageService.updatePage(PAGE_ID, newName, layoutName);
-        
-        verify(curPage);
-    }
-    
-    
-    @Test
-    public void updatePage_removeRegion_moveWidgetToEmptyColumn() {
-        String newName = "new page name";
-        String layoutName = "layout name";
-        
-        
-        List<RegionWidget> newLastWidgetColumn = new ArrayList<RegionWidget>();
-        
-        List<Region> regions = new ArrayList<Region>();
-        Region region = createStrictMock(Region.class);
-        expect(region.getRegionWidgets()).andReturn(newLastWidgetColumn).times(2);
-        expect(region.getRenderOrder()).andReturn(1);
-        replay(region);
-        regions.add(region);
-        
-        
-        RegionWidget widget = createStrictMock(RegionWidget.class);
-        widget.setRegion(region);
-        widget.setRenderOrder(1);
-        replay(widget);
-        List<RegionWidget> movedWidgets = new ArrayList<RegionWidget>();
-        movedWidgets.add(widget);
-        
-        Region deletedRegion = createStrictMock(Region.class);
-        expect(deletedRegion.getRegionWidgets()).andReturn(movedWidgets);
-        replay(deletedRegion);
-        regions.add(deletedRegion);
-        
-        PageLayout prevLayout = createStrictMock(PageLayout.class);
-        expect(prevLayout.getNumberOfRegions()).andReturn(new Long(2)).anyTimes();
-        replay(prevLayout);
-        
-        PageLayout layout = createStrictMock(PageLayout.class);
-        expect(layout.getNumberOfRegions()).andReturn(new Long(1)).anyTimes();
-        replay(layout);
-        
-        regionRepository.delete(deletedRegion);
-        expect(regionRepository.save(region)).andReturn(region);
-        replay(regionRepository);
-        
-        //create a strict mock that ensures that the appropriate setters are
-        //called, rather than checking the return value from the function
-        Page curPage = createStrictMock(Page.class);
-        expect(curPage.getPageLayout()).andReturn(prevLayout);
-        expect(curPage.getRegions()).andReturn(regions);
-        curPage.setName(newName);
-        curPage.setPageLayout(layout);
-        replay(curPage);
-        
-        expect(pageRepository.get(PAGE_ID)).andReturn(curPage);
-        expect(pageRepository.save(curPage)).andReturn(curPage);
-        replay(pageRepository);
-        
-        expect(pageLayoutRepository.getByPageLayoutCode(layoutName)).andReturn(layout);
-        replay(pageLayoutRepository);
-        
-        pageService.updatePage(PAGE_ID, newName, layoutName);
-        assertThat(newLastWidgetColumn.size(), is (1));
-        
-        verify(curPage);
-    }
-    
-    
-    @Test
-    public void updatePage_removeRegion_moveWidgetToNonEmptyColumn() {
-        String newName = "new page name";
-        String layoutName = "layout name";
-        
-        
-        RegionWidget widget = createStrictMock(RegionWidget.class);
-        expect(widget.getRenderOrder()).andReturn(0).anyTimes();
-        replay(widget);
-        List<RegionWidget> newLastWidgetColumn = new ArrayList<RegionWidget>();
-        newLastWidgetColumn.add(widget);
-        
-        List<Region> regions = new ArrayList<Region>();
-        Region region = createStrictMock(Region.class);
-        expect(region.getRegionWidgets()).andReturn(newLastWidgetColumn).times(2);
-        expect(region.getRenderOrder()).andReturn(1);
-        replay(region);
-        regions.add(region);
-        
-        
-        widget = createStrictMock(RegionWidget.class);
-        widget.setRegion(region);
-        widget.setRenderOrder(1);
-        expect(widget.getRenderOrder()).andReturn(1).anyTimes();
-        replay(widget);
-        List<RegionWidget> movedWidgets = new ArrayList<RegionWidget>();
-        movedWidgets.add(widget);
-        
-        Region deletedRegion = createStrictMock(Region.class);
-        expect(deletedRegion.getRegionWidgets()).andReturn(movedWidgets);
-        replay(deletedRegion);
-        regions.add(deletedRegion);
-        
-        PageLayout prevLayout = createStrictMock(PageLayout.class);
-        expect(prevLayout.getNumberOfRegions()).andReturn(new Long(2)).anyTimes();
-        replay(prevLayout);
-        
-        PageLayout layout = createStrictMock(PageLayout.class);
-        expect(layout.getNumberOfRegions()).andReturn(new Long(1)).anyTimes();
-        replay(layout);
-        
-        regionRepository.delete(deletedRegion);
-        expect(regionRepository.save(region)).andReturn(region);
-        replay(regionRepository);
-        
-        //create a strict mock that ensures that the appropriate setters are
-        //called, rather than checking the return value from the function
-        Page curPage = createStrictMock(Page.class);
-        expect(curPage.getPageLayout()).andReturn(prevLayout);
-        expect(curPage.getRegions()).andReturn(regions);
-        curPage.setName(newName);
-        curPage.setPageLayout(layout);
-        replay(curPage);
-        
-        expect(pageRepository.get(PAGE_ID)).andReturn(curPage);
-        expect(pageRepository.save(curPage)).andReturn(curPage);
-        replay(pageRepository);
-        
-        expect(pageLayoutRepository.getByPageLayoutCode(layoutName)).andReturn(layout);
-        replay(pageLayoutRepository);
-        
-        pageService.updatePage(PAGE_ID, newName, layoutName);
-        assertThat(newLastWidgetColumn.size(), is (2));
-        assertThat(newLastWidgetColumn.get(0).getRenderOrder(), is (0));
-        assertThat(newLastWidgetColumn.get(1).getRenderOrder(), is (1));
-        
-        verify(curPage);
-    }
-    // private methods    
-    private void verifyPositions(int newPosition, RegionWidget widget, boolean sameRegion) {
-        assertThat(widget.getRenderOrder(), is(equalTo(newPosition)));        
-        assertOrder(originalRegion);
-        assertThat(originalRegion.getRegionWidgets().contains(widget), is(sameRegion));
-        if (!sameRegion) {
-            assertOrder(targetRegion);
-            assertThat(targetRegion.getRegionWidgets().contains(widget), is(true));
-        }
-    }
-
-    private void createMoveBetweenRegionsExpectations() {
-        expect(regionRepository.get(TO_REGION_ID)).andReturn(targetRegion);
-        expect(regionRepository.get(FROM_REGION_ID)).andReturn(originalRegion);
-        expect(regionRepository.save(targetRegion)).andReturn(targetRegion);
-        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
-        replay(regionRepository);
-    }
-
-    private void createMoveWithinRegionsExpectations() {
-        expect(regionRepository.get(FROM_REGION_ID)).andReturn(originalRegion);
-        expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
-        replay(regionRepository);
-    }
-
-    private void assertOrder(Region region) {
-        for (int i = 0; i < region.getRegionWidgets().size(); i++) {
-            assertThat(region.getRegionWidgets().get(i).getRenderOrder(), is(equalTo(i)));
-        }
-    }
-    
-    private List<Region> createEmptyRegionList(long numberOfRegions) {
-        List<Region> regions = new ArrayList<Region>();
-        int regionCount;
-        for (regionCount = 0; regionCount < numberOfRegions; regionCount++) {
-              Region region = new Region();
-              regions.add(region);
-        }
-        return regions;
-    }
-
-    @Test
-    public void moveRegionWidgetToPage_valid() {
-        final long WIDGET_ID = 1L;
-        final long CURRENT_PAGE_ID = 1L;
-        final long TO_PAGE_ID = 2L;
-
-        Page currentPageValue = new Page();
-        currentPageValue.setRegions(new ArrayList<Region>());
-        currentPageValue.getRegions().add(originalRegion);
-        currentPageValue.getRegions().add(targetRegion);
-
-        Page toPageValue = new Page();
-        toPageValue.setRegions(new ArrayList<Region>());
-        toPageValue.getRegions().add(originalRegion);
-        toPageValue.getRegions().add(targetRegion);
-
-        RegionWidget regionWidget = new RegionWidget(VALID_REGION_WIDGET_ID);
-
-        expect(pageRepository.get(TO_PAGE_ID)).andReturn(toPageValue);
-        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(regionWidget).times(2);
-
-        replay(pageRepository);
-        replay(regionWidgetRepository);
-
-        RegionWidget updatedRegionWidget = pageService.moveRegionWidgetToPage(VALID_REGION_WIDGET_ID, TO_PAGE_ID);
-
-        verify(pageRepository);
-        verify(regionWidgetRepository);
-        verifyPositions(0, regionWidget, true);
-
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void moveRegionWidgetToPage_invalidWidget() {
-        long WIDGET_ID = -1L;
-        final long CURRENT_PAGE_ID = 1L;
-        final long TO_PAGE_ID = 2L;
-
-        Page currentPageValue = new Page();
-        currentPageValue.setRegions(new ArrayList<Region>());
-        currentPageValue.getRegions().add(originalRegion);
-        currentPageValue.getRegions().add(targetRegion);
-
-        Page toPageValue = new Page();
-        toPageValue.setRegions(new ArrayList<Region>());
-        toPageValue.getRegions().add(originalRegion);
-        toPageValue.getRegions().add(targetRegion);
-
-        expect(pageRepository.get(CURRENT_PAGE_ID)).andReturn(currentPageValue);
-        expect(pageRepository.get(TO_PAGE_ID)).andReturn(toPageValue);
-        expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(null);
-
-        pageService.moveRegionWidgetToPage(VALID_REGION_WIDGET_ID, TO_PAGE_ID);
-    }
-}
+        assertThat(pageLayoutService.getPageLayoutByCode(INVALID_LAYOUT_CODE), is(nullValue(PageLayout.class)));
+        verify(pageLayoutRepository);
+    }    
+}
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql (original)
+++ incubator/rave/trunk/rave-components/rave-core/src/test/resources/test_data.sql Fri Dec 16 19:48:38 2011
@@ -51,38 +51,38 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
   -- ***********************************************************************************
   -- start page layout data, required to make the portal work ---
 set @one_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@one_col_id, 'columns_1', 1);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@one_col_id, 'columns_1', 1, 0);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @two_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@two_col_id, 'columns_2', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@two_col_id, 'columns_2', 2, 1);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @twown_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@twown_col_id, 'columns_2wn', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@twown_col_id, 'columns_2wn', 2, 2);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @three_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@three_col_id, 'columns_3', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@three_col_id, 'columns_3', 3, 3);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @threewn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@threewn_col_id, 'columns_3nwn', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@threewn_col_id, 'columns_3nwn', 3, 4);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @four_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@four_col_id, 'columns_4', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@four_col_id, 'columns_4', 4, 5);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @fourwn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4, 6);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 --- end page layout data ----
 

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/PageController.java Fri Dec 16 19:48:38 2011
@@ -19,7 +19,9 @@
 package org.apache.rave.portal.web.controller;
 
 import org.apache.rave.portal.model.Page;
+import org.apache.rave.portal.model.PageLayout;
 import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.service.PageLayoutService;
 import org.apache.rave.portal.service.PageService;
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.web.controller.util.ControllerUtils;
@@ -48,19 +50,21 @@ public class PageController {
          
     private PageService pageService;
     private UserService userService;
+    private PageLayoutService pageLayoutService;
 
     @Autowired
-    public PageController(PageService pageService, UserService userService) {
+    public PageController(PageService pageService, UserService userService, PageLayoutService pageLayoutService) {
         this.pageService = pageService;
         this.userService = userService;
+        this.pageLayoutService = pageLayoutService;
     }
  
     @RequestMapping(value = {"/page/view", "/index.html"}, method = RequestMethod.GET)
     public String viewDefault(Model model, HttpServletRequest request) {
         List<Page> pages = getAllPagesForAuthenticatedUser();
         Page page = pageService.getDefaultPageFromList(pages);
-        model.addAttribute(ModelKeys.PAGE, page);
-        model.addAttribute(ModelKeys.PAGES, pages);
+        List<PageLayout> pageLayouts = pageLayoutService.getAll();
+        addAttributesToModel(model, page, pages, pageLayouts);
         return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
     }          
     
@@ -71,9 +75,8 @@ public class PageController {
         
         List<Page> pages = getAllPagesForAuthenticatedUser();
         Page page = pageService.getPageFromList(pageId, pages);
-               
-        model.addAttribute(ModelKeys.PAGE, page);
-        model.addAttribute(ModelKeys.PAGES, pages);
+        List<PageLayout> pageLayouts = pageLayoutService.getAll();
+        addAttributesToModel(model, page, pages, pageLayouts);
         return ControllerUtils.getDeviceAppropriateView(request, ViewNames.getPageView(page.getPageLayout().getCode()), ViewNames.MOBILE_HOME);
     }
     
@@ -90,4 +93,10 @@ public class PageController {
         }
         return pages;
     }
+    
+    private void addAttributesToModel(Model model, Page page, List<Page> pages, List<PageLayout> pageLayouts) {
+        model.addAttribute(ModelKeys.PAGE, page);
+        model.addAttribute(ModelKeys.PAGES, pages);
+        model.addAttribute(ModelKeys.PAGE_LAYOUTS, pageLayouts);
+    }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java Fri Dec 16 19:48:38 2011
@@ -26,6 +26,7 @@ public class ModelKeys {
     private ModelKeys() {}
     public static final String PAGE = "page"; // the current page object
     public static final String PAGES = "pages"; // a list of pages available for the current user
+    public static final String PAGE_LAYOUTS = "pageLayouts"; // a list of all the possible page layouts
     public static final String ERROR_MESSAGE = "errorMessage"; // an error message to be reported to the user
     public static final String WIDGETS = "widgets"; // a list of widget objects
     public static final String WIDGET = "widget";

Modified: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java (original)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/controller/PageControllerTest.java Fri Dec 16 19:48:38 2011
@@ -19,6 +19,7 @@
 
 package org.apache.rave.portal.web.controller;
 
+import org.apache.rave.portal.service.PageLayoutService;
 import org.apache.rave.portal.web.controller.util.MockHttpUtil;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.apache.rave.portal.model.PageLayout;
@@ -44,12 +45,14 @@ import static org.junit.Assert.assertTha
 public class PageControllerTest {
     private UserService userService;
     private PageService pageService;
+    private PageLayoutService pageLayoutService;
     private PageController pageController;
     private MockHttpServletRequest request;
     
     private Model model;
     private Page defaultPage, otherPage;
     private List<Page> allPages;
+    private List<PageLayout> allPageLayouts;
     
     private final Long DEFAULT_PAGE_ID = 99L;
     private final Long OTHER_PAGE_ID = 22L;
@@ -62,7 +65,8 @@ public class PageControllerTest {
     public void setup() {
         userService = createMock(UserService.class);
         pageService = createMock(PageService.class);
-        pageController = new PageController(pageService, userService);
+        pageLayoutService = createMock(PageLayoutService.class);
+        pageController = new PageController(pageService, userService, pageLayoutService);
         model = new ExtendedModelMap();
         request = new MockHttpServletRequest();
 
@@ -78,6 +82,9 @@ public class PageControllerTest {
         allPages = new ArrayList<Page>();
         allPages.add(defaultPage);   
         allPages.add(otherPage);
+
+        allPageLayouts = new ArrayList<PageLayout>();
+        allPageLayouts.add(validPageLayout);
         
         validUser = new User(USER_ID);
         validUser.setDefaultPageLayout(validPageLayout);
@@ -90,15 +97,17 @@ public class PageControllerTest {
         expect(userService.getAuthenticatedUser()).andReturn(validUser).anyTimes(); 
         expect(pageService.getAllPages(USER_ID)).andReturn(allPages);
         expect(pageService.getPageFromList(OTHER_PAGE_ID, allPages)).andReturn(otherPage);
-        replay(userService, pageService);       
+        expect(pageLayoutService.getAll()).andReturn(allPageLayouts);
+        replay(userService, pageService, pageLayoutService);
 
         String results = pageController.view(OTHER_PAGE_ID, model, request);
         
         assertThat(results, equalTo(ViewNames.getPageView(VALID_PAGE_LAYOUT_CODE)));
         assertThat((Page) model.asMap().get(ModelKeys.PAGE), sameInstance(otherPage));
         assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), sameInstance(allPages));
+        assertThat((List<PageLayout>) model.asMap().get(ModelKeys.PAGE_LAYOUTS), sameInstance(allPageLayouts));
         
-        verify(userService, pageService);
+        verify(userService, pageService, pageLayoutService);
     }
     
     @Test
@@ -108,15 +117,17 @@ public class PageControllerTest {
         expect(userService.getAuthenticatedUser()).andReturn(validUser).anyTimes(); 
         expect(pageService.getAllPages(USER_ID)).andReturn(allPages);
         expect(pageService.getPageFromList(OTHER_PAGE_ID, allPages)).andReturn(otherPage);
-        replay(userService, pageService);       
+        expect(pageLayoutService.getAll()).andReturn(allPageLayouts);
+        replay(userService, pageService, pageLayoutService);
 
         String results = pageController.view(OTHER_PAGE_ID, model, request);
         
         assertThat(results, equalTo(ViewNames.MOBILE_HOME));
         assertThat((Page) model.asMap().get(ModelKeys.PAGE), sameInstance(otherPage));
         assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), sameInstance(allPages));
+        assertThat((List<PageLayout>) model.asMap().get(ModelKeys.PAGE_LAYOUTS), sameInstance(allPageLayouts));
         
-        verify(userService, pageService);
+        verify(userService, pageService, pageLayoutService);
     }
     
     @Test
@@ -129,15 +140,17 @@ public class PageControllerTest {
         expect(pageService.getAllPages(USER_ID)).andReturn(pages).times(2);
         expect(pageService.addNewDefaultPage(validUser.getEntityId())).andReturn(defaultPage);
         expect(pageService.getPageFromList(OTHER_PAGE_ID, pages)).andReturn(defaultPage);
-        replay(userService, pageService);         
+        expect(pageLayoutService.getAll()).andReturn(allPageLayouts);
+        replay(userService, pageService, pageLayoutService);
         
         String results = pageController.view(OTHER_PAGE_ID, model, request);
         
         assertThat(results, equalTo(ViewNames.getPageView(VALID_PAGE_LAYOUT_CODE)));
         assertThat((Page) model.asMap().get(ModelKeys.PAGE), sameInstance(defaultPage));
         assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), sameInstance(pages));
+        assertThat((List<PageLayout>) model.asMap().get(ModelKeys.PAGE_LAYOUTS), sameInstance(allPageLayouts));
         
-        verify(userService, pageService);
+        verify(userService, pageService, pageLayoutService);
     }    
     
     @Test
@@ -147,15 +160,17 @@ public class PageControllerTest {
         expect(userService.getAuthenticatedUser()).andReturn(validUser).anyTimes(); 
         expect(pageService.getAllPages(USER_ID)).andReturn(allPages);
         expect(pageService.getDefaultPageFromList(allPages)).andReturn(defaultPage);
-        replay(userService, pageService);
+        expect(pageLayoutService.getAll()).andReturn(allPageLayouts);
+        replay(userService, pageService, pageLayoutService);
 
         String results = pageController.viewDefault(model, request);
         
         assertThat(results, equalTo(ViewNames.getPageView(VALID_PAGE_LAYOUT_CODE)));
         assertThat((Page) model.asMap().get(ModelKeys.PAGE), sameInstance(defaultPage));
         assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), sameInstance(allPages));
+        assertThat((List<PageLayout>) model.asMap().get(ModelKeys.PAGE_LAYOUTS), sameInstance(allPageLayouts));
         
-        verify(userService, pageService);
+        verify(userService, pageService, pageLayoutService);
     }
     
     @Test
@@ -168,14 +183,16 @@ public class PageControllerTest {
         expect(pageService.getAllPages(USER_ID)).andReturn(pages).times(2);
         expect(pageService.addNewDefaultPage(validUser.getEntityId())).andReturn(defaultPage);
         expect(pageService.getDefaultPageFromList(pages)).andReturn(defaultPage);
-        replay(userService, pageService);
+        expect(pageLayoutService.getAll()).andReturn(allPageLayouts);
+        replay(userService, pageService, pageLayoutService);
 
         String results = pageController.viewDefault(model, request);
         
         assertThat(results, equalTo(ViewNames.getPageView(VALID_PAGE_LAYOUT_CODE)));
         assertThat((Page) model.asMap().get(ModelKeys.PAGE), sameInstance(defaultPage));
         assertThat((List<Page>) model.asMap().get(ModelKeys.PAGES), sameInstance(pages));
+        assertThat((List<PageLayout>) model.asMap().get(ModelKeys.PAGE_LAYOUTS), sameInstance(allPageLayouts));
         
-        verify(userService, pageService);
+        verify(userService, pageService, pageLayoutService);
     }    
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/db/initial_data.sql Fri Dec 16 19:48:38 2011
@@ -57,44 +57,45 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
   -- ***********************************************************************************
   -- start page layout data, required to make the portal work ---
 set @one_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@one_col_id, 'columns_1', 1);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@one_col_id, 'columns_1', 1, 0);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @two_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@two_col_id, 'columns_2', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@two_col_id, 'columns_2', 2, 1);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @twown_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@twown_col_id, 'columns_2wn', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@twown_col_id, 'columns_2wn', 2, 2);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @three_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@three_col_id, 'columns_3', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@three_col_id, 'columns_3', 3, 3);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @threewn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@threewn_col_id, 'columns_3nwn', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@threewn_col_id, 'columns_3nwn', 3, 4);
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
+
+set @newuser_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@newuser_col_id, 'columns_3_newuser', 3, 5);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @four_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@four_col_id, 'columns_4', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@four_col_id, 'columns_4', 4, 6);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @fourwn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4, 7);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
-set @newuser_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@newuser_col_id, 'columns_3_newuser', 3);
-UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 --- end page layout data ----
 
   -- ***********************************************************************************

Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/page.jsp Fri Dec 16 19:48:38 2011
@@ -20,6 +20,7 @@
 <%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
 <fmt:setBundle basename="messages"/>
 <jsp:useBean id="pages" type="java.util.List<org.apache.rave.portal.model.Page>" scope="request"/>
+<jsp:useBean id="pageLayouts" type="java.util.List<org.apache.rave.portal.model.PageLayout>" scope="request"/>
 <%--@elvariable id="page" type="org.apache.rave.portal.model.Page"--%>
 <header>
     <nav class="topnav">
@@ -113,14 +114,9 @@
             <input type="text" name="tab_title" id="tab_title" value="" class="required ui-widget-content ui-corner-all" />
             <label for="pageLayout"><fmt:message key="page.general.addpage.selectlayout"/></label>
             <select name="pageLayout" id="pageLayout">
-                <option value="columns_1" id="columns_1_id"><fmt:message key="page.general.addpage.layout.columns_1"/></option>
-                <option value="columns_2" id="columns_2_id" selected="selected"><fmt:message key="page.general.addpage.layout.columns_2"/></option>
-                <option value="columns_2wn" id="columns_2wn_id"><fmt:message key="page.general.addpage.layout.columns_2wn"/></option>
-                <option value="columns_3" id="columns_3_id"><fmt:message key="page.general.addpage.layout.columns_3"/></option>
-                <option value="columns_3nwn" id="columns_3nwn_id"><fmt:message key="page.general.addpage.layout.columns_3nwn"/></option>
-                <option value="columns_3_newuser" id="columns_4_newuser_id"><fmt:message key="page.general.addpage.layout.columns_3_newuser"/></option>
-                <option value="columns_4" id="columns_4_id"><fmt:message key="page.general.addpage.layout.columns_4"/></option>
-                <option value="columns_3nwn_1_bottom" id="columns_3nwn_1_bottom"><fmt:message key="page.general.addpage.layout.columns_3nwn_1_bottom"/></option>
+                <c:forEach var="pageLayout" items="${pageLayouts}">
+                    <option value="${pageLayout.code}" id="${pageLayout.code}_id"><fmt:message key="page.general.addpage.layout.${pageLayout.code}"/></option>
+                </c:forEach>
             </select>
         </fieldset>
     </form>

Modified: incubator/rave/trunk/rave-portal/src/test/resources/test-data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/resources/test-data.sql?rev=1215251&r1=1215250&r2=1215251&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/resources/test-data.sql (original)
+++ incubator/rave/trunk/rave-portal/src/test/resources/test-data.sql Fri Dec 16 19:48:38 2011
@@ -43,38 +43,38 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
   -- ***********************************************************************************
   -- start page layout data, required to make the portal work ---
 set @one_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@one_col_id, 'columns_1', 1);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@one_col_id, 'columns_1', 1, 0);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @two_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@two_col_id, 'columns_2', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@two_col_id, 'columns_2', 2, 1);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @twown_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@twown_col_id, 'columns_2wn', 2);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@twown_col_id, 'columns_2wn', 2, 2);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @three_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@three_col_id, 'columns_3', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@three_col_id, 'columns_3', 3, 3);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @threewn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@threewn_col_id, 'columns_3nwn', 3);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@threewn_col_id, 'columns_3nwn', 3, 4);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @four_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@four_col_id, 'columns_4', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@four_col_id, 'columns_4', 4, 5);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 
 set @fourwn_col_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name = @page_layout_seq);
-insert into page_layout (entity_id, code,  number_of_regions)
-values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4);
+insert into page_layout (entity_id, code,  number_of_regions, render_sequence)
+values (@fourwn_col_id, 'columns_3nwn_1_bottom', 4, 6);
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @page_layout_seq;
 --- end page layout data ----
 



Mime
View raw message