bossenti commented on code in PR #2616: URL: https://github.com/apache/streampipes/pull/2616#discussion_r1537316997
########## ui/projects/streampipes/platform-services/src/lib/model/types/data-type.service.ts: ########## @@ -0,0 +1,45 @@ +/* + * 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 DataTypeService { + 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'; + + // Should we support data type number? Review Comment: Do we need it for some reason? In my mind double, integer, long and float are enough data types to distinguish numerical values. Maybe we can restrict it on a semantic data type (see `SemanticTypeService`)? ########## ui/src/app/dashboard/sdk/ep-requirements.ts: ########## @@ -51,31 +51,35 @@ export class EpRequirements { } static imageReq(): EventPropertyUnion { - return EpRequirements.domainPropertyReq('https://image.com'); + return EpRequirements.domainPropertyReq(SemanticTypeService.IMAGE); } static latitudeReq(): EventPropertyUnion { - return EpRequirements.domainPropertyReq(Vocabulary.GEO + 'lat'); + return EpRequirements.domainPropertyReq( + 'http://www.w3.org/2003/01/geo/wgs84_pos#lat', Review Comment: Don't we want to include them in the `SemanticTypeService`? ########## ui/projects/streampipes/platform-services/src/lib/model/types/semantic-type.service.ts: ########## @@ -0,0 +1,59 @@ +/* + * 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 static readonly SO: string = 'http://schema.org/'; + + public static readonly TIMESTAMP: string = + SemanticTypeService.SO + 'DateTime'; + + public static readonly SO_NUMBER: string = + SemanticTypeService.SO + 'Number'; + public static readonly SO_URL: string = SemanticTypeService.SO + 'URL'; + + public static readonly IMAGE: string = 'https://image.com'; + + public static getValue(inputValue: any, semanticType: string) { + if (semanticType === SemanticTypeService.TIMESTAMP) { + return new Date(inputValue).toLocaleString(); + } else { + return inputValue; + } + } + + public static isTimestamp(property: EventProperty): boolean { + return property.domainProperties.includes( + SemanticTypeService.TIMESTAMP, + ); + } + + public static isImage(property: EventProperty): boolean { + return property.domainProperties.includes(SemanticTypeService.IMAGE); + } + + // TODO should we move this to DataTypeService, and check for the data type instead of domain properties? Review Comment: IMO, only if we keep number as a data type -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
