use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class TestPageManager method testPageStatus.
public void testPageStatus() throws ApsSystemException {
String testCode = "testcode";
try {
PagesStatus status = this._pageManager.getPagesStatus();
IPage parentPage = _pageManager.getDraftRoot();
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, "pagina temporanea", null, null, false, null, null);
PageMetadata draftMeta = metadata;
Page pageToAdd = PageTestUtil.createPage(testCode, parentPage, "free", draftMeta, null);
_pageManager.addPage(pageToAdd);
PagesStatus newStatus = this._pageManager.getPagesStatus();
assertEquals(newStatus.getOnline(), status.getOnline());
assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges());
assertEquals(newStatus.getDraft(), status.getDraft() + 1);
assertEquals(newStatus.getTotal(), status.getTotal() + 1);
this._pageManager.setPageOnline(testCode);
newStatus = this._pageManager.getPagesStatus();
assertEquals(newStatus.getOnline(), status.getOnline() + 1);
assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges());
assertEquals(newStatus.getDraft(), status.getDraft());
assertEquals(newStatus.getTotal(), status.getTotal() + 1);
IPage test = this._pageManager.getDraftPage(testCode);
test.getMetadata().setTitle("it", "modxxxx");
this._pageManager.updatePage(test);
test = this._pageManager.getDraftPage(testCode);
newStatus = this._pageManager.getPagesStatus();
assertEquals(newStatus.getOnline(), status.getOnline());
assertEquals(newStatus.getOnlineWithChanges(), status.getOnlineWithChanges() + 1);
assertEquals(newStatus.getDraft(), status.getDraft());
assertEquals(newStatus.getTotal(), status.getTotal() + 1);
} finally {
this._pageManager.deletePage(testCode);
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class TestPageManager method checkAddPage.
public void checkAddPage() throws Throwable {
IPage parentPage = _pageManager.getDraftPage("service");
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, "pagina temporanea", null, null, false, null, null);
ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this._widgetTypeManager);
Widget[] widgets = { widgetToAdd };
Page pageToAdd = PageTestUtil.createPage("temp", parentPage, "free", metadata, widgets);
_pageManager.addPage(pageToAdd);
IPage addedPage = _pageManager.getDraftPage("temp");
assertEquals(addedPage, _pageManager.getDraftPage(addedPage.getCode()));
PageTestUtil.comparePages(pageToAdd, addedPage, false);
PageTestUtil.comparePageMetadata(pageToAdd.getMetadata(), addedPage.getMetadata(), 0);
assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
parentPage = _pageManager.getDraftPage("service");
pageToAdd.setParent(parentPage);
pageToAdd.setCode("temp1");
_pageManager.addPage(pageToAdd);
addedPage = _pageManager.getDraftPage("temp1");
assertEquals(addedPage, _pageManager.getDraftPage(addedPage.getCode()));
PageTestUtil.comparePages(pageToAdd, addedPage, false);
PageTestUtil.comparePageMetadata(pageToAdd.getMetadata(), addedPage.getMetadata(), 0);
assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
parentPage = _pageManager.getDraftPage("service");
pageToAdd.setParent(parentPage);
pageToAdd.setCode("temp2");
_pageManager.addPage(pageToAdd);
addedPage = _pageManager.getDraftPage("temp2");
assertNotNull(_pageManager.getDraftPage(addedPage.getCode()));
assertNotNull(pageToAdd.getMetadata());
assertEquals(widgetToAdd, addedPage.getWidgets()[0]);
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class ContentMapperCacheWrapper method searchPublishedDataObjects.
private void searchPublishedDataObjects(ContentPageMapper contentPageMapper, IPage page, IPageManager pageManager) {
PageModel pageModel = page.getModel();
if (pageModel != null) {
int mainFrame = pageModel.getMainFrame();
Widget[] widgets = page.getWidgets();
Widget widget = null;
if (null != widgets && mainFrame != -1) {
widget = widgets[mainFrame];
}
ApsProperties config = (null != widget) ? widget.getConfig() : null;
String contentId = (null != config) ? config.getProperty("contentId") : null;
if (null != contentId) {
contentPageMapper.add(contentId, page.getCode());
}
String[] childCodes = page.getChildrenCodes();
for (String childCode : childCodes) {
IPage child = pageManager.getOnlinePage(childCode);
if (null != child) {
this.searchPublishedDataObjects(contentPageMapper, child, pageManager);
}
}
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class AbstractTestPageModelAction method createMockPageModel.
protected 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.pagemodel.PageModel in project entando-core by entando.
the class TestPageModelAction method testSave.
public void testSave() throws Throwable {
String testPageModelCode = "test_pagemodel";
assertNull(this._pageModelManager.getPageModel(testPageModelCode));
try {
PageModel mockModel = this.createMockPageModel(testPageModelCode);
this.setUserOnSession("admin");
this.initAction("/do/PageModel", "save");
super.addParameter("code", mockModel.getCode());
super.addParameter("description", mockModel.getDescription());
super.addParameter("template", mockModel.getTemplate());
PageModelDOM dom = new PageModelDOM(mockModel);
super.addParameter("xmlConfiguration", dom.getXMLDocument());
super.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
assertNotNull(this._pageModelManager.getPageModel(testPageModelCode));
} catch (Exception e) {
throw e;
} finally {
this._pageModelManager.deletePageModel(testPageModelCode);
assertNull(this._pageModelManager.getPageModel(testPageModelCode));
}
}
Aggregations