use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestPageModelManager method testUpdateModel.
public void testUpdateModel() throws Throwable {
String testPageModelCode = "test_pagemodel";
assertNull(this._pageModelManager.getPageModel(testPageModelCode));
try {
PageModel mockModel = this.createMockPageModel(testPageModelCode);
this._pageModelManager.addPageModel(mockModel);
PageModel extractedMockModel = this._pageModelManager.getPageModel(testPageModelCode);
extractedMockModel.setDescription("Modified Description");
Frame[] configuration = extractedMockModel.getConfiguration();
Frame[] newConfiguration = new Frame[4];
for (int i = 0; i < configuration.length; i++) {
newConfiguration[i] = configuration[i];
}
Frame frame3 = new Frame();
frame3.setPos(3);
frame3.setDescription("Freme 3");
Widget defWidg3ToSet = new Widget();
defWidg3ToSet.setType(this._widgetTypeManager.getWidgetType("content_viewer"));
ApsProperties props3 = new ApsProperties();
props3.setProperty("contentId", "ART187");
defWidg3ToSet.setConfig(props3);
frame3.setDefaultWidget(defWidg3ToSet);
newConfiguration[3] = frame3;
extractedMockModel.setConfiguration(newConfiguration);
extractedMockModel.setTemplate("<strong>Modified Freemarker template content</strong>");
this._pageModelManager.updatePageModel(extractedMockModel);
extractedMockModel = this._pageModelManager.getPageModel(testPageModelCode);
assertNotNull(extractedMockModel);
assertEquals(testPageModelCode, extractedMockModel.getCode());
assertEquals("Modified Description", extractedMockModel.getDescription());
assertEquals(4, extractedMockModel.getFrames().length);
Widget[] defaultWidgets = extractedMockModel.getDefaultWidget();
assertEquals(4, defaultWidgets.length);
Widget defWidg0 = defaultWidgets[0];
assertNull(defWidg0);
Widget defWidg1 = defaultWidgets[1];
assertNotNull(defWidg1);
assertEquals("content_viewer_list", defWidg1.getType().getCode());
assertEquals(1, defWidg1.getConfig().size());
assertEquals("ART", defWidg1.getConfig().get("contentType"));
Widget defWidg2 = defaultWidgets[2];
assertNotNull(defWidg2);
assertEquals("login_form", defWidg2.getType().getCode());
assertNull(defWidg2.getConfig());
Widget defWidg3 = defaultWidgets[3];
assertNotNull(defWidg3);
assertEquals("content_viewer", defWidg3.getType().getCode());
assertEquals(1, defWidg3.getConfig().size());
assertEquals("ART187", defWidg3.getConfig().get("contentId"));
assertEquals("<strong>Modified Freemarker template content</strong>", extractedMockModel.getTemplate());
} catch (Exception e) {
throw e;
} finally {
this._pageModelManager.deletePageModel(testPageModelCode);
assertNull(this._pageModelManager.getPageModel(testPageModelCode));
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestPageModelManager method createMockPageModel.
private PageModel createMockPageModel(String code) {
PageModel model = new PageModel();
model.setCode(code);
model.setDescription("Description of model " + code);
Frame frame0 = new Frame();
frame0.setPos(0);
frame0.setDescription("Freme 0");
frame0.setMainFrame(true);
Frame frame1 = new Frame();
frame1.setPos(1);
frame1.setDescription("Freme 1");
Widget defWidg1 = new Widget();
defWidg1.setType(this._widgetTypeManager.getWidgetType("content_viewer_list"));
ApsProperties props1 = new ApsProperties();
props1.setProperty("contentType", "ART");
defWidg1.setConfig(props1);
frame1.setDefaultWidget(defWidg1);
Frame frame2 = new Frame();
frame2.setPos(1);
frame2.setDescription("Freme 2");
Widget defWidg2 = new Widget();
defWidg2.setType(this._widgetTypeManager.getWidgetType("login_form"));
frame2.setDefaultWidget(defWidg2);
Frame[] configuration = { frame0, frame1, frame2 };
model.setConfiguration(configuration);
model.setTemplate("<strong>Freemarker template content</strong>");
return model;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestPageAction method testSavePage_Draft_2.
public void testSavePage_Draft_2() throws Throwable {
String pageCode = "pagina_test";
assertNull(this._pageManager.getDraftPage(pageCode));
try {
IPage root = this._pageManager.getDraftRoot();
Map<String, String> params = new HashMap<String, String>();
params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
params.put("parentPageCode", root.getCode());
params.put("langit", "Pagina Test 2");
params.put("langen", "Test Page 2");
params.put("model", "internal");
params.put("group", Group.FREE_GROUP_NAME);
params.put("pageCode", pageCode);
String result = this.executeSave(params, "admin");
assertEquals(Action.SUCCESS, result);
IPage addedPage = this._pageManager.getDraftPage(pageCode);
this.executeSetDefaultWidgets(params, "admin");
assertNotNull(addedPage);
assertEquals("Pagina Test 2", addedPage.getMetadata().getTitles().getProperty("it"));
Widget[] showlets = addedPage.getWidgets();
assertEquals(addedPage.getMetadata().getModel().getFrames().length, showlets.length);
for (int i = 0; i < showlets.length; i++) {
Widget widget = showlets[i];
if (i == 3) {
assertNotNull(widget);
WidgetType type = widget.getType();
assertEquals("leftmenu", type.getCode());
assertEquals(1, type.getTypeParameters().size());
assertNull(type.getConfig());
ApsProperties config = widget.getConfig();
assertEquals(1, config.size());
assertEquals("code(homepage).subtree(1)", config.getProperty("navSpec"));
} else {
assertNull(widget);
}
}
} catch (Throwable t) {
throw t;
} finally {
this._pageManager.deletePage(pageCode);
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestPageAction method testEditForCoachUser.
public void testEditForCoachUser() throws Throwable {
String selectedPageCode = this._pageManager.getDraftRoot().getCode();
String result = this.executeActionOnPage(selectedPageCode, "pageManagerCoach", "edit");
assertEquals("pageTree", result);
// PAGINA
IPage customers_page = this._pageManager.getDraftPage("customers_page");
// NON
// PREDISPOSTA
// PER
// LA
// PUBBLICAZIONE
// VOLANTE...
result = this.executeActionOnPage(customers_page.getCode(), "pageManagerCustomers", "edit");
assertEquals(Action.SUCCESS, result);
PageAction action = (PageAction) this.getAction();
assertEquals(action.getStrutsAction(), ApsAdminSystemConstants.EDIT);
assertEquals(customers_page.getCode(), action.getPageCode());
assertEquals(customers_page.getModel().getCode(), action.getModel());
assertTrue(action.isShowable());
assertTrue(action.isGroupSelectLock());
Widget widget = customers_page.getWidgets()[customers_page.getModel().getMainFrame()];
if (null != widget) {
assertEquals("content_viewer", widget.getType().getCode());
assertTrue(null != widget.getConfig() && !widget.getConfig().isEmpty());
}
}
use of com.agiletec.aps.system.services.page.Widget 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;
}
Aggregations