khandelwal-prateek commented on code in PR #4052:
URL: https://github.com/apache/gobblin/pull/4052#discussion_r1755153831


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/ddm/util/TemporalWorkFlowUtils.java:
##########
@@ -0,0 +1,52 @@
+package org.apache.gobblin.temporal.ddm.util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import lombok.NonNull;
+import lombok.experimental.UtilityClass;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.temporal.ddm.work.assistance.Help;
+
+
+/**
+ * Utility class for handling Temporal workflow-related operations.
+ */
+@UtilityClass
+public class TemporalWorkFlowUtils {
+
+  /**
+   * Generates search attributes for a WorkFlow  based on the provided GAAS 
job properties.
+   *
+   * @param jobProps the properties of the job, must not be null.
+   * @return a map containing the generated search attributes.
+   */
+  public static Map<String, Object> generateGaasSearchAttributes(@NonNull 
Properties jobProps) {
+    Map<String, Object> attributes = new HashMap<>();
+    attributes.put(Help.GAAS_FLOW_KEY, String.format("%s.%s", 
jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY),
+        jobProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY)));
+    attributes.put(Help.USER_TO_PROXY_SEARCH_KEY, 
jobProps.getProperty(Help.USER_TO_PROXY_KEY));
+    return attributes;
+  }
+
+  /**
+   * Converts search attribute values from a map of lists to a map of objects.
+   *
+   * @param searchAttributes a map where the keys are attribute names and the 
values are lists of attribute values.
+   *                         Can be null.
+   * @return a map where the keys are attribute names and the values are the 
corresponding attribute values.
+   *         If the input map is null, an empty map is returned.
+   */
+  public static Map<String, Object> 
convertSearchAttributesValuesFromListToObject(
+      Map<String, List<?>> searchAttributes) {
+    if (searchAttributes == null) {
+      return null;
+    }
+    Map<String, Object> convertedAttributes = new HashMap<>();
+
+    convertedAttributes.putAll(searchAttributes);

Review Comment:
   It seems like the intention of this method is to convert the input map 
`Map<String, List<?>>` into a `Map<String, Object>` without transforming the 
list values into single objects. This method seems to be written for 
setSearchAttributes on ChildWorkflowOptions in 
AbstractNestingExecWorkflowImpl(which expects Map<String, Object>), we can 
simplify the implementation by directly using `new 
HashMap<>(searchAttributes)`. This would achieve the same result more 
efficiently.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to