Search in sources :

Example 46 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class GuiFragmentDtoSmallBuilder method toDto.

@Override
protected GuiFragmentDtoSmall toDto(GuiFragment src) {
    if (null == src) {
        return null;
    }
    WidgetType type = null;
    if (StringUtils.isNotEmpty(src.getWidgetTypeCode())) {
        type = this.getWidgetTypeManager().getWidgetType(src.getWidgetTypeCode());
    }
    GuiFragmentDtoSmall dest = new GuiFragmentDtoSmall(src, type);
    return dest;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 47 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class PageService method updateWidgetConfiguration.

@Override
public WidgetConfigurationDto updateWidgetConfiguration(String pageCode, int frameId, WidgetConfigurationRequest widgetReq) {
    try {
        IPage page = this.loadPage(pageCode, STATUS_DRAFT);
        if (null == page) {
            throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
        }
        if (frameId > page.getWidgets().length) {
            throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
        }
        if (null == this.getWidgetType(widgetReq.getCode())) {
            throw new RestRourceNotFoundException(ERRCODE_WIDGET_INVALID, "widget", String.valueOf(widgetReq.getCode()));
        }
        BeanPropertyBindingResult validation = this.getWidgetValidatorFactory().get(widgetReq.getCode()).validate(widgetReq, page);
        if (null != validation && validation.hasErrors()) {
            throw new ValidationConflictException(validation);
        }
        ApsProperties properties = (ApsProperties) this.getWidgetProcessorFactory().get(widgetReq.getCode()).buildConfiguration(widgetReq);
        WidgetType widgetType = this.getWidgetType(widgetReq.getCode());
        Widget widget = new Widget();
        widget.setType(widgetType);
        widget.setConfig(properties);
        this.getPageManager().joinWidget(pageCode, widget, frameId);
        ApsProperties outProperties = this.getWidgetProcessorFactory().get(widgetReq.getCode()).extractConfiguration(widget.getConfig());
        return new WidgetConfigurationDto(widget.getType().getCode(), outProperties);
    } catch (ApsSystemException e) {
        logger.error("Error in update widget configuration {}", pageCode, e);
        throw new RestServerError("error in update widget configuration", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) IPage(com.agiletec.aps.system.services.page.IPage) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 48 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class PageTestUtil method createWidget.

public static Widget createWidget(String widgetCode, ApsProperties config, IWidgetTypeManager widgetTypeManager) {
    Widget widget = new Widget();
    widget.setConfig(config);
    WidgetType widgetType = widgetTypeManager.getWidgetType(widgetCode);
    widget.setType(widgetType);
    return widget;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 49 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeDAO method testLoadWidgetTypes.

public void testLoadWidgetTypes() throws Throwable {
    DataSource dataSource = (DataSource) this.getApplicationContext().getBean("portDataSource");
    WidgetTypeDAO widgetTypeDao = new WidgetTypeDAO();
    widgetTypeDao.setDataSource(dataSource);
    ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
    widgetTypeDao.setLangManager(langManager);
    Map<String, WidgetType> types = null;
    try {
        types = widgetTypeDao.loadWidgetTypes();
    } catch (Throwable t) {
        throw t;
    }
    WidgetType showletType = (WidgetType) types.get("content_viewer");
    assertNotNull(showletType);
    showletType = (WidgetType) types.get("content_viewer_list");
    assertNotNull(showletType);
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) WidgetTypeDAO(org.entando.entando.aps.system.services.widgettype.WidgetTypeDAO) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) DataSource(javax.sql.DataSource)

Example 50 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method createNewWidgetType.

private WidgetType createNewWidgetType(String code) {
    WidgetType type = new WidgetType();
    type.setCode(code);
    ApsProperties titles = new ApsProperties();
    titles.put("it", "Titolo");
    titles.put("en", "Title");
    type.setTitles(titles);
    WidgetType parent = this._widgetTypeManager.getWidgetType("content_viewer");
    assertNotNull(parent);
    type.setParentType(parent);
    type.setPluginCode("jacms");
    ApsProperties config = new ApsProperties();
    config.put("contentId", "ART112");
    type.setConfig(config);
    return type;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)70 ApsProperties (com.agiletec.aps.util.ApsProperties)33 Widget (com.agiletec.aps.system.services.page.Widget)20 IPage (com.agiletec.aps.system.services.page.IPage)11 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)10 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 IManager (com.agiletec.aps.system.common.IManager)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 List (java.util.List)3 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)3 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 SelectItem (com.agiletec.aps.util.SelectItem)2 Properties (java.util.Properties)2 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2