Search in sources :

Example 1 with JasperReportValueDto

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);
}
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 JasperReportValueDto

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;
}
Also used : JasperReportValueDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) LookupPropertyModel(com.evolveum.midpoint.web.model.LookupPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ListItem(org.apache.wicket.markup.html.list.ListItem) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

JasperReportValueDto (com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportValueDto)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 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 LookupPropertyModel (com.evolveum.midpoint.web.model.LookupPropertyModel)1 JasperReportParameterDto (com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)1 ReportDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto)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 QName (javax.xml.namespace.QName)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 PropertyModel (org.apache.wicket.model.PropertyModel)1