streampipes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [incubator-streampipes] branch feature_CollectionProperty updated: [STREAMPIPES-22] finish support for collection property - fix jsonld serializing bug - fix ui deserialzing of booleans - fix last bugs for collection
Date Wed, 08 Jan 2020 19:51:18 GMT
This is an automated email from the ASF dual-hosted git repository.

tex pushed a commit to branch feature_CollectionProperty
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/feature_CollectionProperty by this push:
     new f007524  [STREAMPIPES-22] finish support for collection property  - fix jsonld serializing
bug  - fix ui deserialzing of booleans  - fix last bugs for collection
f007524 is described below

commit f0075248cdb51ab33a819b124b9c5850fdc2e51c
Author: tex <tex@fzi.de>
AuthorDate: Wed Jan 8 20:50:50 2020 +0100

    [STREAMPIPES-22] finish support for collection property
     - fix jsonld serializing bug
     - fix ui deserialzing of booleans
     - fix last bugs for collection
---
 .../staticproperty/SelectionStaticProperty.java    |  4 +++
 .../model/staticproperty/StaticPropertyGroup.java  | 12 +++++++++
 .../rest/shared/util/JsonLdUtilsTest.java          | 29 +++++++++++++++++++---
 .../apache/streampipes/sdk/StaticProperties.java   |  1 +
 ui/src/app/connect/model/GroupStaticProperty.ts    |  5 ++--
 .../app/connect/model/SelectionStaticProperty.ts   |  4 +--
 .../static-collection.component.css                |  0
 .../static-properties/static-property.component.ts |  5 ++++
 .../platform-services/tsonld-serializer.service.ts |  2 ++
 ui/src/app/platform-services/tsonld/tsonld.ts      |  8 +++++-
 10 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/SelectionStaticProperty.java
b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/SelectionStaticProperty.java
index 79d466f..165ffe2 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/SelectionStaticProperty.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/SelectionStaticProperty.java
@@ -85,4 +85,8 @@ public abstract class SelectionStaticProperty extends StaticProperty {
   public void setHorizontalRendering(boolean horizontalRendering) {
     this.horizontalRendering = horizontalRendering;
   }
+
+  public boolean isHorizontalRendering() {
+    return horizontalRendering;
+  }
 }
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/StaticPropertyGroup.java
b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/StaticPropertyGroup.java
index 8d567b0..7f1d3e2 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/StaticPropertyGroup.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/staticproperty/StaticPropertyGroup.java
@@ -55,6 +55,10 @@ public class StaticPropertyGroup extends StaticProperty {
     this.horizontalRendering = other.horizontalRendering;
   }
 
+  public void setShowLabel(Boolean showLabel) {
+    this.showLabel = showLabel;
+  }
+
   public StaticPropertyGroup(String internalName, String label, String description) {
     super(StaticPropertyType.StaticPropertyGroup, internalName, label, description);
   }
@@ -80,4 +84,12 @@ public class StaticPropertyGroup extends StaticProperty {
   public void setHorizontalRendering(boolean horizontalRendering) {
     this.horizontalRendering = horizontalRendering;
   }
+
+  public Boolean getShowLabel() {
+    return showLabel;
+  }
+
+  public boolean isHorizontalRendering() {
+    return horizontalRendering;
+  }
 }
diff --git a/streampipes-rest-shared/src/test/java/org/apache/streampipes/rest/shared/util/JsonLdUtilsTest.java
b/streampipes-rest-shared/src/test/java/org/apache/streampipes/rest/shared/util/JsonLdUtilsTest.java
index afc9d5a..892282c 100644
--- a/streampipes-rest-shared/src/test/java/org/apache/streampipes/rest/shared/util/JsonLdUtilsTest.java
+++ b/streampipes-rest-shared/src/test/java/org/apache/streampipes/rest/shared/util/JsonLdUtilsTest.java
@@ -18,16 +18,19 @@
 
 package org.apache.streampipes.rest.shared.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
+import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty;
+import org.apache.streampipes.model.staticproperty.StaticProperty;
+import org.apache.streampipes.model.staticproperty.StaticPropertyGroup;
 import org.junit.Test;
 import org.apache.streampipes.model.connect.grounding.FormatDescription;
 import org.apache.streampipes.model.connect.grounding.FormatDescriptionList;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import static org.junit.Assert.*;
+
 public class JsonLdUtilsTest {
 
     @Test
@@ -83,4 +86,24 @@ public class JsonLdUtilsTest {
         assertEquals(result.getList().get(1).getUri(), "http://id.de#4");
         assertEquals(result.getList().get(1).getName(), "name2" );
     }
+
+    @Test
+    public void jsonldSeriaulizing() {
+        StaticPropertyGroup group = new StaticPropertyGroup();
+        group.setElementId("http://test");
+        List<StaticProperty> staticProperties = new ArrayList<>();
+        staticProperties.add(new FreeTextStaticProperty());
+        group.setStaticProperties(staticProperties);
+        group.setIndex(1);
+        group.setInternalName("interName");
+
+        group.setShowLabel(true);
+        group.setHorizontalRendering(true);
+
+        String adapterDescription = JsonLdUtils.toJsonLD(group);
+        System.out.println(adapterDescription);
+
+        assertTrue( adapterDescription.contains("isHorizontalRendering"));
+    }
+
 }
\ No newline at end of file
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/StaticProperties.java
b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/StaticProperties.java
index 78ac517..73dddbf 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/StaticProperties.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/StaticProperties.java
@@ -126,6 +126,7 @@ public class StaticProperties {
     if (sp.length > 0) {
       StaticPropertyGroup group = StaticProperties.group(label);
       group.setHorizontalRendering(true);
+      group.setStaticProperties(Arrays.asList(sp));
 
       return new CollectionStaticProperty(label.getInternalId(), label.getLabel(),
               label.getDescription(), group);
diff --git a/ui/src/app/connect/model/GroupStaticProperty.ts b/ui/src/app/connect/model/GroupStaticProperty.ts
index 2b5562e..f457508 100644
--- a/ui/src/app/connect/model/GroupStaticProperty.ts
+++ b/ui/src/app/connect/model/GroupStaticProperty.ts
@@ -29,9 +29,8 @@ export class GroupStaticProperty extends StaticProperty {
     @RdfProperty('sp:showLabel')
     public showLabel: boolean;
 
-    //TODO remove setting true, if serialization is fixed
-    @RdfProperty('sp:horizontalRendering')
-    public horizontalRendering: boolean = true;
+    @RdfProperty('sp:isHorizontalRendering')
+    public horizontalRendering: boolean;
 
     constructor(id: string) {
         super();
diff --git a/ui/src/app/connect/model/SelectionStaticProperty.ts b/ui/src/app/connect/model/SelectionStaticProperty.ts
index 416a67f..211d532 100644
--- a/ui/src/app/connect/model/SelectionStaticProperty.ts
+++ b/ui/src/app/connect/model/SelectionStaticProperty.ts
@@ -34,8 +34,8 @@ export class SelectionStaticProperty extends StaticProperty {
   @RdfProperty('sp:hasOption')
   public options: Option[] = [];
 
-  //TODO remove setting true, if serialization is fixed
-  @RdfProperty('sp:horizontalRendering')
+  //TODO - remove if deserialize works correct
+  @RdfProperty('sp:isHorizontalRendering')
   public horizontalRendering: boolean = true;
 
   constructor(id: string) {
diff --git a/ui/src/app/connect/static-properties/static-collection/static-collection.component.css
b/ui/src/app/connect/static-properties/static-collection/static-collection.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/ui/src/app/connect/static-properties/static-property.component.ts b/ui/src/app/connect/static-properties/static-property.component.ts
index 45fc399..568875c 100644
--- a/ui/src/app/connect/static-properties/static-property.component.ts
+++ b/ui/src/app/connect/static-properties/static-property.component.ts
@@ -35,6 +35,7 @@ import {ConfigurationInfo} from "../model/message/ConfigurationInfo";
 import {SecretStaticProperty} from "../model/SecretStaticProperty";
 import {AlternativesStaticProperty} from '../model/AlternativesStaticProperty';
 import {GroupStaticProperty} from '../model/GroupStaticProperty';
+import { CollectionStaticProperty } from "../model/CollectionStaticProperty";
 
 @Component({
   selector: 'app-static-property',
@@ -139,6 +140,10 @@ export class StaticPropertyComponent implements OnInit {
       return val instanceof AlternativesStaticProperty;
   }
 
+  isCollectionStaticProperty(val) {
+    return val instanceof CollectionStaticProperty;
+  }
+
   valueChange(hasInput) {
     this.staticProperty.isValid = hasInput;
     this.validateEmitter.emit();
diff --git a/ui/src/app/platform-services/tsonld-serializer.service.ts b/ui/src/app/platform-services/tsonld-serializer.service.ts
index 2b5b208..79b8f9a 100644
--- a/ui/src/app/platform-services/tsonld-serializer.service.ts
+++ b/ui/src/app/platform-services/tsonld-serializer.service.ts
@@ -91,6 +91,7 @@ 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";
 
 
 @Injectable()
@@ -176,6 +177,7 @@ export class TsonLdSerializerService {
         tsonld.addClassMapping(GroupStaticProperty);
         tsonld.addClassMapping(AlternativesStaticProperty);
         tsonld.addClassMapping(AlternativeStaticProperty);
+        tsonld.addClassMapping(CollectionStaticProperty);
 
         tsonld.addContext('sp', 'https://streampipes.org/vocabulary/v1/');
         tsonld.addContext('spi', 'urn:streampipes.org:spi:');
diff --git a/ui/src/app/platform-services/tsonld/tsonld.ts b/ui/src/app/platform-services/tsonld/tsonld.ts
index a2d28e9..5d1582e 100644
--- a/ui/src/app/platform-services/tsonld/tsonld.ts
+++ b/ui/src/app/platform-services/tsonld/tsonld.ts
@@ -315,7 +315,13 @@ export class TsonLd {
               } else {
                 // TODO check with Philipp
                 let type = jsonObject[property]['@type'];
-                if (type === 'xsd:int' || type === 'xsd:double' || type === 'xsd:float' ||
type === 'xsd:boolean') {
+                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'];


Mime
View raw message