-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #2144 updated port number fields to Integer type for ui validation * #2144 added migration for Plc4xModbusAdapter * #2144 added migration for Plc4xModbusAdapter * #2144 added migration V2 for OpcUaAdapter * #2144 added migration V2 for OpcUaAdapter * #2144 added migration for RosBridgeAdapter * checkstyle changes * #2144 Added migration test for Plc4xModbusAdapter * #2144 Added migration test for RosBridgeAdapter * #2144 Added migration test for OpcUaAdapterMigrationV2 * fix(#2144): Fix label generation for migrated elements * fix(#2144): Set default static property values for adapter instance * fix(#2144): Set default static property values for adapter instance * Updated OpcUaAdapterMigrationTest (#2454) * fix(#2144): Rename test for opc migration v2 * fix(#2144): Add methods to provide default if not set by user * fix(#2144): Change logic of opc ua migration * fix(#2144): Update modbus adapater migration * fix(#2144): Update ros bridge adapter migration * fix(#2144): Change default value of replaceTitles --------- Co-authored-by: Isaak <krutisaak099@gmail.com>
- Loading branch information
Showing
26 changed files
with
969 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
.../org/apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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; | ||
import org.apache.streampipes.extensions.api.migration.IAdapterMigrator; | ||
import org.apache.streampipes.model.connect.adapter.AdapterDescription; | ||
import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTagPrefix; | ||
import org.apache.streampipes.model.migration.MigrationResult; | ||
import org.apache.streampipes.model.migration.ModelMigratorConfig; | ||
import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty; | ||
import org.apache.streampipes.model.staticproperty.StaticProperty; | ||
import org.apache.streampipes.vocabulary.XSD; | ||
|
||
import static org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter.ROS_PORT_KEY; | ||
|
||
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<AdapterDescription> migrate(AdapterDescription element, | ||
IStaticPropertyExtractor extractor) throws RuntimeException { | ||
|
||
var portProperty = extractPortProperty(element); | ||
portProperty.setRequiredDatatype(XSD.INTEGER); | ||
|
||
return MigrationResult.success(element); | ||
} | ||
|
||
protected FreeTextStaticProperty extractPortProperty(AdapterDescription adapterDescription) { | ||
return (FreeTextStaticProperty) adapterDescription.getConfig().stream() | ||
.filter(this::isPortConfig) | ||
.findFirst() | ||
.orElseThrow(); | ||
} | ||
|
||
private boolean isPortConfig(StaticProperty config) { | ||
return config.getInternalName().equals(ROS_PORT_KEY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../apache/streampipes/connect/iiot/adapters/migrations/RosBridgeAdapterMigrationV1Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.connect.iiot.adapters.migrations.config.RosBridgeAdapterVersionedConfig; | ||
import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor; | ||
import org.apache.streampipes.model.connect.adapter.AdapterDescription; | ||
import org.apache.streampipes.vocabulary.XSD; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.net.URI; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
|
||
|
||
public class RosBridgeAdapterMigrationV1Test { | ||
|
||
private RosBridgeAdapterMigrationV1 migrationV1; | ||
|
||
@Before | ||
public void setUp() { | ||
migrationV1 = new RosBridgeAdapterMigrationV1(); | ||
} | ||
|
||
@Test | ||
public void testMigrationV1(){ | ||
var rosBridgeAdapterDescriptionV0 = RosBridgeAdapterVersionedConfig.getRosBridgeAdapterDescriptionV0(); | ||
var extractorMock = mock(IStaticPropertyExtractor.class); | ||
|
||
var rosBridgeAdapterDescriptionV1 = migrationV1.migrate(rosBridgeAdapterDescriptionV0 , extractorMock); | ||
|
||
var typeOfPortProperty = getTypeOfPortProperty(rosBridgeAdapterDescriptionV1.element()); | ||
assertEquals(XSD.INTEGER, typeOfPortProperty); | ||
} | ||
|
||
private URI getTypeOfPortProperty(AdapterDescription adapterDescription) { | ||
return migrationV1 | ||
.extractPortProperty(adapterDescription) | ||
.getRequiredDatatype(); | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
.../streampipes/connect/iiot/adapters/migrations/config/RosBridgeAdapterVersionedConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.config; | ||
|
||
import org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter; | ||
import org.apache.streampipes.model.AdapterType; | ||
import org.apache.streampipes.model.connect.adapter.AdapterDescription; | ||
import org.apache.streampipes.sdk.builder.adapter.AdapterConfigurationBuilder; | ||
import org.apache.streampipes.sdk.helpers.Labels; | ||
import org.apache.streampipes.sdk.helpers.Locales; | ||
import org.apache.streampipes.sdk.utils.Assets; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter.ID; | ||
import static org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter.ROS_HOST_KEY; | ||
import static org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter.ROS_PORT_KEY; | ||
import static org.apache.streampipes.connect.iiot.adapters.ros.RosBridgeAdapter.TOPIC_KEY; | ||
|
||
public class RosBridgeAdapterVersionedConfig { | ||
|
||
public static AdapterDescription getRosBridgeAdapterDescriptionV0(){ | ||
return AdapterConfigurationBuilder.create(ID, 0, RosBridgeAdapter::new) | ||
.withLocales(Locales.EN) | ||
.withAssets(Assets.DOCUMENTATION, Assets.ICON) | ||
.withCategory(AdapterType.Manufacturing) | ||
.requiredTextParameter(Labels.withId(ROS_HOST_KEY)) | ||
.requiredTextParameter(Labels.withId(ROS_PORT_KEY)) | ||
.requiredSingleValueSelectionFromContainer( | ||
Labels.withId(TOPIC_KEY), Arrays.asList(ROS_HOST_KEY, ROS_PORT_KEY)) | ||
.buildConfiguration().getAdapterDescription(); | ||
} | ||
|
||
public static AdapterDescription getRosBridgeAdapterDescriptionV1(){ | ||
return AdapterConfigurationBuilder.create(ID, 1, RosBridgeAdapter::new) | ||
.withLocales(Locales.EN) | ||
.withAssets(Assets.DOCUMENTATION, Assets.ICON) | ||
.withCategory(AdapterType.Manufacturing) | ||
.requiredTextParameter(Labels.withId(ROS_HOST_KEY)) | ||
.requiredIntegerParameter(Labels.withId(ROS_PORT_KEY)) | ||
.requiredSingleValueSelectionFromContainer( | ||
Labels.withId(TOPIC_KEY), Arrays.asList(ROS_HOST_KEY, ROS_PORT_KEY)) | ||
.buildConfiguration().getAdapterDescription(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.