use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto in project midpoint by Evolveum.
the class RunReportPopupPanel method runConfirmPerformed.
// private void addFormUpdatingBehavior(FormComponent parent, String id, final IModel<JasperReportParameterDto> model) {
// Component c = parent.get(id);
// if (c == null) {
// return;
// }
// c.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
// }
private void runConfirmPerformed(AjaxRequestTarget target, IModel<ReportDto> model) {
ReportDto reportDto = model.getObject();
PrismContainerDefinition<ReportParameterType> paramContainerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(ReportConstants.REPORT_PARAMS_PROPERTY_NAME);
PrismContainer<ReportParameterType> paramContainer;
try {
paramContainer = paramContainerDef.instantiate();
ReportParameterType reportParam = new ReportParameterType();
PrismContainerValue<ReportParameterType> reportParamValue = reportParam.asPrismContainerValue();
reportParamValue.revive(getPrismContext());
paramContainer.add(reportParamValue);
List<JasperReportParameterDto> params = getParametersView().getModelObject();
for (JasperReportParameterDto paramDto : params) {
if (paramDto.getValue() == null) {
continue;
}
List<JasperReportValueDto> values = paramDto.getValue();
Class<?> paramClass = paramDto.getType();
boolean multivalue = false;
if (List.class.isAssignableFrom(paramClass)) {
paramClass = paramDto.getNestedType();
if (paramClass == null) {
getSession().error("Nested type for list must be defined!");
target.add(getPageBase().getFeedbackPanel());
return;
}
}
QName typeName = getPrismContext().getSchemaRegistry().determineTypeForClass(paramClass);
PrismPropertyDefinitionImpl<?> def = new PrismPropertyDefinitionImpl<>(new QName(ReportConstants.NS_EXTENSION, paramDto.getName()), typeName, getPrismContext());
def.setDynamic(true);
def.setRuntimeSchema(true);
// TODO multivalue is always 'false' here ...
def.setMaxOccurs(multivalue ? -1 : 1);
PrismProperty prop = def.instantiate();
for (JasperReportValueDto paramValue : values) {
Object realValue = paramValue.getValue();
if (realValue == null) {
continue;
}
if (AuditEventType.class.isAssignableFrom(paramClass)) {
paramClass = AuditEventTypeType.class;
realValue = AuditEventType.fromAuditEventType((AuditEventType) realValue);
} else if (AuditEventStage.class.isAssignableFrom(paramClass)) {
paramClass = AuditEventStageType.class;
realValue = AuditEventStage.fromAuditEventStage((AuditEventStage) realValue);
}
prop.addRealValue(realValue);
}
if (!prop.isEmpty()) {
reportParamValue.add(prop);
}
}
} catch (SchemaException | ClassNotFoundException e) {
OperationResult result = new OperationResult("Parameters serialization");
result.recordFatalError("Could not serialize parameters");
getPageBase().showResult(result);
return;
}
runConfirmPerformed(target, reportDto.getObject().asObjectable(), paramContainer);
}
use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method addParameterPerformed.
private void addParameterPerformed(AjaxRequestTarget target) {
ReportDto dto = getModel().getObject();
JasperReportParameterDto parameter = new JasperReportParameterDto();
parameter.setEditing(true);
dto.getJasperReportDto().getParameters().add(parameter);
BoxedTablePanel<JasperReportParameterDto> parametersTable = getParametersTable();
adjustParametersTablePage(parametersTable, dto);
target.add(getParametersTable());
}
use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method deleteParameterPerformed.
private void deleteParameterPerformed(AjaxRequestTarget target) {
Iterator<JasperReportParameterDto> iterator = getModelObject().getJasperReportDto().getParameters().iterator();
while (iterator.hasNext()) {
JasperReportParameterDto item = iterator.next();
if (item.isSelected()) {
iterator.remove();
}
}
target.add(getParametersTable());
}
use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method initParametersTable.
private void initParametersTable() {
ISortableDataProvider<JasperReportParameterDto, String> provider = new ListDataProvider<JasperReportParameterDto>(this, new PropertyModel<List<JasperReportParameterDto>>(getModel(), "jasperReportDto.parameters"));
BoxedTablePanel<JasperReportParameterDto> table = new BoxedTablePanel<>(ID_PARAMETERS_TABLE, provider, initParameterColumns(), null, 10);
// table.setShowPaging(false);
table.setOutputMarkupId(true);
add(table);
AjaxButton addParameter = new AjaxButton(ID_BUTTON_ADD_PARAMETER, createStringResource("JasperReportConfigurationPanel.addParameter")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addParameterPerformed(target);
}
};
add(addParameter);
AjaxButton deleteParameter = new AjaxButton(ID_DELETE_PARAMETER, createStringResource("JasperReportConfigurationPanel.deleteParameter")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteParameterPerformed(target);
}
};
add(deleteParameter);
}
use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method initParameterColumns.
private List<IColumn<JasperReportParameterDto, String>> initParameterColumns() {
List<IColumn<JasperReportParameterDto, String>> columns = new ArrayList<>();
IColumn<JasperReportParameterDto, String> column = new CheckBoxHeaderColumn<>();
columns.add(column);
// name editing column
columns.add(buildEditableLinkColumn("JasperReportConfigurationPanel.parameterName", null, "name", true));
// class editing column
columns.add(buildEditableLinkColumn("JasperReportConfigurationPanel.parameterClass", null, "typeAsString", true));
columns.add(buildEditableLinkColumn("JasperReportConfigurationPanel.nestedClass", null, "nestedTypeAsString", true));
columns.add(new LinkColumn<JasperReportParameterDto>(createStringResource("JasperReportConfigurationPanel.properties")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target, IModel<JasperReportParameterDto> rowModel) {
showPropertiesPopup(target, rowModel);
}
@Override
protected IModel createLinkModel(IModel<JasperReportParameterDto> rowModel) {
return createStringResource("JasperReportConfigurationPanel.configure");
}
});
CheckBoxColumn<JasperReportParameterDto> forPrompting = new CheckBoxColumn<JasperReportParameterDto>(createStringResource("JasperReportConfigurationPanel.forPrompting"), "forPrompting") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<JasperReportParameterDto>> cellItem, String componentId, IModel<JasperReportParameterDto> rowModel) {
CheckBoxPanel checkBox = new CheckBoxPanel(componentId, new PropertyModel<Boolean>(rowModel, getPropertyExpression()), new Model<>(true));
cellItem.add(checkBox);
}
};
columns.add(forPrompting);
return columns;
}
Aggregations