Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 19, 2020
2 parents 266923f + a8ca8ea commit 84567b4
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 111 deletions.
Expand Up @@ -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);
});
Expand Down
Expand Up @@ -11,7 +11,7 @@
<body>
<wicket:extend>
<div class="row dashboard-widgets">
<div class="col-lg-3 col-md-4 col-xs-6" wicket:id="widgets">
<div wicket:id="widgets">
<div class="padding-bottom-20" wicket:id="widget"/>
</div>
</div>
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -104,13 +107,24 @@ private void initInfoBoxes() {
add(new ListView<DashboardWidgetType>(ID_WIDGETS, new PropertyModel(dashboardModel, "widget")) {
@Override
protected void populateItem(ListItem<DashboardWidgetType> 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);
}
});
}
Expand Down
Expand Up @@ -125,7 +125,13 @@ public void finishProcessing(AjaxRequestTarget target, Collection<ObjectDeltaOpe
showResult(result);
Task task = createSimpleTask("run_task");
try {
PrismObject<ReportType> report = (PrismObject<ReportType>) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd();

PrismObject<ReportType> report;
if (getObjectModel().getObject().getOid() != null) {
report = getObjectModel().getObject().getObject();
} else {
report = (PrismObject<ReportType>) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd();
}
getReportManager().runReport(report, null, task, result);
} catch (Exception ex) {
result.recordFatalError(ex);
Expand Down

Large diffs are not rendered by default.

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2020 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<objectCollection xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
oid="00000000-0000-0000-0001-000000000255">
<name>All certification definition</name>
<type>AccessCertificationDefinitionType</type>
<filter>
<q:all/>
</filter>
<getOptions>
<option>
<options>
<resolveNames>true</resolveNames>
</options>
</option>
</getOptions>
</objectCollection>
Expand Up @@ -24088,6 +24088,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 @@ -26290,10 +26304,7 @@
<xsd:annotation>
<xsd:documentation>
<p>
TODO
</p>
<p>
TODO
Configuration Dasboard dashboard showing in GUI.
</p>
</xsd:documentation>
<xsd:appinfo>
Expand All @@ -26309,6 +26320,19 @@
<!-- TODO: layout -->
<xsd:element name="widget" type="tns:DashboardWidgetType" minOccurs="0" maxOccurs="unbounded">
</xsd:element>
<xsd:element name="visibility" type="tns:UserInterfaceElementVisibilityType"
minOccurs="0" maxOccurs="1" default="automatic">
<xsd:annotation>
<xsd:documentation>
<p>
Defines, whether this dashboard will be visible or it will be hidden.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:displayName>DashboardType.visibility</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
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 @@ -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);
Expand Down Expand Up @@ -170,10 +170,8 @@ protected String getRealValueAsString(GuiObjectColumnType column, PrismObject<Ob
Object realObject = value.getRealValue();
if (realObject == null) {
realObject = "";
} else if (realObject instanceof Enum) {
realObject = getMessage((Enum) realObject);
}
sb.append(realObject);
sb.append(ReportUtils.prettyPrintForReport(realObject));
} else if (value instanceof PrismReferenceValue) {
sb.append(getObjectNameFromRef(((PrismReferenceValue) value).getRealValue()));
}
Expand Down Expand Up @@ -237,33 +235,8 @@ private String evaluateExpression(ExpressionType expression, Object valueObject,
return values.iterator().next();
}

// private String getStyleForColumn(String column) {
// switch (column) {
// case TIME_COLUMN:
// return "width: 10%;";
// case INITIATOR_COLUMN:
// return "width: 8%;";
// case EVENT_STAGE_COLUMN:
// return "width: 5%;";
// case EVENT_TYPE_COLUMN:
// return "width: 10%;";
// case TARGET_COLUMN:
// return "width: 8%;";
// case OUTCOME_COLUMN:
// return "width: 7%;";
// case DELTA_COLUMN:
// return "width: 35%;";
// }
// return "";
// }

protected String getColumnLabel(String name, PrismObjectDefinition<ObjectType> 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) {
Expand Down Expand Up @@ -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:
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 84567b4

Please sign in to comment.