This is an automated email from the ASF dual-hosted git repository.
SvenO3 pushed a commit to branch
4430-chart-settings-not-correctly-migrated-after-event-schema-changes
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/4430-chart-settings-not-correctly-migrated-after-event-schema-changes
by this push:
new 6963e5409e Implement data view measure schema refresh
6963e5409e is described below
commit 6963e5409e31b786f37353da99044412328b7524
Author: Sven Oehler <[email protected]>
AuthorDate: Mon May 11 15:14:08 2026 +0200
Implement data view measure schema refresh
---
.../services/chart-field-provider.service.ts | 19 ++++++----
.../components/chart-view/chart-view.component.ts | 41 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/ui/src/app/chart-shared/services/chart-field-provider.service.ts
b/ui/src/app/chart-shared/services/chart-field-provider.service.ts
index cde144b615..ae0090ab87 100644
--- a/ui/src/app/chart-shared/services/chart-field-provider.service.ts
+++ b/ui/src/app/chart-shared/services/chart-field-provider.service.ts
@@ -42,13 +42,14 @@ export class ChartFieldProviderService {
nonNumericFields: [],
};
- sourceConfigs.forEach((sourceConfig, sourceIndex) => {
- sourceConfig.queryConfig.fields
+ (sourceConfigs ?? []).forEach((sourceConfig, sourceIndex) => {
+ (sourceConfig.queryConfig?.fields ?? [])
.filter(field => field.selected)
.forEach(field => {
this.addField(
sourceConfig.measureName,
- sourceConfig.measure.eventSchema.eventProperties,
+ sourceConfig.measure?.eventSchema?.eventProperties ??
+ [],
sourceIndex,
field,
provider,
@@ -73,6 +74,10 @@ export class ChartFieldProviderService {
p => p.runtimeName === fieldConfig.runtimeName,
);
+ if (!property) {
+ return;
+ }
+
if (!useAggregations) {
this.addSingleField(
measure,
@@ -82,7 +87,7 @@ export class ChartFieldProviderService {
provider,
);
} else {
- fieldConfig.aggregations.forEach(agg =>
+ (fieldConfig.aggregations ?? []).forEach(agg =>
this.addSingleField(
measure,
property,
@@ -141,7 +146,7 @@ export class ChartFieldProviderService {
}
public isDimensionProperty(p: EventProperty): boolean {
- return p.propertyScope === 'DIMENSION_PROPERTY';
+ return p?.propertyScope === 'DIMENSION_PROPERTY';
}
public isBoolean(p: EventPropertyUnion): boolean {
@@ -159,7 +164,7 @@ export class ChartFieldProviderService {
}
public isTimestamp(p: EventProperty) {
- return SemanticType.isTimestamp(p);
+ return !!p && SemanticType.isTimestamp(p);
}
public getAddedFields(
@@ -200,7 +205,7 @@ export class ChartFieldProviderService {
private isPrimitive(property: any): boolean {
return (
property instanceof EventPropertyPrimitive ||
- property['@class'] ===
+ property?.['@class'] ===
'org.apache.streampipes.model.schema.EventPropertyPrimitive'
);
}
diff --git a/ui/src/app/chart/components/chart-view/chart-view.component.ts
b/ui/src/app/chart/components/chart-view/chart-view.component.ts
index ffb1f4bc62..1a22154833 100644
--- a/ui/src/app/chart/components/chart-view/chart-view.component.ts
+++ b/ui/src/app/chart/components/chart-view/chart-view.component.ts
@@ -28,9 +28,11 @@ import {
ChartService,
DataExplorerWidgetModel,
DataLakeMeasure,
+ DatalakeRestService,
EventPropertyUnion,
FieldConfig,
LinkageData,
+ SourceConfig,
TimeSelectionConstants,
SpQueryResult,
TimeSettings,
@@ -144,6 +146,7 @@ export class ChartViewComponent
private authService = inject(AuthService);
private fieldProvider = inject(ChartFieldProviderService);
private assetSaveService = inject(AssetSaveService);
+ private datalakeRestService = inject(DatalakeRestService);
currentUser$: Subscription;
queryParams$: Subscription;
@@ -242,6 +245,9 @@ export class ChartViewComponent
this.chartNotFound = true;
return of(null);
}),
+ switchMap(res =>
+ res ? this.refreshDataViewMeasureSchemas(res) : of(null),
+ ),
)
.subscribe(res => {
if (!res) {
@@ -597,6 +603,41 @@ export class ChartViewComponent
this.queryParams$?.unsubscribe();
}
+ private refreshDataViewMeasureSchemas(
+ dataView: DataExplorerWidgetModel,
+ ): Observable<DataExplorerWidgetModel> {
+ const sourceConfigs = this.getSourceConfigs(dataView);
+ if (sourceConfigs.length === 0) {
+ return of(dataView);
+ }
+
+ return this.datalakeRestService.getAllMeasurementSeries().pipe(
+ map(measures => {
+ const measuresByName = new Map(
+ measures.map(measure => [measure.measureName, measure]),
+ );
+
+ sourceConfigs.forEach(sourceConfig => {
+ const latestMeasure = measuresByName.get(
+ sourceConfig.measureName,
+ );
+ if (latestMeasure) {
+ sourceConfig.measure = latestMeasure;
+ }
+ });
+
+ return dataView;
+ }),
+ catchError(() => of(dataView)),
+ );
+ }
+
+ private getSourceConfigs(
+ dataView: DataExplorerWidgetModel,
+ ): SourceConfig[] {
+ return dataView?.dataConfig?.sourceConfigs ?? [];
+ }
+
private hasMultipleSourceConfigs(widget: DataExplorerWidgetModel): boolean
{
return (widget?.dataConfig?.sourceConfigs?.length ?? 0) > 1;
}