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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations