Search in sources :

Example 1 with JasperReportParameterDto

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);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) QName(javax.xml.namespace.QName) ReportParameterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType) ReportDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto) JasperReportValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) PrismObject(com.evolveum.midpoint.prism.PrismObject) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType)

Example 2 with JasperReportParameterDto

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());
}
Also used : ReportDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)

Example 3 with JasperReportParameterDto

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());
}
Also used : JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)

Example 4 with JasperReportParameterDto

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ArrayList(java.util.ArrayList) List(java.util.List) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)

Example 5 with JasperReportParameterDto

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;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) CheckBoxPanel(com.evolveum.midpoint.web.component.data.column.CheckBoxPanel) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Item(org.apache.wicket.markup.repeater.Item) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)

Aggregations

JasperReportParameterDto (com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)6 ReportDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto)2 ArrayList (java.util.ArrayList)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AuditEventStage (com.evolveum.midpoint.audit.api.AuditEventStage)1 AuditEventType (com.evolveum.midpoint.audit.api.AuditEventType)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 CheckBoxColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)1 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)1 CheckBoxPanel (com.evolveum.midpoint.web.component.data.column.CheckBoxPanel)1 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)1 JasperReportValueDto (com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto)1 AuditEventStageType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType)1 ReportParameterType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType)1