Search in sources :

Example 11 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestContentViewerHelper 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 = (IContentViewerHelper) this.getApplicationContext().getBean("jacmsContentViewerHelper");
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 12 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestJaxbPageModel 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;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 13 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageModelDAO 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;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 14 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageModelDAO method testUpdateModel.

public void testUpdateModel() throws Throwable {
    Map<String, PageModel> models = this._pageModelDAO.loadModels();
    String testPageModelCode = "test_pagemodel";
    try {
        assertTrue(!models.containsKey(testPageModelCode));
        PageModel mockModel = this.createMockPageModel(testPageModelCode);
        this._pageModelDAO.addModel(mockModel);
        models = this._pageModelDAO.loadModels();
        PageModel extractedMockModel = models.get(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._pageModelDAO.updateModel(extractedMockModel);
        models = this._pageModelDAO.loadModels();
        extractedMockModel = models.get(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._pageModelDAO.deleteModel(testPageModelCode);
        models = this._pageModelDAO.loadModels();
        assertTrue(!models.containsKey(testPageModelCode));
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 15 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageModelManager method testGetModel.

public void testGetModel() throws Throwable {
    PageModel model = this._pageModelManager.getPageModel("internal");
    assertNotNull(model);
    assertEquals(9, model.getFrames().length);
    Widget[] defaultWidgets = model.getDefaultWidget();
    assertEquals(model.getFrames().length, defaultWidgets.length);
    for (int i = 0; i < defaultWidgets.length; i++) {
        Widget widget = defaultWidgets[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);
        }
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Widget (com.agiletec.aps.system.services.page.Widget)117 ApsProperties (com.agiletec.aps.util.ApsProperties)60 IPage (com.agiletec.aps.system.services.page.IPage)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)20 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 HashMap (java.util.HashMap)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 Page (com.agiletec.aps.system.services.page.Page)7 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)7 ArrayList (java.util.ArrayList)7 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 Properties (java.util.Properties)6 RequestContext (com.agiletec.aps.system.RequestContext)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 JspException (javax.servlet.jsp.JspException)4 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)4 List (java.util.List)3 ServletRequest (javax.servlet.ServletRequest)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3