Search in sources :

Example 21 with PageModel

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

the class PageConfigurationControllerWidgetsIntegrationTest method createPage.

protected Page createPage(String pageCode) {
    IPage parentPage = pageManager.getDraftPage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", 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(pageCode, parentPage, "free", metadata, widgets);
    return pageToAdd;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 22 with PageModel

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

the class PageServiceWidgetIntegrationTest method testUpdatePageWidget.

public void testUpdatePageWidget() throws JsonProcessingException, ApsSystemException {
    String pageCode = "temp001";
    IPage parentPage = pageManager.getDraftRoot();
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode, null, null, false, null, null);
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, null);
    try {
        pageManager.addPage(pageToAdd);
        WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT);
        assertThat(widgetConfigurationDto, is(nullValue()));
        WidgetConfigurationRequest widgetConfigurationRequest = new WidgetConfigurationRequest();
        widgetConfigurationRequest.setCode("login_form");
        widgetConfigurationRequest.setConfig(null);
        this.pageService.updateWidgetConfiguration(pageCode, 0, widgetConfigurationRequest);
        assertThat(this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT).getCode(), is("login_form"));
    } finally {
        pageManager.deletePage(pageCode);
    }
}
Also used : WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 23 with PageModel

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

the class DataObjectMapperCacheWrapper method searchPublishedDataObjects.

private void searchPublishedDataObjects(DataObjectPageMapper dataObjectPageMapper, 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 dataId = (null != config) ? config.getProperty("dataId") : null;
        if (null != dataId) {
            dataObjectPageMapper.add(dataId, page.getCode());
        }
        String[] childCodes = page.getChildrenCodes();
        for (String childCode : childCodes) {
            IPage child = pageManager.getOnlinePage(childCode);
            if (null != child) {
                this.searchPublishedDataObjects(dataObjectPageMapper, 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 24 with PageModel

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

the class GuiFragmentDtoBuilder method toDto.

@Override
protected GuiFragmentDto toDto(GuiFragment src) {
    if (null == src) {
        return null;
    }
    WidgetType type = null;
    if (StringUtils.isNotEmpty(src.getWidgetTypeCode())) {
        type = this.getWidgetTypeManager().getWidgetType(src.getWidgetTypeCode());
    }
    GuiFragmentDto dest = new GuiFragmentDto(src, type);
    ListableBeanFactory factory = (ListableBeanFactory) this.beanFactory;
    String[] defNames = factory.getBeanNamesForType(GuiFragmentUtilizer.class);
    for (String defName : defNames) {
        GuiFragmentUtilizer utilizers = null;
        try {
            utilizers = this.beanFactory.getBean(defName, GuiFragmentUtilizer.class);
            List<Object> references = utilizers.getGuiFragmentUtilizers(src.getCode());
            if (null != references) {
                for (Object reference : references) {
                    if (reference instanceof GuiFragment) {
                        dest.addFragmentRef((GuiFragment) reference);
                    } else if (reference instanceof PageModel) {
                        dest.addPageModelRef((PageModel) reference);
                    } else {
                        logger.info("unexpected reference - type {}", reference.getClass());
                    }
                }
            }
        } catch (Throwable t) {
            logger.error("Error extracting reference from bean '{}'", defName);
            utilizers = null;
        }
    }
    return dest;
}
Also used : GuiFragmentUtilizer(org.entando.entando.aps.system.services.guifragment.GuiFragmentUtilizer) GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 25 with PageModel

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

the class DataObjectMapperCacheWrapperTest method createMockPageModel.

private PageModel createMockPageModel() {
    PageModel model = new PageModel();
    model.setCode("temp_model");
    Frame frame = new Frame();
    frame.setMainFrame(true);
    frame.setDescription("Main Frame");
    frame.setPos(0);
    Frame[] configuration = new Frame[] { frame };
    model.setConfiguration(configuration);
    model.setMainFrame(0);
    return model;
}
Also used : Frame(com.agiletec.aps.system.services.pagemodel.Frame) 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