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 2024/03/22 14:11:08 UTC
(streampipes) branch dev updated: refactor(#2609): Remove service xs (#2610)
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 b668441e9c refactor(#2609): Remove service xs (#2610)
b668441e9c is described below
commit b668441e9cdab41313f763079b48697fdc9ab5c6
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Fri Mar 22 15:11:01 2024 +0100
refactor(#2609): Remove service xs (#2610)
* refactor(#2609): Remove service xs
* refactor(#2609): Move strings to semantic-type.service
* refactor(#2609): Remove unused methods in data-type.service
* refactor(#2609): Rename dir to types
---
...s.service.ts => semantic-types-rest.service.ts} | 2 +-
.../platform-services/src/public-api.ts | 2 +-
ui/src/app/NS/XS.service.spec.ts | 34 ----------------
ui/src/app/NS/xs.service.ts | 46 ----------------------
.../service-configs/service-configs.component.html | 11 ++++--
.../service-configs/service-configs.component.ts | 4 +-
.../event-property-row.component.ts | 6 ++-
.../event-schema/event-schema.component.ts | 6 ++-
ui/src/app/connect/connect.module.ts | 2 -
.../edit-data-type/edit-data-type.component.ts | 2 +-
.../edit-schema-transformation.component.ts | 20 +++++-----
.../edit-event-property.component.ts | 6 +--
ui/src/app/connect/filter/timestamp.pipe.ts | 5 ++-
ui/src/app/connect/services/data-type.service.ts | 27 +------------
.../services/transformation-rule.service.ts | 4 +-
.../semantic-type.service.ts} | 35 ++++++++++++----
.../field-names-table.component.ts | 8 ++--
.../live-preview-table.component.ts | 4 +-
.../static-free-input.component.ts | 22 ++++++-----
.../static-properties/static-property.component.ts | 2 -
.../widgets/table/table-widget.component.ts | 4 +-
ui/src/app/dashboard/dashboard.module.ts | 2 -
ui/src/app/data-explorer/data-explorer.module.ts | 3 +-
.../data-explorer-field-provider-service.ts | 18 ++++-----
.../user-defined-output.component.ts | 18 +++++----
ui/src/app/editor/editor.module.ts | 3 +-
26 files changed, 106 insertions(+), 190 deletions(-)
diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/semantic-types.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/semantic-types-rest.service.ts
similarity index 97%
rename from ui/projects/streampipes/platform-services/src/lib/apis/semantic-types.service.ts
rename to ui/projects/streampipes/platform-services/src/lib/apis/semantic-types-rest.service.ts
index 0f9c180df9..00b729fa92 100644
--- a/ui/projects/streampipes/platform-services/src/lib/apis/semantic-types.service.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/semantic-types-rest.service.ts
@@ -25,7 +25,7 @@ import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
-export class SemanticTypesService {
+export class SemanticTypesRestService {
constructor(
private http: HttpClient,
private platformServicesCommons: PlatformServicesCommons,
diff --git a/ui/projects/streampipes/platform-services/src/public-api.ts b/ui/projects/streampipes/platform-services/src/public-api.ts
index d5cb1d61fc..2e44e5cf9a 100644
--- a/ui/projects/streampipes/platform-services/src/public-api.ts
+++ b/ui/projects/streampipes/platform-services/src/public-api.ts
@@ -44,7 +44,7 @@ export * from './lib/apis/pipeline-element-endpoint.service';
export * from './lib/apis/pipeline-element-template.service';
export * from './lib/apis/pipeline-monitoring.service';
export * from './lib/apis/pipeline-template.service';
-export * from './lib/apis/semantic-types.service';
+export * from './lib/apis/semantic-types-rest.service';
export * from './lib/apis/user.service';
export * from './lib/apis/user-admin.service';
export * from './lib/apis/user-group.service';
diff --git a/ui/src/app/NS/XS.service.spec.ts b/ui/src/app/NS/XS.service.spec.ts
deleted file mode 100644
index 6db8f577a6..0000000000
--- a/ui/src/app/NS/XS.service.spec.ts
+++ /dev/null
@@ -1,34 +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 { XsService } from './xs.service';
-
-describe('XSService', () => {
- const service: XsService = new XsService();
-
- it('should get string XS String', () => {
- expect(service.XS_STRING).toBe('xs:string');
- });
-
- it('should check for numbers', () => {
- expect(service.isNumber(service.XS_DOUBLE)).toBeTrue();
- expect(service.isNumber(service.XS_INTEGER)).toBeTrue();
- expect(service.isNumber(service.XS_NUMBER)).toBeTrue();
- expect(service.isNumber(service.XS_STRING)).toBeFalse();
- });
-});
diff --git a/ui/src/app/NS/xs.service.ts b/ui/src/app/NS/xs.service.ts
deleted file mode 100644
index 03b2382194..0000000000
--- a/ui/src/app/NS/xs.service.ts
+++ /dev/null
@@ -1,46 +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';
-
-@Injectable()
-export class XsService {
- XS_STRING = 'xs:string';
- XS_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer';
- XS_FLOAT = 'http://www.w3.org/2001/XMLSchema#float';
- XS_LONG = 'http://www.w3.org/2001/XMLSchema#long';
- XS_DOUBLE = 'http://www.w3.org/2001/XMLSchema#double';
- XS_BOOLEAN = 'http://www.w3.org/2001/XMLSchema#boolean';
- XS_NUMBER = 'http://www.w3.org/2001/XMLSchema#number';
- XS_STRING1 = 'http://www.w3.org/2001/XMLSchema#string';
- SO_URL = 'https://schema.org/URL';
-
- isNumber(datatype: string): boolean {
- return (
- datatype === this.XS_DOUBLE ||
- datatype === this.XS_INTEGER ||
- datatype === this.XS_LONG ||
- datatype === this.XS_FLOAT ||
- datatype === this.XS_NUMBER
- );
- }
-
- isBoolean(datatype: string): boolean {
- return datatype === this.XS_BOOLEAN;
- }
-}
diff --git a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.html b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.html
index c379b1bd2a..589b5e5d8d 100644
--- a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.html
+++ b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs.component.html
@@ -37,7 +37,7 @@
<sp-service-configs-text
fxFlex="100"
*ngIf="
- configuration.valueType === service.XS_STRING &&
+ configuration.valueType === semanticTypeService.XS_STRING &&
!configuration.isPassword
"
[configuration]="configuration"
@@ -47,8 +47,9 @@
<sp-service-configs-number
fxFlex="100"
*ngIf="
- configuration.valueType === service.XS_INTEGER ||
- configuration.valueType === service.XS_DOUBLE
+ configuration.valueType ===
+ semanticTypeService.XS_INTEGER ||
+ configuration.valueType === semanticTypeService.XS_DOUBLE
"
[configuration]="configuration"
>
@@ -56,7 +57,9 @@
<sp-service-configs-boolean
fxFlex="100"
- *ngIf="configuration.valueType === service.XS_BOOLEAN"
+ *ngIf="
+ configuration.valueType === semanticTypeService.XS_BOOLEAN
+ "
[configuration]="configuration"
>
</sp-service-configs-boolean>
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 0de61e1af8..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
@@ -17,20 +17,18 @@
*/
import { Component, EventEmitter, Input, Output } from '@angular/core';
-import { XsService } from '../../../../NS/xs.service';
import { SpServiceConfiguration } from '@streampipes/platform-services';
@Component({
selector: 'sp-service-configs',
templateUrl: './service-configs.component.html',
- providers: [XsService],
})
export class ServiceConfigsComponent {
@Input() serviceConfiguration: SpServiceConfiguration;
@Output() updateServiceConfiguration: EventEmitter<SpServiceConfiguration> =
new EventEmitter<SpServiceConfiguration>();
- constructor(private service: XsService) {}
+ 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 0231f50d4c..316af7e25c 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
@@ -33,6 +33,7 @@ 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',
@@ -74,6 +75,7 @@ export class EventPropertyRowComponent implements OnInit {
private epUtils: EventPropertyUtilsService,
private shepherdService: ShepherdService,
private idGeneratorService: IdGeneratorService,
+ private semanticTypeService: SemanticTypeService,
) {}
ngOnInit() {
@@ -160,10 +162,10 @@ export class EventPropertyRowComponent implements OnInit {
if (
node.domainProperties &&
node.domainProperties.some(
- dp => dp === 'http://schema.org/DateTime',
+ dp => dp === this.semanticTypeService.TIMESTAMP,
)
) {
- node.runtimeType = 'http://www.w3.org/2001/XMLSchema#long';
+ node.runtimeType = this.semanticTypeService.XS_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 5ce707bf20..8dfcb80598 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
@@ -43,6 +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';
@Component({
selector: 'sp-event-schema',
@@ -56,6 +57,7 @@ export class EventSchemaComponent implements OnChanges {
private transformationRuleService: TransformationRuleService,
private staticValueTransformService: StaticValueTransformService,
private idGeneratorService: IdGeneratorService,
+ private semanticTypeService: SemanticTypeService,
) {}
@Input()
@@ -248,9 +250,9 @@ export class EventSchemaComponent implements OnChanges {
eventProperty.runtimeName = 'timestamp';
eventProperty.label = 'Timestamp';
eventProperty.description = 'The current timestamp value';
- eventProperty.domainProperties = ['http://schema.org/DateTime'];
+ eventProperty.domainProperties = [this.semanticTypeService.TIMESTAMP];
eventProperty.propertyScope = 'HEADER_PROPERTY';
- eventProperty.runtimeType = 'http://www.w3.org/2001/XMLSchema#long';
+ eventProperty.runtimeType = this.semanticTypeService.XS_LONG;
eventProperty.additionalMetadata = {};
this.targetSchema.eventProperties.push(eventProperty);
diff --git a/ui/src/app/connect/connect.module.ts b/ui/src/app/connect/connect.module.ts
index 828f03cfa9..45a0234069 100644
--- a/ui/src/app/connect/connect.module.ts
+++ b/ui/src/app/connect/connect.module.ts
@@ -45,7 +45,6 @@ import { TimestampPipe } from './filter/timestamp.pipe';
import { MatChipsModule } from '@angular/material/chips';
import { MatSliderModule } from '@angular/material/slider';
import { TreeModule } from '@ali-hm/angular-tree-component';
-import { XsService } from '../NS/xs.service';
import { EditDataTypeComponent } from './dialog/edit-event-property/components/edit-schema-transformation/edit-data-type/edit-data-type.component';
import { EditTimestampPropertyComponent } from './dialog/edit-event-property/components/edit-value-transformation/edit-timestamp-property/edit-timestamp-property.component';
import { EditUnitTransformationComponent } from './dialog/edit-event-property/components/edit-unit-transformation/edit-unit-transformation.component';
@@ -198,7 +197,6 @@ import { MatDividerModule } from '@angular/material/divider';
StaticPropertyUtilService,
UnitProviderService,
TimestampPipe,
- XsService,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
diff --git a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-data-type/edit-data-type.component.ts b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-data-type/edit-data-type.component.ts
index 8343d260f3..9bb08cfbe7 100644
--- a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-data-type/edit-data-type.component.ts
+++ b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-data-type/edit-data-type.component.ts
@@ -32,7 +32,7 @@ export class EditDataTypeComponent implements OnInit {
constructor(private dataTypeService: DataTypesService) {}
ngOnInit() {
- this.runtimeDataTypes = this.dataTypeService.getDataTypes();
+ this.runtimeDataTypes = this.dataTypeService.dataTypes;
}
valueChanged() {
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 f65faa1c4f..f87d518b0b 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
@@ -17,10 +17,6 @@
*/
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
-import {
- EventPropertyUnion,
- SemanticTypesService,
-} from '@streampipes/platform-services';
import {
debounceTime,
distinctUntilChanged,
@@ -30,6 +26,8 @@ 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';
@Component({
selector: 'sp-edit-schema-transformation',
@@ -37,8 +35,6 @@ import { ShepherdService } from '../../../../../services/tour/shepherd.service';
styleUrls: ['./edit-schema-transformation.component.scss'],
})
export class EditSchemaTransformationComponent implements OnInit {
- soTimestamp = 'http://schema.org/DateTime';
-
@Input()
cachedProperty: any;
@@ -54,7 +50,8 @@ export class EditSchemaTransformationComponent implements OnInit {
semanticTypes: Observable<string[]>;
constructor(
- private semanticTypesService: SemanticTypesService,
+ private semanticTypesRestService: SemanticTypesRestService,
+ private semanticTypeService: SemanticTypeService,
private shepherdService: ShepherdService,
) {}
@@ -65,7 +62,7 @@ export class EditSchemaTransformationComponent implements OnInit {
distinctUntilChanged(),
switchMap(val => {
return val
- ? this.semanticTypesService.getSemanticTypes(val)
+ ? this.semanticTypesRestService.getSemanticTypes(val)
: [];
}),
);
@@ -74,10 +71,11 @@ export class EditSchemaTransformationComponent implements OnInit {
editTimestampDomainProperty(checked: boolean) {
if (checked) {
this.isTimestampProperty = true;
- this.cachedProperty.domainProperties = [this.soTimestamp];
+ this.cachedProperty.domainProperties = [
+ this.semanticTypeService.TIMESTAMP,
+ ];
this.cachedProperty.propertyScope = 'HEADER_PROPERTY';
- this.cachedProperty.runtimeType =
- 'http://www.w3.org/2001/XMLSchema#long';
+ this.cachedProperty.runtimeType = this.semanticTypeService.XS_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 fd89934f53..6f05628a27 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
@@ -35,13 +35,13 @@ import {
EventPropertyPrimitive,
EventPropertyUnion,
} from '@streampipes/platform-services';
-import { SemanticTypeUtilsService } from '../../../core-services/semantic-type/semantic-type-utils.service';
import { DataTypesService } from '../../services/data-type.service';
import { DialogRef } from '@streampipes/shared-ui';
import { EditSchemaTransformationComponent } from './components/edit-schema-transformation/edit-schema-transformation.component';
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',
@@ -76,7 +76,7 @@ export class EditEventPropertyComponent implements OnInit {
public dialogRef: DialogRef<EditEventPropertyComponent>,
private formBuilder: UntypedFormBuilder,
private dataTypeService: DataTypesService,
- private semanticTypeUtilsService: SemanticTypeUtilsService,
+ private semanticTypeUtilsService: SemanticTypeService,
private shepherdService: ShepherdService,
) {}
@@ -91,7 +91,7 @@ export class EditEventPropertyComponent implements OnInit {
this.isEventPropertyNested =
this.property instanceof EventPropertyNested;
this.isNumericProperty =
- this.semanticTypeUtilsService.isNumeric(this.cachedProperty) ||
+ this.semanticTypeUtilsService.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 fd729a384b..901c421c54 100644
--- a/ui/src/app/connect/filter/timestamp.pipe.ts
+++ b/ui/src/app/connect/filter/timestamp.pipe.ts
@@ -18,16 +18,19 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EventPropertyUnion } from '@streampipes/platform-services';
+import { SemanticTypeService } from '../../core-services/types/semantic-type.service';
@Pipe({
name: 'timestampFilter',
pure: false,
})
export class TimestampPipe implements PipeTransform {
+ constructor(private semanticTypeService: SemanticTypeService) {}
+
transform(items: EventPropertyUnion[]): EventPropertyUnion[] {
return items.filter(item =>
item.domainProperties.some(
- dp => dp === 'http://schema.org/DateTime',
+ dp => dp === this.semanticTypeService.TIMESTAMP,
),
);
}
diff --git a/ui/src/app/connect/services/data-type.service.ts b/ui/src/app/connect/services/data-type.service.ts
index 28b6335b8c..0d9036cadc 100644
--- a/ui/src/app/connect/services/data-type.service.ts
+++ b/ui/src/app/connect/services/data-type.service.ts
@@ -20,7 +20,7 @@ import { Injectable } from '@angular/core';
@Injectable()
export class DataTypesService {
- private dataTypes: { label: string; url: string }[] = [
+ public dataTypes: { label: string; url: string }[] = [
{
label: "String - A textual datatype, e.g., 'machine1'",
url: 'http://www.w3.org/2001/XMLSchema#string',
@@ -49,35 +49,10 @@ export class DataTypesService {
constructor() {}
- getLabel(url: string): string {
- for (const dataType of this.dataTypes) {
- if (dataType.url === url) {
- return dataType.label;
- }
- }
- return 'Invalid data type';
- }
-
- getUrl(id: number): string {
- return this.dataTypes[id].url;
- }
-
- getDataTypes() {
- return this.dataTypes;
- }
-
- getNumberTypeUrl(): string {
- return String(this.dataTypes[2].url);
- }
-
getStringTypeUrl(): string {
return String(this.dataTypes[0].url);
}
- getBooleanTypeUrl(): string {
- return String(this.dataTypes[1].url);
- }
-
isNumeric(uri: string) {
const numericDataTypes = [
'http://www.w3.org/2001/XMLSchema#float',
diff --git a/ui/src/app/connect/services/transformation-rule.service.ts b/ui/src/app/connect/services/transformation-rule.service.ts
index 5dabaf821e..6c5dceab7a 100644
--- a/ui/src/app/connect/services/transformation-rule.service.ts
+++ b/ui/src/app/connect/services/transformation-rule.service.ts
@@ -37,11 +37,13 @@ import {
} 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(
@@ -583,7 +585,7 @@ export class TransformationRuleService {
isTimestampProperty(property: EventPropertyPrimitive) {
return property.domainProperties.some(
- dp => dp === 'http://schema.org/DateTime',
+ dp => dp === this.semanticTypeService.TIMESTAMP,
);
}
diff --git a/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts b/ui/src/app/core-services/types/semantic-type.service.ts
similarity index 55%
rename from ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
rename to ui/src/app/core-services/types/semantic-type.service.ts
index f93d2eeddf..35b0141db9 100644
--- a/ui/src/app/core-services/semantic-type/semantic-type-utils.service.ts
+++ b/ui/src/app/core-services/types/semantic-type.service.ts
@@ -19,15 +19,24 @@
import { Injectable } from '@angular/core';
import { EventProperty } from '@streampipes/platform-services';
-@Injectable()
-export class SemanticTypeUtilsService {
+@Injectable({ providedIn: 'root' })
+export class SemanticTypeService {
public TIMESTAMP = 'http://schema.org/DateTime';
public IMAGE = 'https://image.com';
- public NUMBER = 'http://schema.org/Number';
+ 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, semanticType) {
+ public getValue(inputValue: any, semanticType: string) {
if (semanticType === this.TIMESTAMP) {
return new Date(inputValue).toLocaleString();
} else {
@@ -43,11 +52,21 @@ export class SemanticTypeUtilsService {
return property.domainProperties.includes(this.IMAGE);
}
- public is(property: EventProperty, uri: string): boolean {
- return property.domainProperties.includes(uri);
+ 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
+ );
}
- public isNumeric(property: EventProperty): boolean {
- return property.domainProperties.includes(this.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 afc7a66489..3330d96a89 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
@@ -18,7 +18,7 @@
import { Component, Input } from '@angular/core';
import { EventSchema } from '@streampipes/platform-services';
-import { XsService } from '../../../NS/xs.service';
+import { SemanticTypeService } from '../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-field-names-table',
@@ -36,12 +36,12 @@ export class FieldNamesTableComponent {
'runtimeType',
];
- constructor(private xsService: XsService) {}
+ constructor(private semanticTypeService: SemanticTypeService) {}
getFriendlyRuntimeType(runtimeType: string) {
- if (this.xsService.isNumber(runtimeType)) {
+ if (this.semanticTypeService.isNumberType(runtimeType)) {
return 'Number';
- } else if (this.xsService.isBoolean(runtimeType)) {
+ } else if (this.semanticTypeService.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 9e9a64d2ed..1ae75a0c7a 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
@@ -18,7 +18,7 @@
import { Component, Input } from '@angular/core';
import { EventSchema } from '@streampipes/platform-services';
-import { SemanticTypeUtilsService } from '../../../core-services/semantic-type/semantic-type-utils.service';
+import { SemanticTypeService } from '../../../core-services/types/semantic-type.service';
@Component({
selector: 'sp-live-preview-table',
@@ -34,7 +34,7 @@ export class LivePreviewTableComponent {
displayedColumns: string[] = ['runtimeName', 'value'];
- constructor(private semanticTypeUtilsService: SemanticTypeUtilsService) {}
+ constructor(private semanticTypeUtilsService: SemanticTypeService) {}
isImage(runtimeName: string) {
const property = this.getProperty(runtimeName);
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 a927281c19..657610b0d3 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
@@ -18,10 +18,8 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ValidatorFn, Validators } from '@angular/forms';
-import { StaticPropertyUtilService } from '../static-property-util.service';
import { ConfigurationInfo } from '../../../connect/model/ConfigurationInfo';
import { FreeTextStaticProperty } from '@streampipes/platform-services';
-import { XsService } from '../../../NS/xs.service';
import {
ValidateNumber,
ValidateString,
@@ -29,6 +27,7 @@ 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',
@@ -56,10 +55,7 @@ export class StaticFreeInputComponent
@ViewChild('textEditor', { static: false })
quillEditorComponent: QuillEditorComponent;
- constructor(
- public staticPropertyUtil: StaticPropertyUtilService,
- private xsService: XsService,
- ) {
+ constructor(private semanticTypeService: SemanticTypeService) {
super();
}
@@ -73,18 +69,24 @@ export class StaticFreeInputComponent
const validators: ValidatorFn[] = [];
validators.push(Validators.required);
if (
- this.xsService.isNumber(this.staticProperty.requiredDatatype) ||
- this.xsService.isNumber(this.staticProperty.requiredDomainProperty)
+ this.semanticTypeService.isNumberType(
+ this.staticProperty.requiredDatatype,
+ ) ||
+ this.semanticTypeService.isNumberType(
+ this.staticProperty.requiredDomainProperty,
+ )
) {
validators.push(ValidateNumber);
this.errorMessage = 'The value should be a number';
} else if (
- this.staticProperty.requiredDomainProperty === this.xsService.SO_URL
+ this.staticProperty.requiredDomainProperty ===
+ this.semanticTypeService.SO_URL
) {
validators.push(ValidateUrl);
this.errorMessage = 'Please enter a valid URL';
} else if (
- this.staticProperty.requiredDatatype === this.xsService.XS_STRING1
+ this.staticProperty.requiredDatatype ===
+ this.semanticTypeService.XS_STRING
) {
validators.push(ValidateString);
this.errorMessage = 'Please enter a valid String';
diff --git a/ui/src/app/core-ui/static-properties/static-property.component.ts b/ui/src/app/core-ui/static-properties/static-property.component.ts
index a62c2f8392..ff579a3888 100644
--- a/ui/src/app/core-ui/static-properties/static-property.component.ts
+++ b/ui/src/app/core-ui/static-properties/static-property.component.ts
@@ -18,7 +18,6 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
-import { XsService } from '../../NS/xs.service';
import { ConfigurationInfo } from '../../connect/model/ConfigurationInfo';
import {
AnyStaticProperty,
@@ -47,7 +46,6 @@ import { InvocablePipelineElementUnion } from '../../editor/model/editor.model';
selector: 'sp-app-static-property',
templateUrl: './static-property.component.html',
styleUrls: ['./static-property.component.css'],
- providers: [XsService],
})
export class StaticPropertyComponent implements OnInit {
@Input()
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 1a876ea3a9..3faf709cbc 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
@@ -21,10 +21,10 @@ import { BaseStreamPipesWidget } from '../base/base-widget';
import { StaticPropertyExtractor } from '../../../sdk/extractor/static-property-extractor';
import { MatTableDataSource } from '@angular/material/table';
import { TableConfig } from './table-config';
-import { SemanticTypeUtilsService } from '../../../../core-services/semantic-type/semantic-type-utils.service';
import { ResizeService } from '../../../services/resize.service';
import { DatalakeRestService } 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 +46,7 @@ export class TableWidgetComponent
constructor(
dataLakeService: DatalakeRestService,
resizeService: ResizeService,
- private semanticTypeUtils: SemanticTypeUtilsService,
+ private semanticTypeUtils: SemanticTypeService,
) {
super(dataLakeService, resizeService, false);
}
diff --git a/ui/src/app/dashboard/dashboard.module.ts b/ui/src/app/dashboard/dashboard.module.ts
index 9dd11be626..348e508518 100644
--- a/ui/src/app/dashboard/dashboard.module.ts
+++ b/ui/src/app/dashboard/dashboard.module.ts
@@ -37,7 +37,6 @@ import { ResizeService } from './services/resize.service';
import { TableWidgetComponent } from './components/widgets/table/table-widget.component';
import { CdkTableModule } from '@angular/cdk/table';
import { RefreshDashboardService } from './services/refresh-dashboard.service';
-import { SemanticTypeUtilsService } from '../core-services/semantic-type/semantic-type-utils.service';
import { GaugeWidgetComponent } from './components/widgets/gauge/gauge-widget.component';
import { ImageWidgetComponent } from './components/widgets/image/image-widget.component';
import { AreaWidgetComponent } from './components/widgets/area/area-widget.component';
@@ -132,7 +131,6 @@ import { DashboardPanelCanDeactivateGuard } from './dashboard.can-deactivate.gua
ReloadPipelineService,
ResizeService,
RefreshDashboardService,
- SemanticTypeUtilsService,
],
exports: [DashboardWidgetComponent, StandaloneDashboardComponent],
})
diff --git a/ui/src/app/data-explorer/data-explorer.module.ts b/ui/src/app/data-explorer/data-explorer.module.ts
index 32a124f707..da87156deb 100644
--- a/ui/src/app/data-explorer/data-explorer.module.ts
+++ b/ui/src/app/data-explorer/data-explorer.module.ts
@@ -34,7 +34,6 @@ import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { NgxChartsModule } from '@swimlane/ngx-charts';
import { GridsterModule } from 'angular-gridster2';
import { ColorPickerModule } from 'ngx-color-picker';
-import { SemanticTypeUtilsService } from '../core-services/semantic-type/semantic-type-utils.service';
import { PlatformServicesModule } from '@streampipes/platform-services';
import { CoreUiModule } from '../core-ui/core-ui.module';
import { CustomMaterialModule } from '../CustomMaterial/custom-material.module';
@@ -193,7 +192,7 @@ import { SpDataZoomConfigComponent } from './components/widgets/utils/data-zoom-
SpTimeSeriesAppearanceConfigComponent,
SpDataZoomConfigComponent,
],
- providers: [SemanticTypeUtilsService],
+ providers: [],
exports: [],
})
export class DataExplorerModule {
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 7142a430bb..d1a04626e2 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
@@ -26,9 +26,12 @@ import {
FieldConfig,
SourceConfig,
} from '@streampipes/platform-services';
+import { SemanticTypeService } from '../../core-services/types/semantic-type.service';
@Injectable({ providedIn: 'root' })
export class DataExplorerFieldProviderService {
+ constructor(private semanticTypeService: SemanticTypeService) {}
+
public generateFieldLists(sourceConfigs: SourceConfig[]): FieldProvider {
const provider: FieldProvider = {
allFields: [],
@@ -141,7 +144,7 @@ export class DataExplorerFieldProviderService {
return (
this.isPrimitive(p) &&
(p as EventPropertyPrimitive).runtimeType ===
- 'http://www.w3.org/2001/XMLSchema#boolean'
+ this.semanticTypeService.XS_BOOLEAN
);
}
@@ -149,13 +152,13 @@ export class DataExplorerFieldProviderService {
return (
this.isPrimitive(p) &&
(p as EventPropertyPrimitive).runtimeType ===
- 'http://www.w3.org/2001/XMLSchema#string'
+ this.semanticTypeService.XS_STRING
);
}
public isTimestamp(p: EventProperty) {
return p.domainProperties.some(
- dp => dp === 'http://schema.org/DateTime',
+ dp => dp === this.semanticTypeService.TIMESTAMP,
);
}
@@ -188,14 +191,7 @@ export class DataExplorerFieldProviderService {
isNumber(p: EventPropertyUnion): boolean {
if (this.isPrimitive(p)) {
const runtimeType = (p as EventPropertyPrimitive).runtimeType;
-
- return (
- runtimeType === 'http://schema.org/Number' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#float' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#double' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#integer' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#long'
- );
+ return this.semanticTypeService.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 727c6fe304..ecfe3ce1f3 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
@@ -24,6 +24,7 @@ import {
} 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',
@@ -35,15 +36,18 @@ export class UserDefinedOutputStrategyComponent
implements OnInit
{
primitiveClasses = [
- { label: 'String', id: 'http://www.w3.org/2001/XMLSchema#string' },
- { label: 'Boolean', id: 'http://www.w3.org/2001/XMLSchema#boolean' },
- { label: 'Integer', id: 'http://www.w3.org/2001/XMLSchema#integer' },
- { label: 'Long', id: 'http://www.w3.org/2001/XMLSchema#long' },
- { label: 'Double', id: 'http://www.w3.org/2001/XMLSchema#double' },
- { label: 'Float', id: 'http://www.w3.org/2001/XMLSchema#float' },
+ { 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 },
];
- constructor(private idGeneratorService: IdGeneratorService) {
+ constructor(
+ private idGeneratorService: IdGeneratorService,
+ private semanticTypeService: SemanticTypeService,
+ ) {
super();
}
diff --git a/ui/src/app/editor/editor.module.ts b/ui/src/app/editor/editor.module.ts
index afcc37f430..763bb41126 100644
--- a/ui/src/app/editor/editor.module.ts
+++ b/ui/src/app/editor/editor.module.ts
@@ -23,7 +23,6 @@ import { GridsterModule } from 'angular-gridster2';
import { MatTabsModule } from '@angular/material/tabs';
import { CustomMaterialModule } from '../CustomMaterial/custom-material.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
-import { SemanticTypeUtilsService } from '../core-services/semantic-type/semantic-type-utils.service';
import { EditorComponent } from './editor.component';
import { PipelineElementIconStandComponent } from './components/pipeline-element-icon-stand/pipeline-element-icon-stand.component';
import { PipelineAssemblyComponent } from './components/pipeline-assembly/pipeline-assembly.component';
@@ -93,7 +92,7 @@ import { PipelineElementGroupFilterPipe } from './services/pipeline-element-grou
SavePipelineComponent,
SafeCss,
],
- providers: [SemanticTypeUtilsService, SafeCss],
+ providers: [SafeCss],
exports: [EditorComponent, PipelineComponent, PipelineElementComponent],
})
export class EditorModule {