Skip to content
Snippets Groups Projects
Commit 01d6da99 authored by goei's avatar goei
Browse files

TMSS-152: Create also SchedulingRelationBlueprint of SchedulingRelationDraft...

TMSS-152: Create also SchedulingRelationBlueprint of SchedulingRelationDraft during draft-to-blueprint. Fix in name test data for rest api.
parent f114f606
Branches
Tags
1 merge request!180Resolve TMSS-152
...@@ -639,7 +639,7 @@ class Migration(migrations.Migration): ...@@ -639,7 +639,7 @@ class Migration(migrations.Migration):
('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128), blank=True, default=list, help_text='User-defined search keywords for object.', size=8)), ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128), blank=True, default=list, help_text='User-defined search keywords for object.', size=8)),
('created_at', models.DateTimeField(auto_now_add=True, help_text='Moment of object creation.')), ('created_at', models.DateTimeField(auto_now_add=True, help_text='Moment of object creation.')),
('updated_at', models.DateTimeField(auto_now=True, help_text='Moment of last object update.')), ('updated_at', models.DateTimeField(auto_now=True, help_text='Moment of last object update.')),
('time_offset', models.FloatField(help_text='Time Offset between first and second Task Blueprint')), ('time_offset', models.IntegerField(default=60, help_text='Time offset of start of second task with respect to start of first task.')),
], ],
options={ options={
'abstract': False, 'abstract': False,
...@@ -652,7 +652,7 @@ class Migration(migrations.Migration): ...@@ -652,7 +652,7 @@ class Migration(migrations.Migration):
('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128), blank=True, default=list, help_text='User-defined search keywords for object.', size=8)), ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=128), blank=True, default=list, help_text='User-defined search keywords for object.', size=8)),
('created_at', models.DateTimeField(auto_now_add=True, help_text='Moment of object creation.')), ('created_at', models.DateTimeField(auto_now_add=True, help_text='Moment of object creation.')),
('updated_at', models.DateTimeField(auto_now=True, help_text='Moment of last object update.')), ('updated_at', models.DateTimeField(auto_now=True, help_text='Moment of last object update.')),
('time_offset', models.FloatField(help_text='Time Offset between first and second Task Draft')), ('time_offset', models.IntegerField(default=60, help_text='Time offset of start of second task with respect to start of first task.')),
], ],
options={ options={
'abstract': False, 'abstract': False,
......
...@@ -150,6 +150,28 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model ...@@ -150,6 +150,28 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model
dataformat=task_relation_draft.dataformat) dataformat=task_relation_draft.dataformat)
logger.info("Task Blueprint (id=%s) connected to Task Blueprint (id=%s) via Task Relation Blueprint (id=%s)", logger.info("Task Blueprint (id=%s) connected to Task Blueprint (id=%s) via Task Relation Blueprint (id=%s)",
task_blueprint.pk, producing_task_blueprint.pk, task_relation_blueprint.pk) task_blueprint.pk, producing_task_blueprint.pk, task_relation_blueprint.pk)
# Do the sam 'trick' for Task Scheduling Relation Draft to Blueprint
task_draft_scheduling_relations = list(task_draft.first_to_connect.all()) + list(task_draft.second_to_connect.all())
for task_scheduling_relation_draft in task_draft_scheduling_relations:
for first_task_blueprint in task_scheduling_relation_draft.first.task_blueprints.all():
for second_task_blueprint in task_scheduling_relation_draft.second.task_blueprints.all():
try:
# do nothing if task_scheduling_relation_blueprint already exists...
models.TaskSchedulingRelationBlueprint.objects.get(first_id=first_task_blueprint.id,
second_id=second_task_blueprint.id)
except models.TaskSchedulingRelationBlueprint.DoesNotExist:
# ...'else' create it.
task_scheduling_relation_blueprint = models.TaskSchedulingRelationBlueprint.objects.create(
first=first_task_blueprint,
second=second_task_blueprint,
time_offset=task_scheduling_relation_draft.time_offset,
placement=task_scheduling_relation_draft.placement)
logger.info("Task Blueprint (id=%s) connected via scheduling relation with id=%s",
task_blueprint.pk, task_scheduling_relation_blueprint.pk)
logger.info("The scheduling relation is: '%s' (id=%s) '%s' '%s' (id=%s)",
first_task_blueprint.name, first_task_blueprint.pk, task_scheduling_relation_blueprint.placement,
second_task_blueprint.name, second_task_blueprint.pk)
return task_blueprint return task_blueprint
...@@ -180,6 +202,7 @@ def create_task_blueprint_and_subtasks_and_schedule_subtasks_from_task_draft(tas ...@@ -180,6 +202,7 @@ def create_task_blueprint_and_subtasks_and_schedule_subtasks_from_task_draft(tas
task_blueprint.refresh_from_db() task_blueprint.refresh_from_db()
return task_blueprint return task_blueprint
def create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint: def create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint:
'''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s)''' '''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s)'''
task_drafts = list(scheduling_unit_blueprint.draft.task_drafts.all()) task_drafts = list(scheduling_unit_blueprint.draft.task_drafts.all())
...@@ -196,6 +219,7 @@ def create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_bluepr ...@@ -196,6 +219,7 @@ def create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_bluepr
scheduling_unit_blueprint.refresh_from_db() scheduling_unit_blueprint.refresh_from_db()
return scheduling_unit_blueprint return scheduling_unit_blueprint
def create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint: def create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint:
'''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s), then create each task_blueprint's subtasks''' '''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s), then create each task_blueprint's subtasks'''
scheduling_unit_blueprint = create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_blueprint) scheduling_unit_blueprint = create_task_blueprints_from_scheduling_unit_blueprint(scheduling_unit_blueprint)
...@@ -213,6 +237,7 @@ def create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(schedulin ...@@ -213,6 +237,7 @@ def create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(schedulin
scheduling_unit_blueprint.refresh_from_db() scheduling_unit_blueprint.refresh_from_db()
return scheduling_unit_blueprint return scheduling_unit_blueprint
def create_task_blueprints_and_subtasks_and_schedule_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint: def create_task_blueprints_and_subtasks_and_schedule_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint: models.SchedulingUnitBlueprint) -> models.SchedulingUnitBlueprint:
'''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s), then create the task_blueprint's subtasks, and schedule the ones that are not dependend on predecessors''' '''Convenience method: Create the scheduling_unit_blueprint's task_blueprint(s), then create the task_blueprint's subtasks, and schedule the ones that are not dependend on predecessors'''
scheduling_unit_blueprint = create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint) scheduling_unit_blueprint = create_task_blueprints_and_subtasks_from_scheduling_unit_blueprint(scheduling_unit_blueprint)
......
...@@ -226,8 +226,8 @@ class TMSSRESTTestDataCreator(): ...@@ -226,8 +226,8 @@ class TMSSRESTTestDataCreator():
'task_blueprints': [], 'task_blueprints': [],
'produced_by': [], 'produced_by': [],
'consumed_by': [], 'consumed_by': [],
'scheduling_relation_first': [], 'first_to_connect': [],
'scheduling_relation_second': []} 'second_to_connect': []}
def TaskRelationDraft(self, producer_url=None, consumer_url=None, template_url=None, input_role_url=None, output_role_url=None): def TaskRelationDraft(self, producer_url=None, consumer_url=None, template_url=None, input_role_url=None, output_role_url=None):
...@@ -294,8 +294,8 @@ class TMSSRESTTestDataCreator(): ...@@ -294,8 +294,8 @@ class TMSSRESTTestDataCreator():
"subtasks": [], "subtasks": [],
"produced_by": [], "produced_by": [],
"consumed_by": [], "consumed_by": [],
'scheduling_relation_first': [], 'first_to_connect': [],
'scheduling_relation_second': []} 'second_to_connect': []}
def TaskRelationBlueprint(self, draft_url=None, template_url=None, input_role_url=None, output_role_url=None, consumer_url=None, producer_url=None): def TaskRelationBlueprint(self, draft_url=None, template_url=None, input_role_url=None, output_role_url=None, consumer_url=None, producer_url=None):
if draft_url is None: if draft_url is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment