Search in sources :

Example 26 with ApsProperties

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

the class TestApiWidgetTypeInterface method testUpdateJaxbWidgetType.

public void testUpdateJaxbWidgetType() throws Throwable {
    ApsProperties titles = new ApsProperties();
    titles.setProperty("en", "English title");
    titles.setProperty("it", "Italian title");
    this.testInvokeUpdateJaxbNoLogicWidgetType("login_form", titles, true, null, true);
    this.testInvokeUpdateJaxbNoLogicWidgetType("login_form", titles, true, "Gui of login_form", true);
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 27 with ApsProperties

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

the class TestApiWidgetTypeInterface method addMockWidget.

private void addMockWidget(String widgetTypeCode) throws Throwable {
    WidgetType type = new WidgetType();
    type.setCode(widgetTypeCode);
    ApsProperties titles = new ApsProperties();
    titles.setProperty("en", "English title");
    titles.setProperty("it", "Italian title");
    type.setTitles(titles);
    this._widgetTypeManager.addWidgetType(type);
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 28 with ApsProperties

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

the class JAXBWidgetType method getNewWidgetType.

public WidgetType getNewWidgetType(IWidgetTypeManager widgetTypeManager) {
    WidgetType type = new WidgetType();
    type.setCode(this.getCode());
    type.setTitles(this.getTitles());
    List<WidgetTypeParameter> parameters = this.getTypeParameters();
    if (null != parameters && !parameters.isEmpty()) {
        type.setTypeParameters(parameters);
        type.setAction("configSimpleParameter");
    } else {
        ApsProperties configuration = this.getConfig();
        String parentTypeCode = this.getParentTypeCode();
        if (null != parentTypeCode && null != configuration && !configuration.isEmpty()) {
            WidgetType parentType = widgetTypeManager.getWidgetType(parentTypeCode);
            type.setParentType(parentType);
            type.setConfig(configuration);
        }
    }
    type.setMainGroup(this.getMainGroup());
    // type.setLocked(this.isLocked());
    type.setPluginCode(this.getPluginCode());
    return type;
}
Also used : 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 29 with ApsProperties

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

the class WidgetTypeDAO method createWidgetTypeFromResultSet.

protected WidgetType createWidgetTypeFromResultSet(ResultSet res) throws ApsSystemException {
    WidgetType widgetType = new WidgetType();
    String code = null;
    try {
        code = res.getString(1);
        widgetType.setCode(code);
        String xmlTitles = res.getString(2);
        ApsProperties titles = new ApsProperties();
        titles.loadFromXml(xmlTitles);
        widgetType.setTitles(titles);
        String xml = res.getString(3);
        if (null != xml && xml.trim().length() > 0) {
            WidgetTypeDOM showletTypeDom = new WidgetTypeDOM(xml, this.getLangManager().getLangs());
            widgetType.setTypeParameters(showletTypeDom.getParameters());
            widgetType.setAction(showletTypeDom.getAction());
        }
        widgetType.setPluginCode(res.getString(4));
        widgetType.setParentTypeCode(res.getString(5));
        String config = res.getString(6);
        if (null != config && config.trim().length() > 0) {
            ApsProperties defaultConfig = new ApsProperties();
            defaultConfig.loadFromXml(config);
            widgetType.setConfig(defaultConfig);
        }
        if ((null != widgetType.getConfig() && null == widgetType.getParentTypeCode())) {
            throw new ApsSystemException("Default configuration found in the type '" + code + "' with no parent type assigned");
        }
        int isLocked = res.getInt(7);
        widgetType.setLocked(isLocked == 1);
        String mainGroup = res.getString(8);
        if (null != mainGroup && mainGroup.trim().length() > 0) {
            widgetType.setMainGroup(mainGroup.trim());
        }
        String configUi = res.getString(9);
        if (StringUtils.isNotEmpty(configUi)) {
            widgetType.setConfigUi(configUi);
        }
        String bundleId = res.getString(10);
        if (StringUtils.isNotEmpty(bundleId)) {
            widgetType.setBundleId(bundleId);
        }
    } catch (Throwable t) {
        logger.error("Error parsing the Widget Type '{}'", code, t);
        throw new ApsSystemException("Error in the parsing in the Widget Type '" + code + "'", t);
    }
    return widgetType;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 30 with ApsProperties

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

the class WidgetTypeAction method extractWidgetTypeConfig.

private ApsProperties extractWidgetTypeConfig(List<WidgetTypeParameter> parameters) throws Exception {
    ApsProperties config = new ApsProperties();
    for (int i = 0; i < parameters.size(); i++) {
        WidgetTypeParameter param = parameters.get(i);
        String paramName = param.getName();
        String value = this.getRequest().getParameter(paramName);
        if (value != null && value.trim().length() > 0) {
            config.setProperty(paramName, value);
        }
    }
    return config;
}
Also used : WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)157 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)35 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)28 HashMap (java.util.HashMap)22 IPage (com.agiletec.aps.system.services.page.IPage)18 Lang (com.agiletec.aps.system.services.lang.Lang)14 Test (org.junit.Test)12 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 Page (com.agiletec.aps.system.services.page.Page)8 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)8 List (java.util.List)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)5