1212from process_tracker .models .model_base import Base
1313from process_tracker .models .actor import Actor
1414from process_tracker .models .capacity import Cluster , ClusterProcess
15+ from process_tracker .models .contact import Contact
1516from process_tracker .models .extract import ExtractStatus
1617from process_tracker .models .process import (
1718 ErrorType ,
@@ -198,6 +199,7 @@ def topic_creator(
198199 max_memory = None ,
199200 memory_unit = None ,
200201 cluster = None ,
202+ email = None ,
201203 ):
202204 """
203205 For the command line tool, validate the topic and create the new instance.
@@ -220,6 +222,8 @@ def topic_creator(
220222 :type memory_unit: string
221223 :param cluster: For cluster/process relationships, the name of the cluster.
222224 :type cluster: string
225+ :param email: For contacts, the contact's email address
226+ :type email: string
223227 :return:
224228 """
225229 self .logger .info ("Attempting to create %s item: %s" % (topic , name ))
@@ -230,6 +234,12 @@ def topic_creator(
230234 item = self .get_or_create_item (model = Actor , actor_name = name )
231235 self .logger .info ("Actor created: %s" % item .__repr__ )
232236
237+ elif topic == "contact" :
238+ item = self .get_or_create_item (
239+ model = Contact , contact_name = name , contact_email = email
240+ )
241+ self .logger .info ("Contact created: %s" % item .__repr__ )
242+
233243 elif topic == "cluster" :
234244 item = self .get_or_create_item (
235245 model = Cluster ,
@@ -257,16 +267,16 @@ def topic_creator(
257267
258268 self .logger .info ("Cluster Process created: %s" % item .__repr__ )
259269
270+ elif topic == "error type" :
271+ item = self .get_or_create_item (model = ErrorType , error_type_name = name )
272+ self .logger .info ("Error Type created: %s" % item .__repr__ )
273+
260274 elif topic == "extract status" :
261275 item = self .get_or_create_item (
262276 model = ExtractStatus , extract_status_name = name
263277 )
264278 self .logger .info ("Extract Status created: %s" % item .__repr__ )
265279
266- elif topic == "error type" :
267- item = self .get_or_create_item (model = ErrorType , error_type_name = name )
268- self .logger .info ("Error Type created: %s" % item .__repr__ )
269-
270280 elif topic == "process dependency" :
271281 parent_process = self .get_or_create_item (
272282 model = Process , process_name = parent , create = False
@@ -283,18 +293,18 @@ def topic_creator(
283293
284294 self .logger .info ("Process Dependency created: %s" % item .__repr__ )
285295
286- elif topic == "process type" :
287- item = self .get_or_create_item (
288- model = ProcessType , process_type_name = name
289- )
290- self .logger .info ("Process Type created: %s" % item .__repr__ )
291-
292296 elif topic == "process status" :
293297 item = self .get_or_create_item (
294298 model = ProcessStatus , process_status_name = name
295299 )
296300 self .logger .info ("Process Status created: %s" % item .__repr__ )
297301
302+ elif topic == "process type" :
303+ item = self .get_or_create_item (
304+ model = ProcessType , process_type_name = name
305+ )
306+ self .logger .info ("Process Type created: %s" % item .__repr__ )
307+
298308 elif topic == "source" :
299309 item = self .get_or_create_item (model = Source , source_name = name )
300310 self .logger .info ("Source created: %s" % item .__repr__ )
@@ -339,6 +349,13 @@ def topic_deleter(self, topic, name, parent=None, child=None, cluster=None):
339349 self .session .query (Actor ).filter (Actor .actor_name == name ).delete ()
340350 self .logger .info ("%s %s deleted." % (topic , name ))
341351
352+ elif topic == "contact" :
353+ item_delete = True
354+ self .session .query (Contact ).filter (
355+ Contact .contact_name == name
356+ ).delete ()
357+ self .logger .info ("%s %s deleted." % (topic , name ))
358+
342359 elif topic == "cluster" :
343360 item_delete = True
344361 self .session .query (Cluster ).filter (
@@ -448,6 +465,7 @@ def topic_updater(
448465 processing_unit = None ,
449466 max_memory = None ,
450467 memory_unit = None ,
468+ email = None ,
451469 ):
452470 """
453471 For the command line tool, validate that the topic name is not a default value and if not, update it.
@@ -465,6 +483,8 @@ def topic_updater(
465483 :type processing_unit: string
466484 :param memory_unit: For performance clusters, the unit of allocated memory to the cluster
467485 :type memory_unit: string
486+ :param email: For contacts, the contact's email address
487+ :type email: string
468488 :return:
469489 """
470490 if self .topic_validator (topic = topic ):
@@ -475,6 +495,17 @@ def topic_updater(
475495 item .actor_name = name
476496 self .logger .info ("%s %s updated." % (topic , name ))
477497
498+ elif topic == "contact" :
499+ item = self .get_or_create_item (
500+ model = Contact , create = False , contact_name = initial_name
501+ )
502+
503+ item .contact_name = name
504+
505+ if email is not None :
506+ item .contact_email = email
507+ self .logger .info ("%s %s updated." % (topic , name ))
508+
478509 elif topic == "cluster" :
479510 item = self .get_or_create_item (
480511 model = Cluster , create = False , cluster_name = initial_name
@@ -615,13 +646,15 @@ def topic_validator(self, topic):
615646 "actor" ,
616647 "cluster" ,
617648 "cluster process" ,
649+ "contact" ,
618650 "error type" ,
619651 "extract status" ,
620652 "process dependency" ,
621653 "process run" ,
622654 "process status" ,
623655 "process type" ,
624656 "source" ,
657+ "source contact" ,
625658 "tool" ,
626659 ]
627660
0 commit comments