use of com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto 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.JasperReportValueDto in project midpoint by Evolveum.
the class RunReportPopupPanel method createParameterPanel.
private WebMarkupContainer createParameterPanel(final IModel<JasperReportParameterDto> parameterModel) {
WebMarkupContainer paramPanel = new WebMarkupContainer("paramPanel");
paramPanel.setOutputMarkupId(true);
String paramValue = new PropertyModel<String>(parameterModel, "name").getObject();
StringResourceModel paramDisplay = PageBase.createStringResourceStatic(RunReportPopupPanel.this, "runReportPopupContent.param.name." + paramValue, new Object[] {});
// use display name rather than property name
paramPanel.add(new Label("name", paramDisplay));
String paramClass = new PropertyModel<String>(parameterModel, "nestedTypeAsString").getObject();
if (StringUtils.isBlank(paramClass)) {
paramClass = new PropertyModel<String>(parameterModel, "typeAsString").getObject();
}
paramClass = paramClass == null ? "" : paramClass.substring(paramClass.lastIndexOf(".") + 1);
paramPanel.add(new Label("type", paramClass));
ListView<JasperReportValueDto> listView = new ListView<JasperReportValueDto>(ID_VALUE_LIST, new PropertyModel<>(parameterModel, "value")) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<JasperReportValueDto> item) {
item.add(createInputMarkup(item.getModel(), parameterModel.getObject()));
}
};
listView.setOutputMarkupId(true);
paramPanel.add(listView);
return paramPanel;
}
Aggregations