You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/03/12 20:47:09 UTC
[incubator-streampipes] 03/04: Select runtime names from event
schema
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch STREAMPIPES-79
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit b5dbb190059859dd8576180217412b319148f3cd
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Mar 11 22:43:30 2020 +0100
Select runtime names from event schema
---
.../widgets/base/base-data-explorer-widget.ts | 44 +++++++++++++++++++---
.../line-chart/line-chart-widget.component.ts | 5 ++-
.../widgets/table/table-widget.component.ts | 2 +-
3 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts b/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
index 5ecfceb..3589308 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/base/base-data-explorer-widget.ts
@@ -23,6 +23,7 @@ import { DateRange } from '../../../../core-model/datalake/DateRange';
import { IDataViewDashboardItem } from '../../../models/dataview-dashboard.model';
import { EventSchema } from '../../../../connect/schema-editor/model/EventSchema';
import { EventPropertyPrimitive } from '../../../../connect/schema-editor/model/EventPropertyPrimitive';
+import { EventPropertyComponent } from '../../../../connect/schema-editor/event-property/event-property.component';
export abstract class BaseDataExplorerWidget implements OnChanges {
@@ -67,18 +68,49 @@ export abstract class BaseDataExplorerWidget implements OnChanges {
public abstract updateData();
- // TODO add static properties that are ignored
- getPropertyKeys(eventSchema: EventSchema, except: string[] = []) {
+ getValuePropertyKeys(eventSchema: EventSchema) {
const propertyKeys: string[] = [];
- // eventSchema.eventProperties.forEach(p => {
- // if (except.p.domainProperty)
- // propertyKeys.push(p.getRuntimeName());
- // });
+ eventSchema.eventProperties.forEach(p => {
+ if (p.domainProperty !== 'http://schema.org/DateTime') {
+ propertyKeys.push(p.getRuntimeName());
+ }
+ });
return propertyKeys;
}
+ getNumericPropertyKeys(eventSchema: EventSchema) {
+ const propertyKeys: string[] = [];
+
+ eventSchema.eventProperties.forEach(p => {
+ if (p.domainProperty !== 'http://schema.org/DateTime' && this.isNumber(p)) {
+ propertyKeys.push(p.getRuntimeName());
+ }
+ });
+
+ return propertyKeys;
+ }
+
+ getTimestampPropertyKey(eventSchema: EventSchema) {
+ const propertyKeys: string[] = [];
+
+ const result = eventSchema.eventProperties.find(p =>
+ p.domainProperty === 'http://schema.org/DateTime'
+ );
+
+ return result.getRuntimeName();
+ }
+
+ isNumber(p: EventProperty): boolean {
+ return (p instanceof EventPropertyPrimitive &&
+ (p.runtimeType === 'http://www.w3.org/2001/XMLSchema#number') ||
+ (p.runtimeType === 'http://www.w3.org/2001/XMLSchema#float') ||
+ (p.runtimeType === 'http://www.w3.org/2001/XMLSchema#double') ||
+ (p.runtimeType === 'http://www.w3.org/2001/XMLSchema#integer'))
+ ? true : false;
+}
+
// TODO add get a specific property
getPropertyKeysOfStaticProperty(eventSchema) {
diff --git a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
index f3f57e5..8d4f3b5 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/line-chart/line-chart-widget.component.ts
@@ -31,7 +31,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget implements
data: any[] = undefined;
availableColumns: string[] = [];
yKeys: string[] = [];
- xKey = 'timestamp';
+ xKey: string;
constructor(private dataLakeRestService: DatalakeRestService) {
super();
@@ -40,7 +40,8 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget implements
ngOnInit(): void {
- this.availableColumns = this.getPropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
+ this.availableColumns = this.getNumericPropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
+ this.xKey = this.getTimestampPropertyKey(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
// Reduce selected columns when more then 6
this.yKeys = this.availableColumns.length > 6 ? this.availableColumns.slice(0, 5) : this.availableColumns;
diff --git a/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts b/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
index 9f33492..59540a8 100644
--- a/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
+++ b/ui/src/app/data-explorer-v2/components/widgets/table/table-widget.component.ts
@@ -45,7 +45,7 @@ export class TableWidgetComponent extends BaseDataExplorerWidget implements OnIn
ngOnInit(): void {
this.dataSource.sort = this.sort;
- this.availableColumns = this.getPropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
+ this.availableColumns = this.getValuePropertyKeys(this.dataExplorerWidget.dataLakeMeasure.eventSchema);
// Reduce selected columns when more then 6
this.selectedColumns = this.availableColumns.length > 6 ? this.availableColumns.slice(0, 5) : this.availableColumns;