diff --git a/LTA/sip/lib/siplib.py b/LTA/sip/lib/siplib.py index a4f9faf5867c93e730a709c2328d8a7f71487188..af6c39adf031d466fdcbb4c8d7e4e06ca46ee3c3 100644 --- a/LTA/sip/lib/siplib.py +++ b/LTA/sip/lib/siplib.py @@ -1071,7 +1071,7 @@ class ProcessMap(): for rel in relations: __relations.append(rel._get_pyxb_processrelation(suppress_warning=True)) self.process_map = dict(processIdentifier=identifier._get_pyxb_identifier(suppress_warning=True), - observationId=observation_identifier._get_pyxb_identifier(suppress_warning=True), + observationId=observation_identifier._get_pyxb_identifier(suppress_warning=True), relations=__relations, strategyName=strategyname, strategyDescription=strategydescription, startTime=starttime, duration=duration) diff --git a/SAS/TMSS/backend/src/remakemigrations.py b/SAS/TMSS/backend/src/remakemigrations.py index feb80bbb50063f5618e83c3f11b08ad5a497c486..ceb04af2b7220d8f40cc0ebb7c75d17b8edd48dd 100755 --- a/SAS/TMSS/backend/src/remakemigrations.py +++ b/SAS/TMSS/backend/src/remakemigrations.py @@ -130,6 +130,7 @@ class Migration(migrations.Migration): IF OLD.specifications_doc <> NEW.specifications_doc OR OLD.name <> NEW.name OR OLD.description <> NEW.description OR + OLD.short_description <> NEW.short_description OR OLD.specifications_template_id <> NEW.specifications_template_id OR OLD.scheduling_unit_blueprint_id <> NEW.scheduling_unit_blueprint_id THEN RAISE EXCEPTION 'ILLEGAL UPDATE OF IMMUTABLE BLUEPRINT FIELD'; diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py index 1621708ea605b50ec04c29091c057eabb5252df5..f299db6d2fb0a7e8464777a3e71650281ee1bc30 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py @@ -78,7 +78,7 @@ def get_siplib_stations_list(subtask): return siplib_station_list -def get_siplib_identifier(sipid_obj: SIPidentifier, context_str="") -> siplib.Identifier: +def get_siplib_identifier(sipid_obj: SIPidentifier, context_str="", name:str=None) -> siplib.Identifier: """ Retrieve an Identifier object. Get the unique_identifier and source of the given sip object and covert that to a siblib object @@ -98,7 +98,7 @@ def get_siplib_identifier(sipid_obj: SIPidentifier, context_str="") -> siplib.Id ltasip.IdentifierType( source=source, identifier=unique_id, - name=None, + name=name, label=None), suppress_warning=True) return identifier @@ -133,7 +133,7 @@ def create_sip_representation_for_subtask(subtask: Subtask): :return: A siplib.Observation object or one of the various siplib pipeline object flavors """ # determine common properties - subtask_sip_identifier = get_siplib_identifier(subtask.global_identifier, "Subtask id=%s" % subtask.id) + subtask_sip_identifier = get_siplib_identifier(subtask.global_identifier, "Subtask id=%s" % subtask.id, name=subtask.task_blueprint.short_description) name = str(subtask.id) process_map = siplib.ProcessMap(strategyname=subtask.specifications_template.name, strategydescription=subtask.specifications_template.description, diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py index bfd95c9f273df7aaf63d3ba8c5b1c41d75bec30d..5d19ced6b7659cc33e41585611baf168cc7aeac1 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.9 on 2021-09-27 14:27 +# Generated by Django 3.0.9 on 2021-10-05 17:32 from django.conf import settings import django.contrib.auth.models diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0002_populate.py b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0002_populate.py index c1ef378f9059ec3f0dea83cc6270fb555189d323..8c9cb85cebe6990cf3b0ac2af2e117bd4b62ab84 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0002_populate.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0002_populate.py @@ -9,6 +9,7 @@ from django.db import migrations from lofar.sas.tmss.tmss.tmssapp.populate import * class Migration(migrations.Migration): + dependencies = [ ('tmssapp', '0001_initial'), ] diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0003_taskblueprint_shortdescription.py b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0003_taskblueprint_shortdescription.py new file mode 100644 index 0000000000000000000000000000000000000000..c00080d12019c8b7c494f045f26ed521420eaa92 --- /dev/null +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0003_taskblueprint_shortdescription.py @@ -0,0 +1,50 @@ +# Generated by Django 3.0.9 on 2021-10-07 09:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tmssapp', '0002_populate'), + ] + + operations = [ + migrations.AddField( + model_name='taskblueprint', + name='short_description', + field=models.CharField(blank=True, default='', help_text='A short description of this task, usually the name of the target and abbreviated task type.', max_length=32), + ), + migrations.AddField( + model_name='taskdraft', + name='short_description', + field=models.CharField(blank=True, default='', help_text='A short description of this task, usually the name of the target and abbreviated task type.', max_length=32), + ), + migrations.AlterField( + model_name='project', + name='project_state', + field=models.ForeignKey(default='opened', help_text='The state this project is in.', on_delete=django.db.models.deletion.PROTECT, to='tmssapp.ProjectState'), + ), + migrations.RunSQL('''CREATE OR REPLACE FUNCTION tmssapp_block_task_blueprint_immutable_fields_update() + RETURNS trigger AS + $BODY$ + BEGIN + IF OLD.specifications_doc <> NEW.specifications_doc OR + OLD.name <> NEW.name OR + OLD.description <> NEW.description OR + OLD.short_description <> NEW.short_description OR + OLD.specifications_template_id <> NEW.specifications_template_id OR + OLD.scheduling_unit_blueprint_id <> NEW.scheduling_unit_blueprint_id THEN + RAISE EXCEPTION 'ILLEGAL UPDATE OF IMMUTABLE BLUEPRINT FIELD'; + END IF; + RETURN NEW; + END; + $BODY$ + LANGUAGE plpgsql VOLATILE; + DROP TRIGGER IF EXISTS tmssapp_block_task_blueprint_immutable_fields_update ON tmssapp_TaskBlueprint ; + CREATE TRIGGER tmssapp_block_task_blueprint_immutable_fields_update + BEFORE UPDATE ON tmssapp_TaskBlueprint + FOR EACH ROW EXECUTE PROCEDURE tmssapp_block_task_blueprint_immutable_fields_update(); + ''') + ] diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 85e8a589c36b5ca66723fbbd1f8212543f0752d1..35417a7499018cba594f373058455b8cb2434349 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -983,6 +983,7 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo class TaskDraft(NamedCommon, TemplateSchemaMixin, ProjectPropertyMixin): + short_description = CharField(max_length=32, help_text='A short description of this task, usually the name of the target and abbreviated task type.', blank=True, default="") specifications_doc = JSONField(help_text='Specifications for this task.') scheduling_unit_draft = ForeignKey('SchedulingUnitDraft', related_name='task_drafts', on_delete=CASCADE, help_text='Scheduling Unit draft to which this task draft belongs.') specifications_template = ForeignKey('TaskTemplate', on_delete=CASCADE, help_text='Schema used for specifications_doc.') # todo: 'schema'? @@ -1123,6 +1124,7 @@ class TaskBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCommon): SCHEDULED = "scheduled" SCHEDULABLE = "schedulable" + short_description = CharField(max_length=32, help_text='A short description of this task, usually the name of the target and abbreviated task type.', blank=True, default="") specifications_doc = JSONField(help_text='Schedulings for this task (IMMUTABLE).') specifications_template = ForeignKey('TaskTemplate', on_delete=CASCADE, help_text='Schema used for specifications_doc (IMMUTABLE).') draft = ForeignKey('TaskDraft', related_name='task_blueprints', null=True, on_delete=SET_NULL, help_text='TaskDraft from which this TaskBlueprint was created. If the TaskDraft is deleted the we loose this reference, which is ok.') diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_unit_template-scheduling_unit-1.json b/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_unit_template-scheduling_unit-1.json index 466d87bc2b7d5f65437a5db64279f09778d08465..073f13b8f3e522bcc2e38d51f152a534fc98e1c6 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_unit_template-scheduling_unit-1.json +++ b/SAS/TMSS/backend/src/tmss/tmssapp/schemas/scheduling_unit_template-scheduling_unit-1.json @@ -17,10 +17,17 @@ "additionalProperties": false, "default": {}, "properties": { + "short description": { + "type": "string", + "title": "Short Description", + "default": "", + "description": "A short description of this task, usually the name of the target/source and abbreviated task type" + }, "description": { "type": "string", "title": "Description", - "default": "" + "default": "", + "description": "A long(er) description of this task" }, "tags": { "type": "array", diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py index 090bf84731519e91e1e31a25e46b5c0192768bd5..e365caec1b6d878fa2d0eec7d311306aebbabcc1 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py @@ -144,6 +144,7 @@ def copy_task_draft(task_draft: models.TaskDraft, including_relations: bool=Fals with transaction.atomic(): task_draft_copy = models.TaskDraft.objects.create(name="%s (Copy)" % (task_draft.name,), description="%s (Copy from task_draft id=%s)" % (task_draft.description, task_draft.id), + short_description=task_draft.short_description, specifications_doc=task_draft.specifications_doc, scheduling_unit_draft=task_draft.scheduling_unit_draft, specifications_template=task_draft.specifications_template) @@ -174,6 +175,7 @@ def copy_task_blueprint_to_task_draft(task_blueprint: models.TaskBlueprint, incl with transaction.atomic(): task_draft_copy = models.TaskDraft.objects.create(name="%s (Copy)" % (task_blueprint.name,), description="%s (Copy from task_blueprint id=%s)" % (task_blueprint.description, task_blueprint.id), + short_description=task_blueprint.short_description, specifications_doc=task_blueprint.specifications_doc, scheduling_unit_draft=task_blueprint.scheduling_unit_blueprint.draft, specifications_template=task_blueprint.specifications_template) @@ -244,6 +246,7 @@ def update_task_graph_from_specifications_doc(scheduling_unit_draft: models.Sche try: task_draft = scheduling_unit_draft.task_drafts.get(name=task_name) task_draft.description = task_definition.get("description", "") + task_draft.short_description = task_definition.get("short description", "") task_draft.specifications_doc = task_specifications_doc task_draft.specifications_template = task_template task_draft.save() @@ -253,6 +256,7 @@ def update_task_graph_from_specifications_doc(scheduling_unit_draft: models.Sche except models.TaskDraft.DoesNotExist: task_draft = models.TaskDraft.objects.create(name=task_name, description=task_definition.get("description", ""), + short_description=task_definition.get("short description", ""), scheduling_unit_draft=scheduling_unit_draft, specifications_doc = task_specifications_doc, specifications_template=task_template) @@ -332,6 +336,7 @@ def create_task_blueprint_from_task_draft(task_draft: models.TaskDraft) -> model task_blueprint.save() except TaskBlueprint.DoesNotExist: task_blueprint = TaskBlueprint.objects.create(description=task_draft.description, + short_description=task_draft.short_description, name=task_draft.name, draft=task_draft, scheduling_unit_blueprint=scheduling_unit_blueprint,