Search in sources :

Example 96 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestWidgetTypeManager method testUpdateTitles.

public void testUpdateTitles() throws Throwable {
    String widgetTypeCode = "test_widgetType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo", extracted.getTitles().get("it"));
        assertEquals("Title", extracted.getTitles().get("en"));
        ApsProperties newTitles = new ApsProperties();
        newTitles.put("it", "Titolo modificato");
        newTitles.put("en", "Modified title");
        this._widgetTypeManager.updateWidgetType(widgetTypeCode, newTitles, type.getConfig(), type.getMainGroup());
        extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato", extracted.getTitles().get("it"));
        assertEquals("Modified title", extracted.getTitles().get("en"));
    } 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 97 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 98 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 99 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 100 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ApiServiceAction method extractParametersFromWidgetProperties.

private ApsProperties extractParametersFromWidgetProperties(ApiMethodRelatedWidget relatedWidget, ApsProperties widgetProperties) {
    ApsProperties parameters = new ApsProperties();
    ApsProperties mapping = relatedWidget.getMapping();
    if (null != widgetProperties && null != mapping) {
        Iterator<Object> keyIter = widgetProperties.keySet().iterator();
        while (keyIter.hasNext()) {
            Object key = keyIter.next();
            if (null != mapping.get(key)) {
                parameters.put(mapping.get(key), widgetProperties.get(key));
            }
        }
    }
    return parameters;
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)146 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)34 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)29 HashMap (java.util.HashMap)17 IPage (com.agiletec.aps.system.services.page.IPage)16 Lang (com.agiletec.aps.system.services.lang.Lang)14 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 List (java.util.List)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 Page (com.agiletec.aps.system.services.page.Page)6 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6