use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeManager method testGetWidgetTypes.
public void testGetWidgetTypes() throws ApsSystemException {
List<WidgetType> list = _widgetTypeManager.getWidgetTypes();
Iterator<WidgetType> iter = list.iterator();
Map<String, String> widgetTypes = new HashMap<String, String>();
while (iter.hasNext()) {
WidgetType widgetType = iter.next();
widgetTypes.put(widgetType.getCode(), widgetType.getTitles().getProperty("it"));
}
boolean containsKey = widgetTypes.containsKey("content_viewer_list");
boolean containsValue = widgetTypes.containsValue("Contenuti - Pubblica una Lista di Contenuti");
assertTrue(containsKey);
assertTrue(containsValue);
containsKey = widgetTypes.containsKey("content_viewer");
containsValue = widgetTypes.containsValue("Contenuti - Pubblica un Contenuto");
assertTrue(containsKey);
assertTrue(containsValue);
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeManager method testUpdate.
public void testUpdate() throws Throwable {
String widgetTypeCode = "test_showletType";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
try {
WidgetType type = this.createNewWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("content_viewer", extracted.getParentType().getCode());
assertEquals("ART112", extracted.getConfig().get("contentId"));
ApsProperties newProperties = new ApsProperties();
this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertNotNull(extracted.getConfig());
assertEquals(0, extracted.getConfig().size());
newProperties.put("contentId", "EVN103");
this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("EVN103", extracted.getConfig().get("contentId"));
} catch (Throwable t) {
throw t;
} finally {
if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ContentMapperCacheWrapperTest method createMockWidget.
private Widget createMockWidget() {
Widget widget = new Widget();
WidgetType type = new WidgetType();
type.setCode("type");
WidgetTypeParameter param1 = new WidgetTypeParameter();
param1.setName("contentId");
WidgetTypeParameter param2 = new WidgetTypeParameter();
param2.setName("testParam");
List<WidgetTypeParameter> params = Arrays.asList(new WidgetTypeParameter[] { param1, param2 });
type.setTypeParameters(params);
widget.setType(type);
ApsProperties props = new ApsProperties();
props.put("contentId", "ART1");
props.put("testParam", "test");
widget.setConfig(props);
return widget;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiServiceAction method copyFromWidget.
/**
* Copy an exist widget (physic and with parameters, joined with a exist api
* method) and value the form of creation of new api service.
*
* @return The result code.
*/
public String copyFromWidget() {
try {
String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
if (null != check) {
return check;
}
ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
// TODO Verify if DRAFT/ONLINE
IPage page = this.getPageManager().getOnlinePage(this.getPageCode());
if (null == page) {
this.addFieldError("pageCode", this.getText("error.service.paste.invalidPageCode", new String[] { this.getPageCode() }));
return INPUT;
}
Widget[] widgets = page.getWidgets();
if (null == this.getFramePos() || this.getFramePos() > widgets.length || null == widgets[this.getFramePos()]) {
String framePosString = (null != this.getFramePos()) ? this.getFramePos().toString() : "null";
this.addFieldError("framePos", this.getText("error.service.paste.invalidFramePos", new String[] { this.getPageCode(), framePosString }));
return INPUT;
}
Widget masterWidget = widgets[this.getFramePos()];
WidgetType type = (masterWidget.getType().isLogic()) ? masterWidget.getType().getParentType() : masterWidget.getType();
if (null == masterMethod.getRelatedWidget() || !masterMethod.getRelatedWidget().getWidgetCode().equals(type.getCode())) {
this.addFieldError("framePos", this.getText("error.service.paste.invalidWidget", new String[] { masterWidget.getType().getCode(), masterMethod.getResourceName() }));
return INPUT;
}
ApsProperties parameters = this.extractParametersFromWidget(masterMethod.getRelatedWidget(), masterWidget);
this.setApiParameterValues(parameters);
this.setApiParameters(masterMethod.getParameters());
this.setStrutsAction(ApsAdminSystemConstants.PASTE);
this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
} catch (Throwable t) {
_logger.error("error in copyFromWidget", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction 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);
return type;
}
Aggregations