Skip to content

Commit

Permalink
Add download button for import reports
Browse files Browse the repository at this point in the history
"Import report" was added to archetypes that show the download
button, plus the code to find dataRef in import report activity
definition was added.

This resolves MID-7862.
  • Loading branch information
mederly committed Apr 26, 2022
1 parent 43e0eb5 commit ca5d1d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,10 @@ public static boolean isRecomputation(TaskType task) {
}

public static boolean isReport(TaskType task) {
return isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_TASK) || isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_EXPORT_CLASSIC_TASK) || isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_EXPORT_DISTRIBUTED_TASK);
return isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_TASK)
|| isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_EXPORT_CLASSIC_TASK)
|| isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_EXPORT_DISTRIBUTED_TASK)
|| isArchetypedTask(task, SystemObjectsType.ARCHETYPE_REPORT_IMPORT_CLASSIC_TASK);
}

public static boolean isImport(TaskType task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.evolveum.midpoint.gui.impl.page.admin.component;

import static com.evolveum.midpoint.prism.Referencable.getOid;

import static java.util.Collections.singletonList;

import java.io.InputStream;
Expand Down Expand Up @@ -70,6 +72,9 @@
import com.evolveum.midpoint.web.util.TaskOperationUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class TaskOperationalButtonsPanel extends AssignmentHolderOperationalButtonsPanel<TaskType> {

private static final Trace LOGGER = TraceManager.getTrace(TaskOperationalButtonsPanel.class);
Expand Down Expand Up @@ -435,16 +440,34 @@ private ReportDataType getReportData() {

private String getReportDataOid() {
PrismObject<TaskType> task = getObjectType().asPrismObject();
PrismReference reportData = task.findReference(ItemPath.create(TaskType.F_EXTENSION, ReportConstants.REPORT_DATA_PROPERTY_NAME));
if (reportData == null || reportData.getRealValue() == null || reportData.getRealValue().getOid() == null) {
PrismProperty<String> reportOutputOid = task.findProperty(ItemPath.create(TaskType.F_EXTENSION, ReportConstants.REPORT_OUTPUT_OID_PROPERTY_NAME));
if (reportOutputOid == null) {
return null;
}
PrismReference reportData = task.findReference(
ItemPath.create(TaskType.F_EXTENSION, ReportConstants.REPORT_DATA_PROPERTY_NAME));
if (reportData != null && reportData.getRealValue() != null && reportData.getRealValue().getOid() != null) {
return reportData.getRealValue().getOid();
}
PrismProperty<String> reportOutputOid = task.findProperty(
ItemPath.create(TaskType.F_EXTENSION, ReportConstants.REPORT_OUTPUT_OID_PROPERTY_NAME));
if (reportOutputOid != null) {
return reportOutputOid.getRealValue();
}
return getReportDataOidFromImportActivity(task.asObjectable());
}

return reportData.getRealValue().getOid();
/** An approximate version for now: assumes that the report activity is the root one. */
private @Nullable String getReportDataOidFromImportActivity(@NotNull TaskType task) {
ActivityDefinitionType activity = task.getActivity();
if (activity == null) {
return null;
}
WorkDefinitionsType work = activity.getWork();
if (work == null) {
return null;
}
ClassicReportImportWorkDefinitionType reportImport = work.getReportImport();
if (reportImport == null) {
return null;
}
return getOid(reportImport.getReportDataRef());
}

private void createRefreshNowIconButton(RepeatingView repeatingView) {
Expand Down

0 comments on commit ca5d1d4

Please sign in to comment.