Search in sources :

Example 66 with Widget

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

the class TestPageModelManager method testAddRemoveModel.

public void testAddRemoveModel() 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);
        assertNotNull(extractedMockModel);
        assertEquals(testPageModelCode, extractedMockModel.getCode());
        assertTrue(extractedMockModel.getDescription().contains(testPageModelCode));
        assertEquals(3, extractedMockModel.getFrames().length);
        Widget[] defaultWidgets = extractedMockModel.getDefaultWidget();
        assertEquals(3, 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());
        assertEquals("<strong>Freemarker template content</strong>", extractedMockModel.getTemplate());
    } catch (Exception e) {
        throw e;
    } finally {
        this._pageModelManager.deletePageModel(testPageModelCode);
        assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 67 with Widget

use of com.agiletec.aps.system.services.page.Widget 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;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 68 with Widget

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

the class ContentMapperCacheWrapperTest method createMockPage.

private IPage createMockPage() {
    Page root = new Page();
    root.setCode("root_code");
    root.setModel(this.createMockPageModel());
    root.setGroup(Group.FREE_GROUP_NAME);
    Widget[] widgets = new Widget[] { this.createMockWidget() };
    root.setWidgets(widgets);
    root.setChildrenCodes(new String[] {});
    return root;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage)

Example 69 with Widget

use of com.agiletec.aps.system.services.page.Widget 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;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) Widget(com.agiletec.aps.system.services.page.Widget) ApiMethodRelatedWidget(org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 70 with Widget

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

the class TestPageAction method addPage.

private void addPage(String pageCode) throws ApsSystemException {
    IPage parentPage = _pageManager.getOnlinePage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, "pagina temporanea", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("tempKey", "tempValue", "contentId", "ART1");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this._widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
    this._pageManager.addPage(pageToAdd);
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) 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