Search in sources :

Example 16 with ReportType

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

the class ReportDto method getObject.

public PrismObject<ReportType> getObject() {
    if (reportType == null) {
        reportType = new ReportType();
        //TODO FIXME temporary every new report will be set as parent report
        reportType.setParent(Boolean.TRUE);
    }
    reportType.setName(new PolyStringType(name));
    reportType.setExport(exportType);
    reportType.setTemplate(jasperReportDto.getTemplate());
    reportType.setTemplateStyle(templateStyle);
    reportType.setDescription(description);
    reportType.setVirtualizer(virtualizer);
    reportType.setVirtualizerKickOn(virtualizerKickOn);
    reportType.setMaxPages(maxPages);
    reportType.setTimeout(timeout);
    return reportType.asPrismObject();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 17 with ReportType

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

the class PageReport method onSavePerformed.

protected void onSavePerformed(AjaxRequestTarget target) {
    Task task = createSimpleTask(OPERATION_SAVE_REPORT);
    OperationResult result = task.getResult();
    try {
        //TODO TODO TODO
        PrismObject<ReportType> newReport = model.getObject().getObject();
        ObjectDelta<ReportType> delta = null;
        if (newReport.getOid() == null) {
            getPrismContext().adopt(newReport);
            delta = ObjectDelta.createAddDelta(newReport);
            delta.setPrismContext(getPrismContext());
        } else {
            PrismObject<ReportType> oldReport = WebModelServiceUtils.loadObject(ReportType.class, newReport.getOid(), this, task, result);
            if (oldReport != null) {
                delta = oldReport.diff(newReport);
            }
        }
        if (delta != null) {
            getPrismContext().adopt(delta);
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
        }
    } catch (Exception e) {
        result.recordFatalError("Couldn't save report.", e);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result);
        redirectBack();
    } else {
        showResult(result);
        target.add(getFeedbackPanel());
    }
}
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) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 18 with ReportType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType in project jqa-core-framework by buschmais.

the class ReportPluginRepositoryImpl method getReportPlugins.

private Map<String, ReportPlugin> getReportPlugins(List<JqassistantPlugin> plugins) throws PluginRepositoryException {
    Map<String, ReportPlugin> reportPlugins = new HashMap<>();
    for (JqassistantPlugin plugin : plugins) {
        ReportType reportType = plugin.getReport();
        if (reportType != null) {
            for (IdClassType classType : reportType.getClazz()) {
                ReportPlugin reportPlugin = createInstance(classType.getValue());
                if (reportPlugin != null) {
                    try {
                        reportPlugin.initialize();
                    } catch (ReportException e) {
                        throw new PluginRepositoryException("Cannot initialize report plugin " + reportPlugin, e);
                    }
                    String id = classType.getId();
                    if (id == null) {
                        id = reportPlugin.getClass().getSimpleName();
                    }
                    reportPlugins.put(id, reportPlugin);
                }
            }
        }
    }
    return reportPlugins;
}
Also used : IdClassType(com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType) PluginRepositoryException(com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) HashMap(java.util.HashMap) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) ReportException(com.buschmais.jqassistant.core.report.api.ReportException) ReportType(com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)

Example 19 with ReportType

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

the class ReportServiceImpl method evaluateSubreportParameters.

public VariablesMap evaluateSubreportParameters(PrismObject<ReportType> report, VariablesMap variables, Task task, OperationResult result) {
    VariablesMap subreportVariable = new VariablesMap();
    if (report != null && report.asObjectable().getObjectCollection() != null && report.asObjectable().getObjectCollection().getSubreport() != null && !report.asObjectable().getObjectCollection().getSubreport().isEmpty()) {
        Collection<SubreportParameterType> subreports = report.asObjectable().getObjectCollection().getSubreport();
        List<SubreportParameterType> sortedSubreports = new ArrayList<>(subreports);
        sortedSubreports.sort(Comparator.comparingInt(s -> ObjectUtils.defaultIfNull(s.getOrder(), Integer.MAX_VALUE)));
        for (SubreportParameterType subreport : sortedSubreports) {
            if (subreport.getExpression() == null || subreport.getName() == null) {
                continue;
            }
            ExpressionType expression = subreport.getExpression();
            try {
                Collection<? extends PrismValue> subreportParameter = evaluateScript(report, expression, variables, "subreport parameter", task, result);
                Class<?> subreportParameterClass;
                if (subreport.getType() != null) {
                    subreportParameterClass = getPrismContext().getSchemaRegistry().determineClassForType(subreport.getType());
                } else {
                    if (subreportParameter != null && !subreportParameter.isEmpty()) {
                        subreportParameterClass = subreportParameter.iterator().next().getRealClass();
                    } else {
                        subreportParameterClass = Object.class;
                    }
                }
                subreportVariable.put(subreport.getName(), subreportParameter, subreportParameterClass);
            } catch (Exception e) {
                LOGGER.error("Couldn't execute expression " + expression, e);
            }
        }
        return subreportVariable;
    }
    return subreportVariable;
}
Also used : com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) java.util(java.util) ArchetypeManager(com.evolveum.midpoint.model.common.ArchetypeManager) GroovyScriptEvaluator(com.evolveum.midpoint.model.common.expression.script.groovy.GroovyScriptEvaluator) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) ScriptExpressionFactory(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionFactory) com.evolveum.midpoint.schema.expression(com.evolveum.midpoint.schema.expression) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) ModelExpressionThreadLocalHolder(com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder) TaskManager(com.evolveum.midpoint.task.api.TaskManager) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) LocalizationService(com.evolveum.midpoint.common.LocalizationService) ExpressionEnvironment(com.evolveum.midpoint.model.common.expression.ExpressionEnvironment) QNameUtil(com.evolveum.midpoint.util.QNameUtil) com.evolveum.midpoint.model.api(com.evolveum.midpoint.model.api) ObjectUtils(org.apache.commons.lang3.ObjectUtils) ScriptExpression(com.evolveum.midpoint.model.common.expression.script.ScriptExpression) Qualifier(org.springframework.beans.factory.annotation.Qualifier) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) AuditService(com.evolveum.midpoint.audit.api.AuditService) DashboardUtils(com.evolveum.midpoint.model.api.util.DashboardUtils) CommandLineScriptExecutor(com.evolveum.midpoint.repo.common.commandline.CommandLineScriptExecutor) ScriptExpressionEvaluationContext(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext) ScriptExpressionEvaluatorFactory(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluatorFactory) AuthorizationParameters(com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters) SecurityEnforcer(com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) Task(com.evolveum.midpoint.task.api.Task) DefaultColumnUtils(com.evolveum.midpoint.model.common.util.DefaultColumnUtils) Component(org.springframework.stereotype.Component) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) FunctionLibrary(com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary) ExpressionUtil(com.evolveum.midpoint.repo.common.expression.ExpressionUtil) DashboardService(com.evolveum.midpoint.model.api.interaction.DashboardService) ReportService(com.evolveum.midpoint.report.api.ReportService) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull) Clock(com.evolveum.midpoint.common.Clock) Validate(org.apache.commons.lang.Validate) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap)

Example 20 with ReportType

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

the class TestCsvReportMultiNode method test102ExportAuditRecordsInsideTwoTimestamps.

@Test
public void test102ExportAuditRecordsInsideTwoTimestamps() 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(500).getTimestamp()).and().item(AuditEventRecordType.F_TIMESTAMP).le(auditRecords.get(1300).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() > 800 && rows.size() <= 810, "Unexpected number of rows in report. Expected:800-810, 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)

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