-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,060 additions
and
74 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
...c/main/java/com/evolveum/midpoint/report/impl/activity/AbstractReportActivitySupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.report.impl.activity; | ||
|
||
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; | ||
import com.evolveum.midpoint.repo.common.ObjectResolver; | ||
import com.evolveum.midpoint.repo.common.activity.Activity; | ||
import com.evolveum.midpoint.repo.common.activity.ActivityExecutionException; | ||
import com.evolveum.midpoint.repo.common.activity.execution.ExecutionInstantiationContext; | ||
import com.evolveum.midpoint.repo.common.activity.state.ActivityState; | ||
import com.evolveum.midpoint.repo.common.task.CommonTaskBeans; | ||
import com.evolveum.midpoint.report.impl.ReportServiceImpl; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.RunningTask; | ||
import com.evolveum.midpoint.util.exception.*; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportExportWorkStateType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static com.evolveum.midpoint.schema.result.OperationResultStatus.FATAL_ERROR; | ||
import static com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus.PERMANENT_ERROR; | ||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.ReportExportWorkStateType.F_REPORT_DATA_REF; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Contains common functionality for all activity executions (export and import). | ||
* This is an experiment - using object composition instead of inheritance. | ||
* | ||
* TODO better name | ||
*/ | ||
abstract class AbstractReportActivitySupport { | ||
|
||
@NotNull protected final RunningTask runningTask; | ||
@NotNull protected final CommonTaskBeans beans; | ||
|
||
/** | ||
* Resolved report object. | ||
*/ | ||
private ReportType report; | ||
|
||
/** | ||
* Compiled final collection from more collections and archetypes related to object type. | ||
*/ | ||
private CompiledObjectCollectionView compiledView; | ||
|
||
AbstractReportActivitySupport( | ||
ExecutionInstantiationContext context) { | ||
runningTask = context.getTaskExecution().getRunningTask(); | ||
beans = context.getTaskExecution().getBeans(); | ||
} | ||
|
||
void initializeExecution(OperationResult result) throws CommonException, ActivityExecutionException { | ||
setupReportObject(result); | ||
} | ||
|
||
private void setupReportObject(OperationResult result) throws CommonException { | ||
AbstractReportWorkDefinition workDefinition = getWorkDefinition(); | ||
report = getObjectResolver().resolve(workDefinition.getReportRef(), ReportType.class, | ||
null, "resolving report", runningTask, result); | ||
} | ||
|
||
protected abstract ObjectResolver getObjectResolver(); | ||
|
||
protected abstract AbstractReportWorkDefinition getWorkDefinition(); | ||
|
||
private void setupCompiledView(OperationResult result) throws CommonException { | ||
compiledView = getReportService().createCompiledView(report.getObjectCollection(), true, runningTask, result); | ||
} | ||
|
||
protected abstract ReportServiceImpl getReportService(); | ||
|
||
/** | ||
* Should be called only after initialization. | ||
*/ | ||
public @NotNull ReportType getReport() { | ||
return requireNonNull(report); | ||
} | ||
|
||
/** | ||
* Should be called only after initialization. | ||
*/ | ||
@NotNull CompiledObjectCollectionView getCompiledCollectionView(OperationResult result) throws CommonException { | ||
if (compiledView == null) { | ||
setupCompiledView(result); | ||
} | ||
return compiledView; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...-impl/src/main/java/com/evolveum/midpoint/report/impl/activity/ActivityImportSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.report.impl.activity; | ||
|
||
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; | ||
import com.evolveum.midpoint.repo.common.ObjectResolver; | ||
import com.evolveum.midpoint.repo.common.activity.Activity; | ||
import com.evolveum.midpoint.repo.common.activity.ActivityExecutionException; | ||
import com.evolveum.midpoint.repo.common.activity.execution.ExecutionInstantiationContext; | ||
import com.evolveum.midpoint.repo.common.activity.state.ActivityState; | ||
import com.evolveum.midpoint.report.impl.ReportServiceImpl; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.exception.ObjectNotFoundException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportDataType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportExportWorkStateType; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static com.evolveum.midpoint.schema.result.OperationResultStatus.FATAL_ERROR; | ||
import static com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus.PERMANENT_ERROR; | ||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.ReportExportWorkStateType.F_REPORT_DATA_REF; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Contains common functionality for both activity executions (data creation + data aggregation). | ||
* This is an experiment - using object composition instead of inheritance. | ||
* | ||
* TODO better name | ||
*/ | ||
class ActivityImportSupport extends AbstractReportActivitySupport { | ||
|
||
@NotNull private final Activity<ClassicReportImportWorkDefinition, ClassicReportImportActivityHandler> activity; | ||
|
||
/** | ||
* Resolved report data object. | ||
*/ | ||
private ReportDataType reportData; | ||
|
||
ActivityImportSupport( | ||
ExecutionInstantiationContext<ClassicReportImportWorkDefinition, ClassicReportImportActivityHandler> context) { | ||
super(context); | ||
activity = context.getActivity(); | ||
} | ||
|
||
@Override | ||
void initializeExecution(OperationResult result) throws CommonException, ActivityExecutionException { | ||
super.initializeExecution(result); | ||
setupReportDataObject(result); | ||
} | ||
|
||
private void setupReportDataObject(OperationResult result) throws CommonException { | ||
@NotNull ClassicReportImportWorkDefinition workDefinition = activity.getWorkDefinition(); | ||
reportData = getObjectResolver().resolve(workDefinition.getReportDataRef(), ReportDataType.class, | ||
null, "resolving report data", runningTask, result); | ||
} | ||
|
||
@Override | ||
protected ObjectResolver getObjectResolver() { | ||
return activity.getHandler().objectResolver; | ||
} | ||
|
||
@Override | ||
protected AbstractReportWorkDefinition getWorkDefinition() { | ||
return activity.getWorkDefinition(); | ||
} | ||
|
||
@Override | ||
protected ReportServiceImpl getReportService() { | ||
return activity.getHandler().reportService; | ||
} | ||
|
||
public ReportDataType getReportData() { | ||
return reportData; | ||
} | ||
|
||
boolean existImportScript() { | ||
return getReport().getBehavior() != null && getReport().getBehavior().getImportScript() != null; | ||
} | ||
|
||
boolean existCollectionConfiguration() { | ||
return getReport().getObjectCollection() != null; | ||
} | ||
} |
Oops, something went wrong.