Commit da609b2f authored by Yann Voté's avatar Yann Voté
Browse files

[code gen] Remove CustodialHistory from schema/views/uicfg

It makes no sense to specify it at profile definition time.

We must export it manually when generating an XSD profile, since this is a
required element.
parent a2e13f04b2c1
......@@ -527,21 +527,6 @@ class SEDAKeywordType(AnyEntity):
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
class SEDACustodialHistoryItem(AnyEntity):
__regid__ = 'SEDACustodialHistoryItem'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality', 'custodial_history_item'])
value_attr = 'custodial_history_item'
class SEDACustodialHistoryFile(AnyEntity):
__regid__ = 'SEDACustodialHistoryFile'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
class SEDAwhen(AnyEntity):
__regid__ = 'SEDAwhen'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
value_attr = None
class SEDARelationship(AnyEntity):
__regid__ = 'SEDARelationship'
fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
......
......@@ -205,6 +205,22 @@ class SEDA2XSDExport(EntityAdapter):
if xselement.local_name == 'Signature':
attrs['type'] = 'OpenType'
self._target_element(xselement, profile_element, attrs)
elif xselement.local_name == 'CustodialHistory': # XXX: do not hardcode, read it from xsd
ch = self._target_element(xselement, profile_element, {})
ch_type = self.element('xsd:complexType', ch)
ch_seq = self.element('xsd:sequence', ch_type)
chi = self.element('xsd:element', ch_seq,
attributes={'name': 'CustodialHistoryItem', 'minOccurs': '1',
'maxOccurs': 'unbounded'})
chi_type = self.element('xsd:complexType', chi)
chi_content = self.element('xsd:simpleContent', chi_type)
chi_extension = self.element('xsd:extension', chi_content,
attributes={'base': 'xsd:string'})
self.element('xsd:attribute', chi_extension,
attributes={'name': 'when', 'type': 'datedateTime', 'use': 'optional'})
self.element('xsd:element', ch_seq,
attributes={'name': 'CustodialHistoryFile', 'minOccurs': '0',
'type': 'xsd:IDREF'})
elif isinstance(occ, dict): # fake occurence introduced for some elements'content
# target element has already been introduced: it is now given as profile_element
target_element = profile_element
......
......@@ -129,7 +129,6 @@ class EnsureArchiveUnitHasAContentOp(hook.DataOperationMixIn, hook.Operation):
continue
content = self.cnx.create_entity('SEDAContent', seda_content=seq)
self.cnx.create_entity('SEDATitle', seda_title=content)
self.cnx.create_entity('SEDACustodialHistoryItem', seda_custodial_history_item=content)
class EnsureArchiveUnitHasAContentHook(hook.Hook):
......
......@@ -203,12 +203,6 @@ msgstr ""
msgid "New SEDACreatingOsVersion"
msgstr ""
msgid "New SEDACustodialHistoryFile"
msgstr ""
msgid "New SEDACustodialHistoryItem"
msgstr ""
msgid "New SEDADataObjectReference"
msgstr ""
......@@ -509,9 +503,6 @@ msgstr ""
msgid "New SEDArestrictionValue"
msgstr ""
msgid "New SEDAwhen"
msgstr ""
msgid "SEDA 2.0 export"
msgstr ""
......@@ -860,18 +851,6 @@ msgstr ""
msgid "SEDACreatingOs_plural"
msgstr ""
msgid "SEDACustodialHistoryFile"
msgstr ""
msgid "SEDACustodialHistoryFile_plural"
msgstr ""
msgid "SEDACustodialHistoryItem"
msgstr ""
msgid "SEDACustodialHistoryItem_plural"
msgstr ""
msgid "SEDADataObjectReference"
msgstr ""
......@@ -1751,16 +1730,6 @@ msgstr ""
msgid "SEDArestrictionValue_plural"
msgstr ""
msgid "SEDAwhen"
msgstr ""
msgctxt "inlined:SEDACustodialHistoryItem.seda_when.object"
msgid "SEDAwhen"
msgstr ""
msgid "SEDAwhen_plural"
msgstr ""
msgid ""
"Special relation from a concept scheme to a relation type, that may be used "
"to restrict possible concept of a particular relation without depending on "
......@@ -2013,18 +1982,6 @@ msgstr ""
msgid "This SEDACreatingOsVersion:"
msgstr ""
msgid "This SEDACustodialHistoryFile"
msgstr ""
msgid "This SEDACustodialHistoryFile:"
msgstr ""
msgid "This SEDACustodialHistoryItem"
msgstr ""
msgid "This SEDACustodialHistoryItem:"
msgstr ""
msgid "This SEDADataObjectReference"
msgstr ""
......@@ -2625,12 +2582,6 @@ msgstr ""
msgid "This SEDArestrictionValue:"
msgstr ""
msgid "This SEDAwhen"
msgstr ""
msgid "This SEDAwhen:"
msgstr ""
msgid "add a Agent"
msgstr ""
......@@ -2859,12 +2810,6 @@ msgstr ""
msgid "add a SEDACreatingOsVersion"
msgstr ""
msgid "add a SEDACustodialHistoryFile"
msgstr ""
msgid "add a SEDACustodialHistoryItem"
msgstr ""
msgid "add a SEDADataObjectReference"
msgstr ""
......@@ -3444,13 +3389,6 @@ msgctxt "inlined:SEDAContent.seda_restriction_value.object"
msgid "add a SEDArestrictionValue"
msgstr ""
msgid "add a SEDAwhen"
msgstr ""
msgctxt "inlined:SEDACustodialHistoryItem.seda_when.object"
msgid "add a SEDAwhen"
msgstr ""
msgid "archival_agency_archive_unit_identifier"
msgstr ""
......@@ -3645,14 +3583,6 @@ msgctxt "SEDACreatingOsVersion"
msgid "container"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "container"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "container"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "container"
msgstr ""
......@@ -4053,10 +3983,6 @@ msgctxt "SEDArestrictionValue"
msgid "container"
msgstr ""
msgctxt "SEDAwhen"
msgid "container"
msgstr ""
msgid "container_object"
msgstr ""
......@@ -4212,12 +4138,6 @@ msgstr ""
msgid "ctxcomponents_seda.tree_description"
msgstr ""
msgid "custodial_history_item"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "custodial_history_item"
msgstr ""
msgctxt "SEDADescription"
msgid "description"
......@@ -5173,34 +5093,6 @@ msgctxt "SEDABinaryDataObject"
msgid "seda_creating_os_version_object"
msgstr ""
msgid "seda_custodial_history_file"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "seda_custodial_history_file"
msgstr ""
msgid "seda_custodial_history_file_object"
msgstr ""
msgctxt "SEDAContent"
msgid "seda_custodial_history_file_object"
msgstr ""
msgid "seda_custodial_history_item"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "seda_custodial_history_item"
msgstr ""
msgid "seda_custodial_history_item_object"
msgstr ""
msgctxt "SEDAContent"
msgid "seda_custodial_history_item_object"
msgstr ""
msgid "seda_data_object_reference"
msgstr ""
......@@ -5211,10 +5103,6 @@ msgstr ""
msgid "seda_data_object_reference_id"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "seda_data_object_reference_id"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "seda_data_object_reference_id"
msgstr ""
......@@ -7231,20 +7119,6 @@ msgctxt "SEDAPhysicalDataObject"
msgid "seda_weight_object"
msgstr ""
msgid "seda_when"
msgstr ""
msgctxt "SEDAwhen"
msgid "seda_when"
msgstr ""
msgid "seda_when_object"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "seda_when_object"
msgstr ""
msgid "seda_width"
msgstr ""
......@@ -7493,14 +7367,6 @@ msgctxt "SEDACreatingOsVersion"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "user_cardinality"
msgstr ""
......@@ -7881,10 +7747,6 @@ msgctxt "SEDArestrictionValue"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDAwhen"
msgid "user_cardinality"
msgstr ""
msgid "version"
msgstr ""
......
......@@ -206,12 +206,6 @@ msgstr ""
msgid "New SEDACreatingOsVersion"
msgstr ""
msgid "New SEDACustodialHistoryFile"
msgstr ""
msgid "New SEDACustodialHistoryItem"
msgstr ""
msgid "New SEDADataObjectReference"
msgstr ""
......@@ -512,9 +506,6 @@ msgstr ""
msgid "New SEDArestrictionValue"
msgstr ""
msgid "New SEDAwhen"
msgstr ""
msgid "SEDA 2.0 export"
msgstr ""
......@@ -863,18 +854,6 @@ msgstr ""
msgid "SEDACreatingOs_plural"
msgstr ""
msgid "SEDACustodialHistoryFile"
msgstr ""
msgid "SEDACustodialHistoryFile_plural"
msgstr ""
msgid "SEDACustodialHistoryItem"
msgstr ""
msgid "SEDACustodialHistoryItem_plural"
msgstr ""
msgid "SEDADataObjectReference"
msgstr ""
......@@ -1754,16 +1733,6 @@ msgstr ""
msgid "SEDArestrictionValue_plural"
msgstr ""
msgid "SEDAwhen"
msgstr "date"
msgctxt "inlined:SEDACustodialHistoryItem.seda_when.object"
msgid "SEDAwhen"
msgstr ""
msgid "SEDAwhen_plural"
msgstr ""
msgid ""
"Special relation from a concept scheme to a relation type, that may be used "
"to restrict possible concept of a particular relation without depending on "
......@@ -2016,18 +1985,6 @@ msgstr ""
msgid "This SEDACreatingOsVersion:"
msgstr ""
msgid "This SEDACustodialHistoryFile"
msgstr ""
msgid "This SEDACustodialHistoryFile:"
msgstr ""
msgid "This SEDACustodialHistoryItem"
msgstr ""
msgid "This SEDACustodialHistoryItem:"
msgstr ""
msgid "This SEDADataObjectReference"
msgstr ""
......@@ -2628,12 +2585,6 @@ msgstr ""
msgid "This SEDArestrictionValue:"
msgstr ""
msgid "This SEDAwhen"
msgstr ""
msgid "This SEDAwhen:"
msgstr ""
msgid "add a Agent"
msgstr ""
......@@ -2862,12 +2813,6 @@ msgstr ""
msgid "add a SEDACreatingOsVersion"
msgstr ""
msgid "add a SEDACustodialHistoryFile"
msgstr "ajouter une référence à un fichier de journalisation externe"
msgid "add a SEDACustodialHistoryItem"
msgstr ""
msgid "add a SEDADataObjectReference"
msgstr ""
......@@ -3447,12 +3392,6 @@ msgctxt "inlined:SEDAContent.seda_restriction_value.object"
msgid "add a SEDArestrictionValue"
msgstr ""
msgid "add a SEDAwhen"
msgstr "ajouter un horodatage"
msgctxt "inlined:SEDACustodialHistoryItem.seda_when.object"
msgid "add a SEDAwhen"
msgstr ""
msgid "archival_agency_archive_unit_identifier"
msgstr "valeur"
......@@ -3648,14 +3587,6 @@ msgctxt "SEDACreatingOsVersion"
msgid "container"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "container"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "container"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "container"
msgstr ""
......@@ -4056,10 +3987,6 @@ msgctxt "SEDArestrictionValue"
msgid "container"
msgstr ""
msgctxt "SEDAwhen"
msgid "container"
msgstr ""
msgid "container_object"
msgstr ""
......@@ -4220,12 +4147,6 @@ msgstr ""
msgid "ctxcomponents_seda.tree_description"
msgstr ""
msgid "custodial_history_item"
msgstr "période ou évènement"
msgctxt "SEDACustodialHistoryItem"
msgid "custodial_history_item"
msgstr ""
msgctxt "SEDADescription"
msgid "description"
......@@ -5181,34 +5102,6 @@ msgctxt "SEDABinaryDataObject"
msgid "seda_creating_os_version_object"
msgstr ""
msgid "seda_custodial_history_file"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "seda_custodial_history_file"
msgstr ""
msgid "seda_custodial_history_file_object"
msgstr ""
msgctxt "SEDAContent"
msgid "seda_custodial_history_file_object"
msgstr ""
msgid "seda_custodial_history_item"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "seda_custodial_history_item"
msgstr ""
msgid "seda_custodial_history_item_object"
msgstr "élément d'historique"
msgctxt "SEDAContent"
msgid "seda_custodial_history_item_object"
msgstr ""
msgid "seda_data_object_reference"
msgstr ""
......@@ -5219,10 +5112,6 @@ msgstr ""
msgid "seda_data_object_reference_id"
msgstr "objet-données référencé"
msgctxt "SEDACustodialHistoryFile"
msgid "seda_data_object_reference_id"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "seda_data_object_reference_id"
msgstr ""
......@@ -7239,20 +7128,6 @@ msgctxt "SEDAPhysicalDataObject"
msgid "seda_weight_object"
msgstr ""
msgid "seda_when"
msgstr ""
msgctxt "SEDAwhen"
msgid "seda_when"
msgstr ""
msgid "seda_when_object"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "seda_when_object"
msgstr ""
msgid "seda_width"
msgstr ""
......@@ -7501,14 +7376,6 @@ msgctxt "SEDACreatingOsVersion"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDACustodialHistoryFile"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDACustodialHistoryItem"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDADataObjectReference"
msgid "user_cardinality"
msgstr ""
......@@ -7889,10 +7756,6 @@ msgctxt "SEDArestrictionValue"
msgid "user_cardinality"
msgstr ""
msgctxt "SEDAwhen"
msgid "user_cardinality"
msgstr ""
msgid "version"
msgstr "valeur"
......
......@@ -1882,61 +1882,6 @@ class keyword_type_keyword_type_to(RelationDefinition):
inlined = True
constraints = [RQLConstraint('O in_scheme CS, CS scheme_relation_type CR, CR name "seda_keyword_type_to"')]
@seda_profile_element(cardinalities=['1..n', '1'], default_cardinality='1..n',
annotable=False)
class SEDACustodialHistoryItem(EntityType):
u""""""
custodial_history_item = String()
class content_custodial_history_item(RelationDefinition):
name = 'seda_custodial_history_item'
subject = 'SEDACustodialHistoryItem'
object = 'SEDAContent'
cardinality = '1+'
composite = fulltext_container = 'object'
inlined = True
constraints = []
@seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
annotable=False)
class SEDACustodialHistoryFile(EntityType):
u""""""
class content_custodial_history_file(RelationDefinition):
name = 'seda_custodial_history_file'
subject = 'SEDACustodialHistoryFile'
object = 'SEDAContent'
cardinality = '1?'
composite = fulltext_container = 'object'
inlined = True
constraints = []
class custodial_history_file_data_object_reference_id(RelationDefinition):
name = 'seda_data_object_reference_id'
subject = 'SEDACustodialHistoryFile'
object = ('SEDABinaryDataObject', 'SEDAPhysicalDataObject')
cardinality = '?*'
composite = fulltext_container = None
inlined = True
constraints = [RQLConstraint('S container C, O container C')]
@seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
annotable=False)
class SEDAwhen(EntityType):
u""""""
class custodial_history_item_when(RelationDefinition):
name = 'seda_when'
subject = 'SEDAwhen'
object = 'SEDACustodialHistoryItem'
cardinality = '1?'
composite = fulltext_container = 'object'
inlined = True
constraints = []
class seq_alt_archive_unit_archive_unit_ref_id_management_storage_rule(RelationDefinition):
name = 'seda_storage_rule'
subject = 'SEDAStorageRule'
......
......@@ -75,10 +75,9 @@ class ArchiveUnitContentTC(CubicWebTC):
au = cnx.entity_from_eid(au.eid)
# Check that a SEDAContent has been created
self.assertTrue(au.first_level_choice.content_sequence.reverse_seda_content)
# A title and a custodial history item have also been created
# A title have also been created
content = au.first_level_choice.content_sequence.reverse_seda_content[0]
self.assertTrue(content.reverse_seda_title)
self.assertTrue(content.reverse_seda_custodial_history_item)
def test_no_new_content_create(self):
"""Check that a SEDAContent entity is not created when an ArchiveUnit with one is created.
......@@ -94,7 +93,6 @@ class ArchiveUnitContentTC(CubicWebTC):
reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management=alt)
content = cnx.create_entity('SEDAContent', seda_content=seq)
cnx.create_entity('SEDATitle', seda_title=content)
cnx.create_entity('SEDACustodialHistoryItem', seda_custodial_history_item=content)
cnx.commit()
au = cnx.entity_from_eid(au.eid)
# Check that no new SEDAContent has been created
......
......@@ -369,8 +369,6 @@ class SEDAXSDExportFuncTC(XmlTestMixin, CubicWebTC):
create('SEDAKeywordReference', seda_keyword_reference_from=kw,
seda_keyword_reference_to_scheme=scheme)
create('SEDAKeywordContent', reverse_seda_keyword_content=kw)
history_item = create('SEDACustodialHistoryItem', seda_custodial_history_item=content)
create('SEDAwhen', seda_when=history_item)
version_of = create('SEDAIsVersionOf', seda_is_version_of=content)
alt2 = create('SEDAAltIsVersionOfArchiveUnitRefId',
reverse_seda_alt_is_version_of_archive_unit_ref_id=version_of)
......
......@@ -107,6 +107,13 @@ class XSIterateTC(unittest.TestCase):
]))
self.assertRaises(StopIteration, next, element_defs)
def test_custodial_history(self):
mapping = XSDMMapping('Content')
edef = mapping[mapping.element_by_name('Content')]
edef = readable_edef(edef)
custodial_def = [x for x in edef[1] if x[0] == 'CustodialHistory']
self.assertEqual(custodial_def[0], ('CustodialHistory', []))
def test_binarydataobject(self):
element_defs = XSDMMapping('BinaryDataObject')
edef = next(iter(element_defs))
......
......@@ -91,7 +91,6 @@ class ContentTabbedPrimaryView(tabs.TabbedPrimaryView):
_('seda_content_classification_tab'),
_('seda_content_relation_tab'),
_('seda_content_event_tab'),
_('seda_content_history_tab'),
]
......@@ -236,18 +235,6 @@ class ContentEventTab(viewlib.SubObjectsTab):
_('creating SEDAEvent (SEDAEvent seda_event SEDAContent %(linkto)s)')