Search in sources :

Example 1 with WidgetTypeParameter

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

use of org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter 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)

Example 3 with WidgetTypeParameter

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

the class DataObjectMapperCacheWrapperTest method createMockWidget.

private Widget createMockWidget() {
    Widget widget = new Widget();
    WidgetType type = new WidgetType();
    type.setCode("type");
    WidgetTypeParameter param1 = new WidgetTypeParameter();
    param1.setName("dataId");
    WidgetTypeParameter param2 = new WidgetTypeParameter();
    param2.setName("testParam");
    List<WidgetTypeParameter> params = Arrays.asList(param1, param2);
    type.setTypeParameters(params);
    widget.setType(type);
    ApsProperties props = new ApsProperties();
    props.put("dataId", "id1");
    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 4 with WidgetTypeParameter

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

the class TestWidgetTypeDOM method testParseConfig.

public void testParseConfig() throws ApsSystemException {
    String framesXml = "<config>" + "<parameter name=\"contentType\">" + "Tipo di contenuto (obbligatorio)" + "</parameter>" + "<parameter name=\"modelId\">" + "Modello di contenuto (obbligatorio)" + "</parameter>" + "<parameter name=\"filters\" />" + "<action name=\"listViewerConfig\"/>" + "</config>";
    WidgetTypeDOM showletTypeDOM = new WidgetTypeDOM(framesXml);
    String action = showletTypeDOM.getAction();
    assertTrue(action.equals("listViewerConfig"));
    List<WidgetTypeParameter> params = showletTypeDOM.getParameters();
    assertEquals(3, params.size());
}
Also used : WidgetTypeDOM(org.entando.entando.aps.system.services.widgettype.WidgetTypeDOM) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 5 with WidgetTypeParameter

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

the class PageUtils method isFreeViewerPage.

/**
 * Check whether the page can publish free content, related to the model and
 * the widgets of the page.
 *
 * @param model The model of the page to check.
 * @param widgets The widgets of the page to check.
 * @param viewerWidgetCode The code of the viewer widget (optional)
 * @return True if the page can publish free content, false else.
 */
public static boolean isFreeViewerPage(PageModel model, Widget[] widgets, String viewerWidgetCode) {
    try {
        if (model != null && widgets != null) {
            int mainFrame = model.getMainFrame();
            if (mainFrame < 0) {
                return false;
            }
            Widget viewer = widgets[mainFrame];
            if (null == viewer) {
                return false;
            }
            boolean isRightCode = null == viewerWidgetCode || viewer.getType().getCode().equals(viewerWidgetCode);
            String actionName = viewer.getType().getAction();
            boolean isRightAction = (null != actionName && actionName.toLowerCase().indexOf("viewer") >= 0);
            List<WidgetTypeParameter> typeParameters = viewer.getType().getTypeParameters();
            if ((isRightCode || isRightAction) && (null != typeParameters && !typeParameters.isEmpty()) && (null == viewer.getConfig() || viewer.getConfig().isEmpty())) {
                return true;
            }
        }
    } catch (Throwable t) {
        logger.error("Error while checking page for widget '{}'", viewerWidgetCode, t);
    }
    return false;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Aggregations

WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)12 Widget (com.agiletec.aps.system.services.page.Widget)5 ApsProperties (com.agiletec.aps.util.ApsProperties)5 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)5 WidgetTypeDOM (org.entando.entando.aps.system.services.widgettype.WidgetTypeDOM)2 IPage (com.agiletec.aps.system.services.page.IPage)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 RestServerError (org.entando.entando.aps.system.exception.RestServerError)1 Component (org.entando.entando.aps.system.init.model.Component)1 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)1