[code gen] Change cardinality of seda_mime_type_to and seda_format_id_to relations
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 Oct 2017 16:40:21 +0200
changeset 2749 5b3ec7300aae
parent 2746 0f01adf6f65e
child 2750 1ef4f5936c15
[code gen] Change cardinality of seda_mime_type_to and seda_format_id_to relations So they may link to several mime types / formats deducted from the file category. This was actually not very usable before, since one could not expect a single pronom format (e.g. for a specific PDF version). Related to #36331831
cubicweb_seda/migration/0.11.0_Any.py
cubicweb_seda/schema/seda2.py
cubicweb_seda/xsd2yams.py
--- a/cubicweb_seda/migration/0.11.0_Any.py	Wed Oct 11 15:12:19 2017 +0200
+++ b/cubicweb_seda/migration/0.11.0_Any.py	Wed Oct 11 16:40:21 2017 +0200
@@ -47,3 +47,6 @@
 add_relation_type('file_category')
 
 import_seda_schemes(cnx)
+
+sync_schema_props_perms('seda_mime_type_to')
+sync_schema_props_perms('seda_format_id_to')
--- a/cubicweb_seda/schema/seda2.py	Wed Oct 11 15:12:19 2017 +0200
+++ b/cubicweb_seda/schema/seda2.py	Wed Oct 11 16:40:21 2017 +0200
@@ -907,9 +907,9 @@
     name = 'seda_mime_type_to'
     subject = 'SEDAMimeType'
     object = 'Concept'
-    cardinality = '?*'
+    cardinality = '**'
     composite = fulltext_container = None
-    inlined = True
+    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")')]
 
 @seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='1',
@@ -931,9 +931,9 @@
     name = 'seda_format_id_to'
     subject = 'SEDAFormatId'
     object = 'Concept'
-    cardinality = '?*'
+    cardinality = '**'
     composite = fulltext_container = None
-    inlined = True
+    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')]
 
 @seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='1',
--- a/cubicweb_seda/xsd2yams.py	Wed Oct 11 15:12:19 2017 +0200
+++ b/cubicweb_seda/xsd2yams.py	Wed Oct 11 16:40:21 2017 +0200
@@ -1,4 +1,4 @@
-# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact@logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -201,6 +201,8 @@
     'seda_custodial_history_item': '1*',
     'seda_description': '1?',
     'seda_description_level': '1*',
+    'seda_format_id_to': '**',
+    'seda_mime_type_to': '**',
     'seda_physical_data_object': '?*',
     'seda_title': '11',
 }
@@ -380,6 +382,8 @@
                     composite = rdef_options.get('composite')
                     if rtype in RTYPE_CARDS:
                         rdef_options['card'] = RTYPE_CARDS[rtype]
+                        if RTYPE_CARDS[rtype][0] not in '?1':
+                            rdef_options['inlined'] = False
                     elif composite == 'subject':
                         rdef_options['card'] = fixedcard + '1'
                     elif composite == 'object':