diff --git a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1.java b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1.java index b8ffe0a6d7..9d1cdb2674 100644 --- a/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1.java +++ b/streampipes-extensions/streampipes-connect-adapters-iiot/src/main/java/org/apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1.java @@ -1,3 +1,21 @@ +/* + * 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.connect.iiot.adapters.migrations; import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor; @@ -16,34 +34,35 @@ public class RosBridgeAdapterMigrationV1 implements IAdapterMigrator { - @Override - public ModelMigratorConfig config() { - return new ModelMigratorConfig( - "org.apache.streampipes.connect.iiot.adapters.ros", - SpServiceTagPrefix.ADAPTER, - 0, - 1); - } - - @Override - public MigrationResult migrate(AdapterDescription element, IStaticPropertyExtractor extractor) throws RuntimeException { - var newConfigs = element.getConfig().stream().map(config->{ - if (isPortConfig(config)){ - Label label = Labels.withId(ROS_PORT_KEY); - return new FreeTextStaticProperty(label.getInternalId(), - label.getLabel(), - label.getDescription(), - XSD.INTEGER); - } else { - return config; - } - }).toList(); - element.setConfig(newConfigs); - - return MigrationResult.success(element); - } - - private boolean isPortConfig(StaticProperty config) { - return config.getInternalName().equals(ROS_PORT_KEY); - } + @Override + public ModelMigratorConfig config() { + return new ModelMigratorConfig( + "org.apache.streampipes.connect.iiot.adapters.ros", + SpServiceTagPrefix.ADAPTER, + 0, + 1); + } + + @Override + public MigrationResult migrate(AdapterDescription element, + IStaticPropertyExtractor extractor) throws RuntimeException { + var newConfigs = element.getConfig().stream().map(config->{ + if (isPortConfig(config)){ + Label label = Labels.withId(ROS_PORT_KEY); + return new FreeTextStaticProperty(label.getInternalId(), + label.getLabel(), + label.getDescription(), + XSD.INTEGER); + } else { + return config; + } + }).toList(); + element.setConfig(newConfigs); + + return MigrationResult.success(element); + } + + private boolean isPortConfig(StaticProperty config) { + return config.getInternalName().equals(ROS_PORT_KEY); + } } \ No newline at end of file diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/migration/OpcUaAdapterMigrationV2.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/migration/OpcUaAdapterMigrationV2.java index 8e0ae9067c..1571353ab4 100644 --- a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/migration/OpcUaAdapterMigrationV2.java +++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/migration/OpcUaAdapterMigrationV2.java @@ -1,3 +1,21 @@ +/* + * 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.extensions.connectors.opcua.migration; import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor; @@ -11,50 +29,60 @@ import org.apache.streampipes.sdk.helpers.Alternatives; import org.apache.streampipes.sdk.helpers.Labels; -import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.*; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.HOST_PORT; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_HOST; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_HOST_OR_URL; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_SERVER_HOST; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_SERVER_PORT; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_SERVER_URL; +import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.OPC_URL; + + + public class OpcUaAdapterMigrationV2 implements IAdapterMigrator { - @Override - public ModelMigratorConfig config() { - return new ModelMigratorConfig( - "org.apache.streampipes.connect.iiot.adapters.opcua", - SpServiceTagPrefix.ADAPTER, - 1, - 2); - } - - @Override - public MigrationResult migrate(AdapterDescription element, IStaticPropertyExtractor extractor) throws RuntimeException { - var newConfigs = element.getConfig().stream().map(config->{ - if (isHostOrUrlConfig(config)){ - return modifiedAlternatives(); - } else { - return config; - } - }).toList(); - - element.setConfig(newConfigs); - return MigrationResult.success(element); - } - - private StaticProperty modifiedAlternatives() { - return StaticProperties.alternatives(Labels.withId(OPC_HOST_OR_URL), - Alternatives.from( - Labels.withId(OPC_URL), - StaticProperties.stringFreeTextProperty( - Labels.withId(OPC_SERVER_URL), "opc.tcp://localhost:4840")) - , - Alternatives.from(Labels.withId(OPC_HOST), - StaticProperties.group( - Labels.withId(HOST_PORT), - StaticProperties.stringFreeTextProperty( - Labels.withId(OPC_SERVER_HOST)), - StaticProperties.integerFreeTextProperty( - Labels.withId(OPC_SERVER_PORT)) - ))); - } - - private boolean isHostOrUrlConfig(StaticProperty config){ - return config.getInternalName().equals(OPC_HOST_OR_URL.name()); - } + @Override + public ModelMigratorConfig config() { + return new ModelMigratorConfig( + "org.apache.streampipes.connect.iiot.adapters.opcua", + SpServiceTagPrefix.ADAPTER, + 1, + 2); + } + + @Override + public MigrationResult migrate(AdapterDescription element, + IStaticPropertyExtractor extractor) throws RuntimeException { + var newConfigs = element.getConfig().stream().map(config->{ + if (isHostOrUrlConfig(config)){ + return modifiedAlternatives(); + } else { + return config; + } + }).toList(); + + element.setConfig(newConfigs); + return MigrationResult.success(element); + } + + private StaticProperty modifiedAlternatives() { + return StaticProperties.alternatives(Labels.withId(OPC_HOST_OR_URL), + Alternatives.from( + Labels.withId(OPC_URL), + StaticProperties.stringFreeTextProperty( + Labels.withId(OPC_SERVER_URL), "opc.tcp://localhost:4840")) + , + Alternatives.from(Labels.withId(OPC_HOST), + StaticProperties.group( + Labels.withId(HOST_PORT), + StaticProperties.stringFreeTextProperty( + Labels.withId(OPC_SERVER_HOST)), + StaticProperties.integerFreeTextProperty( + Labels.withId(OPC_SERVER_PORT)) + ))); + } + + private boolean isHostOrUrlConfig(StaticProperty config){ + return config.getInternalName().equals(OPC_HOST_OR_URL.name()); + } } diff --git a/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/migration/Plc4xModbusAdapterMigrationV1.java b/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/migration/Plc4xModbusAdapterMigrationV1.java index e79242a329..a6f9495b56 100644 --- a/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/migration/Plc4xModbusAdapterMigrationV1.java +++ b/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/migration/Plc4xModbusAdapterMigrationV1.java @@ -1,3 +1,21 @@ +/* + * 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.extensions.connectors.plc.adapter.migration; import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor; @@ -14,35 +32,36 @@ import static org.apache.streampipes.extensions.connectors.plc.adapter.modbus.Plc4xModbusAdapter.PLC_PORT; public class Plc4xModbusAdapterMigrationV1 implements IAdapterMigrator { - @Override - public ModelMigratorConfig config() { - return new ModelMigratorConfig( - "org.apache.streampipes.connect.iiot.adapters.plc4x.modbus", - SpServiceTagPrefix.ADAPTER, - 0, - 1 - ); - } + @Override + public ModelMigratorConfig config() { + return new ModelMigratorConfig( + "org.apache.streampipes.connect.iiot.adapters.plc4x.modbus", + SpServiceTagPrefix.ADAPTER, + 0, + 1 + ); + } - @Override - public MigrationResult migrate(AdapterDescription element, IStaticPropertyExtractor extractor) throws RuntimeException { - var newConfigs = element.getConfig().stream().map(config->{ - if (isPortConfig(config)){ - var label = Labels.withId(PLC_PORT); - return new FreeTextStaticProperty(label.getInternalId(), - label.getLabel(), - label.getDescription(), - XSD.INTEGER); - } else { - return config; - } - }).toList(); - element.setConfig(newConfigs); + @Override + public MigrationResult migrate(AdapterDescription element, + IStaticPropertyExtractor extractor) throws RuntimeException { + var newConfigs = element.getConfig().stream().map(config->{ + if (isPortConfig(config)){ + var label = Labels.withId(PLC_PORT); + return new FreeTextStaticProperty(label.getInternalId(), + label.getLabel(), + label.getDescription(), + XSD.INTEGER); + } else { + return config; + } + }).toList(); + element.setConfig(newConfigs); - return MigrationResult.success(element); - } + return MigrationResult.success(element); + } - private boolean isPortConfig(StaticProperty config) { - return config.getInternalName().equals(PLC_PORT); - } + private boolean isPortConfig(StaticProperty config) { + return config.getInternalName().equals(PLC_PORT); + } }