-
Notifications
You must be signed in to change notification settings - Fork 10
Modifica template OAI-PMH article_compile.txt para geração de metadados nos formatos AOI_DC e MODS #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Modifica template OAI-PMH article_compile.txt para geração de metadados nos formatos AOI_DC e MODS #1236
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,108 +5,293 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xsi:schemaLocation="http://www.lyncode.com/xoai http://www.lyncode.com/xsd/xoai.xsd"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- ================================================================== --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- DUBLIN CORE (OAI_DC) - Metadados básicos para interoperabilidade --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- ================================================================== --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="dc"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- ========== TITLE ========== --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="title"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="none"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% for title in object.titles.all %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% for title in object.titles.all %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <field name="value">{{ title.plain_text }}</field> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% endfor%} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% endfor %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </element> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </element> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="creator"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- ========== CONTRIBUTOR / AUTHOR ========== --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="contributor"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element name="author"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% for research in object.researchers.all %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <element> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% if research.orcid %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rossi-Luciano deixe o código mais enxuto aqui. Transfira a complexidade para o modelo Researcher, assim como foi feito para Article.source ou Article.license_url (ambos property). O Article.license_url ficará disponível em um futuro PR meu |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <field name="value" orcid="{{ research.orcid }}"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {% else %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <field name="value"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+31
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <field name="value" orcid="{{ research.orcid }}"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> | |
| {% else %} | |
| <field name="value"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> | |
| <field name="value" orcid="{{ research.orcid }}"{% if research.affiliation and research.affiliation.institution and research.affiliation.institution.institution_identification %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> | |
| {% else %} | |
| <field name="value"{% if research.affiliation and research.affiliation.institution and research.affiliation.institution.institution_identification %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 86-103 access object.journal.official and its ISSN fields without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. The conditional check should first verify object.journal exists before checking object.journal.official.
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nested loops on lines 107-113 generate a URI for every combination of collection and language, which could result in N×M elements. This may create a large number of duplicate or redundant URIs if an article belongs to multiple collections. Consider whether all these URIs are necessary for OAI-PMH metadata, or if a single canonical URI would be more appropriate. This could also impact performance for articles with many collections and languages.
| {% for lang in object.languages.all %} | |
| <element> | |
| <field name="value">http://{{ collection.domain }}/scielo.php?script=sci_arttext&pid={{ object.pid_v2 }}&tlng={{ lang.code2 }}</field> | |
| </element> | |
| {% endfor %} | |
| {% endfor %} | |
| <element> | |
| <field name="value">http://{{ collection.domain }}/scielo.php?script=sci_arttext&pid={{ object.pid_v2 }}</field> | |
| </element> | |
| {% endfor %} |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 121 accesses kwd.vocabulary.acronym without checking if vocabulary is null. Since vocabulary is a nullable ForeignKey on the Keyword model, this could cause a template error if a keyword doesn't have an associated vocabulary. Consider adding a conditional check or using a default filter.
| {% for kwd in object.keywords.all %} | |
| <field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field> | |
| {% for kwd in object.keywords.all %} | |
| {% if kwd.vocabulary %} | |
| <field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field> | |
| {% else %} | |
| <field name="value">{{ kwd.text }}</field> | |
| {% endif %} |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 128 states 'Abstract específico (CRÍTICO para MODS!)' which suggests this is critical for MODS format. However, the element is named 'abstract' which is a qualifier under 'description', following Dublin Core convention. This is appropriate for OAI_DC but should be verified against MODS requirements. According to MODS schema, abstracts should be in mods:abstract elements directly, not under description qualifiers. Consider reviewing if this structure properly supports both OAI_DC and MODS formats as intended.
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 151 accesses object.journal.publisher_history without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. The {% with %} block should include a null check for object.journal before accessing its publisher_history.
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The publisher extraction accesses deep nullable relationships (ph.institution.institution.institution_identification.name and ph.organization.name) without null checks beyond verifying ph and the top-level fields exist. If institution or institution_identification is null in the institution branch, this will cause a template error. Consider adding nested conditional checks to verify the entire chain is not null before accessing the name field.
| {% if ph.institution %} | |
| <field name="value">{{ ph.institution.institution.institution_identification.name }}</field> | |
| {% elif ph.organization %} | |
| {% if ph.institution and ph.institution.institution and ph.institution.institution.institution_identification %} | |
| <field name="value">{{ ph.institution.institution.institution_identification.name }}</field> | |
| {% elif ph.organization and ph.organization.name %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rossi-Luciano dar prioridade para organization que conterá dados padronizados
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 170 accesses object.journal.title without checking if object.journal is null. Since the journal field on Article is nullable (null=True, blank=True), this could cause a template error if an article doesn't have an associated journal. Consider wrapping this section in a conditional check {% if object.journal %} or using a default filter.
| <!-- Título do periódico --> | |
| <element name="ispartof"> | |
| <element> | |
| <field name="value">{{ object.journal.title }}</field> | |
| </element> | |
| </element> | |
| <!-- Título do periódico --> | |
| {% if object.journal %} | |
| <element name="ispartof"> | |
| <element> | |
| <field name="value">{{ object.journal.title }}</field> | |
| </element> | |
| </element> | |
| {% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rossi-Luciano apesar de não existir um campo, há o property Article.source. Não funcionou?
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic source citation generation on line 231 creates an extremely long single line with multiple conditional concatenations. This makes the template difficult to read and maintain. Consider breaking this into multiple lines using Django template tags like {% with %} blocks or {% filter %} to improve readability, or pre-format this citation in a model property or template filter.
| <field name="value">{{ object.journal.title }}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %}</field> | |
| <field name="value"> | |
| {{ object.journal.title }}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %} | |
| </field> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 231 accesses object.journal.title in the source citation generation without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. Consider adding a conditional check before accessing journal properties.
| <field name="value">{{ object.journal.title }}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %}</field> | |
| <field name="value">{% if object.journal %}{{ object.journal.title }}{% endif %}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %}</field> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 231 accesses object.issue.volume and object.issue.number in the source citation without checking if object.issue is null. Since the issue field is nullable, this could cause a template error. Consider adding a conditional check or restructuring the source generation logic to handle null issue safely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rossi-Luciano criei o Article.license_url (property) para simplificar este código
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license type string matching logic uses multiple conditions with 'in' checks for different hyphenation formats (e.g., 'CC BY 4.0' and 'CC-BY 4.0'). This approach is brittle and could produce incorrect matches. For example, 'CC BY-NC 4.0' would match the condition for 'CC BY 4.0' on line 246 because 'CC BY 4.0' is a substring of 'CC BY-NC 4.0'. The conditions should be reordered to check more specific licenses first (those with more components like CC BY-NC-ND, CC BY-NC-SA, CC BY-NC, CC BY-SA, CC BY-ND) before checking less specific ones (CC BY), or use exact string matching with multiple elif conditions for each variant.
| {% if 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by/4.0/</field> | |
| {% elif 'CC BY-NC 4.0' in object.license.license_type or 'CC-BY-NC 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc/4.0/</field> | |
| {% elif 'CC BY-SA 4.0' in object.license.license_type or 'CC-BY-SA 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-sa/4.0/</field> | |
| {% elif 'CC BY-ND 4.0' in object.license.license_type or 'CC-BY-ND 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nd/4.0/</field> | |
| {% elif 'CC BY-NC-SA 4.0' in object.license.license_type or 'CC-BY-NC-SA 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc-sa/4.0/</field> | |
| {% elif 'CC BY-NC-ND 4.0' in object.license.license_type or 'CC-BY-NC-ND 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc-nd/4.0/</field> | |
| {% elif 'CC BY 3.0' in object.license.license_type or 'CC-BY 3.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by/3.0/</field> | |
| {% elif 'CC BY-NC 3.0' in object.license.license_type or 'CC-BY-NC 3.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc/3.0/</field> | |
| {% if 'CC BY-NC-ND 4.0' in object.license.license_type or 'CC-BY-NC-ND 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc-nd/4.0/</field> | |
| {% elif 'CC BY-NC-SA 4.0' in object.license.license_type or 'CC-BY-NC-SA 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc-sa/4.0/</field> | |
| {% elif 'CC BY-NC 4.0' in object.license.license_type or 'CC-BY-NC 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc/4.0/</field> | |
| {% elif 'CC BY-SA 4.0' in object.license.license_type or 'CC-BY-SA 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-sa/4.0/</field> | |
| {% elif 'CC BY-ND 4.0' in object.license.license_type or 'CC-BY-ND 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nd/4.0/</field> | |
| {% elif 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by/4.0/</field> | |
| {% elif 'CC BY-NC 3.0' in object.license.license_type or 'CC-BY-NC 3.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by-nc/3.0/</field> | |
| {% elif 'CC BY 3.0' in object.license.license_type or 'CC-BY 3.0' in object.license.license_type %} | |
| <field name="value">http://creativecommons.org/licenses/by/3.0/</field> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The funding section accesses a deep chain of nullable relationships (funding.funding_source.institution.institution_identification.name) without null checks. If any intermediate relationship is null, this will cause a template error. Consider adding conditional checks to ensure funding_source, institution, and institution_identification are not None before accessing the name field.
| {% for funding in object.fundings.all %} | |
| <element> | |
| <field name="value">{{ funding.funding_source.institution.institution_identification.name }}{% if funding.award_id %} grant {{ funding.award_id }}{% endif %}</field> | |
| </element> | |
| {% for funding in object.fundings.all %} | |
| {% if funding.funding_source and funding.funding_source.institution and funding.funding_source.institution.institution_identification %} | |
| <element> | |
| <field name="value">{{ funding.funding_source.institution.institution_identification.name }}{% if funding.award_id %} grant {{ funding.award_id }}{% endif %}</field> | |
| </element> | |
| {% endif %} |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template comments mix Portuguese and English inconsistently. For example, line 10 has 'Metadados básicos para interoperabilidade' (Portuguese), while section headers use English (e.g., 'TITLE', 'CONTRIBUTOR / AUTHOR'). Consider using a single language throughout the comments for better maintainability and consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: 'AOI_DC' should be 'OAI_DC' (Open Archives Initiative - Dublin Core)