use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.
the class ReportTypeUtil method applyConfigurationDefinition.
public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext) throws SchemaException {
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 + ".");
}
Collection<ItemDelta> modifications = delta.getModifications();
for (ItemDelta itemDelta : modifications) {
if (itemDelta.hasCompleteDefinition()) {
continue;
}
ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().tail());
if (def != null) {
itemDelta.applyDefinition(def);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.
the class RReport method toJAXB.
@Override
public ReportType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
ReportType object = new ReportType();
RUtil.revive(object, prismContext);
RReport.copyToJAXB(this, object, prismContext, options);
return object;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.
the class ReportCreateTaskHandler method getSubreportParameters.
private Map<String, Object> getSubreportParameters(SubreportType subreportType, Task task, OperationResult subResult) throws SchemaException, ObjectNotFoundException {
Map<String, Object> reportParams = new HashMap<String, Object>();
ReportType reportType = objectResolver.resolve(subreportType.getReportRef(), ReportType.class, null, "resolve subreport", task, subResult);
Map<String, Object> parameters = prepareReportParameters(reportType, subResult);
reportParams.putAll(parameters);
JasperReport jasperReport = ReportTypeUtil.loadJasperReport(reportType);
reportParams.put(subreportType.getName(), jasperReport);
Map<String, Object> subReportParams = processSubreportParameters(reportType, task, subResult);
reportParams.putAll(subReportParams);
return reportParams;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.
the class ReportCreateTaskHandler method run.
@Override
public TaskRunResult run(Task task) {
// TODO Auto-generated method stub
OperationResult parentResult = task.getResult();
OperationResult result = parentResult.createSubresult(ReportCreateTaskHandler.class.getSimpleName() + ".run");
TaskRunResult runResult = new TaskRunResult();
runResult.setOperationResult(result);
recordProgress(task, 0, result);
long progress = task.getProgress();
JRSwapFile swapFile = null;
// http://community.jaspersoft.com/wiki/virtualizers-jasperreports
JRAbstractLRUVirtualizer virtualizer = null;
try {
ReportType parentReport = objectResolver.resolve(task.getObjectRef(), ReportType.class, null, "resolving report", task, result);
Map<String, Object> parameters = completeReport(parentReport, task, result);
JasperReport jasperReport = ReportTypeUtil.loadJasperReport(parentReport);
LOGGER.trace("compile jasper design, create jasper report : {}", jasperReport);
PrismContainer<ReportParameterType> reportParams = (PrismContainer) task.getExtensionItem(ReportConstants.REPORT_PARAMS_PROPERTY_NAME);
if (reportParams != null) {
PrismContainerValue<ReportParameterType> reportParamsValues = reportParams.getValue();
List<Item<?, ?>> items = reportParamsValues.getItems();
if (items != null) {
for (Item item : items) {
PrismProperty pp = (PrismProperty) item;
String paramName = ItemPath.getName(pp.getPath().lastNamed()).getLocalPart();
Object value = null;
if (isSingleValue(paramName, jasperReport.getParameters())) {
value = pp.getRealValues().iterator().next();
} else {
value = pp.getRealValues();
}
parameters.put(paramName, value);
}
}
}
String virtualizerS = parentReport.getVirtualizer();
Integer virtualizerKickOn = parentReport.getVirtualizerKickOn();
Integer maxPages = parentReport.getMaxPages();
Integer timeout = parentReport.getTimeout();
if (maxPages != null && maxPages > 0) {
LOGGER.trace("Setting hardlimit on number of report pages: " + maxPages);
jasperReport.setProperty(MaxPagesGovernor.PROPERTY_MAX_PAGES_ENABLED, Boolean.TRUE.toString());
jasperReport.setProperty(MaxPagesGovernor.PROPERTY_MAX_PAGES, String.valueOf(maxPages));
}
if (timeout != null && timeout > 0) {
LOGGER.trace("Setting timeout on report execution [ms]: " + timeout);
jasperReport.setProperty(TimeoutGovernor.PROPERTY_TIMEOUT_ENABLED, Boolean.TRUE.toString());
jasperReport.setProperty(TimeoutGovernor.PROPERTY_TIMEOUT, String.valueOf(timeout));
}
if (virtualizerS != null && virtualizerKickOn != null && virtualizerKickOn > 0) {
String virtualizerClassName = JASPER_VIRTUALIZER_PKG + "." + virtualizerS;
try {
Class<?> clazz = Class.forName(virtualizerClassName);
if (clazz.equals(JRSwapFileVirtualizer.class)) {
swapFile = new JRSwapFile(TEMP_DIR, 4096, 200);
virtualizer = new JRSwapFileVirtualizer(virtualizerKickOn, swapFile);
} else if (clazz.equals(JRGzipVirtualizer.class)) {
virtualizer = new JRGzipVirtualizer(virtualizerKickOn);
} else if (clazz.equals(JRFileVirtualizer.class)) {
virtualizer = new JRFileVirtualizer(virtualizerKickOn, TEMP_DIR);
} else {
throw new ClassNotFoundException("No support for virtualizer class: " + clazz.getName());
}
LOGGER.trace("Setting explicit Jasper virtualizer: " + virtualizer);
virtualizer.setReadOnly(false);
parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
} catch (ClassNotFoundException e) {
LOGGER.error("Cannot find Jasper virtualizer: " + e.getMessage());
}
}
LOGGER.trace("All Report parameters : {}", parameters);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters);
LOGGER.trace("fill report : {}", jasperPrint);
String reportFilePath = generateReport(parentReport, jasperPrint);
LOGGER.trace("generate report : {}", reportFilePath);
saveReportOutputType(reportFilePath, parentReport, task, result);
LOGGER.trace("create report output type : {}", reportFilePath);
result.computeStatus();
} catch (Exception ex) {
LOGGER.error("CreateReport: {}", ex.getMessage(), ex);
result.recordFatalError(ex.getMessage(), ex);
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
runResult.setProgress(progress);
return runResult;
} finally {
if (swapFile != null) {
swapFile.dispose();
}
if (virtualizer != null) {
virtualizer.cleanup();
}
}
// This "run" is finished. But the task goes on ...
runResult.setRunResultStatus(TaskRunResultStatus.FINISHED);
runResult.setProgress(progress);
LOGGER.trace("CreateReportTaskHandler.run stopping");
return runResult;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project midpoint by Evolveum.
the class ReportCreateTaskHandler method processSubreportParameters.
private Map<String, Object> processSubreportParameters(ReportType reportType, Task task, OperationResult subreportResult) throws SchemaException, ObjectNotFoundException {
Map<String, Object> subreportParameters = new HashMap<String, Object>();
for (SubreportType subreport : reportType.getSubreport()) {
Map<String, Object> subreportParam = getSubreportParameters(subreport, task, subreportResult);
LOGGER.trace("create subreport params : {}", subreportParam);
subreportParameters.putAll(subreportParam);
}
return subreportParameters;
}
Aggregations