Search in sources :

Example 1 with WidgetConfigurationRequest

use of org.entando.entando.web.page.model.WidgetConfigurationRequest in project entando-core by entando.

the class RowContentListViewerConfigProcessor method buildConfiguration.

@SuppressWarnings("unchecked")
@Override
public Object buildConfiguration(WidgetConfigurationRequest widget) {
    ApsProperties properties = new ApsProperties();
    List<RowContentListConfigurationEntry> entryList = (List<RowContentListConfigurationEntry>) widget.getProcessInfo().get(WidgetConfigurationValidator.PROCESS_INFO_CONFIG);
    if (null != entryList && !entryList.isEmpty()) {
        StringBuffer sbuffer = new StringBuffer("[");
        List<String> configTokens = entryList.stream().map(i -> i.toCfg()).collect(Collectors.toList());
        sbuffer.append(StringUtils.join(configTokens, ","));
        sbuffer.append("]");
        properties.put("contents", sbuffer.toString());
    }
    return properties;
}
Also used : Properties(java.util.Properties) IOException(java.io.IOException) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties) WidgetConfigurationProcessor(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationProcessor) RowContentListHelper(org.entando.entando.plugins.jacms.aps.system.services.content.widget.RowContentListHelper) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) List(java.util.List) Map(java.util.Map) WidgetConfigurationValidator(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationValidator) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) JsonParseException(com.fasterxml.jackson.core.JsonParseException) List(java.util.List) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 2 with WidgetConfigurationRequest

use of org.entando.entando.web.page.model.WidgetConfigurationRequest 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 3 with WidgetConfigurationRequest

use of org.entando.entando.web.page.model.WidgetConfigurationRequest in project entando-core by entando.

the class PageServiceWidgetIntegrationTest method testRemovePageWidget.

public void testRemovePageWidget() 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"));
        this.pageService.deleteWidgetConfiguration(pageToAdd.getCode(), 0);
        assertThat(widgetConfigurationDto, is(nullValue()));
    } 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)

Aggregations

WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)3 IPage (com.agiletec.aps.system.services.page.IPage)2 Page (com.agiletec.aps.system.services.page.Page)2 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)2 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)2 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)2 ApsProperties (com.agiletec.aps.util.ApsProperties)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 WidgetConfigurationProcessor (org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationProcessor)1 WidgetConfigurationValidator (org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationValidator)1 RowContentListHelper (org.entando.entando.plugins.jacms.aps.system.services.content.widget.RowContentListHelper)1