Search in sources :

Example 1 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.

the class PageReport method loadReport.

private ReportDto loadReport() {
    StringValue reportOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);
    Task task = createSimpleTask(OPERATION_LOAD_REPORT);
    OperationResult result = task.getResult();
    PrismObject<ReportType> prismReport = WebModelServiceUtils.loadObject(ReportType.class, reportOid.toString(), this, task, result);
    if (prismReport == null) {
        LOGGER.error("Couldn't load report.");
        throw new RestartResponseException(PageReports.class);
    }
    return new ReportDto(prismReport.asObjectable());
//        return prismReport;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) ReportDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) StringValue(org.apache.wicket.util.string.StringValue) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 2 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.

the class PageReports method initColumns.

private List<IColumn<ReportType, String>> initColumns() {
    List<IColumn<ReportType, String>> columns = new ArrayList<IColumn<ReportType, String>>();
    IColumn column;
    column = new LinkColumn<SelectableBean<ReportType>>(createStringResource("PageReports.table.name"), ReportType.F_NAME.getLocalPart(), "value.name") {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> rowModel) {
            ReportType report = rowModel.getObject().getValue();
            if (report != null) {
                reportTypeFilterPerformed(target, report.getOid());
            }
        }

        @Override
        public boolean isEnabled(IModel<SelectableBean<ReportType>> rowModel) {
            return rowModel.getObject().getValue() != null && rowModel.getObject().getValue().isParent();
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageReports.table.description"), "value.description");
    columns.add(column);
    column = new DoubleButtonColumn<SelectableBean<ReportType>>(new Model(), null) {

        @Override
        public String getFirstCap() {
            return PageReports.this.createStringResource("PageReports.button.run").getString();
        }

        @Override
        public String getSecondCap() {
            return PageReports.this.createStringResource("PageReports.button.configure").getString();
        }

        @Override
        public String getFirstColorCssClass() {
            if (getRowModel().getObject().getValue() != null && getRowModel().getObject().getValue().isParent()) {
                return BUTTON_COLOR_CLASS.PRIMARY.toString();
            } else {
                return BUTTON_COLOR_CLASS.PRIMARY.toString() + " " + BUTTON_DISABLED;
            }
        }

        @Override
        public void firstClicked(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> model) {
            runReportPerformed(target, model.getObject().getValue());
        }

        @Override
        public void secondClicked(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> model) {
            configurePerformed(target, model.getObject().getValue());
        }

        @Override
        public boolean isFirstButtonEnabled(IModel<SelectableBean<ReportType>> rowModel) {
            return getRowModel().getObject().getValue() != null && rowModel.getObject().getValue().isParent();
        }
    };
    columns.add(column);
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 3 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.

the class PageReports method runReportPerformed.

protected void runReportPerformed(AjaxRequestTarget target, ReportType report) {
    RunReportPopupPanel runReportPopupPanel = new RunReportPopupPanel(getMainPopupBodyId(), report) {

        private static final long serialVersionUID = 1L;

        protected void runConfirmPerformed(AjaxRequestTarget target, ReportType reportType, PrismContainer<ReportParameterType> reportParam) {
            OperationResult result = new OperationResult(OPERATION_RUN_REPORT);
            try {
                Task task = createSimpleTask(OPERATION_RUN_REPORT);
                getReportManager().runReport(reportType.asPrismObject(), reportParam, task, result);
            } catch (Exception ex) {
                result.recordFatalError(ex);
            } finally {
                result.computeStatusIfUnknown();
            }
            showResult(result);
            target.add(getFeedbackPanel(), get(createComponentPath(ID_MAIN_FORM)));
            hideMainPopup(target);
        }

        ;
    };
    showMainPopup(runReportPopupPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Task(com.evolveum.midpoint.task.api.Task) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RunReportPopupPanel(com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 4 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.

the class PageCreatedReports method initColumns.

//TODO - consider adding Author name, File Type and ReportType to columns
private List<IColumn<SelectableBean<ReportOutputType>, String>> initColumns(final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior) {
    List<IColumn<SelectableBean<ReportOutputType>, String>> columns = new ArrayList<>();
    IColumn column;
    column = new CheckBoxHeaderColumn();
    columns.add(column);
    column = new PropertyColumn(createStringResource("pageCreatedReports.table.name"), "name", "value.name");
    columns.add(column);
    column = new PropertyColumn(createStringResource("pageCreatedReports.table.description"), "value.description");
    columns.add(column);
    column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(createStringResource("pageCreatedReports.table.time"), "createTimestamp") {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> rowModel) {
            cellItem.add(new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {

                @Override
                public Date getObject() {
                    ReportOutputType object = rowModel.getObject().getValue();
                    MetadataType metadata = object != null ? object.getMetadata() : null;
                    if (metadata == null) {
                        return null;
                    }
                    return XmlTypeConverter.toDate(metadata.getCreateTimestamp());
                }
            }, DateLabelComponent.LONG_MEDIUM_STYLE));
        }
    };
    columns.add(column);
    column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(new Model(), null) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> model) {
            DownloadButtonPanel panel = new DownloadButtonPanel(componentId) {

                @Override
                protected void deletePerformed(AjaxRequestTarget target) {
                    deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SINGLE, model.getObject().getValue());
                }

                @Override
                protected void downloadPerformed(AjaxRequestTarget target) {
                    currentReport = model.getObject().getValue();
                    PageCreatedReports.this.downloadPerformed(target, model.getObject().getValue(), ajaxDownloadBehavior);
                }
            };
            cellItem.add(panel);
        }
    };
    columns.add(column);
    column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {

        @Override
        public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
            cellItem.add(new Label(componentId));
        }
    };
    columns.add(column);
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) InlineMenuable(com.evolveum.midpoint.web.component.data.column.InlineMenuable) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DownloadButtonPanel(com.evolveum.midpoint.web.page.admin.reports.component.DownloadButtonPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 5 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.

the class ReportTypeUtil method applyDefinition.

public static void applyDefinition(PrismObject<ReportType> report, PrismContext prismContext) throws SchemaException {
    PrismContainer<ReportConfigurationType> configuration = report.findContainer(ReportType.F_CONFIGURATION);
    if (configuration == null) {
        //nothing to apply definitions on
        return;
    }
    PrismContainer xmlSchema = report.findContainer(ReportType.F_CONFIGURATION_SCHEMA);
    Element xmlSchemaElement = ObjectTypeUtil.findXsdElement(xmlSchema);
    if (xmlSchemaElement == null) {
        //no schema definition available
        throw new SchemaException("Couldn't find schema for configuration in report type " + report + ".");
    }
    PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext);
    PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema);
    if (definition == null) {
        //no definition found for container
        throw new SchemaException("Couldn't find definitions for report type " + report + ".");
    }
    configuration.applyDefinition(definition, true);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Element(org.w3c.dom.Element) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ReportConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType)

Aggregations

ReportType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)13 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 Task (com.evolveum.midpoint.task.api.Task)5 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 ReportConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType)2 ReportOutputType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JasperReport (net.sf.jasperreports.engine.JasperReport)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)2 IModel (org.apache.wicket.model.IModel)2 Model (org.apache.wicket.model.Model)2 PropertyModel (org.apache.wicket.model.PropertyModel)2