[PATCH 3 of 9 seda] [code gen] Change cardinality of seda_mime_type_to and seda_format_id_to relations

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Oct 12 16:59:48 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1507732821 -7200
#      Wed Oct 11 16:40:21 2017 +0200
# Node ID 5b3ec7300aaec6a5c726b8c952db4bb4605f0b5e
# Parent  0f01adf6f65eaa9c97734763cec3ca45de9fb8a3
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r 5b3ec7300aae
[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

diff --git a/cubicweb_seda/migration/0.11.0_Any.py b/cubicweb_seda/migration/0.11.0_Any.py
--- a/cubicweb_seda/migration/0.11.0_Any.py
+++ b/cubicweb_seda/migration/0.11.0_Any.py
@@ -45,5 +45,8 @@ for i, concept in enumerate(rset.entitie
 sync_schema_props_perms('user_cardinality')
 
 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')
diff --git a/cubicweb_seda/schema/seda2.py b/cubicweb_seda/schema/seda2.py
--- a/cubicweb_seda/schema/seda2.py
+++ b/cubicweb_seda/schema/seda2.py
@@ -905,13 +905,13 @@ class binary_data_object_mime_type_from(
 
 class mime_type_mime_type_to(RelationDefinition):
     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',
                       annotable=True)
 class SEDAFormatId(EntityType):
@@ -929,13 +929,13 @@ class binary_data_object_format_id_from(
 
 class format_id_format_id_to(RelationDefinition):
     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',
                       annotable=True)
 class SEDAEncoding(EntityType):
diff --git a/cubicweb_seda/xsd2yams.py b/cubicweb_seda/xsd2yams.py
--- a/cubicweb_seda/xsd2yams.py
+++ b/cubicweb_seda/xsd2yams.py
@@ -1,6 +1,6 @@
-# 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 at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Lesser General Public License as published by the Free
 # Software Foundation, either version 2.1 of the License, or (at your option)
@@ -199,10 +199,12 @@ RTYPE_CARDS = {
     'seda_binary_data_object': '?*',
     'seda_comment': '1?',
     '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',
 }
 RTYPE_CARD = {
     'seda_custodial_history_item': '*',
@@ -378,10 +380,12 @@ class XSYMapping(object):
                         rdef_options['alias'] = _alias(objtype, rtype)
                     # compute rdef cardinalities depending on composite and fixedcard
                     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':
                         rdef_options['card'] = '1' + fixedcard
                     elif fixedcard in '1?':


More information about the saem-devel mailing list