You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/08/23 21:32:32 UTC
[incubator-streampipes] 03/03: [STREAMPIPES-206] Remove tson-ld
serializer and service
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit c495a1b91d6345281a3b9fdf16b55c476c8d0bf5
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Sun Aug 23 23:22:14 2020 +0200
[STREAMPIPES-206] Remove tson-ld serializer and service
---
.../app-image-labeling.component.ts | 5 +-
.../image-categorize/image-categorize.component.ts | 4 +-
.../image-labeling/image-labeling.component.ts | 27 +-
.../image/image-viewer/image-viewer.component.ts | 5 +-
ui/src/app/dashboard/services/dashboard.service.ts | 8 +-
.../services/data-view-data-explorer.service.ts | 5 +-
.../apis/pipeline-template.service.ts | 1 -
ui/src/app/platform-services/platform.module.ts | 2 -
.../platform-services/tsonld-serializer.service.ts | 229 ------------
ui/src/app/platform-services/tsonld/index.ts | 19 -
.../app/platform-services/tsonld/model/Person.js | 63 ----
.../app/platform-services/tsonld/model/Person.ts | 54 ---
ui/src/app/platform-services/tsonld/tsonld.js | 245 ------------
ui/src/app/platform-services/tsonld/tsonld.ts | 410 ---------------------
14 files changed, 23 insertions(+), 1054 deletions(-)
diff --git a/ui/src/app/app-image-labeling/app-image-labeling.component.ts b/ui/src/app/app-image-labeling/app-image-labeling.component.ts
index b06195b..e867e3f 100644
--- a/ui/src/app/app-image-labeling/app-image-labeling.component.ts
+++ b/ui/src/app/app-image-labeling/app-image-labeling.component.ts
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-import { Component, EventEmitter, OnInit, Output } from '@angular/core';
-import { DatalakeRestService } from "../core-services/datalake/datalake-rest.service";
-import { TsonLdSerializerService } from "../platform-services/tsonld-serializer.service";
+import {Component, EventEmitter, OnInit, Output} from '@angular/core';
+import {DatalakeRestService} from "../core-services/datalake/datalake-rest.service";
import {DataLakeMeasure} from "../core-model/gen/streampipes-model";
@Component({
diff --git a/ui/src/app/core-ui/image/image-categorize/image-categorize.component.ts b/ui/src/app/core-ui/image/image-categorize/image-categorize.component.ts
index 2e062dd..bead55f 100644
--- a/ui/src/app/core-ui/image/image-categorize/image-categorize.component.ts
+++ b/ui/src/app/core-ui/image/image-categorize/image-categorize.component.ts
@@ -18,7 +18,6 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { DatalakeRestService } from '../../../core-services/datalake/datalake-rest.service';
-import { TsonLdSerializerService } from '../../../platform-services/tsonld-serializer.service';
import { ColorService } from '../services/color.service';
@@ -47,8 +46,7 @@ export class ImageCategorizeComponent implements OnInit, AfterViewInit {
private setImagesIndexToFirst = false;
private setImagesIndexToLast = false;
- constructor(private restService: DatalakeRestService, public colorService: ColorService, private snackBar: MatSnackBar,
- private tsonLdSerializerService: TsonLdSerializerService) { }
+ constructor(private restService: DatalakeRestService, public colorService: ColorService, private snackBar: MatSnackBar) { }
ngOnInit(): void {
// TODO: Load labels for images
diff --git a/ui/src/app/core-ui/image/image-labeling/image-labeling.component.ts b/ui/src/app/core-ui/image/image-labeling/image-labeling.component.ts
index 696505c..64ab20e 100644
--- a/ui/src/app/core-ui/image/image-labeling/image-labeling.component.ts
+++ b/ui/src/app/core-ui/image/image-labeling/image-labeling.component.ts
@@ -17,21 +17,20 @@
*/
-import { AfterViewInit, Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
-import { MatSnackBar } from '@angular/material/snack-bar';
+import {AfterViewInit, Component, Input, OnChanges, OnInit, ViewChild} from '@angular/core';
+import {MatSnackBar} from '@angular/material/snack-bar';
import Konva from 'konva';
-import { Annotation } from '../../../core-model/coco/Annotation';
-import { CocoFormat } from '../../../core-model/coco/Coco.format';
-import { DatalakeRestService } from '../../../core-services/datalake/datalake-rest.service';
-import { TsonLdSerializerService } from '../../../platform-services/tsonld-serializer.service';
-import { ImageContainerComponent } from '../components/image-container/image-container.component';
-import { ICoordinates } from '../model/coordinates';
-import { LabelingMode } from '../model/labeling-mode';
-import { BrushLabelingService } from '../services/BrushLabeling.service';
-import { CocoFormatService } from '../services/CocoFormat.service';
-import { LabelingModeService } from '../services/LabelingMode.service';
-import { PolygonLabelingService } from '../services/PolygonLabeling.service';
-import { ReactLabelingService } from '../services/ReactLabeling.service';
+import {Annotation} from '../../../core-model/coco/Annotation';
+import {CocoFormat} from '../../../core-model/coco/Coco.format';
+import {DatalakeRestService} from '../../../core-services/datalake/datalake-rest.service';
+import {ImageContainerComponent} from '../components/image-container/image-container.component';
+import {ICoordinates} from '../model/coordinates';
+import {LabelingMode} from '../model/labeling-mode';
+import {BrushLabelingService} from '../services/BrushLabeling.service';
+import {CocoFormatService} from '../services/CocoFormat.service';
+import {LabelingModeService} from '../services/LabelingMode.service';
+import {PolygonLabelingService} from '../services/PolygonLabeling.service';
+import {ReactLabelingService} from '../services/ReactLabeling.service';
@Component({
selector: 'sp-image-labeling',
diff --git a/ui/src/app/core-ui/image/image-viewer/image-viewer.component.ts b/ui/src/app/core-ui/image/image-viewer/image-viewer.component.ts
index 83ac05d..afa3b7c 100644
--- a/ui/src/app/core-ui/image/image-viewer/image-viewer.component.ts
+++ b/ui/src/app/core-ui/image/image-viewer/image-viewer.component.ts
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-import { Component, OnInit } from '@angular/core';
-import { DatalakeRestService } from '../../../core-services/datalake/datalake-rest.service';
-import { TsonLdSerializerService } from '../../../platform-services/tsonld-serializer.service';
+import {Component, OnInit} from '@angular/core';
+import {DatalakeRestService} from '../../../core-services/datalake/datalake-rest.service';
@Component({
selector: 'sp-image-viewer',
diff --git a/ui/src/app/dashboard/services/dashboard.service.ts b/ui/src/app/dashboard/services/dashboard.service.ts
index defa4fe..07563a6 100644
--- a/ui/src/app/dashboard/services/dashboard.service.ts
+++ b/ui/src/app/dashboard/services/dashboard.service.ts
@@ -16,13 +16,12 @@
*
*/
-import {HttpClient, HttpHeaders} from "@angular/common/http";
+import {HttpClient} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {map} from "rxjs/operators";
-import {from, Observable} from "rxjs";
+import {Observable} from "rxjs";
import {AuthStatusService} from "../../services/auth-status.service";
import {Dashboard} from "../models/dashboard.model";
-import {TsonLdSerializerService} from "../../platform-services/tsonld-serializer.service";
import {MeasurementUnit} from "../../core-model/measurement-unit/MeasurementUnit";
import {DashboardWidgetModel, VisualizablePipeline} from "../../core-model/gen/streampipes-model";
@@ -31,8 +30,7 @@ export class DashboardService {
constructor(private http: HttpClient,
- private authStatusService: AuthStatusService,
- private tsonLdSerializerService: TsonLdSerializerService) {
+ private authStatusService: AuthStatusService) {
}
diff --git a/ui/src/app/data-explorer/services/data-view-data-explorer.service.ts b/ui/src/app/data-explorer/services/data-view-data-explorer.service.ts
index efe58ec..9566b17 100644
--- a/ui/src/app/data-explorer/services/data-view-data-explorer.service.ts
+++ b/ui/src/app/data-explorer/services/data-view-data-explorer.service.ts
@@ -16,14 +16,13 @@
*
*/
-import {HttpClient, HttpHeaders} from '@angular/common/http';
+import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
-import {from, Observable} from 'rxjs';
+import {Observable} from 'rxjs';
import 'rxjs-compat/add/observable/of';
import {map} from 'rxjs/operators';
import {DatalakeRestService} from '../../core-services/datalake/datalake-rest.service';
import {SharedDatalakeRestService} from '../../core-services/shared/shared-dashboard.service';
-import {TsonLdSerializerService} from '../../platform-services/tsonld-serializer.service';
import {AuthStatusService} from '../../services/auth-status.service';
import {IDataViewDashboard} from '../models/dataview-dashboard.model';
import {DataExplorerWidgetModel, DataLakeMeasure} from "../../core-model/gen/streampipes-model";
diff --git a/ui/src/app/platform-services/apis/pipeline-template.service.ts b/ui/src/app/platform-services/apis/pipeline-template.service.ts
index efa06e8..d806ac6 100644
--- a/ui/src/app/platform-services/apis/pipeline-template.service.ts
+++ b/ui/src/app/platform-services/apis/pipeline-template.service.ts
@@ -25,7 +25,6 @@ import {PipelineTemplateInvocation} from '../../connect/model/PipelineTemplateIn
import {StaticProperty} from '../../connect/model/StaticProperty';
import {AuthStatusService} from '../../services/auth-status.service';
import 'rxjs-compat/add/operator/map';
-import {TsonLdSerializerService} from '../tsonld-serializer.service';
@Injectable()
export class PipelineTemplateService {
diff --git a/ui/src/app/platform-services/platform.module.ts b/ui/src/app/platform-services/platform.module.ts
index 5df955d..66588e3 100644
--- a/ui/src/app/platform-services/platform.module.ts
+++ b/ui/src/app/platform-services/platform.module.ts
@@ -17,7 +17,6 @@
*/
import {NgModule} from '@angular/core';
-import {TsonLdSerializerService} from './tsonld-serializer.service';
import {PipelineTemplateService} from './apis/pipeline-template.service';
import {PipelineElementService} from "./apis/pipeline-element.service";
import {PipelineService} from "./apis/pipeline.service";
@@ -30,7 +29,6 @@ import {PipelineElementEndpointService} from "./apis/pipeline-element-endpoint.s
providers: [
PlatformServicesCommons,
PipelineElementEndpointService,
- TsonLdSerializerService,
PipelineTemplateService,
PipelineElementService,
PipelineService
diff --git a/ui/src/app/platform-services/tsonld-serializer.service.ts b/ui/src/app/platform-services/tsonld-serializer.service.ts
deleted file mode 100644
index 34c408e..0000000
--- a/ui/src/app/platform-services/tsonld-serializer.service.ts
+++ /dev/null
@@ -1,229 +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 {AnyStaticProperty} from '../connect/model/AnyStaticProperty';
-import {OneOfStaticProperty} from '../connect/model/OneOfStaticProperty';
-import {ProtocolDescription} from '../connect/model/connect/grounding/ProtocolDescription';
-import {ProtocolDescriptionList} from '../connect/model/connect/grounding/ProtocolDescriptionList';
-import {FreeTextStaticProperty} from '../connect/model/FreeTextStaticProperty';
-import {FileStaticProperty} from '../connect/model/FileStaticProperty';
-import {FormatDescriptionList} from '../connect/model/connect/grounding/FormatDescriptionList';
-import {FormatDescription} from '../connect/model/connect/grounding/FormatDescription';
-import {AdapterDescriptionList} from '../connect/model/connect/AdapterDescriptionList';
-import {Option} from '../connect/model/Option';
-import {AdapterDescription} from '../connect/model/connect/AdapterDescription';
-import {AdapterSetDescription} from '../connect/model/connect/AdapterSetDescription';
-import {AdapterStreamDescription} from '../connect/model/connect/AdapterStreamDescription';
-import {DataSetDescription} from '../connect/model/DataSetDescription';
-import {EventSchema} from '../connect/schema-editor/model/EventSchema';
-import {EventProperty} from '../connect/schema-editor/model/EventProperty';
-import {EventPropertyNested} from '../connect/schema-editor/model/EventPropertyNested';
-import {EventPropertyList} from '../connect/schema-editor/model/EventPropertyList';
-import {EventPropertyPrimitive} from '../connect/schema-editor/model/EventPropertyPrimitive';
-import {DomainPropertyProbability} from '../connect/schema-editor/model/DomainPropertyProbability';
-import {DomainPropertyProbabilityList} from '../connect/schema-editor/model/DomainPropertyProbabilityList';
-import {GuessSchema} from '../connect/schema-editor/model/GuessSchema';
-import {URI} from '../connect/model/URI';
-import {RenameRuleDescription} from '../connect/model/connect/rules/RenameRuleDescription';
-import {DeleteRuleDescription} from '../connect/model/connect/rules/DeleteRuleDescription';
-import {AddNestedRuleDescription} from '../connect/model/connect/rules/AddNestedRuleDescription';
-import {RemoveDuplicatesRuleDescription} from '../connect/model/connect/rules/RemoveDuplicatesRuleDescription';
-import {AddTimestampRuleDescription} from '../connect/model/connect/rules/AddTimestampRuleDescription';
-import {AddValueTransformationRuleDescription} from '../connect/model/connect/rules/AddValueTransformationRuleDescription';
-import {MoveRuleDescription} from '../connect/model/connect/rules/MoveRuleDesctiption';
-import {UnitTransformRuleDescription} from '../connect/model/connect/rules/UnitTransformRuleDescription';
-import {TsonLd} from './tsonld/index';
-import {Observable} from 'rxjs';
-import {TransformationRuleDescription} from '../connect/model/connect/rules/TransformationRuleDescription';
-import {GenericAdapterSetDescription} from '../connect/model/connect/GenericAdapterSetDescription';
-import {SpecificAdapterSetDescription} from '../connect/model/connect/SpecificAdapterSetDescription';
-import {GenericAdapterStreamDescription} from '../connect/model/connect/GenericAdapterStreamDescription';
-import {SpecificAdapterStreamDescription} from '../connect/model/connect/SpecificAdapterStreamDescription';
-import {MessageLd} from '../connect/model/message/MessageLd';
-import {NotificationLd} from '../connect/model/message/NotificationLd';
-import {SuccessMessageLd} from '../connect/model/message/SuccessMessage';
-import {ErrorMessageLd} from '../connect/model/message/ErrorMessage';
-import {TimestampTransformationRuleDescription} from '../connect/model/connect/rules/TimestampTransformationRuleDescription';
-import {DataStreamDescription} from '../connect/model/DataStreamDescription';
-import {PipelineTemplateInvocation} from '../connect/model/PipelineTemplateInvocation';
-import {MappingPropertyUnary} from '../connect/model/MappingPropertyUnary';
-import {DataProcessorInvocation} from '../connect/model/DataProcessorInvocation';
-import {AppendOutputStrategy} from '../connect/model/output/AppendOutputStrategy';
-import {CustomOutputStrategy} from '../connect/model/output/CustomOutputStrategy';
-import {CustomTransformOutputStrategy} from '../connect/model/output/CustomTransformOutputStrategy';
-import {FixedOutputStrategy} from '../connect/model/output/FixedOutputStrategy';
-import {KeepOutputStrategy} from '../connect/model/output/KeepOutputStrategy';
-import {ListOutputStrategy} from '../connect/model/output/ListOutputStrategy';
-import {OutputStrategy} from '../connect/model/output/OutputStrategy';
-import {PropertyRenameRule} from '../connect/model/output/PropertyRenameRule';
-import {TransformOutputStrategy} from '../connect/model/output/TransformOutputStrategy';
-import {TransformOperation} from '../connect/model/output/TransformOperation';
-import {DataStreamContainer} from '../connect/model/DataStreamContainer';
-import {Enumeration} from '../connect/schema-editor/model/Enumeration';
-import {QuantitativeValue} from '../connect/schema-editor/model/QuantitativeValue';
-import {PipelineTemplateDescriptionContainer} from '../connect/model/PipelineTemplateDescriptionContainer';
-import {PipelineTemplateDescription} from '../connect/model/PipelineTemplateDescription';
-import {BoundPipelineElement} from '../connect/model/BoundPipelineElement';
-import {DataSinkInvocation} from '../connect/model/DataSinkInvocation';
-import {RuntimeResolvableOneOfStaticProperty} from "../connect/model/RuntimeResolvableOneOfStaticProperty";
-import {RuntimeResolvableAnyStaticProperty} from "../connect/model/RuntimeResolvableAnyStaticProperty";
-import {RuntimeOptionsRequest} from "../connect/model/connect/runtime/RuntimeOptionsRequest";
-import {RuntimeOptionsResponse} from "../connect/model/connect/runtime/RuntimeOptionsResponse";
-import {EventRateTransformationRuleDescription} from '../connect/model/connect/rules/EventRateTransformationRuleDescription';
-import {SecretStaticProperty} from "../connect/model/SecretStaticProperty";
-import {AlternativesStaticProperty} from '../connect/model/AlternativesStaticProperty';
-import {AlternativeStaticProperty} from '../connect/model/AlternativeStaticProperty';
-import {GroupStaticProperty} from '../connect/model/GroupStaticProperty';
-import {CollectionStaticProperty} from "../connect/model/CollectionStaticProperty";
-import {VisualizablePipeline} from "../core-model/dashboard/VisualizablePipeline";
-import {DashboardWidget} from "../core-model/dashboard/DashboardWidget";
-import {DashboardWidgetSettings} from "../core-model/dashboard/DashboardWidgetSettings";
-import {ColorPickerStaticProperty} from "../connect/model/ColorPickerStaticProperty";
-import {MappingPropertyNary} from "../connect/model/MappingPropertyNary";
-import {UserDefinedOutputStrategy} from "../connect/model/output/UserDefinedOutputStrategy";
-import {CodeInputStaticProperty} from "../connect/model/CodeInputStaticProperty";
-import {DataSourceDescription} from "../connect/model/DataSourceDescription";
-import {EventGrounding} from "../connect/model/grounding/EventGrounding";
-import {TransportFormat} from "../connect/model/grounding/TransportFormat";
-import {TransportProtocol} from "../connect/model/grounding/TransportProtocol";
-
-
-@Injectable()
-export class TsonLdSerializerService {
-
- private getTsonLd(): any {
- const tsonld = new TsonLd();
- tsonld.addClassMapping(ProtocolDescription);
- tsonld.addClassMapping(ProtocolDescriptionList);
- tsonld.addClassMapping(FreeTextStaticProperty);
- tsonld.addClassMapping(SecretStaticProperty);
- tsonld.addClassMapping(FileStaticProperty);
- tsonld.addClassMapping(FormatDescriptionList);
- tsonld.addClassMapping(FormatDescription);
- tsonld.addClassMapping(AdapterDescriptionList);
- tsonld.addClassMapping(AdapterDescription);
- tsonld.addClassMapping(AdapterSetDescription);
- tsonld.addClassMapping(SpecificAdapterSetDescription);
- tsonld.addClassMapping(GenericAdapterSetDescription);
- tsonld.addClassMapping(AdapterStreamDescription);
- tsonld.addClassMapping(GenericAdapterStreamDescription);
- tsonld.addClassMapping(SpecificAdapterStreamDescription);
- tsonld.addClassMapping(DataSetDescription);
- tsonld.addClassMapping(DataStreamDescription);
- tsonld.addClassMapping(DataSourceDescription);
- tsonld.addClassMapping(EventGrounding);
- tsonld.addClassMapping(TransportFormat);
- tsonld.addClassMapping(TransportProtocol);
- tsonld.addClassMapping(EventSchema);
- tsonld.addClassMapping(EventProperty);
- tsonld.addClassMapping(EventPropertyNested);
- tsonld.addClassMapping(PipelineTemplateInvocation);
- tsonld.addClassMapping(MappingPropertyUnary);
- tsonld.addClassMapping(MappingPropertyNary);
- tsonld.addClassMapping(EventPropertyList);
- tsonld.addClassMapping(EventPropertyPrimitive);
- tsonld.addClassMapping(DomainPropertyProbability);
- tsonld.addClassMapping(DomainPropertyProbabilityList);
- tsonld.addClassMapping(GuessSchema);
- tsonld.addClassMapping(URI);
- tsonld.addClassMapping(RenameRuleDescription);
- tsonld.addClassMapping(DeleteRuleDescription);
- tsonld.addClassMapping(AddNestedRuleDescription);
- tsonld.addClassMapping(TransformationRuleDescription);
- tsonld.addClassMapping(RemoveDuplicatesRuleDescription);
- tsonld.addClassMapping(AddTimestampRuleDescription);
- tsonld.addClassMapping(AddValueTransformationRuleDescription);
- tsonld.addClassMapping(EventRateTransformationRuleDescription);
- tsonld.addClassMapping(MoveRuleDescription);
- tsonld.addClassMapping(UnitTransformRuleDescription);
- tsonld.addClassMapping(DataStreamContainer);
- tsonld.addClassMapping(Option);
- tsonld.addClassMapping(AnyStaticProperty);
- tsonld.addClassMapping(OneOfStaticProperty);
- tsonld.addClassMapping(TimestampTransformationRuleDescription);
- tsonld.addClassMapping(NotificationLd);
- tsonld.addClassMapping(MessageLd);
- tsonld.addClassMapping(SuccessMessageLd);
- tsonld.addClassMapping(ErrorMessageLd);
-
- tsonld.addClassMapping(Enumeration);
- tsonld.addClassMapping(QuantitativeValue);
-
- tsonld.addClassMapping(PipelineTemplateDescriptionContainer);
- tsonld.addClassMapping(PipelineTemplateDescription);
- tsonld.addClassMapping(DataProcessorInvocation);
- tsonld.addClassMapping(DataSinkInvocation);
- tsonld.addClassMapping(BoundPipelineElement);
-
- tsonld.addClassMapping(AppendOutputStrategy);
- tsonld.addClassMapping(CodeInputStaticProperty)
- tsonld.addClassMapping(CustomOutputStrategy);
- tsonld.addClassMapping(CustomTransformOutputStrategy);
- tsonld.addClassMapping(FixedOutputStrategy);
- tsonld.addClassMapping(KeepOutputStrategy);
- tsonld.addClassMapping(ListOutputStrategy);
- tsonld.addClassMapping(OutputStrategy);
- tsonld.addClassMapping(PropertyRenameRule);
- tsonld.addClassMapping(TransformOperation);
- tsonld.addClassMapping(TransformOutputStrategy);
- tsonld.addClassMapping(UserDefinedOutputStrategy);
-
- tsonld.addClassMapping(RuntimeResolvableAnyStaticProperty);
- tsonld.addClassMapping(RuntimeResolvableOneOfStaticProperty);
-
- tsonld.addClassMapping(RuntimeOptionsRequest);
- tsonld.addClassMapping(RuntimeOptionsResponse);
- tsonld.addClassMapping(RuntimeOptionsResponse);
-
- tsonld.addClassMapping(GroupStaticProperty);
- tsonld.addClassMapping(AlternativesStaticProperty);
- tsonld.addClassMapping(AlternativeStaticProperty);
- tsonld.addClassMapping(CollectionStaticProperty);
-
- tsonld.addClassMapping(DashboardWidget);
- tsonld.addClassMapping(DashboardWidgetSettings);
-
- tsonld.addClassMapping(VisualizablePipeline);
- tsonld.addClassMapping(ColorPickerStaticProperty);
-
- tsonld.addContext('sp', 'https://streampipes.org/vocabulary/v1/');
- tsonld.addContext('spi', 'urn:streampipes.org:spi:');
- tsonld.addContext('foaf', 'http://xmlns.com/foaf/0.1/');
-
-
- return tsonld;
- }
-
- public toJsonLd(o: any): Observable<{}> {
- return this.getTsonLd().toflattenJsonLd(o);
- }
-
- public fromJsonLd(o: any, type: string): any {
- return this.getTsonLd().fromJsonLdType(o, type);
- }
-
- public fromJsonLdContainer(o: any, type: string): any {
- return this.getTsonLd().fromJsonLdContainer(o, type);
- }
-
- public jsonLdToFlattenJsonLd(object: any): any {
- return this.getTsonLd().jsonLdToFlattenJsonLd(object);
- }
-
-}
diff --git a/ui/src/app/platform-services/tsonld/index.ts b/ui/src/app/platform-services/tsonld/index.ts
deleted file mode 100644
index 5be6310..0000000
--- a/ui/src/app/platform-services/tsonld/index.ts
+++ /dev/null
@@ -1,19 +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 {TsonLd} from './tsonld';
diff --git a/ui/src/app/platform-services/tsonld/model/Person.js b/ui/src/app/platform-services/tsonld/model/Person.js
deleted file mode 100644
index 6d96765..0000000
--- a/ui/src/app/platform-services/tsonld/model/Person.js
+++ /dev/null
@@ -1,63 +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.
- *
- */
-
-"use strict";
-var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-require("reflect-metadata");
-var RdfsClass_1 = require("../RdfsClass");
-var RdfsProperty_1 = require("../RdfsProperty");
-var RdfId_1 = require("../RdfId");
-var Person = /** @class */ (function () {
- // constructor();
- function Person(id, label, description, age, heights) {
- this.id = id;
- this.label = label;
- this.description = description;
- this.age = age;
- this.heights = heights;
- }
- __decorate([
- RdfId_1.RdfId
- ], Person.prototype, "id", void 0);
- __decorate([
- RdfsProperty_1.RdfProperty('sp:label')
- ], Person.prototype, "label", void 0);
- __decorate([
- RdfsProperty_1.RdfProperty('sp:description')
- ], Person.prototype, "description", void 0);
- __decorate([
- RdfsProperty_1.RdfProperty('sp:age')
- ], Person.prototype, "age", void 0);
- __decorate([
- RdfsProperty_1.RdfProperty('sp:heights')
- ], Person.prototype, "heights", void 0);
- __decorate([
- RdfsProperty_1.RdfProperty('foaf:friend')
- ], Person.prototype, "friend", void 0);
- Person = __decorate([
- RdfsClass_1.RdfsClass('sp:Person')
- ], Person);
- return Person;
-}());
-exports.Person = Person;
diff --git a/ui/src/app/platform-services/tsonld/model/Person.ts b/ui/src/app/platform-services/tsonld/model/Person.ts
deleted file mode 100644
index 6eebb89..0000000
--- a/ui/src/app/platform-services/tsonld/model/Person.ts
+++ /dev/null
@@ -1,54 +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 'reflect-metadata';
-import {RdfsClass} from '../RdfsClass';
-import {RdfProperty} from '../RdfsProperty';
-import {RdfId} from '../RdfId';
-
-@RdfsClass('sp:Person')
-export class Person {
-
- @RdfId
- public id: string;
-
- @RdfProperty('sp:label')
- public label: string;
-
- @RdfProperty('sp:description')
- public description: string;
-
- @RdfProperty('sp:age')
- public age: number;
-
- @RdfProperty('sp:heights')
- public heights: number;
-
- @RdfProperty('foaf:friend')
- public friend: Person;
-
-
- // constructor();
- constructor(id: string, label: string, description: string, age: number, heights: number) {
- this.id = id;
- this.label = label;
- this.description = description;
- this.age = age;
- this.heights = heights;
- }
-}
diff --git a/ui/src/app/platform-services/tsonld/tsonld.js b/ui/src/app/platform-services/tsonld/tsonld.js
deleted file mode 100644
index f0b3cf2..0000000
--- a/ui/src/app/platform-services/tsonld/tsonld.js
+++ /dev/null
@@ -1,245 +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.
- *
- */
-
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-require("reflect-metadata");
-var Observable_1 = require("rxjs/Observable");
-require("rxjs/add/observable/fromPromise");
-var jsonld = require("jsonld");
-var util_1 = require("util");
-var TsonLd = /** @class */ (function () {
- // private context: {key: string, value: string}[];
- function TsonLd() {
- // this.context = [];
- this.context = {};
- this.classMapping = {};
- }
- TsonLd.prototype.addContext = function (key, value) {
- this.context[key] = value;
- };
- TsonLd.prototype.addClassMapping = function (value) {
- var key = Reflect.getMetadata('RdfsClass', value.prototype.constructor);
- if (util_1.isUndefined(key)) {
- console.error('The value parameter of addClassMapping needs the RdfsClass annotation');
- }
- else {
- this.classMapping[key] = value;
- }
- };
- TsonLd.prototype.toflattenJsonLd = function (object) {
- var obj = this.toJsonLd(object);
- var context = obj['@context'];
- delete obj['@context'];
- return Observable_1.Observable.fromPromise(new Promise(function (resolve, reject) {
- jsonld.flatten(obj, context, function (err, data) {
- // console.log('flatten data: bla bla bla: ' + JSON.stringify(data, null, 2));
- resolve(data);
- });
- }));
- };
- /**
- *
- * @param object the object to serialize
- * @param {boolean} setContext defines whether the context should be added or not
- * @param {any[]} allIds used to avoid cycles
- * @returns {{}}
- */
- TsonLd.prototype.toJsonLd = function (object, setContext, allIds) {
- if (setContext === void 0) { setContext = true; }
- if (allIds === void 0) { allIds = []; }
- // 1. object to json object
- var jsObject = Object.assign({}, object);
- // console.log('1. Step (js Object): ' + JSON.stringify(jsObject));
- var properties = Object.getOwnPropertyNames(object);
- // 2. Search for key id in object
- var objectIdProperty = {};
- for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {
- var property = properties_1[_i];
- // TODO add check that just one id is available
- var idProperty = Reflect.getMetadata('RdfsId', object, property);
- if (idProperty === 'rdfsId') {
- objectIdProperty = property;
- }
- }
- if (objectIdProperty === {}) {
- console.error('Error no key Property');
- // TODO generate a key
- }
- if (allIds.includes(jsObject[objectIdProperty])) {
- return { '@id': jsObject[objectIdProperty] };
- }
- else {
- allIds.push(jsObject[objectIdProperty]);
- }
- // 3. exchange keys with URIs
- for (var _a = 0, properties_2 = properties; _a < properties_2.length; _a++) {
- var property = properties_2[_a];
- if (property !== objectIdProperty) {
- var newProperty = Reflect.getMetadata('RdfProperty', object, property);
- // check if the value is an array
- if (Array.isArray(jsObject[property])) {
- jsObject[newProperty] = [];
- if (typeof jsObject[property][0] === 'object') {
- for (var _b = 0, _c = jsObject[property]; _b < _c.length; _b++) {
- var elem = _c[_b];
- jsObject[newProperty].push(this.toJsonLd(elem, false, allIds));
- }
- }
- else {
- jsObject[newProperty] = jsObject[property];
- }
- }
- else if (typeof jsObject[property] === 'object') {
- jsObject[newProperty] = this.toJsonLd(jsObject[property], false, allIds);
- }
- else {
- jsObject[newProperty] = jsObject[property];
- }
- }
- else {
- jsObject['@id'] = jsObject[property];
- }
- delete jsObject[property];
- }
- // console.log('2. Step (js Object with URIs as key): ' + JSON.stringify(jsObject));
- // 4. add @type to object
- // console.log('3. Step (add type): ' + JSON.stringify(jsObject));
- var objectType = Reflect.getMetadata('RdfsClass', object.constructor);
- jsObject['@type'] = objectType;
- // 5. add @context to object
- if (setContext) {
- var tmp = {};
- tmp['@graph'] = jsObject;
- tmp['@context'] = this.context;
- jsObject = tmp;
- }
- // console.log('testttest ' + JSON.stringify(jsObject));
- return jsObject;
- };
- /**
- *
- * @param {Object} obj
- * @param {T} p
- * @param {{}} ids
- * @returns {any}
- */
- // fromJsonLd<T>(obj: Object, p: T, ids: {}= {}) {
- TsonLd.prototype.fromJsonLd = function (obj, ids, id) {
- if (ids === void 0) { ids = {}; }
- var context = obj['@context'];
- var graph = obj['@graph'];
- // Get rdfs type of p
- // const objectType: String = Reflect.getMetadata('RdfsClass', Person);
- // Find first object in graph with this type
- // TODO think what should happen when more of one types are in graph
- var jsonObject = null;
- // for (const o of graph) {
- var o = graph[0];
- if (graph.length > 0) {
- jsonObject = o;
- }
- else if (!util_1.isUndefined(ids[id])) {
- return ids[id];
- }
- // Create the result object
- var c = this.classMapping[jsonObject['@type']];
- if (util_1.isUndefined(c)) {
- console.error('Type: ' + jsonObject['@type'] + ' is not registered in tsonld');
- }
- var result = new c();
- for (var property in jsonObject) {
- var objectProp = void 0;
- // Remove the @type property
- if (property === '@id') {
- objectProp = Reflect.getMetadata('TsId', c.prototype, property);
- }
- else {
- objectProp = Reflect.getMetadata('TsProperty', c.prototype, property);
- }
- // skip the @type property
- if (property !== '@type') {
- // check whether property is object or literal
- if (typeof jsonObject[property] === 'object') {
- result[objectProp] = [];
- // check if object or array
- if (Array.isArray(jsonObject[property])) {
- // ARRAY
- if (jsonObject[property].length > 0 && typeof jsonObject[property][0] === 'object') {
- for (var _i = 0, _a = jsonObject[property]; _i < _a.length; _i++) {
- var elem = _a[_i];
- // 1. check if already deserialized
- if (!util_1.isUndefined(ids[elem['@id']])) {
- // TODO never called
- }
- else {
- // 2. deserialize
- // remove current object from graph
- var index = graph.indexOf(jsonObject, 0);
- if (index > -1) {
- graph.splice(index, 1);
- }
- var newObj = { '@context': context, '@graph': graph };
- ids[jsonObject['@id']] = result;
- var arrayResult = this.fromJsonLd(newObj, ids, elem['@id']);
- // TODO hot fix not sure if it works for all cases
- graph.splice(0, 1);
- result[objectProp].push(arrayResult);
- }
- }
- }
- else {
- // ARRAY of literals
- result[objectProp] = jsonObject[property];
- }
- }
- else {
- // NO ARRAY
- // console.log('bbbb ' + jsonObject[property] + ' xxxx ' + Array.isArray(jsonObject[property]));
- // check if already deserialized
- if (!util_1.isUndefined(ids[jsonObject[property]['@id']])) {
- // when already desirialized use object from stored array
- result[objectProp] = ids[jsonObject[property]['@id']];
- }
- else {
- // if not recursion and add to ids array
- var index = graph.indexOf(jsonObject, 0);
- if (index > -1) {
- graph.splice(index, 1);
- }
- var newObj = { '@context': context, '@graph': graph };
- ids[jsonObject['@id']] = result;
- var nestedResult = this.fromJsonLd(newObj, ids);
- result[objectProp] = nestedResult;
- }
- }
- }
- else {
- result[objectProp] = jsonObject[property];
- }
- }
- }
- // TODO add handling for and for nested properties
- return result;
- };
- return TsonLd;
-}());
-exports.TsonLd = TsonLd;
-function prop(obj, key) {
- return obj[key];
-}
diff --git a/ui/src/app/platform-services/tsonld/tsonld.ts b/ui/src/app/platform-services/tsonld/tsonld.ts
deleted file mode 100644
index 0f0f687..0000000
--- a/ui/src/app/platform-services/tsonld/tsonld.ts
+++ /dev/null
@@ -1,410 +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 'reflect-metadata';
-import {from, Observable} from 'rxjs';
-
-import * as jsonld from 'jsonld';
-
-import {isUndefined} from 'util';
-
-export class TsonLd {
-
- private context: { [key: string]: string; } = {};
- private classMapping: { [key: string]: any; } = {};
-
- constructor() {
-
- }
-
- public addContext(key: string, value: string) {
- this.context[key] = value;
- }
-
- public addClassMapping(value: any) {
- const key: string = Reflect.getMetadata('RdfsClass', value.prototype.constructor);
- if (isUndefined(key)) {
- console.error('The value parameter of addClassMapping needs the RdfsClass annotation');
- } else {
- this.classMapping[key] = value;
- }
- }
-
- public toflattenJsonLd(object: any): Observable<{}> {
-
- const obj = this.toJsonLd(object);
- const context = obj['@context'];
- delete obj['@context'];
-
- let promise = new Promise(function (resolve, reject) {
- (jsonld as any).flatten(obj, context, function (err, data) {
- resolve(data);
- });
- });
-
- return from(promise);
- }
-
- public jsonLdToFlattenJsonLd(object: any) {
- const context = object['@context'];
- delete object['@context'];
-
- let promise = new Promise(function(resolve, reject) {
- (jsonld as any).flatten(object, context, function (err, data) {
- resolve(data);
- });
- });
-
- return from(promise);
- }
-
- /**
- *
- * @param object the object to serialize
- * @param {boolean} setContext defines whether the context should be added or not
- * @param {any[]} allIds used to avoid cycles
- * @returns {{}}
- */
- public toJsonLd(object: any, setContext = true, allIds: any[] = []): {} {
-
- // 1. object to json object
- let jsObject = Object.assign({}, object);
- // console.log('1. Step (js Object): ' + JSON.stringify(jsObject));
-
- const properties = Object.getOwnPropertyNames(object);
-
-
- // 2. Search for key id in object
- let objectIdProperty: any = {};
- for (const property of properties) {
- // TODO add check that just one id is available
- const idProperty = Reflect.getMetadata('RdfsId', object, property);
- if (idProperty === 'rdfsId') {
- objectIdProperty = property;
- }
- }
-
- if (objectIdProperty === {}) {
- console.error('Error no key Property');
- // TODO generate a key
- }
-
- if (allIds.includes(jsObject[objectIdProperty])) {
- return {'@id': jsObject[objectIdProperty]};
- } else {
- allIds.push(jsObject[objectIdProperty]);
- }
-
- // 3. exchange keys with URIs
- for (const property of properties) {
-
- if (property !== objectIdProperty) {
- const newProperty = Reflect.getMetadata('RdfProperty', object, property);
- // check if the value is an array
- if (Array.isArray(jsObject[property])) {
- jsObject[newProperty] = [];
- if (typeof jsObject[property][0] === 'object') {
- for (const elem of jsObject[property]) {
- jsObject[newProperty].push(this.toJsonLd(elem, false, allIds));
- }
- } else {
- jsObject[newProperty] = jsObject[property];
- }
- } else if (typeof jsObject[property] === 'object') {
- jsObject[newProperty] = this.toJsonLd(jsObject[property], false, allIds);
- } else {
- let parseHint = Reflect.hasMetadata('Float', object, property);
- if (parseHint) {
- jsObject[newProperty] = parseFloat(jsObject[property]).toFixed(2);
- } else {
- jsObject[newProperty] = jsObject[property];
- }
- }
- } else {
- jsObject['@id'] = jsObject[property];
- }
- delete jsObject[property];
- }
- // console.log('2. Step (js Object with URIs as key): ' + JSON.stringify(jsObject));
-
- // 4. add @type to object
-
- // console.log('3. Step (add type): ' + JSON.stringify(jsObject));
- const objectType = Reflect.getMetadata('RdfsClass', object.constructor);
- jsObject['@type'] = objectType;
-
- // 5. add @context to object
- if (setContext) {
- const tmp = {};
- tmp['@graph'] = jsObject;
- tmp['@context'] = this.context;
- jsObject = tmp;
- }
- // console.log('testttest ' + JSON.stringify(jsObject));
-
- return jsObject;
- }
-
- fromJsonLdType(obj: Object, type: String) {
- let topElement = null;
- let graph = obj['@graph'];
- graph.forEach((elem, index) => {
- if (elem['@type'] === type) {
- topElement = elem;
- obj['@graph'].splice(index, 1);
- }
- });
- if (topElement != null) {
- obj['@graph'].unshift(topElement);
- return this.fromJsonLd(obj);
- } else {
- console.log("Element" +type + " not found in graph");
- return {};
- }
- }
-
- fromJsonLdContainer(obj: Object, type: string): Array<any> {
- let topElements: Array<string> = [];
- let deserializedObjects: Array<any> = [];
- let graph = obj['@graph'];
- graph.forEach(elem => {
- if (elem['@type'] === type) {
- topElements.push(this.makeJsonLdGraphForElement(elem['@id'], obj, type));
- }
- });
- topElements.forEach(topElement => {
- deserializedObjects.push(this.fromJsonLdType(topElement, type));
- });
- return deserializedObjects;
- }
-
- makeJsonLdGraphForElement(id: string, obj: any, type: string): any {
- let clonedObj = {} ;
- clonedObj['@graph'] = [];
- let graph = obj['@graph'];
- graph.forEach(elem => {
- if ((elem['@type'] === type && elem['@id'] !== id) || elem['@type'] === "sp:EntityContainer") {
-
- } else {
- clonedObj['@graph'].push(elem);
- }
- });
- clonedObj['@context'] = obj['@context'];
- return clonedObj;
- }
-
-
- /**
- *
- * @param {Object} obj
- * @param {T} p
- * @param {{}} ids
- * @returns {any}
- */
- // fromJsonLd<T>(obj: Object, p: T, ids: {}= {}) {
- fromJsonLd(obj: Object, ids: {}= {}, id?: string) {
-
- const context = obj['@context'];
- const graph = obj['@graph'];
-
- // Get rdfs type of p
- // const objectType: String = Reflect.getMetadata('RdfsClass', Person);
-
- // Find first object in graph with this type
- // TODO think what should happen when more of one types are in graph
- let jsonObject = null;
- // for (const o of graph) {
- // const o = graph[0];
- if (graph.length > 0) {
- if (!isUndefined(id)) {
- for (const elem of graph) {
- if (elem['@id'] === id) {
- jsonObject = elem;
- }
- }
- if (isUndefined(jsonObject) || jsonObject == null) {
- console.error('id ' + id + ' is not in graph. this should never happen');
- }
- } else {
- jsonObject = graph[0];
- }
- } else if (!isUndefined(ids[id])) {
- return ids[id];
- } else {
- console.log('FIX BUG: Pass id to fromJSON-LD');
- }
-
- // Create the result object
- const c = this.classMapping[jsonObject['@type']];
- if (isUndefined(c)) {
- console.error('Type: ' + jsonObject['@type'] + ' is not registered in tsonld');
- }
- const result = new c();
-
-
- for (const property in jsonObject) {
- let objectProp: string;
- // Remove the @type property
- if (property === '@id') {
- objectProp = Reflect.getMetadata('TsId', c.prototype, property);
- } else {
- objectProp = Reflect.getMetadata('TsProperty', c.prototype, property);
- }
- // skip the @type property
- if (property !== '@type') {
- // check whether property is object or literal
- if (typeof jsonObject[property] === 'object' && !isUndefined(objectProp)) {
- // check if object or array
- if (Array.isArray(jsonObject[property])) {
- // TODO check if needed
- result[objectProp] = [];
- // ARRAY
- if (jsonObject[property].length > 0 && typeof jsonObject[property][0] === 'object') {
- for (const elem of jsonObject[property]) {
-
- // 1. check if already deserialized
- if (!isUndefined(ids[elem['@id']])) {
- // TODO never called
-
- } else {
- // 2. deserialize
- // remove current object from graph
- const tmpIndex = graph.indexOf(jsonObject, 0);
- if (tmpIndex > -1) {
- graph.splice(tmpIndex, 1);
- }
-
- const newObj = {'@context': context, '@graph': graph};
-
- ids[jsonObject['@id']] = result;
-
- const arrayResult = this.fromJsonLd(newObj, ids, elem['@id']);
-
- // TODO hot fix not sure if it works for all cases
- // graph.splice(0, 1);
- const index = graph.indexOf(jsonObject, 0);
- if (index > -1) {
- graph.splice(index, 1);
- }
- result[objectProp].push(arrayResult);
-
- }
- }
- } else {
- // ARRAY of literals
- result[objectProp] = jsonObject[property];
- }
-
- } else {
- // NO ARRAY
- // console.log('bbbb ' + jsonObject[property] + ' xxxx ' + Array.isArray(jsonObject[property]));
-
- // if (Array.isArray(result[objectProp])) {
-
- // check if already deserialized
- if (!isUndefined(ids[jsonObject[property]['@id']])) {
- // when already desirialized use object from stored array
-
- // case where array just has one element (this is serialized as an object)
-
- if (Array.isArray(result[objectProp])) {
- result[objectProp] = [ids[jsonObject[property]['@id']]];
- // result[objectProp] = ids[jsonObject[property]['@id']];
- } else {
- result[objectProp] = ids[jsonObject[property]['@id']];
- }
- } else {
- // if not recursion and add to ids array
- const index = graph.indexOf(jsonObject, 0);
- if (index > -1) {
- graph.splice(index, 1);
- }
- const newObj = {'@context': context, '@graph': graph};
- ids[jsonObject['@id']] = result;
-
- // console.log('ddddd: ' + JSON.stringify(ids,null, 2));
- const current_id = jsonObject[property]['@id'];
- if (!isUndefined(current_id)) {
- // TODO last statement either 0 or now graph does not contain object id with more
- if (Object.keys(jsonObject[property]).length === 1 && isUndefined(ids[current_id]) && !this.containsIdObject(newObj['@graph'], current_id)) {
-
- // ids does not contain
- result[objectProp] = jsonObject[property]['@id'];
-
- } else {
- // if object just contains an @id initialize it as a string
- const nestedResult = this.fromJsonLd(newObj, ids, jsonObject[property]['@id']);
- // case where array just has one element (this is serialized as an object)
-
- if (Array.isArray(result[objectProp])) {
-
- result[objectProp] = [nestedResult];
- } else {
- result[objectProp] = nestedResult;
- }
- }
- } else {
- // TODO check with Philipp
- let type = jsonObject[property]['@type'];
- if(type === 'xsd:boolean') {
- if (jsonObject[property]['@value'].toLowerCase() === "true") {
- result[objectProp] = true;
- } else {
- result[objectProp] = false;
- }
- } else if (type === 'xsd:int' || type === 'xsd:double' || type === 'xsd:float') {
- result[objectProp] = +jsonObject[property]['@value'];
- } else {
- result[objectProp] = jsonObject[property]['@value'];
- }
- }
- }
- }
- } else {
- if (!isUndefined(objectProp)) {
- result[objectProp] = jsonObject[property];
- }
- }
- }
- }
-
-// TODO add handling for and for nested properties
- return result;
-
- }
- // }
-
- public containsIdObject(array: any[], id: string): boolean {
- let result = false;
-
- for (const entry of array) {
- if (entry['@id'] === id && Object.keys(entry).length > 1) {
- result = true;
- }
-
- }
-
- return result;
- }
-}
-
-function prop<T, K extends keyof T>(obj: T, key: K) {
- return obj[key];
-}
-
-