Search in sources :

Example 56 with WidgetType

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

the class TestWidgetTypeManager method testGetWidgetTypes.

public void testGetWidgetTypes() throws ApsSystemException {
    List<WidgetType> list = _widgetTypeManager.getWidgetTypes();
    Iterator<WidgetType> iter = list.iterator();
    Map<String, String> widgetTypes = new HashMap<String, String>();
    while (iter.hasNext()) {
        WidgetType widgetType = iter.next();
        widgetTypes.put(widgetType.getCode(), widgetType.getTitles().getProperty("it"));
    }
    boolean containsKey = widgetTypes.containsKey("content_viewer_list");
    boolean containsValue = widgetTypes.containsValue("Contenuti - Pubblica una Lista di Contenuti");
    assertTrue(containsKey);
    assertTrue(containsValue);
    containsKey = widgetTypes.containsKey("content_viewer");
    containsValue = widgetTypes.containsValue("Contenuti - Pubblica un Contenuto");
    assertTrue(containsKey);
    assertTrue(containsValue);
}
Also used : HashMap(java.util.HashMap) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 57 with WidgetType

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

the class TestWidgetTypeManager method testUpdate.

public void testUpdate() throws Throwable {
    String widgetTypeCode = "test_showletType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("content_viewer", extracted.getParentType().getCode());
        assertEquals("ART112", extracted.getConfig().get("contentId"));
        ApsProperties newProperties = new ApsProperties();
        this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
        extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertNotNull(extracted.getConfig());
        assertEquals(0, extracted.getConfig().size());
        newProperties.put("contentId", "EVN103");
        this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
        extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("EVN103", extracted.getConfig().get("contentId"));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
        }
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 58 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType 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 59 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType 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 60 with WidgetType

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

the class TestWidgetTypeAction method createNewWidgetType.

private WidgetType createNewWidgetType(String code) {
    WidgetType type = new WidgetType();
    type.setCode(code);
    ApsProperties titles = new ApsProperties();
    titles.put("it", "Titolo");
    titles.put("en", "Title");
    type.setTitles(titles);
    return type;
}
Also used : 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