From 6d5559bae9ca53f949869b86c81801cf4a1c116a Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Mon, 29 Jan 2024 17:25:02 +0100
Subject: [PATCH] TMSS-2829: taskconnectors for copypipeline

---
 SAS/TMSS/backend/src/tmss/tmssapp/populate.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py
index b093121ea48..8298bd9871b 100644
--- a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py
@@ -722,6 +722,23 @@ def populate_connectors():
                                                      task_template_name=task_template_name,
                                                      iotype=IOType.objects.get(value=IOType.Choices.INPUT.value))
 
+    # The Copy (sub)task accepts any kinds of data, and passes it on.
+    task_template_name = "copy pipeline"
+    for output_connector_type in TaskConnectorType.objects.filter(iotype=IOType.objects.get(value=IOType.Choices.OUTPUT.value)).all():
+        # always create two input connectors for the specific output_connector_type.role and the any_role
+        any_role = Role.objects.get(value=Role.Choices.ANY.value)
+        for role in [output_connector_type.role, any_role]:
+            create_task_connector_skip_duplicate(role=role,
+                                                 datatype=output_connector_type.datatype,
+                                                 dataformat=output_connector_type.dataformat,
+                                                 task_template_name="copy pipeline",
+                                                 iotype=IOType.objects.get(value=IOType.Choices.INPUT.value))
+            create_task_connector_skip_duplicate(role=role,
+                                                 datatype=output_connector_type.datatype,
+                                                 dataformat=output_connector_type.dataformat,
+                                                 task_template_name=task_template_name,
+                                                 iotype=IOType.objects.get(value=IOType.Choices.OUTPUT.value))
+
 
 def populate_permissions():
     logger.info('Populating permissions')
-- 
GitLab