This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch refactor-datatypes-connect
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit ad5b9d6d7e19c2479f805b962f81bcecb2e96883
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Apr 16 18:00:01 2024 +0200

    refactor: Remove legacy data type service in connect
---
 .../edit-data-type/edit-data-type.component.ts     | 38 ++++++++++---
 .../edit-event-property.component.ts               |  7 +--
 ui/src/app/connect/services/data-type.service.ts   | 65 ----------------------
 3 files changed, 32 insertions(+), 78 deletions(-)

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 9bb08cfbe7..0995353ea4 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
@@ -16,24 +16,44 @@
  *
  */
 
-import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
-import { DataTypesService } from '../../../../../services/data-type.service';
+import { Component, EventEmitter, Input, Output } from '@angular/core';
+import { DataType } from '@streampipes/platform-services';
 
 @Component({
     selector: 'sp-edit-data-type',
     templateUrl: './edit-data-type.component.html',
     styleUrls: ['./edit-data-type.component.scss'],
 })
-export class EditDataTypeComponent implements OnInit {
+export class EditDataTypeComponent {
     @Input() cachedProperty: any;
     @Output() dataTypeChanged = new EventEmitter<boolean>();
 
-    runtimeDataTypes;
-    constructor(private dataTypeService: DataTypesService) {}
-
-    ngOnInit() {
-        this.runtimeDataTypes = this.dataTypeService.dataTypes;
-    }
+    runtimeDataTypes: { label: string; url: string }[] = [
+        {
+            label: 'String - A textual datatype, e.g., \'machine1\'',
+            url: DataType.STRING,
+        },
+        {
+            label: 'Boolean - A true/false value',
+            url: DataType.BOOLEAN,
+        },
+        {
+            label: 'Double - A number, e.g., \'1.25\'',
+            url: DataType.DOUBLE,
+        },
+        {
+            label: 'Float - A number, e.g., \'1.25\'',
+            url: DataType.FLOAT,
+        },
+        {
+            label: 'Integer - A number, e.g., \'2\'',
+            url: DataType.INTEGER,
+        },
+        {
+            label: 'Long - A number, e.g., \'1623871455232\'',
+            url: DataType.LONG,
+        },
+    ];
 
     valueChanged() {
         this.dataTypeChanged.emit(true);
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 8004dfe958..ce422494af 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
@@ -30,13 +30,13 @@ import {
     Validators,
 } from '@angular/forms';
 import {
+    DataType,
     EventPropertyList,
     EventPropertyNested,
     EventPropertyPrimitive,
     EventPropertyUnion,
     SemanticType,
 } from '@streampipes/platform-services';
-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';
@@ -73,7 +73,6 @@ export class EditEventPropertyComponent implements OnInit {
     constructor(
         public dialogRef: DialogRef<EditEventPropertyComponent>,
         private formBuilder: UntypedFormBuilder,
-        private dataTypeService: DataTypesService,
         private shepherdService: ShepherdService,
     ) {}
 
@@ -89,7 +88,7 @@ export class EditEventPropertyComponent implements OnInit {
             this.property instanceof EventPropertyNested;
         this.isNumericProperty =
             SemanticType.isNumber(this.cachedProperty) ||
-            this.dataTypeService.isNumeric(
+            DataType.isNumberType(
                 (this.cachedProperty as any).runtimeType,
             );
         this.createForm();
@@ -188,7 +187,7 @@ export class EditEventPropertyComponent implements OnInit {
     }
 
     handleDataTypeChange(changed: boolean) {
-        this.isNumericProperty = this.dataTypeService.isNumeric(
+        this.isNumericProperty = DataType.isNumberType(
             (this.cachedProperty as any).runtimeType,
         );
     }
diff --git a/ui/src/app/connect/services/data-type.service.ts 
b/ui/src/app/connect/services/data-type.service.ts
deleted file mode 100644
index aad5dd6c3d..0000000000
--- a/ui/src/app/connect/services/data-type.service.ts
+++ /dev/null
@@ -1,65 +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({ providedIn: 'root' })
-export class DataTypesService {
-    public dataTypes: { label: string; url: string }[] = [
-        {
-            label: "String - A textual datatype, e.g., 'machine1'",
-            url: 'http://www.w3.org/2001/XMLSchema#string',
-        },
-        {
-            label: 'Boolean - A true/false value',
-            url: 'http://www.w3.org/2001/XMLSchema#boolean',
-        },
-        {
-            label: "Double - A number, e.g., '1.25'",
-            url: 'http://www.w3.org/2001/XMLSchema#double',
-        },
-        {
-            label: "Float - A number, e.g., '1.25'",
-            url: 'http://www.w3.org/2001/XMLSchema#float',
-        },
-        {
-            label: "Integer - A number, e.g., '2'",
-            url: 'http://www.w3.org/2001/XMLSchema#integer',
-        },
-        {
-            label: "Long - A number, e.g., '1623871455232'",
-            url: 'http://www.w3.org/2001/XMLSchema#long',
-        },
-    ];
-
-    constructor() {}
-
-    getStringTypeUrl(): string {
-        return String(this.dataTypes[0].url);
-    }
-
-    isNumeric(uri: string) {
-        const numericDataTypes = [
-            'http://www.w3.org/2001/XMLSchema#float',
-            'http://www.w3.org/2001/XMLSchema#double',
-            'http://www.w3.org/2001/XMLSchema#integer',
-            'http://www.w3.org/2001/XMLSchema#long',
-        ];
-        return numericDataTypes.includes(uri);
-    }
-}

Reply via email to