diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py index 76e057c97456f40d5b35c670c27f1f60d9d88ccc..50f95df8bd533083a2553df25b75c9c2480197e8 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/sip.py @@ -1,5 +1,5 @@ from lofar.sas.tmss.tmss.exceptions import * -from lofar.sas.tmss.tmss.tmssapp.models.scheduling import Dataproduct, SubtaskType, Subtask, SubtaskOutput, SIPidentifier, Algorithm +from lofar.sas.tmss.tmss.tmssapp.models.scheduling import Dataproduct, SubtaskType, Subtask, SubtaskOutput, SIPidentifier, HashAlgorithm from lofar.sas.tmss.tmss.tmssapp.models.specification import Datatype, Dataformat from lofar.lta.sip import siplib, ltasip, validator, constants @@ -447,12 +447,12 @@ def generate_sip_for_dataproduct(dataproduct: Dataproduct) -> siplib.Sip: if dataproduct.hashes: from django.core.exceptions import ObjectDoesNotExist try: - sip_dataproduct.set_checksum_md5(dataproduct.hashes.get(algorithm=Algorithm.Choices.MD5.value).hash) + sip_dataproduct.set_checksum_md5(dataproduct.hashes.get(hash_algorithm=HashAlgorithm.Choices.MD5.value).hash) except ObjectDoesNotExist: pass try: - sip_dataproduct.set_checksum_adler32(dataproduct.hashes.get(algorithm=Algorithm.Choices.ADLER32.value).hash) + sip_dataproduct.set_checksum_adler32(dataproduct.hashes.get(hash_algorithm=HashAlgorithm.Choices.ADLER32.value).hash) except ObjectDoesNotExist: pass 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 d4095c88c950c3c628f52c4a477d6389e9dd2699..b621cd42951714df6a431e196e12c76fd6fbc313 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0001_initial.py @@ -19,7 +19,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Algorithm', + name='HashAlgorithm', fields=[ ('value', models.CharField(max_length=128, primary_key=True, serialize=False, unique=True)), ], @@ -1356,8 +1356,8 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name='dataproducthash', - name='algorithm', - field=models.ForeignKey(help_text='Algorithm used (MD5, AES256).', on_delete=django.db.models.deletion.PROTECT, to='tmssapp.Algorithm'), + name='hash_algorithm', + field=models.ForeignKey(help_text='Algorithm used for hashing (MD5, AES256).', on_delete=django.db.models.deletion.PROTECT, to='tmssapp.HashAlgorithm'), ), migrations.AddField( model_name='dataproducthash', diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py index 9535b3c3d9732a2ae062b3186717697a5f853cd4..234f8ab359cd7dad4c3bb3abcad5d0e4dabc4cd8 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py @@ -76,8 +76,8 @@ class StationType(AbstractChoice): INTERNATIONAL = "international" -class Algorithm(AbstractChoice): - """Defines the model and predefined list of possible Algorithm's for DataproductHash. +class HashAlgorithm(AbstractChoice): + """Defines the model and predefined list of possible HashAlgorithm's for DataproductHash. The items in the Choices class below are automagically populated into the database via a data migration.""" class Choices(Enum): @@ -434,6 +434,6 @@ class DataproductArchiveInfo(BasicCommon): class DataproductHash(BasicCommon): dataproduct = ForeignKey('Dataproduct', related_name='hashes', on_delete=PROTECT, help_text='The dataproduct to which this hash refers.') - algorithm = ForeignKey('Algorithm', null=False, on_delete=PROTECT, help_text='Algorithm used (MD5, AES256).') + hash_algorithm = ForeignKey('HashAlgorithm', null=False, on_delete=PROTECT, help_text='Algorithm used for hashing (MD5, AES256).') hash = CharField(max_length=128, help_text='Hash value.') diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py index 72c334977eb4d4369ab8f78e35d31ae46341aa1a..a53992b096237eb18d0033db76221516a02f51f3 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py @@ -41,7 +41,7 @@ def populate_choices(apps, schema_editor): :return: None ''' choice_classes = [Role, Datatype, Dataformat, CopyReason, - SubtaskState, SubtaskType, StationType, Algorithm, SchedulingRelationPlacement, + SubtaskState, SubtaskType, StationType, HashAlgorithm, SchedulingRelationPlacement, Flag, ProjectCategory, PeriodCategory, Quantity, TaskType, ProjectRole] # upload choices in parallel diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/serializers/scheduling.py b/SAS/TMSS/backend/src/tmss/tmssapp/serializers/scheduling.py index 7c8bd8c29ee090cf6af7f48d6431e03418830c61..e77cd1e3194586d1dbad0f4591ab987dc953d2fc 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/serializers/scheduling.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/serializers/scheduling.py @@ -34,9 +34,9 @@ class StationTypeSerializer(DynamicRelationalHyperlinkedModelSerializer): fields = '__all__' -class AlgorithmSerializer(DynamicRelationalHyperlinkedModelSerializer): +class HashAlgorithmSerializer(DynamicRelationalHyperlinkedModelSerializer): class Meta: - model = models.Algorithm + model = models.HashAlgorithm fields = '__all__' diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/scheduling.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/scheduling.py index 8bda4797baab86e450e9d4bec910d9132503287f..a1201686b644fd793dee48bcf869b90547b9781f 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/scheduling.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/scheduling.py @@ -77,9 +77,9 @@ class StationTypeViewSet(LOFARViewSet): queryset = models.StationType.objects.all() serializer_class = serializers.StationTypeSerializer -class AlgorithmViewSet(LOFARViewSet): - queryset = models.Algorithm.objects.all() - serializer_class = serializers.AlgorithmSerializer +class HashAlgorithmViewSet(LOFARViewSet): + queryset = models.HashAlgorithm.objects.all() + serializer_class = serializers.HashAlgorithmSerializer class SubtaskTemplateFilter(filters.FilterSet): class Meta: @@ -412,12 +412,12 @@ class DataproductViewSet(LOFARViewSet): if 'md5_checksum' in json_doc: models.DataproductHash.objects.create(dataproduct=dataproduct, - algorithm=models.Algorithm.objects.get(value=models.Algorithm.Choices.MD5.value), + hash_algorithm=models.HashAlgorithm.objects.get(value=models.HashAlgorithm.Choices.MD5.value), hash=json_doc['md5_checksum']) if 'adler32_checksum' in json_doc: models.DataproductHash.objects.create(dataproduct=dataproduct, - algorithm=models.Algorithm.objects.get(value=models.Algorithm.Choices.ADLER32.value), + hash_algorithm=models.HashAlgorithm.objects.get(value=models.HashAlgorithm.Choices.ADLER32.value), hash=json_doc['adler32_checksum']) # create empty feedback. Apart from the archive info above, ingest does not create feedback like observations/pipelines do. diff --git a/SAS/TMSS/backend/src/tmss/urls.py b/SAS/TMSS/backend/src/tmss/urls.py index 66e58162725f917a20c5020e6492ad6f39bed7d0..29301b9659189075cc6a43687c28fecc8a151ad8 100644 --- a/SAS/TMSS/backend/src/tmss/urls.py +++ b/SAS/TMSS/backend/src/tmss/urls.py @@ -192,7 +192,7 @@ router.register(r'scheduling_unit_blueprint/(?P<scheduling_unit_blueprint_id>\d+ router.register(r'subtask_state', viewsets.SubtaskStateViewSet) router.register(r'subtask_type', viewsets.SubtaskTypeViewSet) router.register(r'station_type', viewsets.StationTypeViewSet) -router.register(r'algorithm', viewsets.AlgorithmViewSet) +router.register(r'hash_algorithm', viewsets.HashAlgorithmViewSet) router.register(r'scheduling_relation_placement', viewsets.SchedulingRelationPlacement) # templates diff --git a/SAS/TMSS/backend/test/t_tmssapp_scheduling_REST_API.py b/SAS/TMSS/backend/test/t_tmssapp_scheduling_REST_API.py index 232c237ec2f18edd7c91b514281425a8bc232089..711ebc4a0d5f0b448358b4a302efeb20dfddba8d 100755 --- a/SAS/TMSS/backend/test/t_tmssapp_scheduling_REST_API.py +++ b/SAS/TMSS/backend/test/t_tmssapp_scheduling_REST_API.py @@ -1171,7 +1171,7 @@ class DataproductHashTestCase(unittest.TestCase): url = r_dict['url'] GET_OK_and_assert_equal_expected_response(self, url, dph_test_data) - test_patch = {"algorithm": BASE_URL + '/algorithm/aes256', + test_patch = {"hash_algorithm": BASE_URL + '/hash_algorithm/aes256', "hash": 'bender-was-here'} # PATCH item and verify @@ -1207,7 +1207,7 @@ class DataproductHashTestCase(unittest.TestCase): self.assertTrue("ProtectedError" in str(response.content)) GET_and_assert_equal_expected_code(self, dph_test_data['dataproduct'], 200) - def test_dataproduct_hash_PROTECT_behavior_on_algorithm_deleted(self): + def test_dataproduct_hash_PROTECT_behavior_on_hash_algorithm_deleted(self): dph_test_data = test_data_creator.DataproductHash(dataproduct_url=self.dataproduct_url) # POST new item and verify @@ -1217,10 +1217,10 @@ class DataproductHashTestCase(unittest.TestCase): # Try to DELETE dependency, verify that was not successful # Unfortunately we don't get a nice error in json, but a Django debug page on error 500... - response = requests.delete(dph_test_data['algorithm'], auth=AUTH) + response = requests.delete(dph_test_data['hash_algorithm'], auth=AUTH) self.assertEqual(500, response.status_code) self.assertTrue("ProtectedError" in str(response.content)) - GET_and_assert_equal_expected_code(self, dph_test_data['algorithm'], 200) + GET_and_assert_equal_expected_code(self, dph_test_data['hash_algorithm'], 200) class DataproductArchiveInfoTestCase(unittest.TestCase): diff --git a/SAS/TMSS/backend/test/test_utils.py b/SAS/TMSS/backend/test/test_utils.py index ad64349b5c195fb1d7b5381cc2a4404a535711ae..ac81d6d0c43f46ad8ed5ca7bd286ef2799db4e50 100644 --- a/SAS/TMSS/backend/test/test_utils.py +++ b/SAS/TMSS/backend/test/test_utils.py @@ -848,8 +848,8 @@ def create_scheduling_unit_blueprint_simulator(scheduling_unit_blueprint_id: int models.DataproductArchiveInfo.objects.create(dataproduct=output_dp, storage_ticket=uuid4()) - for algo in models.Algorithm.objects.all(): - models.DataproductHash.objects.create(dataproduct=output_dp, algorithm=algo, hash=uuid4()) + for algo in models.HashAlgorithm.objects.all(): + models.DataproductHash.objects.create(dataproduct=output_dp, hash_algorithm=algo, hash=uuid4()) elif status == models.SubtaskState.Choices.DEFINED.value: state_transition = models.SubtaskStateLog.objects.filter(subtask__id=subtask.id, old_state__value=models.SubtaskState.Choices.SCHEDULING.value, diff --git a/SAS/TMSS/backend/test/tmss_test_data_django_models.py b/SAS/TMSS/backend/test/tmss_test_data_django_models.py index 03bd63e347821654485556b3e2c146e9aea2d92b..c4c98b7f64b79b5aa6f7a1d4926e7ca7ecf68a2f 100644 --- a/SAS/TMSS/backend/test/tmss_test_data_django_models.py +++ b/SAS/TMSS/backend/test/tmss_test_data_django_models.py @@ -519,7 +519,7 @@ def DataproductArchiveInfo_test_data() -> dict: def DataproductHash_test_data() -> dict: return {"dataproduct": models.Dataproduct.objects.create(**Dataproduct_test_data()), - "algorithm": models.Algorithm.objects.get(value='md5'), + "hash_algorithm": models.HashAlgorithm.objects.get(value='md5'), "hash": "myhash_1", "tags": ['tmss', 'testing']} diff --git a/SAS/TMSS/backend/test/tmss_test_data_rest.py b/SAS/TMSS/backend/test/tmss_test_data_rest.py index 551a251a68857807ceb4e4bf63699d6bd575c44d..046bc7fa6a34e02934d55b214a66a3164481c108 100644 --- a/SAS/TMSS/backend/test/tmss_test_data_rest.py +++ b/SAS/TMSS/backend/test/tmss_test_data_rest.py @@ -764,15 +764,15 @@ class TMSSRESTTestDataCreator(): "identity": True, "tags": ['tmss', 'testing']} - def DataproductHash(self, algorithm_url=None, hash="my_hash", dataproduct_url=None): - if algorithm_url is None: - algorithm_url = self.django_api_url + '/algorithm/md5' + def DataproductHash(self, hash_algorithm_url=None, hash="my_hash", dataproduct_url=None): + if hash_algorithm_url is None: + hash_algorithm_url = self.django_api_url + '/hash_algorithm/md5' if dataproduct_url is None: dataproduct_url = self.cached_dataproduct_url return {"dataproduct": dataproduct_url, - "algorithm": algorithm_url, + "hash_algorithm": hash_algorithm_url, "hash": hash, "tags": ['tmss', 'testing']}