You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2023/10/20 14:15:24 UTC
[streampipes] 04/09: feat: add version to models & builders
This is an automated email from the ASF dual-hosted git repository.
bossenti pushed a commit to branch 2045-implement-migration-for-adapter-and-pipeline-element-configurations
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit ecd20c4e8f6ef8636996e799064abba43c5ff269
Author: bossenti <bo...@posteo.de>
AuthorDate: Thu Oct 19 11:26:38 2023 +0200
feat: add version to models & builders
---
.../model/base/ConsumableStreamPipesEntity.java | 15 ++++++++++++-
.../model/base/VersionedStreamPipesEntity.java | 25 ++++++++++++++++++++++
.../model/connect/adapter/AdapterDescription.java | 17 +++++++++++++--
.../builder/AbstractProcessingElementBuilder.java | 4 ++++
.../adapter/AdapterConfigurationBuilder.java | 5 ++++-
5 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/base/ConsumableStreamPipesEntity.java b/streampipes-model/src/main/java/org/apache/streampipes/model/base/ConsumableStreamPipesEntity.java
index 67be04100..c3550bf1c 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/base/ConsumableStreamPipesEntity.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/base/ConsumableStreamPipesEntity.java
@@ -26,10 +26,12 @@ import org.apache.streampipes.model.util.Cloner;
import java.util.ArrayList;
import java.util.List;
-public abstract class ConsumableStreamPipesEntity extends NamedStreamPipesEntity {
+public abstract class ConsumableStreamPipesEntity extends NamedStreamPipesEntity implements VersionedStreamPipesEntity{
private static final long serialVersionUID = -6617391345752016449L;
+ private int version;
+
protected List<SpDataStream> spDataStreams;
protected List<StaticProperty> staticProperties;
@@ -57,6 +59,7 @@ public abstract class ConsumableStreamPipesEntity extends NamedStreamPipesEntity
if (other.getSupportedGrounding() != null) {
this.supportedGrounding = new EventGrounding(other.getSupportedGrounding());
}
+ this.version = other.version;
}
public List<SpDataStream> getSpDataStreams() {
@@ -87,4 +90,14 @@ public abstract class ConsumableStreamPipesEntity extends NamedStreamPipesEntity
this.supportedGrounding = supportedGrounding;
}
+ @Override
+ public int getVersion(){
+ return this.version;
+ }
+
+ @Override
+ public void setVersion(int version){
+ this.version = version;
+ }
+
}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/base/VersionedStreamPipesEntity.java b/streampipes-model/src/main/java/org/apache/streampipes/model/base/VersionedStreamPipesEntity.java
new file mode 100644
index 000000000..5194340dc
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/base/VersionedStreamPipesEntity.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.model.base;
+
+public interface VersionedStreamPipesEntity {
+ int getVersion();
+
+ void setVersion(int version);
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/connect/adapter/AdapterDescription.java b/streampipes-model/src/main/java/org/apache/streampipes/model/connect/adapter/AdapterDescription.java
index d77d8567a..f78df953a 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/connect/adapter/AdapterDescription.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/connect/adapter/AdapterDescription.java
@@ -20,6 +20,7 @@ package org.apache.streampipes.model.connect.adapter;
import org.apache.streampipes.model.SpDataStream;
import org.apache.streampipes.model.base.NamedStreamPipesEntity;
+import org.apache.streampipes.model.base.VersionedStreamPipesEntity;
import org.apache.streampipes.model.connect.rules.TransformationRuleDescription;
import org.apache.streampipes.model.connect.rules.schema.SchemaTransformationRuleDescription;
import org.apache.streampipes.model.connect.rules.stream.StreamTransformationRuleDescription;
@@ -35,11 +36,12 @@ import java.util.ArrayList;
import java.util.List;
@TsModel
-public class AdapterDescription extends NamedStreamPipesEntity {
+public class AdapterDescription extends NamedStreamPipesEntity implements VersionedStreamPipesEntity {
protected SpDataStream dataStream;
protected boolean running;
+ private int version;
private EventGrounding eventGrounding;
private String icon;
@@ -74,11 +76,12 @@ public class AdapterDescription extends NamedStreamPipesEntity {
this.dataStream = new SpDataStream();
}
- public AdapterDescription(String elementId, String name, String description) {
+ public AdapterDescription(String elementId, String name, String description, int version) {
super(elementId, name, description);
this.rules = new ArrayList<>();
this.category = new ArrayList<>();
this.dataStream = new SpDataStream();
+ this.version = version;
}
@@ -87,6 +90,7 @@ public class AdapterDescription extends NamedStreamPipesEntity {
this.config = new Cloner().staticProperties(other.getConfig());
this.rules = other.getRules();
this.icon = other.getIcon();
+ this.version = other.getVersion();
this.category = new Cloner().epaTypes(other.getCategory());
this.createdAt = other.getCreatedAt();
this.selectedEndpointUrl = other.getSelectedEndpointUrl();
@@ -250,4 +254,13 @@ public class AdapterDescription extends NamedStreamPipesEntity {
this.running = running;
}
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int newVersion) {
+ this.version = newVersion;
+ }
}
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractProcessingElementBuilder.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractProcessingElementBuilder.java
index 2a91e74ae..8db25a057 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractProcessingElementBuilder.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/AbstractProcessingElementBuilder.java
@@ -264,6 +264,10 @@ public abstract class AbstractProcessingElementBuilder<K extends
stream2 = true;
return me();
}
+ public K withVersion(int version) {
+ this.elementDescription.setVersion(version);
+ return me();
+ }
@Override
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/adapter/AdapterConfigurationBuilder.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/adapter/AdapterConfigurationBuilder.java
index 3d626e2e5..4dd39e1c8 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/adapter/AdapterConfigurationBuilder.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/builder/adapter/AdapterConfigurationBuilder.java
@@ -87,5 +87,8 @@ public class AdapterConfigurationBuilder extends
return me();
}
-
+ public AdapterConfigurationBuilder withVersion(int version) {
+ this.elementDescription.setVersion(version);
+ return this;
+ }
}