Search in sources :

Example 11 with ReportType

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

the class ReportCreateTaskHandler method saveReportOutputType.

private void saveReportOutputType(String filePath, ReportType reportType, Task task, OperationResult parentResult) throws Exception {
    String fileName = FilenameUtils.getBaseName(filePath);
    String reportOutputName = fileName + " - " + reportType.getExport().value();
    ReportOutputType reportOutputType = new ReportOutputType();
    prismContext.adopt(reportOutputType);
    reportOutputType.setFilePath(filePath);
    reportOutputType.setReportRef(MiscSchemaUtil.createObjectReference(reportType.getOid(), ReportType.COMPLEX_TYPE));
    reportOutputType.setName(new PolyStringType(reportOutputName));
    reportOutputType.setDescription(reportType.getDescription() + " - " + reportType.getExport().value());
    reportOutputType.setExportType(reportType.getExport());
    ObjectDelta<ReportOutputType> objectDelta = null;
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    OperationResult subResult = null;
    objectDelta = ObjectDelta.createAddDelta((PrismObject<ReportOutputType>) reportOutputType.asPrismObject());
    deltas.add(objectDelta);
    subResult = parentResult.createSubresult(ReportCreateTaskHandler.class.getName() + "createRepourtOutput");
    modelService.executeChanges(deltas, null, task, subResult);
    String outputOid = objectDelta.getOid();
    LOGGER.debug("Created report output with OID {}", outputOid);
    PrismProperty<String> outputOidProperty = prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(ReportConstants.REPORT_OUTPUT_OID_PROPERTY_NAME).instantiate();
    outputOidProperty.setRealValue(outputOid);
    task.setExtensionPropertyImmediate(outputOidProperty, subResult);
    subResult.computeStatus();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 12 with ReportType

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

the class ClassicReportExportActivityHandler method resolveExecution.

private AbstractActivityRun<ClassicReportExportWorkDefinition, ClassicReportExportActivityHandler, ?> resolveExecution(ActivityRunInstantiationContext<ClassicReportExportWorkDefinition, ClassicReportExportActivityHandler> context, OperationResult result) {
    @NotNull ClassicReportExportWorkDefinition workDefinition = context.getActivity().getWorkDefinition();
    ReportType report;
    try {
        report = reportService.getObjectResolver().resolve(workDefinition.getReportRef(), ReportType.class, null, "resolving report", context.getTaskRun().getRunningTask(), result);
    } catch (CommonException e) {
        throw new IllegalArgumentException(e);
    }
    if (report.getDashboard() != null) {
        return new ClassicDashboardReportExportActivityRun(context);
    }
    if (report.getObjectCollection() != null) {
        return new ClassicCollectionReportExportActivityRun(context);
    }
    LOGGER.error("Report don't contains engine");
    throw new IllegalArgumentException("Report don't contains engine");
}
Also used : NotNull(org.jetbrains.annotations.NotNull) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 13 with ReportType

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

the class TestCsvReportMultiNode method test103ExportAuditRecordsOutsideTwoTimestamps.

@Test
public void test103ExportAuditRecordsOutsideTwoTimestamps() throws Exception {
    List<AuditEventRecordType> auditRecords = getAllAuditRecords(getTestTask(), getTestTask().getResult());
    SearchFilterType filter = PrismContext.get().getQueryConverter().createSearchFilterType(PrismContext.get().queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_TIMESTAMP).ge(auditRecords.get(1300).getTimestamp()).or().item(AuditEventRecordType.F_TIMESTAMP).le(auditRecords.get(500).getTimestamp()).buildFilter());
    modifyObjectReplaceProperty(ObjectCollectionType.class, OBJECT_COLLECTION_ALL_AUDIT_RECORDS.oid, ObjectCollectionType.F_FILTER, getTestTask(), getTestTask().getResult(), filter);
    auditTest();
    PrismObject<ReportType> report = getObject(ReportType.class, REPORT_AUDIT_COLLECTION_WITH_DEFAULT_COLUMN.oid);
    List<String> rows = basicCheckOutputFile(report, -1, 8, null);
    assertTrue(rows.size() > 1200 && rows.size() <= 1250, "Unexpected number of rows in report. Expected:1200-1250, Actual:" + rows.size());
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType) Test(org.testng.annotations.Test)

Example 14 with ReportType

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

the class TestCsvReportMultiNode method test100ExportUsers.

@Test
public void test100ExportUsers() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    runExportTask(TASK_DISTRIBUTED_EXPORT_USERS, REPORT_OBJECT_COLLECTION_USERS, result);
    when();
    waitForTaskCloseOrSuspend(TASK_DISTRIBUTED_EXPORT_USERS.oid);
    then();
    assertTask(TASK_DISTRIBUTED_EXPORT_USERS.oid, "after").assertSuccess().display();
    PrismObject<ReportType> report = getObject(ReportType.class, REPORT_OBJECT_COLLECTION_USERS.oid);
    basicCheckOutputFile(report, 1004, 2, null);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType) Test(org.testng.annotations.Test)

Example 15 with ReportType

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

the class PageCreatedReports method createSearchDto.

private ReportOutputSearchDto createSearchDto() {
    ReportOutputSearchDto dto = new ReportOutputSearchDto();
    Map<String, String> reportTypeMap = dto.getReportTypeMap();
    List<PrismObject<ReportType>> reportTypes = WebModelServiceUtils.searchObjects(ReportType.class, null, null, getPageBase());
    LOGGER.debug("Found {} report types.", reportTypes.size());
    for (PrismObject o : reportTypes) {
        ReportType reportType = (ReportType) o.asObjectable();
        if (reportType.isParent()) {
            String name = WebComponentUtil.getName(o);
            reportTypeMap.put(name, reportType.getOid());
        }
    }
    StringValue param = getPage().getPageParameters().get(OnePageParameterEncoder.PARAMETER);
    if (param != null) {
        for (String key : dto.getReportTypeMap().keySet()) {
            if (reportTypeMap.get(key).equals(param.toString())) {
                dto.setReportType(key);
            }
        }
    }
    return dto;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ReportOutputSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportOutputSearchDto) StringValue(org.apache.wicket.util.string.StringValue) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

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