Repository: apache/streampipes (java)

Issue:
Unify the labels for OPC UA adapter & sink 
### Body

Currently the adapter and the sink use different labels for the same configuration.
This should be harmonized and both components should use the ENUM configuration as discussed in #1663.


### StreamPipes Committer

I acknowledge that I am a maintainer/committer of the Apache StreamPipes project.

Pull request description:
[#1664] Extract all opc labels into an enum class
<!--
  ~ 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.
  ~
  -->
  
  <!--
Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
1. If this is your first time, please read our contributor guidelines:
    - https://streampipes.apache.org/getinvolved.html
    - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
4. Please write your PR title to summarize what this PR proposes/fixes.
5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar. 
6. Be sure to keep the PR description updated to reflect all changes.
7. If possible, provide a concise example to reproduce the issue for a faster review.
8. Make sure tests pass via `mvn clean install`.
9. (Optional) If the contribution is large, please file an Apache ICLA
    - http://apache.org/licenses/icla.pdf
-->

### Purpose
<!--
Please clarify what changes you are proposing and describe how those changes will address the issue.
Furthermore, describe potential consequences the changes might have.
-->
Fixes #1664 by  unifiing the labels for OPC UA adapter & sink.

### Remarks
<!--
Is there anything left we need to pay attention on?
Are there some references that might be important? E.g. links to Confluence, or discussions
on the mailing list or GitHub.
-->
PR introduces (a) breaking change(s): no

PR introduces (a) deprecation(s): yes

Patch:
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/OpcUaAdapter.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/OpcUaAdapter.java
index f642a3d91a..60fd1b3337 100644
--- a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/OpcUaAdapter.java
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/OpcUaAdapter.java
@@ -62,17 +62,26 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.AVAILABLE_NODES;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.NAMESPACE_INDEX;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.NODE_ID;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_HOST;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_HOST_OR_URL;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_SERVER_HOST;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_SERVER_PORT;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_SERVER_URL;
-import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.OpcUaLabels.OPC_URL;
 import static org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUtil.getSchema;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.ACCESS_MODE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.ADAPTER_TYPE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.AVAILABLE_NODES;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.HOST_PORT;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NAMESPACE_INDEX;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NODE_ID;
+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;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.PASSWORD;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.PULLING_INTERVAL;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.PULL_MODE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.SUBSCRIPTION_MODE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.UNAUTHENTICATED;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.USERNAME;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.USERNAME_GROUP;
 
 public class OpcUaAdapter implements StreamPipesAdapter, IPullAdapter, SupportsRuntimeConfig {
 
@@ -236,40 +245,40 @@ public class OpcUaAdapter implements StreamPipesAdapter, IPullAdapter, SupportsR
         .withAssets(Assets.DOCUMENTATION, Assets.ICON)
         .withLocales(Locales.EN)
         .withCategory(AdapterType.Generic, AdapterType.Manufacturing)
-        .requiredAlternatives(Labels.withId(OpcUaLabels.ADAPTER_TYPE.name()),
-            Alternatives.from(Labels.withId(OpcUaLabels.PULL_MODE.name()),
+        .requiredAlternatives(Labels.withId(ADAPTER_TYPE),
+            Alternatives.from(Labels.withId(PULL_MODE),
                 StaticProperties.integerFreeTextProperty(
-                    Labels.withId(OpcUaLabels.PULLING_INTERVAL.name()))),
-            Alternatives.from(Labels.withId(OpcUaLabels.SUBSCRIPTION_MODE.name())))
-        .requiredAlternatives(Labels.withId(OpcUaLabels.ACCESS_MODE.name()),
-            Alternatives.from(Labels.withId(OpcUaLabels.UNAUTHENTICATED.name())),
-            Alternatives.from(Labels.withId(OpcUaLabels.USERNAME_GROUP.name()),
+                    Labels.withId(PULLING_INTERVAL))),
+            Alternatives.from(Labels.withId(SUBSCRIPTION_MODE)))
+        .requiredAlternatives(Labels.withId(ACCESS_MODE),
+            Alternatives.from(Labels.withId(UNAUTHENTICATED)),
+            Alternatives.from(Labels.withId(USERNAME_GROUP),
                 StaticProperties.group(
-                    Labels.withId(OpcUaLabels.USERNAME_GROUP.name()),
+                    Labels.withId(USERNAME_GROUP),
                     StaticProperties.stringFreeTextProperty(
-                        Labels.withId(OpcUaLabels.USERNAME.name())),
-                    StaticProperties.secretValue(Labels.withId(OpcUaLabels.PASSWORD.name()))
+                        Labels.withId(USERNAME)),
+                    StaticProperties.secretValue(Labels.withId(PASSWORD))
                 ))
         )
-        .requiredAlternatives(Labels.withId(OPC_HOST_OR_URL.name()),
+        .requiredAlternatives(Labels.withId(OPC_HOST_OR_URL),
             Alternatives.from(
-                Labels.withId(OPC_URL.name()),
+                Labels.withId(OPC_URL),
                 StaticProperties.stringFreeTextProperty(
-                    Labels.withId(OPC_SERVER_URL.name()), "opc.tcp://localhost:4840"))
+                    Labels.withId(OPC_SERVER_URL), "opc.tcp://localhost:4840"))
             ,
-            Alternatives.from(Labels.withId(OPC_HOST.name()),
+            Alternatives.from(Labels.withId(OPC_HOST),
                 StaticProperties.group(
-                    Labels.withId("host-port"),
+                    Labels.withId(HOST_PORT),
                     StaticProperties.stringFreeTextProperty(
-                        Labels.withId(OPC_SERVER_HOST.name())),
+                        Labels.withId(OPC_SERVER_HOST)),
                     StaticProperties.stringFreeTextProperty(
-                        Labels.withId(OPC_SERVER_PORT.name()))
+                        Labels.withId(OPC_SERVER_PORT))
                 ))
         )
-        .requiredTextParameter(Labels.withId(NAMESPACE_INDEX.name()))
-        .requiredTextParameter(Labels.withId(NODE_ID.name()))
+        .requiredTextParameter(Labels.withId(NAMESPACE_INDEX))
+        .requiredTextParameter(Labels.withId(NODE_ID))
         .requiredRuntimeResolvableTreeInput(
-            Labels.withId(AVAILABLE_NODES.name()),
+            Labels.withId(AVAILABLE_NODES),
             Arrays.asList(NAMESPACE_INDEX.name(), NODE_ID.name())
         )
         .buildConfiguration();
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/configuration/SpOpcUaConfigBuilder.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/configuration/SpOpcUaConfigBuilder.java
index 66d7633e9b..c467afae9c 100644
--- a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/configuration/SpOpcUaConfigBuilder.java
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/configuration/SpOpcUaConfigBuilder.java
@@ -23,6 +23,22 @@ import org.apache.streampipes.extensions.connectors.opcua.adapter.utils.OpcUaUti
 
 import java.util.List;
 
+import static org.apache.kafka.common.config.ConfigDef.Type.PASSWORD;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.ACCESS_MODE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.ADAPTER_TYPE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.AVAILABLE_NODES;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NAMESPACE_INDEX;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NODE_ID;
+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;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.PULLING_INTERVAL;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.PULL_MODE;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.UNAUTHENTICATED;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.USERNAME;
+
 public class SpOpcUaConfigBuilder {
 
   /**
@@ -35,61 +51,77 @@ public class SpOpcUaConfigBuilder {
   public static SpOpcUaConfig from(IStaticPropertyExtractor extractor) {
 
     String selectedAlternativeConnection =
-        extractor.selectedAlternativeInternalId(OpcUaUtil.OpcUaLabels.OPC_HOST_OR_URL.name());
+        extractor.selectedAlternativeInternalId(OPC_HOST_OR_URL.name());
     String selectedAlternativeAuthentication =
-        extractor.selectedAlternativeInternalId(OpcUaUtil.OpcUaLabels.ACCESS_MODE.name());
+        extractor.selectedAlternativeInternalId(ACCESS_MODE.name());
 
-    int namespaceIndex = extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.NAMESPACE_INDEX.name(), int.class);
-    String nodeId = extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.NODE_ID.name(), String.class);
+    int namespaceIndex = extractor.singleValueParameter(NAMESPACE_INDEX.name(), int.class);
+    String nodeId = extractor.singleValueParameter(NODE_ID.name(), String.class);
 
-    boolean usePullMode = extractor.selectedAlternativeInternalId(OpcUaUtil.OpcUaLabels.ADAPTER_TYPE.name())
-        .equals(OpcUaUtil.OpcUaLabels.PULL_MODE.name());
-    boolean useURL = selectedAlternativeConnection.equals(OpcUaUtil.OpcUaLabels.OPC_URL.name());
-    boolean unauthenticated = selectedAlternativeAuthentication.equals(OpcUaUtil.OpcUaLabels.UNAUTHENTICATED.name());
+    boolean usePullMode = extractor.selectedAlternativeInternalId(ADAPTER_TYPE.name())
+        .equals(PULL_MODE.name());
+    boolean useURL = selectedAlternativeConnection.equals(OPC_URL.name());
+    boolean unauthenticated = selectedAlternativeAuthentication.equals(UNAUTHENTICATED.name());
 
     Integer pullIntervalSeconds = null;
     if (usePullMode) {
       pullIntervalSeconds =
-          extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.PULLING_INTERVAL.name(), Integer.class);
+          extractor.singleValueParameter(PULLING_INTERVAL.name(), Integer.class);
     }
 
     List<String> selectedNodeNames =
-        extractor.selectedTreeNodesInternalNames(OpcUaUtil.OpcUaLabels.AVAILABLE_NODES.name(), String.class, true);
+        extractor.selectedTreeNodesInternalNames(AVAILABLE_NODES.name(), String.class, true);
 
     if (useURL && unauthenticated) {
 
       String serverAddress =
-          extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_URL.name(), String.class);
+          extractor.singleValueParameter(OPC_SERVER_URL.name(), String.class);
       serverAddress = OpcUaUtil.formatServerAddress(serverAddress);
 
       return new SpOpcUaConfig(serverAddress, namespaceIndex, nodeId, pullIntervalSeconds, selectedNodeNames);
 
     } else if (!useURL && unauthenticated) {
       String serverAddress =
-          extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_HOST.name(), String.class);
+          extractor.singleValueParameter(OPC_SERVER_HOST.name(), String.class);
       serverAddress = OpcUaUtil.formatServerAddress(serverAddress);
-      int port = extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_PORT.name(), int.class);
-
-      return new SpOpcUaConfig(serverAddress, port, namespaceIndex, nodeId, pullIntervalSeconds, selectedNodeNames);
+      int port = extractor.singleValueParameter(OPC_SERVER_PORT.name(), int.class);
+
+      return new SpOpcUaConfig(serverAddress,
+          port,
+          namespaceIndex,
+          nodeId,
+          pullIntervalSeconds,
+          selectedNodeNames);
     } else {
 
-      String username = extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.USERNAME.name(), String.class);
-      String password = extractor.secretValue(OpcUaUtil.OpcUaLabels.PASSWORD.name());
+      String username = extractor.singleValueParameter(USERNAME.name(), String.class);
+      String password = extractor.secretValue(PASSWORD.name());
 
       if (useURL) {
         String serverAddress =
-            extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_URL.name(), String.class);
+            extractor.singleValueParameter(OPC_SERVER_URL.name(), String.class);
         serverAddress = OpcUaUtil.formatServerAddress(serverAddress);
 
-        return new SpOpcUaConfig(serverAddress, namespaceIndex, nodeId, username, password, pullIntervalSeconds,
+        return new SpOpcUaConfig(serverAddress,
+            namespaceIndex,
+            nodeId,
+            username,
+            password,
+            pullIntervalSeconds,
             selectedNodeNames);
       } else {
         String serverAddress =
-            extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_HOST.name(), String.class);
+            extractor.singleValueParameter(OPC_SERVER_HOST.name(), String.class);
         serverAddress = OpcUaUtil.formatServerAddress(serverAddress);
-        int port = extractor.singleValueParameter(OpcUaUtil.OpcUaLabels.OPC_SERVER_PORT.name(), int.class);
-
-        return new SpOpcUaConfig(serverAddress, port, namespaceIndex, nodeId, username, password, pullIntervalSeconds,
+        int port = extractor.singleValueParameter(OPC_SERVER_PORT.name(), int.class);
+
+        return new SpOpcUaConfig(serverAddress,
+            port,
+            namespaceIndex,
+            nodeId,
+            username,
+            password,
+            pullIntervalSeconds,
             selectedNodeNames);
       }
     }
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/utils/OpcUaUtil.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/utils/OpcUaUtil.java
index 6acb0a70b0..e7a250f85c 100644
--- a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/utils/OpcUaUtil.java
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/utils/OpcUaUtil.java
@@ -23,10 +23,12 @@ import org.apache.streampipes.commons.exceptions.connect.AdapterException;
 import org.apache.streampipes.commons.exceptions.connect.ParseException;
 import org.apache.streampipes.extensions.api.extractor.IAdapterParameterExtractor;
 import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor;
+import org.apache.streampipes.extensions.api.runtime.ResolvesContainerProvidedOptions;
 import org.apache.streampipes.extensions.connectors.opcua.adapter.OpcNode;
 import org.apache.streampipes.extensions.connectors.opcua.adapter.OpcUaNodeBrowser;
 import org.apache.streampipes.extensions.connectors.opcua.adapter.SpOpcUaClient;
 import org.apache.streampipes.extensions.connectors.opcua.adapter.configuration.SpOpcUaConfigBuilder;
+import org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels;
 import org.apache.streampipes.model.connect.guess.FieldStatusInfo;
 import org.apache.streampipes.model.connect.guess.GuessSchema;
 import org.apache.streampipes.model.connect.guess.GuessTypeInfo;
@@ -72,8 +74,8 @@ public class OpcUaUtil {
   }
 
   /***
-   * OPC UA specific implementation of {@link Adapter}
-   * @param adapterStreamDescription
+   * OPC UA specific implementation of
+   * @param extractor
    * @return guess schema
    * @throws AdapterException
    * @throws ParseException
@@ -157,9 +159,8 @@ public class OpcUaUtil {
 
 
   /***
-   * OPC UA specific implementation of {@link
-   * ResolvesContainerProvidedOptions
-   * resolveOptions(String, StaticPropertyExtractor)}.
+   * OPC UA specific implementation of
+   * {@link ResolvesContainerProvidedOptions resolveOptions(String, StaticPropertyExtractor)}.
    * @param internalName The internal name of the Static Property
    * @param parameterExtractor to extract parameters from the OPC UA config
    * @return {@code List<Option>} with available node names for the given OPC UA configuration
@@ -232,27 +233,5 @@ public class OpcUaUtil {
     }
   }
 
-  /***
-   * Enum for all possible labels in the context of OPC UA adapters
-   */
-  public enum OpcUaLabels {
-    OPC_HOST_OR_URL,
-    OPC_URL,
-    OPC_HOST,
-    OPC_SERVER_URL,
-    OPC_SERVER_HOST,
-    OPC_SERVER_PORT,
-    NAMESPACE_INDEX,
-    NODE_ID,
-    ACCESS_MODE,
-    USERNAME_GROUP,
-    USERNAME,
-    PASSWORD,
-    UNAUTHENTICATED,
-    AVAILABLE_NODES,
-    PULLING_INTERVAL,
-    ADAPTER_TYPE,
-    PULL_MODE,
-    SUBSCRIPTION_MODE;
-  }
+
 }
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/sink/OpcUaSink.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/sink/OpcUaSink.java
index 43e34491a6..8532172b9f 100644
--- a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/sink/OpcUaSink.java
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/sink/OpcUaSink.java
@@ -34,13 +34,13 @@ import org.apache.streampipes.sdk.helpers.Labels;
 import org.apache.streampipes.sdk.helpers.Locales;
 import org.apache.streampipes.sdk.utils.Assets;
 
-public class OpcUaSink implements IStreamPipesDataSink {
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.MAPPING_PROPERY;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NAMESPACE_INDEX;
+import static org.apache.streampipes.extensions.connectors.opcua.utils.OpcUaLabels.NODE_ID;
+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;
 
-  private static final String OPC_SERVER_KEY = "opc_host";
-  private static final String OPC_PORT_KEY = "opc_port";
-  private static final String OPC_NAMESPACE_INDEX_KEY = "opc_namespace_index";
-  private static final String OPC_NODE_ID_KEY = "opc_node_id_index";
-  private static final String MAPPING_PROPERTY_KEY = "mapping_property_key";
+public class OpcUaSink implements IStreamPipesDataSink {
 
   private OpcUa opcUa;
 
@@ -55,12 +55,12 @@ public class OpcUaSink implements IStreamPipesDataSink {
             .requiredStream(StreamRequirementsBuilder
                 .create()
                 .requiredPropertyWithUnaryMapping(EpRequirements.anyProperty(),
-                    Labels.withId(MAPPING_PROPERTY_KEY),
+                    Labels.withId(MAPPING_PROPERY),
                     PropertyScope.NONE).build())
-            .requiredTextParameter(Labels.withId(OPC_SERVER_KEY))
-            .requiredIntegerParameter(Labels.withId(OPC_PORT_KEY))
-            .requiredIntegerParameter(Labels.withId(OPC_NAMESPACE_INDEX_KEY))
-            .requiredTextParameter(Labels.withId(OPC_NODE_ID_KEY))
+            .requiredTextParameter(Labels.withId(OPC_SERVER_HOST))
+            .requiredIntegerParameter(Labels.withId(OPC_SERVER_PORT))
+            .requiredIntegerParameter(Labels.withId(NAMESPACE_INDEX))
+            .requiredTextParameter(Labels.withId(NODE_ID))
             .build()
     );
   }
@@ -69,13 +69,13 @@ public class OpcUaSink implements IStreamPipesDataSink {
   public void onPipelineStarted(IDataSinkParameters parameters,
                                 EventSinkRuntimeContext runtimeContext) {
     var extractor = parameters.extractor();
-    String hostname = extractor.singleValueParameter(OPC_SERVER_KEY, String.class);
-    Integer port = extractor.singleValueParameter(OPC_PORT_KEY, Integer.class);
+    String hostname = extractor.singleValueParameter(OPC_SERVER_HOST.name(), String.class);
+    Integer port = extractor.singleValueParameter(OPC_SERVER_PORT.name(), Integer.class);
 
-    String nodeId = extractor.singleValueParameter(OPC_NODE_ID_KEY, String.class);
-    Integer nameSpaceIndex = extractor.singleValueParameter(OPC_NAMESPACE_INDEX_KEY, Integer.class);
+    String nodeId = extractor.singleValueParameter(NODE_ID.name(), String.class);
+    Integer nameSpaceIndex = extractor.singleValueParameter(NAMESPACE_INDEX.name(), Integer.class);
 
-    String mappingPropertySelector = extractor.mappingPropertyValue(MAPPING_PROPERTY_KEY);
+    String mappingPropertySelector = extractor.mappingPropertyValue(NODE_ID.name());
 
     String mappingPropertyType = "";
     try {
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/utils/OpcUaLabels.java b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/utils/OpcUaLabels.java
new file mode 100644
index 0000000000..69815516b8
--- /dev/null
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/utils/OpcUaLabels.java
@@ -0,0 +1,45 @@
+/*
+ * 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.utils;
+
+/***
+ * Enum for all possible labels in the context of OPC UA adapters
+ */
+public enum OpcUaLabels {
+  OPC_HOST_OR_URL,
+  OPC_URL,
+  OPC_HOST,
+  OPC_SERVER_URL,
+  OPC_SERVER_HOST,
+  OPC_SERVER_PORT,
+  HOST_PORT,
+  NAMESPACE_INDEX,
+  NODE_ID,
+  ACCESS_MODE,
+  USERNAME_GROUP,
+  USERNAME,
+  PASSWORD,
+  UNAUTHENTICATED,
+  AVAILABLE_NODES,
+  PULLING_INTERVAL,
+  ADAPTER_TYPE,
+  PULL_MODE,
+  SUBSCRIPTION_MODE,
+  MAPPING_PROPERY;
+}
diff --git a/streampipes-extensions/streampipes-connectors-opcua/src/main/resources/org.apache.streampipes.sinks.databases.jvm.opcua/strings.en b/streampipes-extensions/streampipes-connectors-opcua/src/main/resources/org.apache.streampipes.sinks.databases.jvm.opcua/strings.en
index 26b0561ef7..4df4e75981 100644
--- a/streampipes-extensions/streampipes-connectors-opcua/src/main/resources/org.apache.streampipes.sinks.databases.jvm.opcua/strings.en
+++ b/streampipes-extensions/streampipes-connectors-opcua/src/main/resources/org.apache.streampipes.sinks.databases.jvm.opcua/strings.en
@@ -18,17 +18,17 @@
 org.apache.streampipes.sinks.databases.jvm.opcua.title=OPC-UA
 org.apache.streampipes.sinks.databases.jvm.opcua.description=Writes values in an OPC-UA server
 
-opc_host.title=Host Address
-opc_host.description=The host address of the OPC-UA server (Example: opc-ua-server.com, opc.tcp://opc-ua-server.com)
+OPC_SERVER_HOST.title=Host Address
+OPC_SERVER_HOST.description=The host address of the OPC-UA server (Example: opc-ua-server.com, opc.tcp://opc-ua-server.com)
 
-opc_port.title=Port
-opc_port.description=The port of the OPC-UA server (Example: 4840)
+OPC_SERVER_PORT.title=Port
+OPC_SERVER_PORT.description=The port of the OPC-UA server (Example: 4840)
 
-opc_namespace_index.title=Namespace Index
-opc_namespace_index.description=The number of the namespace
+NAMESPACE_INDEX.title=Namespace Index
+NAMESPACE_INDEX.description=The number of the namespace
 
-opc_node_id_index.title=Node Id
-opc_node_id_index.description=Id of the node the result should be written to
+NODE_ID.title=Node Id
+NODE_ID.description=Id of the node the result should be written to
 
-mapping_property_key.title=Event Property
-mapping_property_key.description=The event property that should be written to the OPC-UA server
+MAPPING_PROPERY.title=Event Property
+MAPPING_PROPERY.description=The event property that should be written to the OPC-UA server
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/Labels.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/Labels.java
index fb8524eff3..1a29aa0e48 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/Labels.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/Labels.java
@@ -49,6 +49,7 @@ public class Labels {
   public static Label from(String internalId, String label, String description) {
     return new Label(internalId, label, description);
   }
+
   /**
    * @deprecated Externalize labels by using
    * {@link org.apache.streampipes.sdk.builder.AbstractProcessingElementBuilder#withLocales(Locales...)}
@@ -69,13 +70,26 @@ public class Labels {
    * Creates a new label only with an internal id.
    * Static properties require a fully-specified label, see {@link #from(String, String, String)}
    *
+   * @deprecated Use {@link #withId(Enum)} instead
+   *
    * @param internalId The internal identifier of the element, e.g., "latitude-field-mapping"
    * @return
    */
+  @Deprecated(since = "0.93.0")
   public static Label withId(String internalId) {
     return new Label(internalId, "", "");
   }
 
+  /**
+   * Creates a label with the string value of an enum.
+   * Static properties require a fully-specified label, see {@link #from(String, String, String)}
+   * @param internalId The internal identifier of the element, e.g., "LATITUDE-FIELD-MAPPING"
+   * @return
+   */
+  public static Label withId(Enum<?> internalId) {
+    return new Label(internalId.name(), "", "");
+  }
+
   @Deprecated
   /**
    *  @deprecated Externalize labels by using


Test patch:
diff --git a/streampipes-sdk/src/test/java/org/apache/streampipes/sdk/helpers/LabelsTest.java b/streampipes-sdk/src/test/java/org/apache/streampipes/sdk/helpers/LabelsTest.java
new file mode 100644
index 0000000000..4717412677
--- /dev/null
+++ b/streampipes-sdk/src/test/java/org/apache/streampipes/sdk/helpers/LabelsTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.sdk.helpers;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LabelsTest {
+  private enum TestEnum {
+    TEST;
+  }
+
+  @Test
+  public void withEnumId() {
+    var result = Labels.withId(TestEnum.TEST);
+    assertEquals(TestEnum.TEST.name(), result.getInternalId());
+  }
+
+  @Test
+  public void withStringId() {
+    var result = Labels.withId("test");
+    assertEquals("test", result.getInternalId());
+  }
+}
\ No newline at end of file