use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ObjectNameColumn method populateItem.
@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId, final IModel<SelectableBean<O>> rowModel) {
IModel<String> labelModel = new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
return cellItem.getString(props.getStatusLabelKey());
} else {
String name = WebComponentUtil.getName(value);
if (selectableBean.getResult() != null) {
StringBuilder complexName = new StringBuilder();
complexName.append(name);
complexName.append(" (");
complexName.append(selectableBean.getResult().getStatus());
complexName.append(")");
return complexName.toString();
}
return name;
}
}
};
if (isClickable(rowModel)) {
// beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
cellItem.add(new LinkPanel(componentId, labelModel) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
throw new RestartResponseException(new PageOperationResult(result));
} else {
if (selectableBean.getResult() != null) {
throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
} else {
ObjectNameColumn.this.onClick(target, rowModel);
}
}
}
});
} else {
cellItem.add(new Label(componentId, labelModel));
}
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ContainerableListPanel method evaluateExpression.
protected Collection<String> evaluateExpression(C rowValue, Item<?, ?> columnItem, ExpressionType expression, GuiObjectColumnType customColumn) {
Task task = getPageBase().createSimpleTask(OPERATION_EVALUATE_EXPRESSION);
OperationResult result = task.getResult();
try {
VariablesMap variablesMap = new VariablesMap();
variablesMap.put(ExpressionConstants.VAR_OBJECT, rowValue, rowValue.getClass());
if (columnItem != null) {
variablesMap.put(ExpressionConstants.VAR_INPUT, columnItem, columnItem.getDefinition());
}
return ExpressionUtil.evaluateStringExpression(variablesMap, getPageBase().getPrismContext(), expression, MiscSchemaUtil.getExpressionProfile(), getPageBase().getExpressionFactory(), "evaluate column expression", task, result);
} catch (Exception e) {
LOGGER.error("Couldn't execute expression for {} column. Reason: {}", customColumn, e.getMessage(), e);
result.recomputeStatus();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
// TODO: this is not entirely correct
return Collections.singletonList(getPageBase().createStringResource(props.getStatusLabelKey()).getString());
}
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ObjectNameColumn method evaluateExpression.
private String evaluateExpression(Item<ICellPopulator<SelectableBean<O>>> cellItem, ItemPath itemPath, O value) {
Task task = pageBase.createSimpleTask("evaluate column expression");
try {
com.evolveum.midpoint.prism.Item<?, ?> item = value.asPrismObject().findItem(itemPath);
VariablesMap variablesMap = new VariablesMap();
variablesMap.put(ExpressionConstants.VAR_OBJECT, value, value.getClass());
if (item != null) {
variablesMap.put(ExpressionConstants.VAR_INPUT, item, item.getDefinition().getTypeClass());
}
Collection<String> evaluatedValues = ExpressionUtil.evaluateStringExpression(variablesMap, pageBase.getPrismContext(), expression, MiscSchemaUtil.getExpressionProfile(), pageBase.getExpressionFactory(), "evaluate column expression", task, task.getResult());
if (evaluatedValues != null) {
return evaluatedValues.iterator().next();
}
return null;
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
LOGGER.error("Couldn't execute expression for name column");
OperationResult result = task.getResult();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
return cellItem.getString(props.getStatusLabelKey());
}
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class WebComponentUtil method createErrorIcon.
public static String createErrorIcon(OperationResult result) {
if (result == null) {
return "";
}
OperationResultStatus status = result.getStatus();
OperationResultStatusPresentationProperties icon = OperationResultStatusPresentationProperties.parseOperationalResultStatus(status);
return icon.getIcon() + " fa-lg";
}
use of com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties in project midpoint by Evolveum.
the class ObjectNameColumn method getResultAsString.
private String getResultAsString(Item<ICellPopulator<SelectableBean<O>>> cellItem, SelectableBean<O> selectableBean) {
OperationResult result = selectableBean.getResult();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
return cellItem.getString(props.getStatusLabelKey());
}
Aggregations