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();
}
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");
}
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());
}
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);
}
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;
}
Aggregations