use of org.entando.entando.aps.system.services.widgettype.WidgetType 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;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestDataObjectViewerHelper method init.
private void init() throws Exception {
try {
_requestContext = this.getRequestContext();
Lang lang = new Lang();
lang.setCode("it");
lang.setDescr("italiano");
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
Widget widget = new Widget();
IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
widget.setType(showletType);
widget.setConfig(new ApsProperties());
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
this._helper = (IDataObjectViewerHelper) this.getApplicationContext().getBean("DataObjectViewerHelper");
} catch (Throwable t) {
throw new Exception(t);
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestApiWidgetTypeInterface method testDeleteJaxbWidgetType_3.
public void testDeleteJaxbWidgetType_3() throws Throwable {
String code = "jaxb_test_delete_2";
String pageCode = "homepage";
int frame = 5;
assertNull(this._widgetTypeManager.getWidgetType(code));
IPage homepage = this._pageManager.getDraftPage(pageCode);
assertNull(homepage.getWidgets()[frame]);
assertNull(homepage.getWidgets()[frame]);
try {
this.addMockWidget(code);
WidgetType addedWidgetType = this._widgetTypeManager.getWidgetType(code);
assertNotNull(addedWidgetType);
Widget widget = new Widget();
widget.setType(addedWidgetType);
this.setPageWidgets(pageCode, frame, widget);
homepage = this._pageManager.getDraftPage(pageCode);
this.testInvokeDeleteJaxbNoLogicWidgetType(code, false);
this.setPageWidgets(pageCode, frame, null);
this._pageManager.updatePage(homepage);
this.testInvokeDeleteJaxbNoLogicWidgetType(code, true);
} catch (Throwable t) {
this.setPageWidgets(pageCode, frame, null);
throw t;
} finally {
this._widgetTypeManager.deleteWidgetType(code);
assertNull(this._widgetTypeManager.getWidgetType(code));
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestApiWidgetTypeInterface method testInvokeUpdateJaxbNoLogicWidgetType.
private void testInvokeUpdateJaxbNoLogicWidgetType(String widgetTypeCode, ApsProperties titles, boolean removeParametersFromCall, String customSingleGui, boolean expectedSuccess) throws Throwable {
WidgetType widgetType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(widgetType);
WidgetType widgetTypeToEdit = widgetType.clone();
GuiFragment previousFragment = this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode);
ApsProperties originalTitles = widgetType.getTitles();
try {
JAXBWidgetType jaxbWidgetType = this.getJaxbWidgetType(widgetTypeToEdit);
if (StringUtils.isNotBlank(customSingleGui)) {
jaxbWidgetType.setGui(customSingleGui);
}
if (null != titles) {
jaxbWidgetType.setTitles(titles);
}
if (removeParametersFromCall) {
jaxbWidgetType.setTypeParameters(null);
}
this._apiWidgetTypeInterface.updateWidgetType(jaxbWidgetType);
if (!expectedSuccess) {
fail();
}
WidgetType extractedWidgetType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extractedWidgetType);
assertEquals(widgetType.getMainGroup(), extractedWidgetType.getMainGroup());
assertEquals(titles, extractedWidgetType.getTitles());
assertEquals(widgetType.getTypeParameters(), extractedWidgetType.getTypeParameters());
assertEquals(widgetType.isLocked(), extractedWidgetType.isLocked());
if (StringUtils.isNotBlank(customSingleGui) && null == previousFragment) {
assertNotNull(this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode));
}
} catch (ApiException ae) {
if (expectedSuccess) {
fail();
}
} catch (Throwable t) {
throw t;
} finally {
if (null == previousFragment) {
List<String> codes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
if (null != codes) {
for (int i = 0; i < codes.size(); i++) {
String code = codes.get(i);
this._guiFragmentManager.deleteGuiFragment(code);
}
}
} else {
if (null == this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode)) {
this._guiFragmentManager.addGuiFragment(previousFragment);
} else {
this._guiFragmentManager.updateGuiFragment(previousFragment);
}
}
this._widgetTypeManager.updateWidgetType(widgetType.getCode(), originalTitles, widgetType.getConfig(), widgetType.getMainGroup());
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestApiWidgetTypeInterface method testInvokeDeleteJaxbNoLogicWidgetType.
private void testInvokeDeleteJaxbNoLogicWidgetType(String widgetTypeCode, boolean expectedSuccess) throws Throwable {
Properties properties = new Properties();
properties.put(SystemConstants.API_USER_PARAMETER, super.getUser("admin"));
properties.put("code", widgetTypeCode);
WidgetType widgetType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(widgetType);
WidgetType widgetTypeToDelete = widgetType.clone();
GuiFragment previousFragment = this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode);
try {
this._apiWidgetTypeInterface.deleteWidgetType(properties);
if (!expectedSuccess) {
fail();
}
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
assertNull(this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode));
} catch (ApiException ae) {
if (expectedSuccess) {
fail();
}
} catch (Throwable t) {
throw t;
} finally {
if (null != previousFragment && null == this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode)) {
this._guiFragmentManager.addGuiFragment(previousFragment);
}
if (null == this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
this._widgetTypeManager.addWidgetType(widgetTypeToDelete);
}
}
}
Aggregations