This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 45528b25c1 refactor(#2615): Change datatypes from class to string
(#2616)
45528b25c1 is described below
commit 45528b25c15edaeb1a873a6a2e78fd3cc8cb20f1
Author: Philipp Zehnder <[email protected]>
AuthorDate: Sat Apr 6 22:01:50 2024 +0200
refactor(#2615): Change datatypes from class to string (#2616)
* refactor(#2615): Change datatypes from class to string
* refactor(#2615): Move and rename data-type.service
* refactor(#2615): Moving all data types to the data type service
* refactor(#2615): Make semantic data type service static
* refactor(#2615): Change data type names to upper case
* refactor(#2615): Add geo variables to semantic type service
* refactor(#2615): Rename classes semantic type and data type
* fix: Fix linting
* fix(#2651): Change import to platform-service
* fix(#2651): Remove circular dependency
---
.../src/lib/model/types/data-type.ts | 43 +++++++++++++
.../src/lib/model/types/semantic-type.ts | 55 +++++++++++++++++
.../platform-services/src/public-api.ts | 3 +
.../service-configs/service-configs.component.ts | 3 +-
.../event-property-row.component.ts | 10 ++-
.../event-schema/event-schema.component.ts | 12 ++--
.../edit-schema-transformation.component.ts | 14 ++---
.../edit-event-property.component.ts | 9 +--
ui/src/app/connect/filter/timestamp.pipe.ts | 12 ++--
.../services/transformation-rule.service.ts | 5 +-
.../core-services/types/semantic-type.service.ts | 72 ----------------------
.../field-names-table.component.ts | 9 ++-
.../live-preview-table.component.ts | 9 ++-
.../static-free-input.component.ts | 25 +++-----
.../widgets/table/table-widget.component.ts | 11 ++--
.../dashboard/registry/widget-config-builder.ts | 10 +--
ui/src/app/dashboard/sdk/ep-requirements.ts | 22 +++----
.../app/dashboard/sdk/matching/datatype-match.ts | 12 ++--
ui/src/app/dashboard/sdk/model/datatypes.ts | 38 ------------
ui/src/app/dashboard/sdk/model/vocabulary.ts | 23 -------
.../data-explorer-field-provider-service.ts | 17 +++--
.../user-defined-output.component.ts | 19 +++---
22 files changed, 190 insertions(+), 243 deletions(-)
diff --git
a/ui/projects/streampipes/platform-services/src/lib/model/types/data-type.ts
b/ui/projects/streampipes/platform-services/src/lib/model/types/data-type.ts
new file mode 100644
index 0000000000..bc82b2cd54
--- /dev/null
+++ b/ui/projects/streampipes/platform-services/src/lib/model/types/data-type.ts
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+export class DataType {
+ public static readonly XSD: string = 'http://www.w3.org/2001/XMLSchema#';
+
+ public static readonly INTEGER = this.XSD + 'integer';
+ public static readonly LONG = this.XSD + 'long';
+ public static readonly FLOAT = this.XSD + 'float';
+ public static readonly BOOLEAN = this.XSD + 'boolean';
+ public static readonly STRING = this.XSD + 'string';
+ public static readonly DOUBLE = this.XSD + 'double';
+ public static readonly NUMBER = this.XSD + 'number';
+
+ public static isNumberType(datatype: string): boolean {
+ return (
+ datatype === DataType.DOUBLE ||
+ datatype === DataType.INTEGER ||
+ datatype === DataType.LONG ||
+ datatype === DataType.FLOAT ||
+ datatype === DataType.NUMBER
+ );
+ }
+
+ public static isBooleanType(datatype: string): boolean {
+ return datatype === DataType.BOOLEAN;
+ }
+}
diff --git
a/ui/projects/streampipes/platform-services/src/lib/model/types/semantic-type.ts
b/ui/projects/streampipes/platform-services/src/lib/model/types/semantic-type.ts
new file mode 100644
index 0000000000..e0aff4fb37
--- /dev/null
+++
b/ui/projects/streampipes/platform-services/src/lib/model/types/semantic-type.ts
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { EventProperty } from '../gen/streampipes-model';
+
+export class SemanticType {
+ public static readonly SO: string = 'http://schema.org/';
+ public static readonly GEO: string = 'http://www.w3.org/2003/01/geo/';
+
+ public static readonly TIMESTAMP: string = SemanticType.SO + 'DateTime';
+
+ public static readonly SO_NUMBER: string = SemanticType.SO + 'Number';
+ public static readonly SO_URL: string = SemanticType.SO + 'URL';
+
+ public static readonly IMAGE: string = 'https://image.com';
+
+ public static readonly GEO_LAT: string = SemanticType.GEO +
'wgs84_pos#lat';
+ public static readonly GEO_LONG: string =
+ SemanticType.GEO + 'wgs84_pos#long';
+
+ public static getValue(inputValue: any, semanticType: string) {
+ if (semanticType === SemanticType.TIMESTAMP) {
+ return new Date(inputValue).toLocaleString();
+ } else {
+ return inputValue;
+ }
+ }
+
+ public static isTimestamp(property: EventProperty): boolean {
+ return property.domainProperties.includes(SemanticType.TIMESTAMP);
+ }
+
+ public static isImage(property: EventProperty): boolean {
+ return property.domainProperties.includes(SemanticType.IMAGE);
+ }
+
+ public static isNumber(property: EventProperty): boolean {
+ return property.domainProperties.includes(SemanticType.SO_NUMBER);
+ }
+}
diff --git a/ui/projects/streampipes/platform-services/src/public-api.ts
b/ui/projects/streampipes/platform-services/src/public-api.ts
index 669bf4f238..fd66ce0986 100644
--- a/ui/projects/streampipes/platform-services/src/public-api.ts
+++ b/ui/projects/streampipes/platform-services/src/public-api.ts
@@ -67,3 +67,6 @@ export * from './lib/model/user/user.model';
export * from './lib/model/assets/asset.model';
export * from './lib/model/labels/labels.model';
+
+export * from './lib/model/types/data-type';
+export * from './lib/model/types/semantic-type';
diff --git
a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.ts
b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.ts
index 286ff403bf..eb912a4147 100644
---
a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.ts
+++
b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.ts
@@ -18,7 +18,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { SpServiceConfiguration } from '@streampipes/platform-services';
-import { SemanticTypeService } from
'../../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-service-configs',
@@ -29,7 +28,7 @@ export class ServiceConfigsComponent {
@Output() updateServiceConfiguration: EventEmitter<SpServiceConfiguration>
=
new EventEmitter<SpServiceConfiguration>();
- constructor(public semanticTypeService: SemanticTypeService) {}
+ constructor() {}
updateConfiguration(): void {
this.updateServiceConfiguration.emit(this.serviceConfiguration);
diff --git
a/ui/src/app/connect/components/adapter-configuration/schema-editor/event-property-row/event-property-row.component.ts
b/ui/src/app/connect/components/adapter-configuration/schema-editor/event-property-row/event-property-row.component.ts
index 316af7e25c..93e776b6ec 100644
---
a/ui/src/app/connect/components/adapter-configuration/schema-editor/event-property-row/event-property-row.component.ts
+++
b/ui/src/app/connect/components/adapter-configuration/schema-editor/event-property-row/event-property-row.component.ts
@@ -19,12 +19,14 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { TreeNode } from '@ali-hm/angular-tree-component';
import {
+ DataType,
EventProperty,
EventPropertyList,
EventPropertyNested,
EventPropertyPrimitive,
EventPropertyUnion,
EventSchema,
+ SemanticType,
FieldStatusInfo,
} from '@streampipes/platform-services';
import { EditEventPropertyComponent } from
'../../../../dialog/edit-event-property/edit-event-property.component';
@@ -33,7 +35,6 @@ import { StaticValueTransformService } from
'../../../../services/static-value-t
import { EventPropertyUtilsService } from
'../../../../services/event-property-utils.service';
import { ShepherdService } from
'../../../../../services/tour/shepherd.service';
import { IdGeneratorService } from
'../../../../../core-services/id-generator/id-generator.service';
-import { SemanticTypeService } from
'../../../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-event-property-row',
@@ -75,7 +76,6 @@ export class EventPropertyRowComponent implements OnInit {
private epUtils: EventPropertyUtilsService,
private shepherdService: ShepherdService,
private idGeneratorService: IdGeneratorService,
- private semanticTypeService: SemanticTypeService,
) {}
ngOnInit() {
@@ -161,11 +161,9 @@ export class EventPropertyRowComponent implements OnInit {
isTimestampProperty(node) {
if (
node.domainProperties &&
- node.domainProperties.some(
- dp => dp === this.semanticTypeService.TIMESTAMP,
- )
+ node.domainProperties.some(dp => dp === SemanticType.TIMESTAMP)
) {
- node.runtimeType = this.semanticTypeService.XS_LONG;
+ node.runtimeType = DataType.LONG;
return true;
} else {
return false;
diff --git
a/ui/src/app/connect/components/adapter-configuration/schema-editor/event-schema/event-schema.component.ts
b/ui/src/app/connect/components/adapter-configuration/schema-editor/event-schema/event-schema.component.ts
index 8dfcb80598..a8faf61a6a 100644
---
a/ui/src/app/connect/components/adapter-configuration/schema-editor/event-schema/event-schema.component.ts
+++
b/ui/src/app/connect/components/adapter-configuration/schema-editor/event-schema/event-schema.component.ts
@@ -27,9 +27,9 @@ import {
} from '@angular/core';
import { RestService } from '../../../../services/rest.service';
import { ITreeOptions, TreeComponent } from '@ali-hm/angular-tree-component';
-import { DataTypesService } from '../../../../services/data-type.service';
import {
AdapterDescription,
+ DataType,
EventPropertyNested,
EventPropertyPrimitive,
EventPropertyUnion,
@@ -43,7 +43,7 @@ import { UserErrorMessage } from
'../../../../../core-model/base/UserErrorMessag
import { TransformationRuleService } from
'../../../../services/transformation-rule.service';
import { StaticValueTransformService } from
'../../../../services/static-value-transform.service';
import { IdGeneratorService } from
'../../../../../core-services/id-generator/id-generator.service';
-import { SemanticTypeService } from
'../../../../../core-services/types/semantic-type.service';
+import { SemanticType } from '@streampipes/platform-services';
@Component({
selector: 'sp-event-schema',
@@ -53,11 +53,9 @@ import { SemanticTypeService } from
'../../../../../core-services/types/semantic
export class EventSchemaComponent implements OnChanges {
constructor(
private restService: RestService,
- private dataTypesService: DataTypesService,
private transformationRuleService: TransformationRuleService,
private staticValueTransformService: StaticValueTransformService,
private idGeneratorService: IdGeneratorService,
- private semanticTypeService: SemanticTypeService,
) {}
@Input()
@@ -230,7 +228,7 @@ export class EventSchemaComponent implements OnChanges {
this.staticValueTransformService.makeDefaultElementId();
eventProperty.runtimeName = runtimeName;
- eventProperty.runtimeType = this.dataTypesService.getStringTypeUrl();
+ eventProperty.runtimeType = DataType.STRING;
eventProperty.domainProperties = [];
eventProperty.propertyScope = 'DIMENSION_PROPERTY';
eventProperty.additionalMetadata = {};
@@ -250,9 +248,9 @@ export class EventSchemaComponent implements OnChanges {
eventProperty.runtimeName = 'timestamp';
eventProperty.label = 'Timestamp';
eventProperty.description = 'The current timestamp value';
- eventProperty.domainProperties = [this.semanticTypeService.TIMESTAMP];
+ eventProperty.domainProperties = [SemanticType.TIMESTAMP];
eventProperty.propertyScope = 'HEADER_PROPERTY';
- eventProperty.runtimeType = this.semanticTypeService.XS_LONG;
+ eventProperty.runtimeType = DataType.LONG;
eventProperty.additionalMetadata = {};
this.targetSchema.eventProperties.push(eventProperty);
diff --git
a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.ts
b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.ts
index f87d518b0b..80adb96525 100644
---
a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.ts
+++
b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.ts
@@ -26,8 +26,11 @@ import {
import { UntypedFormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { ShepherdService } from
'../../../../../services/tour/shepherd.service';
-import { SemanticTypesRestService } from
'../../../../../../../projects/streampipes/platform-services/src/lib/apis/semantic-types-rest.service';
-import { SemanticTypeService } from
'../../../../../core-services/types/semantic-type.service';
+import {
+ DataType,
+ SemanticType,
+ SemanticTypesRestService,
+} from '@streampipes/platform-services';
@Component({
selector: 'sp-edit-schema-transformation',
@@ -51,7 +54,6 @@ export class EditSchemaTransformationComponent implements
OnInit {
constructor(
private semanticTypesRestService: SemanticTypesRestService,
- private semanticTypeService: SemanticTypeService,
private shepherdService: ShepherdService,
) {}
@@ -71,11 +73,9 @@ export class EditSchemaTransformationComponent implements
OnInit {
editTimestampDomainProperty(checked: boolean) {
if (checked) {
this.isTimestampProperty = true;
- this.cachedProperty.domainProperties = [
- this.semanticTypeService.TIMESTAMP,
- ];
+ this.cachedProperty.domainProperties = [SemanticType.TIMESTAMP];
this.cachedProperty.propertyScope = 'HEADER_PROPERTY';
- this.cachedProperty.runtimeType = this.semanticTypeService.XS_LONG;
+ this.cachedProperty.runtimeType = DataType.LONG;
} else {
this.cachedProperty.domainProperties = [];
this.cachedProperty.propertyScope = 'MEASUREMENT_PROPERTY';
diff --git
a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
index 6f05628a27..8004dfe958 100644
---
a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
+++
b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
@@ -34,6 +34,7 @@ import {
EventPropertyNested,
EventPropertyPrimitive,
EventPropertyUnion,
+ SemanticType,
} from '@streampipes/platform-services';
import { DataTypesService } from '../../services/data-type.service';
import { DialogRef } from '@streampipes/shared-ui';
@@ -41,7 +42,6 @@ import { EditSchemaTransformationComponent } from
'./components/edit-schema-tran
import { EditValueTransformationComponent } from
'./components/edit-value-transformation/edit-value-transformation.component';
import { EditUnitTransformationComponent } from
'./components/edit-unit-transformation/edit-unit-transformation.component';
import { ShepherdService } from '../../../services/tour/shepherd.service';
-import { SemanticTypeService } from
'../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-edit-event-property',
@@ -70,19 +70,16 @@ export class EditEventPropertyComponent implements OnInit {
private propertyForm: UntypedFormGroup;
- private runtimeDataTypes;
-
constructor(
public dialogRef: DialogRef<EditEventPropertyComponent>,
private formBuilder: UntypedFormBuilder,
private dataTypeService: DataTypesService,
- private semanticTypeUtilsService: SemanticTypeService,
private shepherdService: ShepherdService,
) {}
ngOnInit(): void {
this.cachedProperty = this.copyEp(this.property);
- this.isTimestampProperty = this.semanticTypeUtilsService.isTimestamp(
+ this.isTimestampProperty = SemanticType.isTimestamp(
this.cachedProperty,
);
this.isEventPropertyList = this.property instanceof EventPropertyList;
@@ -91,7 +88,7 @@ export class EditEventPropertyComponent implements OnInit {
this.isEventPropertyNested =
this.property instanceof EventPropertyNested;
this.isNumericProperty =
- this.semanticTypeUtilsService.isNumber(this.cachedProperty) ||
+ SemanticType.isNumber(this.cachedProperty) ||
this.dataTypeService.isNumeric(
(this.cachedProperty as any).runtimeType,
);
diff --git a/ui/src/app/connect/filter/timestamp.pipe.ts
b/ui/src/app/connect/filter/timestamp.pipe.ts
index 901c421c54..d3bd4b5c43 100644
--- a/ui/src/app/connect/filter/timestamp.pipe.ts
+++ b/ui/src/app/connect/filter/timestamp.pipe.ts
@@ -17,21 +17,21 @@
*/
import { Pipe, PipeTransform } from '@angular/core';
-import { EventPropertyUnion } from '@streampipes/platform-services';
-import { SemanticTypeService } from
'../../core-services/types/semantic-type.service';
+import {
+ EventPropertyUnion,
+ SemanticType,
+} from '@streampipes/platform-services';
@Pipe({
name: 'timestampFilter',
pure: false,
})
export class TimestampPipe implements PipeTransform {
- constructor(private semanticTypeService: SemanticTypeService) {}
+ constructor() {}
transform(items: EventPropertyUnion[]): EventPropertyUnion[] {
return items.filter(item =>
- item.domainProperties.some(
- dp => dp === this.semanticTypeService.TIMESTAMP,
- ),
+ item.domainProperties.some(dp => dp === SemanticType.TIMESTAMP),
);
}
}
diff --git a/ui/src/app/connect/services/transformation-rule.service.ts
b/ui/src/app/connect/services/transformation-rule.service.ts
index 6c5dceab7a..f1cca8565c 100644
--- a/ui/src/app/connect/services/transformation-rule.service.ts
+++ b/ui/src/app/connect/services/transformation-rule.service.ts
@@ -31,19 +31,18 @@ import {
EventSchema,
MoveRuleDescription,
RenameRuleDescription,
+ SemanticType,
TimestampTranfsformationRuleDescription,
TransformationRuleDescriptionUnion,
UnitTransformRuleDescription,
} from '@streampipes/platform-services';
import { TimestampTransformationRuleMode } from
'../model/TimestampTransformationRuleMode';
import { StaticValueTransformService } from './static-value-transform.service';
-import { SemanticTypeService } from
'../../core-services/types/semantic-type.service';
@Injectable({ providedIn: 'root' })
export class TransformationRuleService {
constructor(
private staticValueTransformService: StaticValueTransformService,
- private semanticTypeService: SemanticTypeService,
) {}
public getTransformationRuleDescriptions(
@@ -585,7 +584,7 @@ export class TransformationRuleService {
isTimestampProperty(property: EventPropertyPrimitive) {
return property.domainProperties.some(
- dp => dp === this.semanticTypeService.TIMESTAMP,
+ dp => dp === SemanticType.TIMESTAMP,
);
}
diff --git a/ui/src/app/core-services/types/semantic-type.service.ts
b/ui/src/app/core-services/types/semantic-type.service.ts
deleted file mode 100644
index 35b0141db9..0000000000
--- a/ui/src/app/core-services/types/semantic-type.service.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-import { Injectable } from '@angular/core';
-import { EventProperty } from '@streampipes/platform-services';
-
-@Injectable({ providedIn: 'root' })
-export class SemanticTypeService {
- public TIMESTAMP = 'http://schema.org/DateTime';
- public IMAGE = 'https://image.com';
- public SO_NUMBER = 'http://schema.org/Number';
- public SO_URL = 'https://schema.org/URL';
-
- public XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer';
- public XS_FLOAT = 'http://www.w3.org/2001/XMLSchema#float';
- public XS_LONG = 'http://www.w3.org/2001/XMLSchema#long';
- public XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double';
- public XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean';
- public XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number';
- public XS_STRING = 'http://www.w3.org/2001/XMLSchema#string';
-
- constructor() {}
-
- public getValue(inputValue: any, semanticType: string) {
- if (semanticType === this.TIMESTAMP) {
- return new Date(inputValue).toLocaleString();
- } else {
- return inputValue;
- }
- }
-
- public isTimestamp(property: EventProperty): boolean {
- return property.domainProperties.includes(this.TIMESTAMP);
- }
-
- public isImage(property: EventProperty): boolean {
- return property.domainProperties.includes(this.IMAGE);
- }
-
- public isNumber(property: EventProperty): boolean {
- return property.domainProperties.includes(this.SO_NUMBER);
- }
-
- public isNumberType(datatype: string): boolean {
- return (
- datatype === this.XS_DOUBLE ||
- datatype === this.XS_INTEGER ||
- datatype === this.XS_LONG ||
- datatype === this.XS_FLOAT ||
- datatype === this.XS_NUMBER
- );
- }
-
- isBooleanType(datatype: string): boolean {
- return datatype === this.XS_BOOLEAN;
- }
-}
diff --git
a/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
index 3330d96a89..466ff0ec14 100644
--- a/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
+++ b/ui/src/app/core-ui/help/field-names-table/field-names-table.component.ts
@@ -17,8 +17,7 @@
*/
import { Component, Input } from '@angular/core';
-import { EventSchema } from '@streampipes/platform-services';
-import { SemanticTypeService } from
'../../../core-services/types/semantic-type.service';
+import { DataType, EventSchema } from '@streampipes/platform-services';
@Component({
selector: 'sp-field-names-table',
@@ -36,12 +35,12 @@ export class FieldNamesTableComponent {
'runtimeType',
];
- constructor(private semanticTypeService: SemanticTypeService) {}
+ constructor() {}
getFriendlyRuntimeType(runtimeType: string) {
- if (this.semanticTypeService.isNumberType(runtimeType)) {
+ if (DataType.isNumberType(runtimeType)) {
return 'Number';
- } else if (this.semanticTypeService.isBooleanType(runtimeType)) {
+ } else if (DataType.isBooleanType(runtimeType)) {
return 'Boolean';
} else {
return 'Text';
diff --git
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
index 1ae75a0c7a..2c49d783e0 100644
---
a/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
+++
b/ui/src/app/core-ui/pipeline-element-runtime-info/live-preview-table/live-preview-table.component.ts
@@ -17,8 +17,7 @@
*/
import { Component, Input } from '@angular/core';
-import { EventSchema } from '@streampipes/platform-services';
-import { SemanticTypeService } from
'../../../core-services/types/semantic-type.service';
+import { EventSchema, SemanticType } from '@streampipes/platform-services';
@Component({
selector: 'sp-live-preview-table',
@@ -34,16 +33,16 @@ export class LivePreviewTableComponent {
displayedColumns: string[] = ['runtimeName', 'value'];
- constructor(private semanticTypeUtilsService: SemanticTypeService) {}
+ constructor() {}
isImage(runtimeName: string) {
const property = this.getProperty(runtimeName);
- return this.semanticTypeUtilsService.isImage(property);
+ return SemanticType.isImage(property);
}
isTimestamp(runtimeName: string) {
const property = this.getProperty(runtimeName);
- return this.semanticTypeUtilsService.isTimestamp(property);
+ return SemanticType.isTimestamp(property);
}
hasNoDomainProperty(runtimeName: string) {
diff --git
a/ui/src/app/core-ui/static-properties/static-free-input/static-free-input.component.ts
b/ui/src/app/core-ui/static-properties/static-free-input/static-free-input.component.ts
index 272401ddb0..78be373e65 100644
---
a/ui/src/app/core-ui/static-properties/static-free-input/static-free-input.component.ts
+++
b/ui/src/app/core-ui/static-properties/static-free-input/static-free-input.component.ts
@@ -19,7 +19,11 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ValidatorFn, Validators } from '@angular/forms';
import { ConfigurationInfo } from '../../../connect/model/ConfigurationInfo';
-import { FreeTextStaticProperty } from '@streampipes/platform-services';
+import {
+ DataType,
+ FreeTextStaticProperty,
+ SemanticType,
+} from '@streampipes/platform-services';
import {
ValidateNumber,
ValidateString,
@@ -27,7 +31,6 @@ import {
} from '../input.validator';
import { AbstractValidatedStaticPropertyRenderer } from
'../base/abstract-validated-static-property';
import { QuillEditorComponent } from 'ngx-quill';
-import { SemanticTypeService } from
'../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-app-static-free-input',
@@ -55,7 +58,7 @@ export class StaticFreeInputComponent
@ViewChild('textEditor', { static: false })
quillEditorComponent: QuillEditorComponent;
- constructor(private semanticTypeService: SemanticTypeService) {
+ constructor() {
super();
}
@@ -71,25 +74,17 @@ export class StaticFreeInputComponent
validators.push(Validators.required);
}
if (
- this.semanticTypeService.isNumberType(
- this.staticProperty.requiredDatatype,
- ) ||
- this.semanticTypeService.isNumberType(
- this.staticProperty.requiredDomainProperty,
- )
+ DataType.isNumberType(this.staticProperty.requiredDatatype) ||
+ DataType.isNumberType(this.staticProperty.requiredDomainProperty)
) {
validators.push(ValidateNumber);
this.errorMessage = 'The value should be a number';
} else if (
- this.staticProperty.requiredDomainProperty ===
- this.semanticTypeService.SO_URL
+ this.staticProperty.requiredDomainProperty === SemanticType.SO_URL
) {
validators.push(ValidateUrl);
this.errorMessage = 'Please enter a valid URL';
- } else if (
- this.staticProperty.requiredDatatype ===
- this.semanticTypeService.XS_STRING
- ) {
+ } else if (this.staticProperty.requiredDatatype === DataType.STRING) {
validators.push(ValidateString);
this.errorMessage = 'Please enter a valid String';
}
diff --git
a/ui/src/app/dashboard/components/widgets/table/table-widget.component.ts
b/ui/src/app/dashboard/components/widgets/table/table-widget.component.ts
index 3faf709cbc..d17e87b7d9 100644
--- a/ui/src/app/dashboard/components/widgets/table/table-widget.component.ts
+++ b/ui/src/app/dashboard/components/widgets/table/table-widget.component.ts
@@ -22,9 +22,11 @@ import { StaticPropertyExtractor } from
'../../../sdk/extractor/static-property-
import { MatTableDataSource } from '@angular/material/table';
import { TableConfig } from './table-config';
import { ResizeService } from '../../../services/resize.service';
-import { DatalakeRestService } from '@streampipes/platform-services';
+import {
+ DatalakeRestService,
+ SemanticType,
+} from '@streampipes/platform-services';
import { WidgetConfigBuilder } from '../../../registry/widget-config-builder';
-import { SemanticTypeService } from
'../../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-table-widget',
@@ -46,7 +48,6 @@ export class TableWidgetComponent
constructor(
dataLakeService: DatalakeRestService,
resizeService: ResizeService,
- private semanticTypeUtils: SemanticTypeService,
) {
super(dataLakeService, resizeService, false);
}
@@ -60,7 +61,7 @@ export class TableWidgetComponent
},
);
this.semanticTypes[BaseStreamPipesWidget.TIMESTAMP_KEY] =
- this.semanticTypeUtils.TIMESTAMP;
+ SemanticType.TIMESTAMP;
}
ngOnDestroy(): void {
@@ -91,7 +92,7 @@ export class TableWidgetComponent
createTableObject(event: any) {
const object = {};
this.selectedProperties.forEach((key, index) => {
- event[key] = this.semanticTypeUtils.getValue(
+ event[key] = SemanticType.getValue(
event[key],
this.semanticTypes[key],
);
diff --git a/ui/src/app/dashboard/registry/widget-config-builder.ts
b/ui/src/app/dashboard/registry/widget-config-builder.ts
index 5786cb1db2..8f371fcc08 100644
--- a/ui/src/app/dashboard/registry/widget-config-builder.ts
+++ b/ui/src/app/dashboard/registry/widget-config-builder.ts
@@ -17,11 +17,11 @@
*/
import { CollectedSchemaRequirements } from
'../sdk/collected-schema-requirements';
-import { Datatypes } from '../sdk/model/datatypes';
import { Tuple2 } from '../../core-model/base/Tuple2';
import {
ColorPickerStaticProperty,
DashboardWidgetSettings,
+ DataType,
FreeTextStaticProperty,
OneOfStaticProperty,
Option,
@@ -122,7 +122,7 @@ export class WidgetConfigBuilder {
WidgetConfigBuilder.QUERY_LIMIT_KEY,
'Past data',
'The number of historic events that should be shown',
- Datatypes.Integer.toUri(),
+ DataType.INTEGER,
);
fst.value = '50';
this.widget.config.push(fst);
@@ -139,7 +139,7 @@ export class WidgetConfigBuilder {
id,
label,
description,
- Datatypes.String.toUri(),
+ DataType.STRING,
);
this.widget.config.push(fst);
return this;
@@ -174,7 +174,7 @@ export class WidgetConfigBuilder {
id,
label,
description,
- Datatypes.Integer.toUri(),
+ DataType.INTEGER,
);
if (defaultValue) {
fst.value = defaultValue.toString();
@@ -220,7 +220,7 @@ export class WidgetConfigBuilder {
id,
label,
description,
- Datatypes.Float.toUri(),
+ DataType.FLOAT,
);
this.widget.config.push(fst);
return this;
diff --git a/ui/src/app/dashboard/sdk/ep-requirements.ts
b/ui/src/app/dashboard/sdk/ep-requirements.ts
index 07653a454f..583902b3a5 100644
--- a/ui/src/app/dashboard/sdk/ep-requirements.ts
+++ b/ui/src/app/dashboard/sdk/ep-requirements.ts
@@ -16,13 +16,13 @@
*
*/
-import { Datatypes } from './model/datatypes';
-import { Vocabulary } from './model/vocabulary';
+import { DataType } from '@streampipes/platform-services';
import {
EventPropertyList,
EventPropertyNested,
EventPropertyPrimitive,
EventPropertyUnion,
+ SemanticType,
} from '@streampipes/platform-services';
export class EpRequirements {
@@ -51,31 +51,31 @@ export class EpRequirements {
}
static imageReq(): EventPropertyUnion {
- return EpRequirements.domainPropertyReq('https://image.com');
+ return EpRequirements.domainPropertyReq(SemanticType.IMAGE);
}
static latitudeReq(): EventPropertyUnion {
- return EpRequirements.domainPropertyReq(Vocabulary.GEO + 'lat');
+ return EpRequirements.domainPropertyReq(SemanticType.GEO_LAT);
}
static longitudeReq(): EventPropertyUnion {
- return EpRequirements.domainPropertyReq(Vocabulary.GEO + 'long');
+ return EpRequirements.domainPropertyReq(SemanticType.GEO_LONG);
}
static timestampReq(): EventPropertyUnion {
- return EpRequirements.domainPropertyReq('http://schema.org/DateTime');
+ return EpRequirements.domainPropertyReq(SemanticType.TIMESTAMP);
}
static numberReq(): EventPropertyUnion {
- return EpRequirements.datatypeReq(Datatypes.Number);
+ return EpRequirements.datatypeReq(DataType.NUMBER);
}
static stringReq(): EventPropertyUnion {
- return EpRequirements.datatypeReq(Datatypes.String);
+ return EpRequirements.datatypeReq(DataType.STRING);
}
static integerReq(): EventPropertyUnion {
- return EpRequirements.datatypeReq(Datatypes.Integer);
+ return EpRequirements.datatypeReq(DataType.INTEGER);
}
static listReq(): EventPropertyList {
@@ -110,9 +110,9 @@ export class EpRequirements {
return eventProperty;
}
- static datatypeReq(datatype: Datatypes): EventPropertyPrimitive {
+ static datatypeReq(datatype: string): EventPropertyPrimitive {
const eventProperty = EpRequirements.ep();
- eventProperty.runtimeType = datatype.toUri();
+ eventProperty.runtimeType = datatype;
return eventProperty;
}
}
diff --git a/ui/src/app/dashboard/sdk/matching/datatype-match.ts
b/ui/src/app/dashboard/sdk/matching/datatype-match.ts
index 76127a28a0..8b7119021b 100644
--- a/ui/src/app/dashboard/sdk/matching/datatype-match.ts
+++ b/ui/src/app/dashboard/sdk/matching/datatype-match.ts
@@ -16,7 +16,7 @@
*
*/
-import { Datatypes } from '../model/datatypes';
+import { DataType } from '@streampipes/platform-services';
export class DatatypeMatch {
match(datatypeRequirement: string, datatypeOffer: string) {
@@ -31,14 +31,14 @@ export class DatatypeMatch {
}
subClassOf(offer: string, requirement: string): boolean {
- if (!(requirement === Datatypes.Number.toUri())) {
+ if (!(requirement === DataType.NUMBER)) {
return false;
} else {
if (
- offer === Datatypes.Integer.toUri() ||
- offer === Datatypes.Long.toUri() ||
- offer === Datatypes.Double.toUri() ||
- offer === Datatypes.Float.toUri()
+ offer === DataType.INTEGER ||
+ offer === DataType.LONG ||
+ offer === DataType.DOUBLE ||
+ offer === DataType.FLOAT
) {
return true;
}
diff --git a/ui/src/app/dashboard/sdk/model/datatypes.ts
b/ui/src/app/dashboard/sdk/model/datatypes.ts
deleted file mode 100644
index 60a10cfad4..0000000000
--- a/ui/src/app/dashboard/sdk/model/datatypes.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-import { Vocabulary } from './vocabulary';
-
-export class Datatypes {
- static readonly Integer = new Datatypes(Vocabulary.XSD, 'integer');
- static readonly Long = new Datatypes(Vocabulary.XSD, 'long');
- static readonly Float = new Datatypes(Vocabulary.XSD, 'float');
- static readonly Boolean = new Datatypes(Vocabulary.XSD, 'boolean');
- static readonly String = new Datatypes(Vocabulary.XSD, 'string');
- static readonly Double = new Datatypes(Vocabulary.XSD, 'double');
- static readonly Number = new Datatypes(Vocabulary.SO, 'Number');
-
- private constructor(
- private readonly vocabulary: string,
- private readonly entity: string,
- ) {}
-
- toUri() {
- return this.vocabulary + this.entity;
- }
-}
diff --git a/ui/src/app/dashboard/sdk/model/vocabulary.ts
b/ui/src/app/dashboard/sdk/model/vocabulary.ts
deleted file mode 100644
index 052f96df93..0000000000
--- a/ui/src/app/dashboard/sdk/model/vocabulary.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-export class Vocabulary {
- static readonly XSD: string = 'http://www.w3.org/2001/XMLSchema#';
- static readonly SO: string = 'http://schema.org/';
- static readonly GEO: string = 'http://www.w3.org/2003/01/geo/wgs84_pos#';
-}
diff --git
a/ui/src/app/data-explorer/services/data-explorer-field-provider-service.ts
b/ui/src/app/data-explorer/services/data-explorer-field-provider-service.ts
index d1a04626e2..40a9e91309 100644
--- a/ui/src/app/data-explorer/services/data-explorer-field-provider-service.ts
+++ b/ui/src/app/data-explorer/services/data-explorer-field-provider-service.ts
@@ -20,17 +20,18 @@ import { Injectable } from '@angular/core';
import { FieldProvider } from '../models/dataview-dashboard.model';
import {
DataExplorerField,
+ DataType,
EventProperty,
EventPropertyPrimitive,
EventPropertyUnion,
FieldConfig,
+ SemanticType,
SourceConfig,
} from '@streampipes/platform-services';
-import { SemanticTypeService } from
'../../core-services/types/semantic-type.service';
@Injectable({ providedIn: 'root' })
export class DataExplorerFieldProviderService {
- constructor(private semanticTypeService: SemanticTypeService) {}
+ constructor() {}
public generateFieldLists(sourceConfigs: SourceConfig[]): FieldProvider {
const provider: FieldProvider = {
@@ -143,23 +144,19 @@ export class DataExplorerFieldProviderService {
public isBoolean(p: EventPropertyUnion): boolean {
return (
this.isPrimitive(p) &&
- (p as EventPropertyPrimitive).runtimeType ===
- this.semanticTypeService.XS_BOOLEAN
+ (p as EventPropertyPrimitive).runtimeType === DataType.BOOLEAN
);
}
public isString(p: EventPropertyUnion): boolean {
return (
this.isPrimitive(p) &&
- (p as EventPropertyPrimitive).runtimeType ===
- this.semanticTypeService.XS_STRING
+ (p as EventPropertyPrimitive).runtimeType === DataType.STRING
);
}
public isTimestamp(p: EventProperty) {
- return p.domainProperties.some(
- dp => dp === this.semanticTypeService.TIMESTAMP,
- );
+ return p.domainProperties.some(dp => dp === SemanticType.TIMESTAMP);
}
public getAddedFields(
@@ -191,7 +188,7 @@ export class DataExplorerFieldProviderService {
isNumber(p: EventPropertyUnion): boolean {
if (this.isPrimitive(p)) {
const runtimeType = (p as EventPropertyPrimitive).runtimeType;
- return this.semanticTypeService.isNumberType(runtimeType);
+ return DataType.isNumberType(runtimeType);
} else {
return false;
}
diff --git
a/ui/src/app/editor/components/output-strategy/user-defined-output/user-defined-output.component.ts
b/ui/src/app/editor/components/output-strategy/user-defined-output/user-defined-output.component.ts
index 5642ed5ee8..94576ade12 100644
---
a/ui/src/app/editor/components/output-strategy/user-defined-output/user-defined-output.component.ts
+++
b/ui/src/app/editor/components/output-strategy/user-defined-output/user-defined-output.component.ts
@@ -19,12 +19,12 @@
import { Component, OnInit } from '@angular/core';
import { BaseOutputStrategy } from '../base/BaseOutputStrategy';
import {
+ DataType,
EventPropertyPrimitive,
UserDefinedOutputStrategy,
} from '@streampipes/platform-services';
import { UntypedFormControl } from '@angular/forms';
import { IdGeneratorService } from
'../../../../core-services/id-generator/id-generator.service';
-import { SemanticTypeService } from
'../../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-user-defined-output-strategy',
@@ -37,18 +37,15 @@ export class UserDefinedOutputStrategyComponent
{
primitiveClasses = [];
- constructor(
- private idGeneratorService: IdGeneratorService,
- private semanticTypeService: SemanticTypeService,
- ) {
+ constructor(private idGeneratorService: IdGeneratorService) {
super();
this.primitiveClasses = [
- { label: 'String', id: this.semanticTypeService.XS_STRING },
- { label: 'Boolean', id: this.semanticTypeService.XS_BOOLEAN },
- { label: 'Integer', id: this.semanticTypeService.XS_INTEGER },
- { label: 'Long', id: this.semanticTypeService.XS_LONG },
- { label: 'Double', id: this.semanticTypeService.XS_DOUBLE },
- { label: 'Float', id: this.semanticTypeService.XS_FLOAT },
+ { label: 'String', id: DataType.STRING },
+ { label: 'Boolean', id: DataType.BOOLEAN },
+ { label: 'Integer', id: DataType.INTEGER },
+ { label: 'Long', id: DataType.LONG },
+ { label: 'Double', id: DataType.DOUBLE },
+ { label: 'Float', id: DataType.FLOAT },
];
}