Search in sources :

Example 11 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class TestPageManager method testPageStatus.

public void testPageStatus() throws ApsSystemException {
    String testCode = "testcode";
    try {
        PagesStatus status = this._pageManager.getPagesStatus();
        IPage parentPage = _pageManager.getDraftRoot();
        PageModel pageModel = parentPage.getMetadata().getModel();
        PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, "pagina temporanea", null, null, false, null, null);
        PageMetadata draftMeta = metadata;
        Page pageToAdd = PageTestUtil.createPage(testCode, parentPage, "free", draftMeta, null);
        _pageManager.addPage(pageToAdd);
        PagesStatus newStatus = this._pageManager.getPagesStatus();
        assertEquals(newStatus.getOnline(), status.getOnline());
        assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges());
        assertEquals(newStatus.getDraft(), status.getDraft() + 1);
        assertEquals(newStatus.getTotal(), status.getTotal() + 1);
        this._pageManager.setPageOnline(testCode);
        newStatus = this._pageManager.getPagesStatus();
        assertEquals(newStatus.getOnline(), status.getOnline() + 1);
        assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges());
        assertEquals(newStatus.getDraft(), status.getDraft());
        assertEquals(newStatus.getTotal(), status.getTotal() + 1);
        IPage test = this._pageManager.getDraftPage(testCode);
        test.getMetadata().setTitle("it", "modxxxx");
        this._pageManager.updatePage(test);
        test = this._pageManager.getDraftPage(testCode);
        newStatus = this._pageManager.getPagesStatus();
        assertEquals(newStatus.getOnline(), status.getOnline());
        assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges() + 1);
        assertEquals(newStatus.getDraft(), status.getDraft());
        assertEquals(newStatus.getTotal(), status.getTotal() + 1);
    } finally {
        this._pageManager.deletePage(testCode);
    }
}
Also used : PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 12 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class TestPageManager method checkAddPage.

public void checkAddPage() throws Throwable {
    IPage parentPage = _pageManager.getDraftPage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, "pagina temporanea", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this._widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage("temp", parentPage, "free", metadata, widgets);
    _pageManager.addPage(pageToAdd);
    IPage addedPage = _pageManager.getDraftPage("temp");
    assertEquals(addedPage, _pageManager.getDraftPage(addedPage.getCode()));
    PageTestUtil.comparePages(pageToAdd, addedPage, false);
    PageTestUtil.comparePageMetadata(pageToAdd.getMetadata(), addedPage.getMetadata(), 0);
    assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
    parentPage = _pageManager.getDraftPage("service");
    pageToAdd.setParent(parentPage);
    pageToAdd.setCode("temp1");
    _pageManager.addPage(pageToAdd);
    addedPage = _pageManager.getDraftPage("temp1");
    assertEquals(addedPage, _pageManager.getDraftPage(addedPage.getCode()));
    PageTestUtil.comparePages(pageToAdd, addedPage, false);
    PageTestUtil.comparePageMetadata(pageToAdd.getMetadata(), addedPage.getMetadata(), 0);
    assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
    parentPage = _pageManager.getDraftPage("service");
    pageToAdd.setParent(parentPage);
    pageToAdd.setCode("temp2");
    _pageManager.addPage(pageToAdd);
    addedPage = _pageManager.getDraftPage("temp2");
    assertNotNull(_pageManager.getDraftPage(addedPage.getCode()));
    assertNotNull(pageToAdd.getMetadata());
    assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
}
Also used : PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 13 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class ContentMapperCacheWrapper method searchPublishedDataObjects.

private void searchPublishedDataObjects(ContentPageMapper contentPageMapper, IPage page, IPageManager pageManager) {
    PageModel pageModel = page.getModel();
    if (pageModel != null) {
        int mainFrame = pageModel.getMainFrame();
        Widget[] widgets = page.getWidgets();
        Widget widget = null;
        if (null != widgets && mainFrame != -1) {
            widget = widgets[mainFrame];
        }
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        String contentId = (null != config) ? config.getProperty("contentId") : null;
        if (null != contentId) {
            contentPageMapper.add(contentId, page.getCode());
        }
        String[] childCodes = page.getChildrenCodes();
        for (String childCode : childCodes) {
            IPage child = pageManager.getOnlinePage(childCode);
            if (null != child) {
                this.searchPublishedDataObjects(contentPageMapper, child, pageManager);
            }
        }
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 14 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class AbstractTestPageModelAction method createMockPageModel.

protected PageModel createMockPageModel(String code) {
    PageModel model = new PageModel();
    model.setCode(code);
    model.setDescription("Description of model " + code);
    Frame frame0 = new Frame();
    frame0.setPos(0);
    frame0.setDescription("Freme 0");
    frame0.setMainFrame(true);
    Frame frame1 = new Frame();
    frame1.setPos(1);
    frame1.setDescription("Freme 1");
    Widget defWidg1 = new Widget();
    defWidg1.setType(this._widgetTypeManager.getWidgetType("content_viewer_list"));
    ApsProperties props1 = new ApsProperties();
    props1.setProperty("contentType", "ART");
    defWidg1.setConfig(props1);
    frame1.setDefaultWidget(defWidg1);
    Frame frame2 = new Frame();
    frame2.setPos(1);
    frame2.setDescription("Freme 2");
    Widget defWidg2 = new Widget();
    defWidg2.setType(this._widgetTypeManager.getWidgetType("login_form"));
    frame2.setDefaultWidget(defWidg2);
    Frame[] configuration = { frame0, frame1, frame2 };
    model.setConfiguration(configuration);
    model.setTemplate("<strong>Freemarker template content</strong>");
    return model;
}
Also used : Frame(com.agiletec.aps.system.services.pagemodel.Frame) Widget(com.agiletec.aps.system.services.page.Widget) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 15 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class TestPageModelAction method testSave.

public void testSave() throws Throwable {
    String testPageModelCode = "test_pagemodel";
    assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    try {
        PageModel mockModel = this.createMockPageModel(testPageModelCode);
        this.setUserOnSession("admin");
        this.initAction("/do/PageModel", "save");
        super.addParameter("code", mockModel.getCode());
        super.addParameter("description", mockModel.getDescription());
        super.addParameter("template", mockModel.getTemplate());
        PageModelDOM dom = new PageModelDOM(mockModel);
        super.addParameter("xmlConfiguration", dom.getXMLDocument());
        super.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        assertNotNull(this._pageModelManager.getPageModel(testPageModelCode));
    } catch (Exception e) {
        throw e;
    } finally {
        this._pageModelManager.deletePageModel(testPageModelCode);
        assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    }
}
Also used : PageModelDOM(com.agiletec.aps.system.services.pagemodel.PageModelDOM) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Aggregations

PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)47 IPage (com.agiletec.aps.system.services.page.IPage)13 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 Page (com.agiletec.aps.system.services.page.Page)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ApsProperties (com.agiletec.aps.util.ApsProperties)10 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)7 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)6 Frame (com.agiletec.aps.system.services.pagemodel.Frame)5 Map (java.util.Map)5 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)5 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)5 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)4 PageModelDOM (com.agiletec.aps.system.services.pagemodel.PageModelDOM)4 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)4