Search in sources :

Example 6 with WidgetTypeParameter

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

the class JAXBWidgetType method getModifiedWidgetType.

public WidgetType getModifiedWidgetType(IWidgetTypeManager widgetTypeManager) throws ApiException {
    WidgetType type = widgetTypeManager.getWidgetType(this.getCode());
    type.setTitles(this.getTitles());
    if (type.isLogic()) {
        ApsProperties configuration = this.getConfig();
        type.setConfig(configuration);
    } else {
        List<WidgetTypeParameter> parameters = this.getTypeParameters();
        if (null != parameters && !parameters.isEmpty()) {
            // type.setAction("configSimpleParameter");
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Parameters of existing widget mustn't been changed", Response.Status.CONFLICT);
        }
    }
    type.setMainGroup(this.getMainGroup());
    // 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) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 7 with WidgetTypeParameter

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

the class CmsPageUtil 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);
    // ApsSystemUtils.logThrowable(t, CmsPageActionUtil.class,
    // "isViewerPage", "Error while checking page '" + page.getCode() +
    // "'");
    }
    return false;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 8 with WidgetTypeParameter

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

the class TestWidgetTypeDOM method testCreateConfig.

public void testCreateConfig() throws ApsSystemException {
    WidgetTypeParameter params1 = new WidgetTypeParameter();
    params1.setName("param1");
    params1.setDescr("Param1 Descr");
    WidgetTypeParameter params2 = new WidgetTypeParameter();
    params2.setName("param2");
    params2.setDescr("Param2 Descr");
    List<WidgetTypeParameter> params = new ArrayList<WidgetTypeParameter>();
    params.add(params1);
    params.add(params2);
    WidgetTypeDOM showletTypeDOM = new WidgetTypeDOM(params, "customActionName");
    String xml = showletTypeDOM.getXMLDocument();
    WidgetTypeDOM showletTypeDOM2 = new WidgetTypeDOM(xml);
    assertEquals("customActionName", showletTypeDOM2.getAction());
    List<WidgetTypeParameter> extractedParams = showletTypeDOM2.getParameters();
    assertEquals(2, extractedParams.size());
    assertEquals("param1", extractedParams.get(0).getName());
    assertEquals("Param2 Descr", extractedParams.get(1).getDescr());
}
Also used : ArrayList(java.util.ArrayList) WidgetTypeDOM(org.entando.entando.aps.system.services.widgettype.WidgetTypeDOM) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 9 with WidgetTypeParameter

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

the class TestWidgetTypeManager method testGetWidgetType_1.

public void testGetWidgetType_1() throws ApsSystemException {
    WidgetType widgetType = _widgetTypeManager.getWidgetType("content_viewer");
    assertEquals("content_viewer", widgetType.getCode());
    assertEquals("Contenuti - Pubblica un Contenuto", widgetType.getTitles().get("it"));
    assertTrue(widgetType.isLocked());
    assertFalse(widgetType.isLogic());
    assertFalse(widgetType.isUserType());
    assertNull(widgetType.getParentType());
    assertNull(widgetType.getConfig());
    String action = widgetType.getAction();
    assertEquals(action, "viewerConfig");
    List<WidgetTypeParameter> list = widgetType.getTypeParameters();
    Iterator<WidgetTypeParameter> iter = list.iterator();
    Map<String, String> parameters = new HashMap<String, String>();
    while (iter.hasNext()) {
        WidgetTypeParameter parameter = (WidgetTypeParameter) iter.next();
        parameters.put(parameter.getName(), parameter.getDescr());
    }
    boolean containsKey = parameters.containsKey("contentId");
    boolean containsValue = parameters.containsValue("Identificativo del Contenuto");
    assertEquals(containsKey, true);
    assertEquals(containsValue, true);
    containsKey = parameters.containsKey("modelId");
    containsValue = parameters.containsValue("Identificativo del Modello di Contenuto");
    assertEquals(containsKey, true);
    assertEquals(containsValue, true);
}
Also used : HashMap(java.util.HashMap) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 10 with WidgetTypeParameter

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

Aggregations

WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)11 ApsProperties (com.agiletec.aps.util.ApsProperties)5 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)5 Widget (com.agiletec.aps.system.services.page.Widget)4 WidgetTypeDOM (org.entando.entando.aps.system.services.widgettype.WidgetTypeDOM)2 IPage (com.agiletec.aps.system.services.page.IPage)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 RestServerError (org.entando.entando.aps.system.exception.RestServerError)1 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)1