From 02a15c935d16eded5837b2eb83c169662c7dbec2 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 18 Jun 2020 13:02:00 +0200 Subject: [PATCH 1/4] adding of 'visibility' element for DashboardType --- .../midpoint/gui/api/page/PageBase.java | 10 ++++++++++ .../admin/home/PageDashboardConfigurable.html | 2 +- .../admin/home/PageDashboardConfigurable.java | 16 +++++++++++++++- .../xml/ns/public/common/common-core-3.xsd | 18 ++++++++++++++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java index 7342e42d1bf..a402c0336e7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/gui/api/page/PageBase.java @@ -2126,6 +2126,16 @@ protected boolean isMenuActive() { StringValue dashboardOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER); return dashboard.getOid().equals(dashboardOid.toString()); } + + @Override + public VisibleEnableBehaviour getVisibleEnable() { + return new VisibleEnableBehaviour(){ + @Override + public boolean isVisible() { + return WebComponentUtil.getElementVisibility(dashboard.getVisibility()); + } + }; + } }; item.getItems().add(menu); }); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.html index 52eb5dbba2e..224f10a3eae 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.html @@ -11,7 +11,7 @@
-
+
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.java index 161038d6bc9..55597736211 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/home/PageDashboardConfigurable.java @@ -6,11 +6,14 @@ */ package com.evolveum.midpoint.web.page.admin.home; +import com.evolveum.midpoint.gui.api.util.WebComponentUtil; import com.evolveum.midpoint.web.application.Url; +import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.StringUtils; import org.apache.wicket.RestartResponseException; +import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.model.IModel; @@ -104,13 +107,24 @@ private void initInfoBoxes() { add(new ListView(ID_WIDGETS, new PropertyModel(dashboardModel, "widget")) { @Override protected void populateItem(ListItem item) { - item.add(new SmallInfoBoxPanel(ID_WIDGET, item.getModel(), + boolean visible = WebComponentUtil.getElementVisibility(item.getModelObject().getVisibility()); + SmallInfoBoxPanel box = new SmallInfoBoxPanel(ID_WIDGET, item.getModel(), PageDashboardConfigurable.this) { @Override public String getDashboardOid() { return dashboardModel.getObject().getOid(); } + }; + box.add(new VisibleEnableBehaviour(){ + @Override + public boolean isVisible() { + return visible; + } }); + if (visible) { + item.add(AttributeAppender.append("class", "col-lg-3 col-md-4 col-xs-6")); + } + item.add(box); } }); } diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index f1c700a8031..61ba44cf7ee 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -26247,10 +26247,7 @@

- TODO -

-

- TODO + Configuration Dasboard dashboard showing in GUI.

@@ -26266,6 +26263,19 @@ + + + +

+ Defines, whether this dashboard will be visible or it will be hidden. +

+
+ + DashboardType.visibility + +
+
From 52879dd38d74670767a47c543dda0a276d9dabf2 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 18 Jun 2020 13:53:10 +0200 Subject: [PATCH 2/4] fix for 'Save and Run' of reports --- .../midpoint/web/page/admin/reports/PageReport.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReport.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReport.java index ac3b91244f6..50865863179 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReport.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/reports/PageReport.java @@ -125,7 +125,13 @@ public void finishProcessing(AjaxRequestTarget target, Collection report = (PrismObject) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd(); + + PrismObject report; + if (getObjectModel().getObject().getOid() != null) { + report = getObjectModel().getObject().getObject(); + } else { + report = (PrismObject) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd(); + } getReportManager().runReport(report, null, task, result); } catch (Exception ex) { result.recordFatalError(ex); From e19ba2b87afbb47bd4f38b16afe54b16a816e232 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 18 Jun 2020 13:54:07 +0200 Subject: [PATCH 3/4] adding of option show only table of widgets in dashboard reports --- .../xml/ns/public/common/common-core-3.xsd | 14 +++ .../engine/DashboardEngineController.java | 7 -- .../export/HtmlExportController.java | 92 ++++++++++--------- 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 61ba44cf7ee..0c17865fe29 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -24045,6 +24045,20 @@
+ + + +

+ Some export types show tables of objects from widgets. + These tables don't show if this element is true. +

+
+ + 4.2 + DashboardReportEngineConfigurationType.showOnlyWidgetsTable + +
+
diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/engine/DashboardEngineController.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/engine/DashboardEngineController.java index be2051573c8..d635f70247a 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/engine/DashboardEngineController.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/engine/DashboardEngineController.java @@ -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; diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/HtmlExportController.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/HtmlExportController.java index e271f78841b..2d0df6c1593 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/HtmlExportController.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/HtmlExportController.java @@ -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++; From 65059be6cb056056873d46c4183f7f17b3bf4f42 Mon Sep 17 00:00:00 2001 From: lskublik Date: Thu, 18 Jun 2020 16:16:04 +0200 Subject: [PATCH 4/4] rewrite 130-report-certification-definitions to new report --- .../130-report-certification-definitions.xml | 128 ++++++++++++++++-- ...ollection-certification-definition-all.xml | 24 ++++ .../controller/export/ExportController.java | 46 ++----- 3 files changed, 146 insertions(+), 52 deletions(-) create mode 100644 gui/admin-gui/src/main/resources/initial-objects/255-object-collection-certification-definition-all.xml diff --git a/gui/admin-gui/src/main/resources/initial-objects/130-report-certification-definitions.xml b/gui/admin-gui/src/main/resources/initial-objects/130-report-certification-definitions.xml index 81c29330196..2414c86e0a8 100644 --- a/gui/admin-gui/src/main/resources/initial-objects/130-report-certification-definitions.xml +++ b/gui/admin-gui/src/main/resources/initial-objects/130-report-certification-definitions.xml @@ -1,6 +1,6 @@ + + + All certification definition + AccessCertificationDefinitionType + + + + + + + diff --git a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/ExportController.java b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/ExportController.java index 813db1ef363..654deec051c 100644 --- a/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/ExportController.java +++ b/model/report-impl/src/main/java/com/evolveum/midpoint/report/impl/controller/export/ExportController.java @@ -89,9 +89,9 @@ protected void recordProgress(Task task, long progress, OperationResult opResult public abstract String getType(); - protected String getMessage(Enum e) { - return getMessage(e.getDeclaringClass().getSimpleName() + '.' + e.name()); - } +// protected String getMessage(Enum e) { +// return getMessage(e.getDeclaringClass().getSimpleName() + '.' + e.name()); +// } protected String getMessage(String key) { return getMessage(key, null); @@ -170,10 +170,8 @@ protected String getRealValueAsString(GuiObjectColumnType column, PrismObject objectDefinition, ItemPath path) { -// if(specialKeyLocalization.containsKey(name)) { -// return getMessage(specialKeyLocalization.get(name)); -// } -// if(isCustomPerformedColumn(path)) { //TODO -// return getLabelNameForCustom(name); -// } if (path != null) { ItemDefinition def = objectDefinition.findItemDefinition(path); if (def == null) { @@ -309,22 +282,21 @@ protected String getStringValueByAuditColumn(AuditEventRecord record, ItemPath p private String getStringValueByAuditColumn(AuditEventRecord record, ItemPath path) { switch (path.toString()) { case AuditConstants.TIME_COLUMN: - SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE, d. MMM yyyy HH:mm:ss", Locale.US); - return dateFormat.format(record.getTimestamp()); + return ReportUtils.prettyPrintForReport(new Date(record.getTimestamp())); case AuditConstants.INITIATOR_COLUMN: return record.getInitiator() == null ? "" : record.getInitiator().getName().getOrig(); case AuditConstants.EVENT_STAGE_COLUMN: - return record.getEventStage() == null ? "" : getMessage(record.getEventStage()); + return record.getEventStage() == null ? "" : ReportUtils.prettyPrintForReport(record.getEventStage()); case AuditConstants.EVENT_TYPE_COLUMN: - return record.getEventType() == null ? "" : getMessage(record.getEventType()); + return record.getEventType() == null ? "" : ReportUtils.prettyPrintForReport(record.getEventType()); case AuditConstants.TARGET_COLUMN: return record.getTarget() == null ? "" : getObjectNameFromRef(record.getTarget().getRealValue()); case AuditConstants.TARGET_OWNER_COLUMN: return record.getTargetOwner() == null ? "" : record.getTargetOwner().getName().getOrig(); case AuditConstants.CHANNEL_COLUMN: - return record.getChannel() == null ? "" : QNameUtil.uriToQName(record.getChannel()).getLocalPart(); + return record.getChannel() == null ? "" : ReportUtils.prettyPrintForReport(QNameUtil.uriToQName(record.getChannel())); case AuditConstants.OUTCOME_COLUMN: - return record.getOutcome() == null ? "" : getMessage(record.getOutcome()); + return record.getOutcome() == null ? "" : ReportUtils.prettyPrintForReport(record.getOutcome()); case AuditConstants.MESSAGE_COLUMN: return record.getMessage() == null ? "" : record.getMessage(); case AuditConstants.DELTA_COLUMN: