Search in sources :

Example 16 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testFailureTrashType_2.

public void testFailureTrashType_2() throws Throwable {
    String widgetTypeCode = "test_widgetType_trash2";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        type.setLocked(true);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executeTrash(widgetTypeCode, "admin");
        assertEquals("inputWidgetTypes", result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getActionErrors().size());
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) ActionSupport(com.opensymphony.xwork2.ActionSupport) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 17 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testPasteNewUserWidgetType_1.

public void testPasteNewUserWidgetType_1() throws Throwable {
    String widgetTypeCode = "randomShowletCode_1";
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executePasteUserWidgetType("admin", widgetTypeCode, "en", "it", "customers_page", "2");
        assertEquals(Action.SUCCESS, result);
        Widget copiedWidget = this._pageManager.getDraftPage("customers_page").getWidgets()[2];
        assertNotNull(copiedWidget);
        assertNotNull(copiedWidget.getConfig());
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        ApsProperties config = addedType.getConfig();
        Iterator<Object> keysIter = config.keySet().iterator();
        while (keysIter.hasNext()) {
            String key = (String) keysIter.next();
            assertEquals(copiedWidget.getConfig().getProperty(key), config.getProperty(key));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
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)

Example 18 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testUpdate_3.

public void testUpdate_3() throws Throwable {
    String widgetTypeCode = "test_widgetType_Upd3";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        ApsProperties newProperties = new ApsProperties();
        newProperties.put("contentId", "EVN191");
        String result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", newProperties, "**GUI**");
        assertEquals(Action.SUCCESS, result);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato", extracted.getTitles().get("it"));
        assertEquals("Modified title", extracted.getTitles().get("en"));
        assertEquals("EVN191", extracted.getConfig().getProperty("contentId"));
        newProperties.put("contentId", "EVN194");
        result = this.executeUpdate(widgetTypeCode, "Titolo modificato 2", "Modified title 2", "pageManagerCoach", newProperties, "*GUI*");
        assertEquals(Action.SUCCESS, result);
        extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato 2", extracted.getTitles().get("it"));
        assertEquals("Modified title 2", extracted.getTitles().get("en"));
        assertEquals("EVN191", extracted.getConfig().getProperty("contentId"));
    } catch (Throwable t) {
        throw t;
    } finally {
        this.cleanDatabase(widgetTypeCode);
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 19 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testUpdate_1.

public void testUpdate_1() throws Throwable {
    String widgetTypeCode = "test_widgetType_Upd1";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    List<String> fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
    assertEquals(0, fragmentCodes.size());
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        String result = this.executeUpdate(widgetTypeCode, "", "english title", "admin", null);
        assertEquals(Action.INPUT, result);
        fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
        assertEquals(0, fragmentCodes.size());
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", null);
        assertEquals(Action.SUCCESS, result);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato", extracted.getTitles().get("it"));
        assertEquals("Modified title", extracted.getTitles().get("en"));
        fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
        assertEquals(0, fragmentCodes.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.cleanDatabase(widgetTypeCode);
    }
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 20 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class PageModelDOM method buildDefaultWidget.

private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
    Widget widget = new Widget();
    String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
    WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
    if (null == type) {
        _logger.error("Unknown code of the default widget - '{}'", widgetCode);
        return;
    }
    widget.setType(type);
    Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
    if (null != propertiesElement) {
        ApsProperties prop = this.buildProperties(propertiesElement);
        widget.setConfig(prop);
    }
    // else {
    // widget.setConfig(new ApsProperties());
    // }
    frame.setDefaultWidget(widget);
}
Also used : Element(org.jdom.Element) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)70 ApsProperties (com.agiletec.aps.util.ApsProperties)33 Widget (com.agiletec.aps.system.services.page.Widget)20 IPage (com.agiletec.aps.system.services.page.IPage)11 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)10 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 IManager (com.agiletec.aps.system.common.IManager)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 List (java.util.List)3 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)3 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 SelectItem (com.agiletec.aps.util.SelectItem)2 Properties (java.util.Properties)2 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2