From 6b90352bde94d69f011fcd4d943d002b0c83f922 Mon Sep 17 00:00:00 2001 From: Dominik Riemer Date: Tue, 21 May 2024 16:58:12 +0200 Subject: [PATCH 1/2] fix(#2830): Properly store property scope in rule definitions --- .../convert/ToTransformedSchemaConverter.java | 4 ++++ .../rules/value/AddTimestampRuleDescription.java | 11 +++++++++++ .../src/lib/model/gen/streampipes-model.ts | 4 +++- .../sp-exception-message.component.html | 8 ++++++-- .../sp-exception-message.component.scss | 1 - .../services/transformation-rule.service.ts | 14 +++++++++----- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java index 60f282abd4..92b1674d0d 100644 --- a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java +++ b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/convert/ToTransformedSchemaConverter.java @@ -109,6 +109,10 @@ public void visit(RemoveDuplicatesTransformationRuleDescription rule) { public void visit(AddTimestampRuleDescription rule) { var timestampProperty = EpProperties.timestampProperty(rule.getRuntimeKey()); timestampProperty.setElementId(TIMESTAMP_ID_PREFIX + UUIDGenerator.generateUuid()); + // null check required for backwards compatibility + if (rule.getPropertyScope() != null) { + timestampProperty.setPropertyScope(rule.getPropertyScope().name()); + } this.properties.add(timestampProperty); } diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/connect/rules/value/AddTimestampRuleDescription.java b/streampipes-model/src/main/java/org/apache/streampipes/model/connect/rules/value/AddTimestampRuleDescription.java index 379ac3b90b..1df522dbd0 100644 --- a/streampipes-model/src/main/java/org/apache/streampipes/model/connect/rules/value/AddTimestampRuleDescription.java +++ b/streampipes-model/src/main/java/org/apache/streampipes/model/connect/rules/value/AddTimestampRuleDescription.java @@ -20,10 +20,12 @@ import org.apache.streampipes.model.connect.rules.ITransformationRuleVisitor; import org.apache.streampipes.model.connect.rules.TransformationRulePriority; +import org.apache.streampipes.model.schema.PropertyScope; public class AddTimestampRuleDescription extends ValueTransformationRuleDescription { private String runtimeKey; + private PropertyScope propertyScope; public AddTimestampRuleDescription() { super(); @@ -36,6 +38,7 @@ public AddTimestampRuleDescription(String runtimeKey) { public AddTimestampRuleDescription(AddTimestampRuleDescription other) { super(other); this.runtimeKey = other.getRuntimeKey(); + this.propertyScope = other.getPropertyScope(); } public String getRuntimeKey() { @@ -46,6 +49,14 @@ public void setRuntimeKey(String runtimeKey) { this.runtimeKey = runtimeKey; } + public PropertyScope getPropertyScope() { + return propertyScope; + } + + public void setPropertyScope(PropertyScope propertyScope) { + this.propertyScope = propertyScope; + } + @Override public void accept(ITransformationRuleVisitor visitor) { visitor.visit(this); diff --git a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts index b0de88590b..1cd4d5a729 100644 --- a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts +++ b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts @@ -20,7 +20,7 @@ /* tslint:disable */ /* eslint-disable */ // @ts-nocheck -// Generated using typescript-generator version 3.2.1263 on 2024-04-30 20:29:03. +// Generated using typescript-generator version 3.2.1263 on 2024-05-21 13:45:10. export class NamedStreamPipesEntity { '@class': @@ -325,6 +325,7 @@ export class ValueTransformationRuleDescription extends TransformationRuleDescri export class AddTimestampRuleDescription extends ValueTransformationRuleDescription { '@class': 'org.apache.streampipes.model.connect.rules.value.AddTimestampRuleDescription'; + 'propertyScope': PropertyScope; 'runtimeKey': string; static 'fromData'( @@ -336,6 +337,7 @@ export class AddTimestampRuleDescription extends ValueTransformationRuleDescript } const instance = target || new AddTimestampRuleDescription(); super.fromData(data, instance); + instance.propertyScope = data.propertyScope; instance.runtimeKey = data.runtimeKey; return instance; } diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.html index 5f9b8ab1e0..04493f10e3 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.html +++ b/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.html @@ -30,13 +30,17 @@
{{ messageTimestamp | date: 'short' }}
-
+
{{ message.title || 'Error' }}
-
diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.scss b/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.scss index 26170c62ba..165ce8fb0f 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.scss +++ b/ui/projects/streampipes/shared-ui/src/lib/components/sp-exception-message/sp-exception-message.component.scss @@ -18,7 +18,6 @@ .error-panel { background: var(--color-bg-1); - border-radius: 5px; } .error { diff --git a/ui/src/app/connect/services/transformation-rule.service.ts b/ui/src/app/connect/services/transformation-rule.service.ts index f1cca8565c..4179a5e02a 100644 --- a/ui/src/app/connect/services/transformation-rule.service.ts +++ b/ui/src/app/connect/services/transformation-rule.service.ts @@ -30,6 +30,7 @@ import { EventPropertyUnion, EventSchema, MoveRuleDescription, + PropertyScope, RenameRuleDescription, SemanticType, TimestampTranfsformationRuleDescription, @@ -55,22 +56,24 @@ export class TransformationRuleService { if (originalSchema == null || targetSchema == null) { console.log('Old and new schema must be defined'); } else { - const addedTimestampProperties = this.getTimestampProperty( + const addedTimestampProperty = this.getTimestampProperty( targetSchema.eventProperties, ); - if (addedTimestampProperties) { + if (addedTimestampProperty) { // add to old event schema for the case users moved the property to a nested property - originalSchema.eventProperties.push(addedTimestampProperties); + originalSchema.eventProperties.push(addedTimestampProperty); const timestampRuleDescription: AddTimestampRuleDescription = new AddTimestampRuleDescription(); timestampRuleDescription['@class'] = 'org.apache.streampipes.model.connect.rules.value.AddTimestampRuleDescription'; timestampRuleDescription.runtimeKey = - addedTimestampProperties.runtimeName; + addedTimestampProperty.runtimeName; + timestampRuleDescription.propertyScope = + addedTimestampProperty.propertyScope as PropertyScope; transformationRuleDescriptions.push(timestampRuleDescription); } - + console.log(transformationRuleDescriptions); const staticValueProperties = this.getStaticValueProperties( targetSchema.eventProperties, ); @@ -84,6 +87,7 @@ export class TransformationRuleService { rule.datatype = ep.runtimeType; rule.label = ep.label; rule.description = ep.description; + rule.propertyScope = ep.propertyScope as PropertyScope; if (ep.domainProperties.length > 0) { rule.semanticType = ep.domainProperties[0]; } From 2aa490c85bd47937d51b6ddfebf24b42a28c91e5 Mon Sep 17 00:00:00 2001 From: Dominik Riemer Date: Tue, 21 May 2024 17:01:17 +0200 Subject: [PATCH 2/2] Remove logging --- ui/src/app/connect/services/transformation-rule.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/src/app/connect/services/transformation-rule.service.ts b/ui/src/app/connect/services/transformation-rule.service.ts index c53c3305ac..443abebab9 100644 --- a/ui/src/app/connect/services/transformation-rule.service.ts +++ b/ui/src/app/connect/services/transformation-rule.service.ts @@ -73,7 +73,6 @@ export class TransformationRuleService { addedTimestampProperty.propertyScope as PropertyScope; transformationRuleDescriptions.push(timestampRuleDescription); } - console.log(transformationRuleDescriptions); const staticValueProperties = this.getStaticValueProperties( targetSchema.eventProperties, );