SPW-DIG / metawal-core-geonetwork

Metawal - Catalogue pour l'information géographique de Wallonie
http://metawal.wallonie.be
GNU General Public License v2.0
3 stars 1 forks source link

Batch Edit - point of contact et licences #869

Closed marceaulouis closed 3 months ago

marceaulouis commented 4 months ago

J'ai deux editions indépendantes à faire, mais comme d'habitude j'ai du mal à les paramétrer pour que ça fonctionne :

Remplacement licences :

Dans le premier cas, j'aimerais remplacer tout ce qui se trouve dans les contraintes par la licence CC-BY J'ai ceci, qui ne fonctionne pas :

xpath : /mdb:MD_Metadata/mdb:identificationInfo/*

value :

<mri:resourceConstraints xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0" xmlns:mco="http://standards.iso.org/iso/19115/-3/mco/1.0" xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0" xmlns:xlink="http://www.w3.org/1999/xlink">
            <mco:MD_LegalConstraints >
               <mco:accessConstraints>
                  <mco:MD_RestrictionCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode"
                                          codeListValue="otherRestrictions"/>
               </mco:accessConstraints>
               <mco:otherConstraints>
                  <gcx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/LimitationsOnPublicAccess/noLimitations">No limitations to public access</gcx:Anchor>
               </mco:otherConstraints>
            </mco:MD_LegalConstraints>
         </mri:resourceConstraints>
         <mri:resourceConstraints>
            <mco:MD_LegalConstraints>
               <mco:accessConstraints>
                  <mco:MD_RestrictionCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode"
                                          codeListValue="unrestricted"/>
               </mco:accessConstraints>
               <mco:useConstraints>
                  <mco:MD_RestrictionCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode"
                                          codeListValue="otherRestrictions"/>
               </mco:useConstraints>
               <mco:otherConstraints>
                  <gcx:Anchor xlink:href="https://creativecommons.org/licenses/by/4.0/legalcode.fr">Ces données sont disponibles sous licence CC-BY 4.0. Un résumé de cette licence est disponible à l'adresse https://creativecommons.org/licenses/by/4.0/deed.fr . Ce résumé ne se substitue pas à la licence complète. Crédits : Service public de Wallonie (2022)</gcx:Anchor>
               </mco:otherConstraints>
            </mco:MD_LegalConstraints>
         </mri:resourceConstraints>

Pour le deuxième cas, j'aimerais ajouter un contact pour les metadata dans le cas où il n'y a rien :

xpath : /mdb:MD_Metadata/mdb:contact condition : count(/mdb:MD_Metadata/mdb:contact/cit:CI_Organisation//text() = 'Direction de la Promotion de l'Energie Durable (SPW - SPW Aménagement du Territoire, Logement, Patrimoine et Energie - Département de l'Énergie et du Bâtiment durable)']) = 0

Value :

<mdb:contact  xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0" xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0" xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
      <cit:CI_Responsibility>
         <cit:role>
            <cit:CI_RoleCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_RoleCode"
                             codeListValue="pointOfContact"/>
         </cit:role>
         <cit:party>
            <cit:CI_Organisation>
               <cit:name>
                  <gco:CharacterString>Direction de la Promotion de l'Energie Durable (SPW - SPW Aménagement du Territoire, Logement, Patrimoine et Energie - Département de l'Énergie et du Bâtiment durable)</gco:CharacterString>
               </cit:name>
               <cit:contactInfo>
                  <cit:CI_Contact>
                     <cit:address>
                        <cit:CI_Address>
                           <cit:electronicMailAddress>
                              <gco:CharacterString>energie@spw.wallonie.be</gco:CharacterString>
                           </cit:electronicMailAddress>
                        </cit:CI_Address>
                     </cit:address>
                  </cit:CI_Contact>
               </cit:contactInfo>
            </cit:CI_Organisation>
         </cit:party>
      </cit:CI_Responsibility>
  </mdb:contact>

votre aide est la bienvenue ! Merci

fxprunayre commented 4 months ago

En mode preview, l'erreur n'est pas affichée - j'améliore ça

image

fxprunayre commented 4 months ago

Pour le changement de licence, le problème est que tu ajoutes 2 noeuds mri:resourceConstraints et le XML qu'on ajoute doit être un seul noeud XML. Donc en faisant dans l'ordre:

{"field":"XPath_1","insertMode":"gn_delete","xpath":"/mdb:MD_Metadata/mdb:identificationInfo/*/mri:resourceConstraints","value":"","isXpath":true,"condition":""}
{"field":"XPath_2","insertMode":"gn_add","xpath":"/mdb:MD_Metadata/mdb:identificationInfo/*","value":"<mri:resourceConstraints xmlns:mri=\"http://standards.iso.org/iso/19115/-3/mri/1.0\" xmlns:mco=\"http://standards.iso.org/iso/19115/-3/mco/1.0\" xmlns:gcx=\"http://standards.iso.org/iso/19115/-3/gcx/1.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n            <mco:MD_LegalConstraints >\n               <mco:accessConstraints>\n                  <mco:MD_RestrictionCode codeList=\"http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode\"\n                                          codeListValue=\"otherRestrictions\"/>\n               </mco:accessConstraints>\n               <mco:otherConstraints>\n                  <gcx:Anchor xlink:href=\"http://inspire.ec.europa.eu/metadata-codelist/LimitationsOnPublicAccess/noLimitations\">No limitations to public access</gcx:Anchor>\n               </mco:otherConstraints>\n            </mco:MD_LegalConstraints>\n         </mri:resourceConstraints>","isXpath":true,"condition":""}
{"field":"XPath_3","insertMode":"gn_add","xpath":"/mdb:MD_Metadata/mdb:identificationInfo/*","value":"<mri:resourceConstraints xmlns:mri=\"http://standards.iso.org/iso/19115/-3/mri/1.0\" xmlns:mco=\"http://standards.iso.org/iso/19115/-3/mco/1.0\" xmlns:gcx=\"http://standards.iso.org/iso/19115/-3/gcx/1.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n            <mco:MD_LegalConstraints>\n               <mco:accessConstraints>\n                  <mco:MD_RestrictionCode codeList=\"http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode\"\n                                          codeListValue=\"unrestricted\"/>\n               </mco:accessConstraints>\n               <mco:useConstraints>\n                  <mco:MD_RestrictionCode codeList=\"http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#MD_RestrictionCode\"\n                                          codeListValue=\"otherRestrictions\"/>\n               </mco:useConstraints>\n               <mco:otherConstraints>\n                  <gcx:Anchor xlink:href=\"https://creativecommons.org/licenses/by/4.0/legalcode.fr\">Ces données sont disponibles sous licence CC-BY 4.0. Un résumé de cette licence est disponible à l'adresse https://creativecommons.org/licenses/by/4.0/deed.fr . Ce résumé ne se substitue pas à la licence complète. Crédits : Service public de Wallonie (2022)</gcx:Anchor>\n               </mco:otherConstraints>\n            </mco:MD_LegalConstraints>\n         </mri:resourceConstraints>","isXpath":true,"condition":""}

Il est possible de copier/coller les config JSON. A tester mais ça me semble bien. Faut peut être faire une sauvegarde de la base avant ?

fxprunayre commented 4 months ago

Pour le deuxième cas, j'aimerais ajouter un contact pour les metadata dans le cas où il n'y a rien :

Déjà, pour récupérer les fiches qui n'ont pas de contact, on peut utiliser le filtre q(-_exists_:OrgObject) pour la recherche

Sinon, dans la condition, il y a des erreurs image

Ensuite, je retombe sur le pb https://github.com/SPW-DIG/metawal-core-geonetwork/issues/812#issuecomment-1469884678. Il y a aussi des problèmes car il y a des ' dans le nom. Il faut utiliser des " du coup eg. "l'énergie"

A priori, cette config fonctionne:

{"field":"XPath_1","insertMode":"gn_add","xpath":"/","value":"<mdb:contact  xmlns:mdb=\"http://standards.iso.org/iso/19115/-3/mdb/2.0\" xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\" xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">\n      <cit:CI_Responsibility>\n         <cit:role>\n            <cit:CI_RoleCode codeList=\"http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_RoleCode\"\n                             codeListValue=\"pointOfContact\"/>\n         </cit:role>\n         <cit:party>\n            <cit:CI_Organisation>\n               <cit:name>\n                  <gco:CharacterString>Direction de la Promotion de l'Energie Durable (SPW - SPW Aménagement du Territoire, Logement, Patrimoine et Energie - Département de l'Énergie et du Bâtiment durable)</gco:CharacterString>\n               </cit:name>\n               <cit:contactInfo>\n                  <cit:CI_Contact>\n                     <cit:address>\n                        <cit:CI_Address>\n                           <cit:electronicMailAddress>\n                              <gco:CharacterString>energie@spw.wallonie.be</gco:CharacterString>\n                           </cit:electronicMailAddress>\n                        </cit:CI_Address>\n                     </cit:address>\n                  </cit:CI_Contact>\n               </cit:contactInfo>\n            </cit:CI_Organisation>\n         </cit:party>\n      </cit:CI_Responsibility>\n  </mdb:contact>","isXpath":true,"condition":"count(./mdb:contact[contains(*/cit:party/cit:CI_Organisation/cit:name/*/text(), \"Direction de la Promotion de l'Energie Durable (SPW - SPW Aménagement du Territoire, Logement, Patrimoine et Energie - Département de l'Énergie et du Bâtiment durable)\")]) = 0"}