[SEDA 2.1] Implement new LegalStatus management information
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Mar 2017 10:21:01 +0100
changeset 2401 317b5c7b3d49
parent 2400 83e093bfa6b9
child 2402 ad791cf90bc2
[SEDA 2.1] Implement new LegalStatus management information
cubicweb_seda/dataimport.py
cubicweb_seda/entities/generated.py
cubicweb_seda/i18n/en.po
cubicweb_seda/i18n/fr.po
cubicweb_seda/migration/0.8.0_Any.py
cubicweb_seda/migration/data/legal_status.csv
cubicweb_seda/schema/seda2.py
cubicweb_seda/views/archivetransfer.py
cubicweb_seda/views/uicfg.py
cubicweb_seda/xsd.py
cubicweb_seda/xsd/seda-2.0-main.xsd
cubicweb_seda/xsd2yams.py
test/test_dataimport.py
test/test_xsd2yams.py
--- a/cubicweb_seda/dataimport.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/dataimport.py	Fri Mar 03 10:21:01 2017 +0100
@@ -45,6 +45,9 @@
     (u'SEDA 2 : Types de mot-clé',
      'seda_keyword_type_to', (),
      'code_keyword_type.csv'),
+    (u'SEDA 2 : Status légaux',
+     'seda_legal_status_to', (),
+     'legal_status.csv'),
     (u'SEDA : Niveaux de description',
      'seda_description_level', (),
      'level_type.csv'),
--- a/cubicweb_seda/entities/generated.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/entities/generated.py	Fri Mar 03 10:21:01 2017 +0100
@@ -153,6 +153,11 @@
     fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality', 'service_level', 'user_annotation'])
     value_attr = 'service_level'
 
+class SEDALegalStatus(SEDAAnyEntity):
+    __regid__ = 'SEDALegalStatus'
+    fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
+    value_attr = None
+
 class SEDAStorageRule(SEDAAnyEntity):
     __regid__ = 'SEDAStorageRule'
     fetch_attrs, cw_fetch_order = fetch_config(['user_cardinality'])
--- a/cubicweb_seda/i18n/en.po	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/i18n/en.po	Fri Mar 03 10:21:01 2017 +0100
@@ -350,6 +350,9 @@
 msgid "New SEDALastModified"
 msgstr ""
 
+msgid "New SEDALegalStatus"
+msgstr ""
+
 msgid "New SEDALength"
 msgstr ""
 
@@ -1275,6 +1278,16 @@
 msgid "SEDALastModified_plural"
 msgstr ""
 
+msgid "SEDALegalStatus"
+msgstr ""
+
+msgctxt "inlined:SEDAArchiveTransfer.seda_legal_status_from.object"
+msgid "SEDALegalStatus"
+msgstr ""
+
+msgid "SEDALegalStatus_plural"
+msgstr ""
+
 msgid "SEDALength"
 msgstr ""
 
@@ -2437,6 +2450,12 @@
 msgid "This SEDALastModified:"
 msgstr ""
 
+msgid "This SEDALegalStatus"
+msgstr ""
+
+msgid "This SEDALegalStatus:"
+msgstr ""
+
 msgid "This SEDALength"
 msgstr ""
 
@@ -3299,6 +3318,13 @@
 msgid "add a SEDALastModified"
 msgstr ""
 
+msgid "add a SEDALegalStatus"
+msgstr ""
+
+msgctxt "inlined:SEDAArchiveTransfer.seda_legal_status_from.object"
+msgid "add a SEDALegalStatus"
+msgstr ""
+
 msgid "add a SEDALength"
 msgstr ""
 
@@ -4156,6 +4182,10 @@
 msgid "container"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "container"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "container"
 msgstr ""
@@ -6358,6 +6388,34 @@
 msgid "seda_last_modified_object"
 msgstr ""
 
+msgid "seda_legal_status_from"
+msgstr ""
+
+msgctxt "SEDALegalStatus"
+msgid "seda_legal_status_from"
+msgstr ""
+
+msgid "seda_legal_status_from_object"
+msgstr ""
+
+msgctxt "SEDAArchiveTransfer"
+msgid "seda_legal_status_from_object"
+msgstr ""
+
+msgid "seda_legal_status_to"
+msgstr ""
+
+msgctxt "SEDALegalStatus"
+msgid "seda_legal_status_to"
+msgstr ""
+
+msgid "seda_legal_status_to_object"
+msgstr ""
+
+msgctxt "Concept"
+msgid "seda_legal_status_to_object"
+msgstr ""
+
 msgid "seda_length"
 msgstr ""
 
@@ -7992,6 +8050,10 @@
 msgid "user_annotation"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "user_annotation"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "user_annotation"
 msgstr ""
@@ -8491,6 +8553,10 @@
 msgid "user_cardinality"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "user_cardinality"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "user_cardinality"
 msgstr ""
--- a/cubicweb_seda/i18n/fr.po	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/i18n/fr.po	Fri Mar 03 10:21:01 2017 +0100
@@ -357,6 +357,9 @@
 msgid "New SEDALastModified"
 msgstr ""
 
+msgid "New SEDALegalStatus"
+msgstr ""
+
 msgid "New SEDALength"
 msgstr ""
 
@@ -1285,6 +1288,16 @@
 msgid "SEDALastModified_plural"
 msgstr ""
 
+msgid "SEDALegalStatus"
+msgstr ""
+
+msgctxt "inlined:SEDAArchiveTransfer.seda_legal_status_from.object"
+msgid "SEDALegalStatus"
+msgstr ""
+
+msgid "SEDALegalStatus_plural"
+msgstr ""
+
 msgid "SEDALength"
 msgstr ""
 
@@ -2449,6 +2462,12 @@
 msgid "This SEDALastModified:"
 msgstr ""
 
+msgid "This SEDALegalStatus"
+msgstr ""
+
+msgid "This SEDALegalStatus:"
+msgstr ""
+
 msgid "This SEDALength"
 msgstr ""
 
@@ -3313,6 +3332,13 @@
 msgid "add a SEDALastModified"
 msgstr ""
 
+msgid "add a SEDALegalStatus"
+msgstr ""
+
+msgctxt "inlined:SEDAArchiveTransfer.seda_legal_status_from.object"
+msgid "add a SEDALegalStatus"
+msgstr ""
+
 msgid "add a SEDALength"
 msgstr ""
 
@@ -4170,6 +4196,10 @@
 msgid "container"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "container"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "container"
 msgstr ""
@@ -6379,6 +6409,34 @@
 msgid "seda_last_modified_object"
 msgstr ""
 
+msgid "seda_legal_status_from"
+msgstr ""
+
+msgctxt "SEDALegalStatus"
+msgid "seda_legal_status_from"
+msgstr ""
+
+msgid "seda_legal_status_from_object"
+msgstr "statut légal"
+
+msgctxt "SEDAArchiveTransfer"
+msgid "seda_legal_status_from_object"
+msgstr ""
+
+msgid "seda_legal_status_to"
+msgstr "valeur"
+
+msgctxt "SEDALegalStatus"
+msgid "seda_legal_status_to"
+msgstr ""
+
+msgid "seda_legal_status_to_object"
+msgstr ""
+
+msgctxt "Concept"
+msgid "seda_legal_status_to_object"
+msgstr ""
+
 msgid "seda_length"
 msgstr ""
 
@@ -8019,6 +8077,10 @@
 msgid "user_annotation"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "user_annotation"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "user_annotation"
 msgstr ""
@@ -8518,6 +8580,10 @@
 msgid "user_cardinality"
 msgstr ""
 
+msgctxt "SEDALegalStatus"
+msgid "user_cardinality"
+msgstr ""
+
 msgctxt "SEDALength"
 msgid "user_cardinality"
 msgstr ""
--- a/cubicweb_seda/migration/0.8.0_Any.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/migration/0.8.0_Any.py	Fri Mar 03 10:21:01 2017 +0100
@@ -1,1 +1,9 @@
+from cubicweb_seda.dataimport import import_seda_schemes, LCSV_FILES
+
+add_entity_type('SEDALegalStatus')
+
+lcsv_files = [file_def for file_def in LCSV_FILES
+              if file_def[-1] == 'legal_status.csv']
+import_seda_schemes(cnx, lcsv_files=lcsv_files)
+
 drop_relation_type('seda_reply_code_list_version')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb_seda/migration/data/legal_status.csv	Fri Mar 03 10:21:01 2017 +0100
@@ -0,0 +1,6 @@
+#;$id;Valeur;définition
+type;url;string;string
+lang;;seda;fr
+url;skos:Concept;skos:prefLabel;skos:prefLabel
+;;Public Archive;Archive publique
+;;Private Archive;Archive privée
--- a/cubicweb_seda/schema/seda2.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/schema/seda2.py	Fri Mar 03 10:21:01 2017 +0100
@@ -552,6 +552,31 @@
 
 @seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
                       annotable=True)
+class SEDALegalStatus(EntityType):
+    u""""""
+
+
+class archive_transfer_legal_status_from(RelationDefinition):
+    name = 'seda_legal_status_from'
+    subject = 'SEDALegalStatus'
+    object = 'SEDAArchiveTransfer'
+    cardinality = '1?'
+    composite = fulltext_container = 'object'
+    inlined = True
+    constraints = []
+
+class legal_status_legal_status_to(RelationDefinition):
+    name = 'seda_legal_status_to'
+    subject = 'SEDALegalStatus'
+    object = 'Concept'
+    cardinality = '?*'
+    composite = fulltext_container = None
+    inlined = True
+    constraints = [RQLConstraint('O in_scheme CS, CS scheme_relation_type CR, CR name "seda_legal_status_to"')]
+
+
+@seda_profile_element(cardinalities=['0..1', '1'], default_cardinality='0..1',
+                      annotable=True)
 class SEDAStorageRule(EntityType):
     u""""""
 
--- a/cubicweb_seda/views/archivetransfer.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/views/archivetransfer.py	Fri Mar 03 10:21:01 2017 +0100
@@ -38,7 +38,8 @@
     ('seda_comment', 'object'),
     ('seda_signature', 'object'),
     ('seda_archival_agreement', 'object'),
-    ('seda_service_level', 'object')]
+    ('seda_service_level', 'object'),
+    ('seda_legal_status_from', 'object')]
 
 pvs = uicfg.primaryview_section
 pvdc = uicfg.primaryview_display_ctrl
--- a/cubicweb_seda/views/uicfg.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/views/uicfg.py	Fri Mar 03 10:21:01 2017 +0100
@@ -72,6 +72,7 @@
 ives['SEDAAltStorageRulePreventInheritance'] = 'subobject'
 ives['SEDAWriter'] = 'subobject'
 ives['SEDAAccessRuleCodeListVersion'] = 'subobject'
+ives['SEDALegalStatus'] = 'subobject'
 ives['SEDADisseminationRule'] = 'subobject'
 ives['SEDAAddressee'] = 'subobject'
 ives['SEDAReferences'] = 'subobject'
@@ -240,6 +241,10 @@
 abaa.tag_object_of(('*', 'seda_archive_unit', '*'), False)
 abaa.tag_subject_of(('*', 'seda_service_level', '*'), False)
 abaa.tag_object_of(('*', 'seda_service_level', '*'), False)
+abaa.tag_subject_of(('*', 'seda_legal_status_from', '*'), False)
+abaa.tag_object_of(('*', 'seda_legal_status_from', '*'), False)
+abaa.tag_object_of(('*', 'seda_legal_status_to', '*'), False)
+abaa.tag_subject_of(('*', 'seda_legal_status_to', '*'), False)
 abaa.tag_subject_of(('*', 'seda_storage_rule', '*'), False)
 abaa.tag_object_of(('*', 'seda_storage_rule', '*'), False)
 abaa.tag_subject_of(('*', 'seda_appraisal_rule', '*'), False)
@@ -649,6 +654,10 @@
 afs.tag_object_of(('*', 'seda_archive_unit', '*'), 'main', 'hidden')
 afs.tag_subject_of(('*', 'seda_service_level', '*'), 'main', 'hidden')
 afs.tag_object_of(('*', 'seda_service_level', '*'), 'main', 'inlined')
+afs.tag_subject_of(('*', 'seda_legal_status_from', '*'), 'main', 'hidden')
+afs.tag_object_of(('*', 'seda_legal_status_from', '*'), 'main', 'inlined')
+afs.tag_object_of(('*', 'seda_legal_status_to', '*'), 'main', 'hidden')
+afs.tag_subject_of(('*', 'seda_legal_status_to', '*'), 'main', 'attributes')
 afs.tag_subject_of(('*', 'seda_storage_rule', '*'), 'main', 'hidden')
 afs.tag_object_of(('*', 'seda_storage_rule', '*'), 'main', 'hidden')
 afs.tag_subject_of(('*', 'seda_appraisal_rule', '*'), 'main', 'hidden')
@@ -982,6 +991,7 @@
 pvs.tag_object_of(('*', 'seda_data_object_version_to', '*'), 'hidden')
 pvs.tag_subject_of(('*', 'seda_archive_unit', '*'), 'hidden')
 pvs.tag_object_of(('*', 'seda_archive_unit', '*'), 'hidden')
+pvs.tag_object_of(('*', 'seda_legal_status_to', '*'), 'hidden')
 pvs.tag_subject_of(('*', 'seda_storage_rule', '*'), 'hidden')
 pvs.tag_object_of(('*', 'seda_storage_rule', '*'), 'hidden')
 pvs.tag_subject_of(('*', 'seda_appraisal_rule', '*'), 'hidden')
@@ -1142,6 +1152,8 @@
 rec.tag_object_of(('*', 'seda_compressed', '*'), {'novalue_label': ' '})
 rec.tag_subject_of(('*', 'service_level', '*'), {'novalue_label': '<no value specified>'})
 rec.tag_object_of(('*', 'seda_service_level', '*'), {'novalue_label': ' '})
+rec.tag_object_of(('*', 'seda_legal_status_from', '*'), {'novalue_label': ' '})
+rec.tag_subject_of(('*', 'seda_legal_status_to', '*'), {'novalue_label': '<no value specified>'})
 rec.tag_object_of(('*', 'seda_storage_rule', '*'), {'novalue_label': ' '})
 rec.tag_object_of(('*', 'seda_appraisal_rule', '*'), {'novalue_label': ' '})
 rec.tag_object_of(('*', 'seda_access_rule', '*'), {'novalue_label': ' '})
--- a/cubicweb_seda/xsd.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/xsd.py	Fri Mar 03 10:21:01 2017 +0100
@@ -136,6 +136,7 @@
     'Encoding': 'Concept',
     'MimeType': 'Concept',
     'EventType': 'Concept',
+    'LegalStatus': 'Concept',
     'KeywordType': 'Concept',
     'KeywordReference': 'Concept',
     'CompressionAlgorithm': 'Concept',
--- a/cubicweb_seda/xsd/seda-2.0-main.xsd	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/xsd/seda-2.0-main.xsd	Fri Mar 03 10:21:01 2017 +0100
@@ -138,6 +138,11 @@
                     <xsd:documentation>Niveau de service applicable aux unités d’archives.</xsd:documentation>
                 </xsd:annotation>
             </xsd:element>
+            <xsd:element name="LegalStatus" type="LegalStatusType" minOccurs="0">
+                <xsd:annotation>
+                    <xsd:documentation>Statut des archives échangées.</xsd:documentation>
+                </xsd:annotation>
+            </xsd:element>
             <xsd:group ref="ManagementGroup" minOccurs="0">
                 <xsd:annotation>
                     <xsd:documentation>Métadonnées de gestion associées à l'ensemble des unités d'archives.</xsd:documentation>
@@ -146,6 +151,19 @@
         </xsd:sequence>
         <xsd:attribute ref="xml:id" use="optional"/>
     </xsd:complexType>
+    
+    <!-- ========================================================= -->
+    <!-- ===== Code List LegalStatusType: LegalStatus Code ======= -->
+    <!-- ========================================================= -->
+    <xsd:simpleType name="LegalStatusType">
+        <xsd:annotation>
+            <xsd:documentation>Valeurs de LegalStatus.</xsd:documentation>
+        </xsd:annotation>
+        <xsd:restriction base="xsd:token">
+            <xsd:enumeration value="Public Archive"/>
+            <xsd:enumeration value="Private Archive"/>
+        </xsd:restriction>
+    </xsd:simpleType>
 
     <!-- Demande d'autorisation -->
     <xsd:complexType name="AuthorizationRequestContentType">
--- a/cubicweb_seda/xsd2yams.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/cubicweb_seda/xsd2yams.py	Fri Mar 03 10:21:01 2017 +0100
@@ -95,6 +95,8 @@
         'O in_scheme CS, CS scheme_relation_type CR, CR name "seda_classification_level"'),
     'seda_language_to': (
         'O in_scheme CS, CS scheme_relation_type CR, CR name "seda_language_to"'),
+    'seda_legal_status_to': (
+        'O in_scheme CS, CS scheme_relation_type CR, CR name "seda_legal_status_to"'),
     'seda_description_language_to': (
         'O in_scheme CS, CS scheme_relation_type CR, CR name "seda_description_language_to"'),
     'seda_event_type_to': (
--- a/test/test_dataimport.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/test/test_dataimport.py	Fri Mar 03 10:21:01 2017 +0100
@@ -25,7 +25,7 @@
     def test_import_seda_schemes(self):
         with self.admin_access.client_cnx() as cnx:
             dataimport.import_seda_schemes(cnx, lcsv_import=dataimport.lcsv_check)
-            self.assertEqual(len(cnx.find('ConceptScheme')), 15)
+            self.assertEqual(len(cnx.find('ConceptScheme')), 16)
 
 
 if __name__ == '__main__':
--- a/test/test_xsd2yams.py	Fri Mar 03 10:19:15 2017 +0100
+++ b/test/test_xsd2yams.py	Fri Mar 03 10:21:01 2017 +0100
@@ -269,6 +269,9 @@
                 ('ServiceLevel',
                  [('seda_service_level', 'object', 'SEDAServiceLevel'),
                   ('service_level', 'subject', 'String')]),
+                ('LegalStatus',
+                 [('seda_legal_status_from', 'object', 'SEDALegalStatus'),
+                  ('seda_legal_status_to', 'subject', 'Concept')]),
                 ('StorageRule', [('seda_storage_rule', 'object', 'SEDAStorageRule')]),
                 ('AppraisalRule', [('seda_appraisal_rule', 'object', 'SEDAAppraisalRule')]),
                 ('AccessRule', [('seda_access_rule', 'object', 'SEDAAccessRule')]),