[PATCH seda] [profile gen] Fix position of the Description element in SEDA 0.2/1.0 exports

Sylvain Thénault sylvain.thenault at logilab.fr
Tue Jun 6 10:27:14 CEST 2017



Le 06/06/2017 à 10:22, Sylvain Thenault a écrit :
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1496295150 -7200
> #      Thu Jun 01 07:32:30 2017 +0200
> # Node ID be4ab6888304e2be8c469e1fc4189b2912121e3f
> # Parent  5cda167cef433720c0fa214e66ebd17fa5f65ced
> # Available At https://hg.logilab.org/review/cubes/seda
> #              hg pull https://hg.logilab.org/review/cubes/seda -r be4ab6888304
> [profile gen] Fix position of the Description element in SEDA 0.2/1.0 exports
>
> It should appears first for SEDA 1.0 and after custodial history in SEDA 0.2.
>
> Update export test accordingly and add Description to SEDA 0.2 validation test.
>
> Closes extranet #XXX

sent a v2 with correct ticket number
>
> diff --git a/cubicweb_seda/entities/profile_generation.py b/cubicweb_seda/entities/profile_generation.py
> --- a/cubicweb_seda/entities/profile_generation.py
> +++ b/cubicweb_seda/entities/profile_generation.py
> @@ -968,14 +968,14 @@ class SEDA1XSDExport(SEDA2ExportAdapter)
>  
>      def xsd_content_description(self, parent, content):
>          """Append XSD elements for a description content to the given parent node"""
>          cd_node = self.element_schema(parent, 'ContentDescription',
>                                        xsd_attributes=[XAttr('Id', 'xsd:ID')])
> +        self.xsd_description(cd_node, content)
>          self.xsd_description_level(cd_node, content.description_level_concept)
>          self.xsd_language(cd_node, content)
>          self.xsd_content_dates(cd_node, content)
> -        self.xsd_description(cd_node, content)
>          self.xsd_custodial_history(cd_node, content)
>          self.xsd_keywords(cd_node, content)
>          self.xsd_originating_agency(cd_node, content)
>  
>      def xsd_language(self, parent, content):
> @@ -1202,13 +1202,13 @@ class SEDA02XSDExport(SEDA1XSDExport):
>      def xsd_content_description(self, parent, content):
>          """Append XSD elements for a description content to the given parent node"""
>          cd_node = self.element_schema(parent, 'ContentDescription',
>                                        xsd_attributes=[XAttr('Id', 'xsd:ID')])
>          self.xsd_custodial_history(cd_node, content)
> +        self.xsd_description(cd_node, content)
>          self.xsd_language(cd_node, content)
>          self.xsd_content_dates(cd_node, content)
> -        self.xsd_description(cd_node, content)
>          self.xsd_originating_agency(cd_node, content)
>          self.xsd_keywords(cd_node, content)
>  
>      def xsd_custodial_history(self, parent, content):
>          if content.custodial_history_items:
> diff --git a/test/data/seda_02_bordereau_ref.xml b/test/data/seda_02_bordereau_ref.xml
> --- a/test/data/seda_02_bordereau_ref.xml
> +++ b/test/data/seda_02_bordereau_ref.xml
> @@ -35,10 +35,11 @@
>      <Contains>
>        <DescriptionLevel listVersionID="edition 2009">file</DescriptionLevel>
>        <Name>Kesso</Name>
>        <TransferringAgencyObjectIdentifier>75241/a000000040</TransferringAgencyObjectIdentifier>
>        <ContentDescription>
> +        <Description>Acte n°1234</Description>
>          <Language listVersionID="edition 2009">fr</Language>
>          <LatestDate>2009-07-14</LatestDate>
>          <OldestDate>2009-07-14</OldestDate>
>          <ContentDescriptive>
>            <KeywordContent>acte authentique</KeywordContent>
> diff --git a/test/data/seda_02_export.rng b/test/data/seda_02_export.rng
> --- a/test/data/seda_02_export.rng
> +++ b/test/data/seda_02_export.rng
> @@ -204,10 +204,20 @@
>                    </rng:attribute>
>                  </rng:optional>
>                  <rng:data type="string"/>
>                </rng:element>
>              </rng:optional>
> +            <rng:optional>
> +              <rng:element name="Description">
> +                <rng:optional>
> +                  <rng:attribute name="languageID">
> +                    <rng:data type="language"/>
> +                  </rng:attribute>
> +                </rng:optional>
> +                <rng:data type="string"/>
> +              </rng:element>
> +            </rng:optional>
>              <rng:element name="Language">
>                <rng:attribute name="listVersionID">
>                  <rng:value type="token">edition 2009</rng:value>
>                </rng:attribute>
>                <rng:data type="string"/>
> @@ -221,20 +231,10 @@
>                <rng:element name="OldestDate">
>                  <rng:data type="string"/>
>                </rng:element>
>              </rng:optional>
>              <rng:optional>
> -              <rng:element name="Description">
> -                <rng:optional>
> -                  <rng:attribute name="languageID">
> -                    <rng:data type="language"/>
> -                  </rng:attribute>
> -                </rng:optional>
> -                <rng:data type="string"/>
> -              </rng:element>
> -            </rng:optional>
> -            <rng:optional>
>                <rng:element name="OriginatingAgency">
>                  <rng:element name="Identification">
>                    <rng:optional>
>                      <rng:attribute name="schemeID">
>                        <rng:data type="token"/>
> diff --git a/test/data/seda_02_export.xsd b/test/data/seda_02_export.xsd
> --- a/test/data/seda_02_export.xsd
> +++ b/test/data/seda_02_export.xsd
> @@ -146,10 +146,19 @@
>                              <xsd:attribute name="languageID" type="xsd:language" use="optional"/>
>                            </xsd:extension>
>                          </xsd:simpleContent>
>                        </xsd:complexType>
>                      </xsd:element>
> +                    <xsd:element minOccurs="0" name="Description">
> +                      <xsd:complexType>
> +                        <xsd:simpleContent>
> +                          <xsd:extension base="udt:TextType">
> +                            <xsd:attribute name="languageID" type="xsd:language" use="optional"/>
> +                          </xsd:extension>
> +                        </xsd:simpleContent>
> +                      </xsd:complexType>
> +                    </xsd:element>
>                      <xsd:element name="Language">
>                        <xsd:complexType>
>                          <xsd:simpleContent>
>                            <xsd:extension base="qdt:CodeLanguageType">
>                              <xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
> @@ -157,19 +166,10 @@
>                          </xsd:simpleContent>
>                        </xsd:complexType>
>                      </xsd:element>
>                      <xsd:element minOccurs="0" name="LatestDate" type="udt:DateType"/>
>                      <xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
> -                    <xsd:element minOccurs="0" name="Description">
> -                      <xsd:complexType>
> -                        <xsd:simpleContent>
> -                          <xsd:extension base="udt:TextType">
> -                            <xsd:attribute name="languageID" type="xsd:language" use="optional"/>
> -                          </xsd:extension>
> -                        </xsd:simpleContent>
> -                      </xsd:complexType>
> -                    </xsd:element>
>                      <xsd:element minOccurs="0" name="OriginatingAgency">
>                        <xsd:complexType>
>                          <xsd:sequence>
>                            <xsd:element fixed="%(agent-id)s" name="Identification">
>                              <xsd:complexType>
> diff --git a/test/data/seda_1_export.rng b/test/data/seda_1_export.rng
> --- a/test/data/seda_1_export.rng
> +++ b/test/data/seda_1_export.rng
> @@ -162,10 +162,20 @@
>              <rng:optional>
>                <rng:attribute name="Id">
>                  <rng:data type="ID"/>
>                </rng:attribute>
>              </rng:optional>
> +            <rng:optional>
> +              <rng:element name="Description">
> +                <rng:optional>
> +                  <rng:attribute name="languageID">
> +                    <rng:data type="language"/>
> +                  </rng:attribute>
> +                </rng:optional>
> +                <rng:data type="string"/>
> +              </rng:element>
> +            </rng:optional>
>              <rng:element name="DescriptionLevel">
>                <rng:attribute name="listVersionID">
>                  <rng:value type="token">edition 2009</rng:value>
>                </rng:attribute>
>                <rng:value type="string">file</rng:value>
> @@ -185,20 +195,10 @@
>                <rng:element name="OldestDate">
>                  <rng:data type="string"/>
>                </rng:element>
>              </rng:optional>
>              <rng:optional>
> -              <rng:element name="Description">
> -                <rng:optional>
> -                  <rng:attribute name="languageID">
> -                    <rng:data type="language"/>
> -                  </rng:attribute>
> -                </rng:optional>
> -                <rng:data type="string"/>
> -              </rng:element>
> -            </rng:optional>
> -            <rng:optional>
>                <rng:element name="CustodialHistory">
>                  <rng:optional>
>                    <rng:element name="CustodialHistoryItem">
>                      <rng:optional>
>                        <rng:attribute name="when">
> diff --git a/test/data/seda_1_export.xsd b/test/data/seda_1_export.xsd
> --- a/test/data/seda_1_export.xsd
> +++ b/test/data/seda_1_export.xsd
> @@ -97,10 +97,19 @@
>                  </xsd:complexType>
>                </xsd:element>
>                <xsd:element name="ContentDescription">
>                  <xsd:complexType>
>                    <xsd:sequence>
> +                    <xsd:element minOccurs="0" name="Description">
> +                      <xsd:complexType>
> +                        <xsd:simpleContent>
> +                          <xsd:extension base="udt:TextType">
> +                            <xsd:attribute name="languageID" type="xsd:language" use="optional"/>
> +                          </xsd:extension>
> +                        </xsd:simpleContent>
> +                      </xsd:complexType>
> +                    </xsd:element>
>                      <xsd:element fixed="file" name="DescriptionLevel">
>                        <xsd:complexType>
>                          <xsd:simpleContent>
>                            <xsd:extension base="qdt:CodeDescriptionLevelType">
>                              <xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
> @@ -117,19 +126,10 @@
>                          </xsd:simpleContent>
>                        </xsd:complexType>
>                      </xsd:element>
>                      <xsd:element minOccurs="0" name="LatestDate" type="udt:DateType"/>
>                      <xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
> -                    <xsd:element minOccurs="0" name="Description">
> -                      <xsd:complexType>
> -                        <xsd:simpleContent>
> -                          <xsd:extension base="udt:TextType">
> -                            <xsd:attribute name="languageID" type="xsd:language" use="optional"/>
> -                          </xsd:extension>
> -                        </xsd:simpleContent>
> -                      </xsd:complexType>
> -                    </xsd:element>
>                      <xsd:element minOccurs="0" name="CustodialHistory">
>                        <xsd:complexType>
>                          <xsd:sequence>
>                            <xsd:element minOccurs="0" name="CustodialHistoryItem">
>                              <xsd:complexType>
> diff --git a/test/test_profile_generation.py b/test/test_profile_generation.py
> --- a/test/test_profile_generation.py
> +++ b/test/test_profile_generation.py
> @@ -895,10 +895,11 @@ class OldSEDARNGExportTC(RelaxNGTestMixi
>                  unit_alt_seq)
>              create('SEDATransferringAgencyArchiveUnitIdentifier',
>                     seda_transferring_agency_archive_unit_identifier=subunit_alt_seq)
>              create('SEDAStartDate', seda_start_date=subunit_alt_seq)
>              create('SEDAEndDate', seda_end_date=subunit_alt_seq)
> +            create('SEDADescription', seda_description=subunit_alt_seq)
>              kw = create('SEDAKeyword', user_cardinality=u'0..n', seda_keyword=subunit_alt_seq)
>              create('SEDAKeywordReference', seda_keyword_reference_from=kw)
>  
>              create('SEDASystemId', seda_system_id=subunit_alt_seq)
>  
>

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list