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;
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations