Skip to content

Commit

Permalink
adding of option show only table of widgets in dashboard reports
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jun 18, 2020
1 parent 52879dd commit e19ba2b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 52 deletions.
Expand Up @@ -24045,6 +24045,20 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="showOnlyWidgetsTable" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false">
<xsd:annotation>
<xsd:documentation>
<p>
Some export types show tables of objects from widgets.
These tables don't show if this element is true.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>4.2</a:since>
<a:displayName>DashboardReportEngineConfigurationType.showOnlyWidgetsTable</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO: other elements to configure the report -->
</xsd:sequence>
</xsd:extension>
Expand Down
Expand Up @@ -6,22 +6,15 @@
*/
package com.evolveum.midpoint.report.impl.controller.engine;

import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.repo.common.ObjectResolver;
import com.evolveum.midpoint.report.api.ReportService;
import com.evolveum.midpoint.report.impl.ReportServiceImpl;
import com.evolveum.midpoint.report.impl.controller.export.ExportController;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.io.File;

Expand Down
Expand Up @@ -85,54 +85,56 @@ public byte[] processDashboard(DashboardReportEngineConfigurationType dashboardC
task.setExpectedTotal((long) dashboard.getWidget().size());
recordProgress(task, i, result, LOGGER);
for (DashboardWidgetType widget : dashboard.getWidget()) {
DashboardWidget widgetData = getReportService().getDashboardService().createWidgetData(widget, task, result);
widgetTBody.with(createTBodyRow(widgetData));
if (widget == null) {
throw new IllegalArgumentException("Widget in DashboardWidget is null");
}
DashboardWidgetPresentationType presentation = widget.getPresentation();
if (!DashboardUtils.isDataFieldsOfPresentationNullOrEmpty(presentation)) {
ContainerTag tableBox = null;
DashboardWidgetSourceTypeType sourceType = DashboardUtils.getSourceType(widget);
if (sourceType == null) {
throw new IllegalStateException("No source type specified in " + widget);
}
CollectionRefSpecificationType collectionRefSpecification = getReportService().getDashboardService().getCollectionRefSpecificationType(widget, task, result);
ObjectCollectionType collection = getReportService().getDashboardService().getObjectCollectionType(widget, task, result);

CompiledObjectCollectionView compiledCollection = new CompiledObjectCollectionView();
if (collection != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, collection.getDefaultView());
} else if (collectionRefSpecification.getBaseCollectionRef() != null
&& collectionRefSpecification.getBaseCollectionRef().getCollectionRef() != null) {
ObjectCollectionType baseCollection = (ObjectCollectionType) getObjectFromReference(collectionRefSpecification.getBaseCollectionRef().getCollectionRef()).asObjectable();
getReportService().getModelInteractionService().applyView(compiledCollection, baseCollection.getDefaultView());
}

if (widget.getPresentation() != null && widget.getPresentation().getView() != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, widget.getPresentation().getView());
}

QName collectionType = resolveTypeQname(collectionRefSpecification, compiledCollection);
GuiObjectListViewType reportView = getReportViewByType(dashboardConfig, collectionType);
if (reportView != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, reportView);
}

switch (sourceType) {
case OBJECT_COLLECTION:
tableBox = createTableBoxForObjectView(widgetData.getLabel(), collectionRefSpecification, compiledCollection, null, task, result, false);
break;
case AUDIT_SEARCH:
if (collection == null) {
LOGGER.error("CollectionRef is null for report of audit records");
throw new IllegalArgumentException("CollectionRef is null for report of audit records");
}
tableBox = createTableBoxForAuditView(widgetData.getLabel(), collectionRefSpecification, compiledCollection, null, task, result, false);
break;
}
if (tableBox != null) {
tableboxesFromWidgets.add(tableBox);
DashboardWidget widgetData = getReportService().getDashboardService().createWidgetData(widget, task, result);
widgetTBody.with(createTBodyRow(widgetData));
if (!Boolean.TRUE.equals(dashboardConfig.isShowOnlyWidgetsTable())) {
DashboardWidgetPresentationType presentation = widget.getPresentation();
if (!DashboardUtils.isDataFieldsOfPresentationNullOrEmpty(presentation)) {
ContainerTag tableBox = null;
DashboardWidgetSourceTypeType sourceType = DashboardUtils.getSourceType(widget);
if (sourceType == null) {
throw new IllegalStateException("No source type specified in " + widget);
}
CollectionRefSpecificationType collectionRefSpecification = getReportService().getDashboardService().getCollectionRefSpecificationType(widget, task, result);
ObjectCollectionType collection = getReportService().getDashboardService().getObjectCollectionType(widget, task, result);

CompiledObjectCollectionView compiledCollection = new CompiledObjectCollectionView();
if (collection != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, collection.getDefaultView());
} else if (collectionRefSpecification.getBaseCollectionRef() != null
&& collectionRefSpecification.getBaseCollectionRef().getCollectionRef() != null) {
ObjectCollectionType baseCollection = (ObjectCollectionType) getObjectFromReference(collectionRefSpecification.getBaseCollectionRef().getCollectionRef()).asObjectable();
getReportService().getModelInteractionService().applyView(compiledCollection, baseCollection.getDefaultView());
}

if (widget.getPresentation() != null && widget.getPresentation().getView() != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, widget.getPresentation().getView());
}

QName collectionType = resolveTypeQname(collectionRefSpecification, compiledCollection);
GuiObjectListViewType reportView = getReportViewByType(dashboardConfig, collectionType);
if (reportView != null) {
getReportService().getModelInteractionService().applyView(compiledCollection, reportView);
}

switch (sourceType) {
case OBJECT_COLLECTION:
tableBox = createTableBoxForObjectView(widgetData.getLabel(), collectionRefSpecification, compiledCollection, null, task, result, false);
break;
case AUDIT_SEARCH:
if (collection == null) {
LOGGER.error("CollectionRef is null for report of audit records");
throw new IllegalArgumentException("CollectionRef is null for report of audit records");
}
tableBox = createTableBoxForAuditView(widgetData.getLabel(), collectionRefSpecification, compiledCollection, null, task, result, false);
break;
}
if (tableBox != null) {
tableboxesFromWidgets.add(tableBox);
}
}
}
i++;
Expand Down

0 comments on commit e19ba2b

Please sign in to comment.