Search in sources :

Example 6 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ContentListHelper method extractContentsId.

protected List<String> extractContentsId(IContentListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
    List<String> contentsId = null;
    try {
        List<UserFilterOptionBean> userFilters = bean.getUserFilterOptions();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        if (null == bean.getContentType() && null != config) {
            bean.setContentType(config.getProperty(WIDGET_PARAM_CONTENT_TYPE));
        }
        if (null == bean.getContentType()) {
            throw new ApsSystemException("Tipo contenuto non definito");
        }
        if (null == bean.getCategory() && null != config && null != config.getProperty(SHOWLET_PARAM_CATEGORY)) {
            bean.setCategory(config.getProperty(SHOWLET_PARAM_CATEGORY));
        }
        this.addWidgetFilters(bean, config, WIDGET_PARAM_FILTERS, reqCtx);
        if (null != userFilters && userFilters.size() > 0) {
            for (UserFilterOptionBean userFilter : userFilters) {
                EntitySearchFilter filter = userFilter.getEntityFilter();
                if (null != filter) {
                    bean.addFilter(filter);
                }
            }
        }
        String[] categories = this.getCategories(bean.getCategories(), config, userFilters);
        Collection<String> userGroupCodes = this.getAllowedGroups(reqCtx);
        boolean orCategoryFilterClause = this.extractOrCategoryFilterClause(config);
        contentsId = this.getContentManager().loadPublicContentsId(bean.getContentType(), categories, orCategoryFilterClause, bean.getFilters(), userGroupCodes);
    } catch (Throwable t) {
        _logger.error("Error extracting contents id", t);
        throw new ApsSystemException("Error extracting contents id", t);
    }
    return contentsId;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 7 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 8 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestContentListViewerWidgetAction method testInitConfigListViewer_2.

public void testInitConfigListViewer_2() throws Throwable {
    String result = this.executeConfigListViewer("admin", "homepage", "0", null);
    assertEquals(Action.SUCCESS, result);
    ContentListViewerWidgetAction action = (ContentListViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    assertEquals("content_viewer_list", widget.getType().getCode());
    ApsProperties props = widget.getConfig();
    assertEquals(4, props.size());
    assertEquals("NEW", props.getProperty("contentType"));
    assertEquals("5", props.getProperty("maxElemForItem"));
    assertEquals("11", props.getProperty("modelId"));
    assertEquals("(order=DESC;attributeFilter=true;likeOption=false;key=Date)+(order=ASC;attributeFilter=true;likeOption=false;key=Title)", props.getProperty("filters"));
    List<Properties> filtersProperties = action.getFiltersProperties();
    assertEquals(2, filtersProperties.size());
    Properties firstFilter = filtersProperties.get(0);
    assertEquals("DESC", firstFilter.getProperty(EntitySearchFilter.ORDER_PARAM));
    assertEquals("true", firstFilter.getProperty(EntitySearchFilter.FILTER_TYPE_PARAM));
    assertEquals("false", firstFilter.getProperty(EntitySearchFilter.LIKE_OPTION_PARAM));
    assertEquals("Date", firstFilter.getProperty(EntitySearchFilter.KEY_PARAM));
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 9 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestContentListViewerWidgetAction method testFailureConfigContentType_2.

public void testFailureConfigContentType_2() throws Throwable {
    // Tipo contenuto inesistente
    String result = this.executeConfigContentType("admin", "homepage", "1", "content_viewer_list", "WRO");
    assertEquals(Action.INPUT, result);
    ContentListViewerWidgetAction action = (ContentListViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(0, props.size());
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 10 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestContentViewerWidgetAction method testInitConfigViewer_2.

public void testInitConfigViewer_2() throws Throwable {
    String result = this.executeConfigViewer("admin", "homepage", "2", null);
    assertEquals(Action.SUCCESS, result);
    ContentViewerWidgetAction action = (ContentViewerWidgetAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    ApsProperties props = widget.getConfig();
    assertEquals(2, props.size());
    assertEquals("ART1", props.getProperty("contentId"));
    assertEquals("2", props.getProperty("modelId"));
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)157 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)35 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)28 HashMap (java.util.HashMap)22 IPage (com.agiletec.aps.system.services.page.IPage)18 Lang (com.agiletec.aps.system.services.lang.Lang)14 Test (org.junit.Test)12 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 Page (com.agiletec.aps.system.services.page.Page)8 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)8 List (java.util.List)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)5