[schema] Fix constraints on seda_mime_type_to and seda_format_id_to relation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 07 Nov 2017 11:15:56 +0100
changeset 2867 fab0834688f7
parent 2866 e2cdb08a7e12
child 2868 9a71e061a886
[schema] Fix constraints on seda_mime_type_to and seda_format_id_to relation The former add to be redirected to use the vocabulary bound to 'file_category' relation, which is also true for the later but this one requires more changes now that it may be used in simplified profile as well.
cubicweb_seda/migration/0.12.0_Any.py
cubicweb_seda/schema/seda2.py
cubicweb_seda/xsd2yams.py
--- a/cubicweb_seda/migration/0.12.0_Any.py	Fri Nov 03 12:04:04 2017 +0100
+++ b/cubicweb_seda/migration/0.12.0_Any.py	Tue Nov 07 11:15:56 2017 +0100
@@ -7,3 +7,6 @@
 rql('INSERT SEDAFormatId X: X user_cardinality "0..1", X seda_format_id_from BDO '
     'WHERE NOT Y seda_format_id_from BDO')
 commit()
+
+sync_schema_props_perms('seda_mime_type_to')
+sync_schema_props_perms('seda_format_id_to')
--- a/cubicweb_seda/schema/seda2.py	Fri Nov 03 12:04:04 2017 +0100
+++ b/cubicweb_seda/schema/seda2.py	Tue Nov 07 11:15:56 2017 +0100
@@ -910,7 +910,7 @@
     cardinality = '**'
     composite = fulltext_container = None
     inlined = False
-    constraints = [RQLConstraint('O in_scheme CS, EXISTS(CACLV seda_mime_type_code_list_version_from AT,        CACLV seda_mime_type_code_list_version_to CS,       S container AT) OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT,            RT name "seda_mime_type_to")')]
+    constraints = [RQLConstraint('O in_scheme CS, EXISTS(CACLV seda_mime_type_code_list_version_from AT,        CACLV seda_mime_type_code_list_version_to CS,       S container AT) OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT,            RT name "file_category")')]
 
 @seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='1',
                       annotable=True)
@@ -934,7 +934,7 @@
     cardinality = '**'
     composite = fulltext_container = None
     inlined = False
-    constraints = [RQLConstraint('O in_scheme CS, CACL seda_file_format_code_list_version_from AT, CACL seda_file_format_code_list_version_to CS, S container AT')]
+    constraints = [RQLConstraint('O in_scheme CS, EXISTS(CACL seda_file_format_code_list_version_from AT,        CACL seda_file_format_code_list_version_to CS,        S container AT) OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT,            RT name "file_category")')]
 
 @seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='1',
                       annotable=True)
--- a/cubicweb_seda/xsd2yams.py	Fri Nov 03 12:04:04 2017 +0100
+++ b/cubicweb_seda/xsd2yams.py	Tue Nov 07 11:15:56 2017 +0100
@@ -131,7 +131,7 @@
         '       CACLV seda_mime_type_code_list_version_to CS,'
         '       S container AT)'
         ' OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT, '
-        '           RT name "seda_mime_type_to")'),
+        '           RT name "file_category")'),
     'seda_encoding_to': (
         'O in_scheme CS, '
         'EXISTS(CACLV seda_encoding_code_list_version_from AT, '
@@ -140,9 +140,12 @@
         ' OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT, '
         '           RT name "seda_encoding_to")'),
     'seda_format_id_to': (
-        'O in_scheme CS, CACL seda_file_format_code_list_version_from AT, '
-        'CACL seda_file_format_code_list_version_to CS, '
-        'S container AT'),
+        'O in_scheme CS, '
+        'EXISTS(CACL seda_file_format_code_list_version_from AT, '
+        '       CACL seda_file_format_code_list_version_to CS, '
+        '       S container AT)'
+        ' OR EXISTS(S container AU, AU is SEDAArchiveUnit, CS scheme_relation_type RT, '
+        '           RT name "file_category")'),
     'seda_data_object_version_to': (
         'O in_scheme CS, CACLV seda_data_object_version_code_list_version_from AT, '
         'CACLV seda_data_object_version_code_list_version_to CS,'