Skip to content
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

Prefer default vocabulary (if a default exists) #568

Closed
wants to merge 1 commit into from
Closed

Prefer default vocabulary (if a default exists) #568

wants to merge 1 commit into from

Conversation

andylolz
Copy link
Contributor

@andylolz andylolz commented Nov 20, 2019

The problem

Some attributes can contain values from different codelists, depending on the @vocabulary used. The dashboard doesn’t have a means of showing this, as per the yellow banner shown on dashboard codelists, and #174.

Given the dashboard doesn’t have the functionality to select from multiple vocabularies, it needs to choose which vocabulary to use. Where a default vocabulary exists, it seems to make sense to prefer that one. That doesn’t necessarily happen at the moment, so this PR fixes that.

So for example, in the case of iati-activity/sector/@code, the default vocabulary is Sector. However, the dashboard currently uses the SectorCategory vocabulary:

Screenshot 2019-11-23 at 14 24 09

Similarly (as reported in #567), iati-activity/default-aid-type/@code uses the AidType vocabulary by default. However, the dashboard currently uses the (rarely used) CashAndVoucherModalities vocabulary:
Screenshot 2019-11-23 at 14 27 26

The proposed solution

This PR ensures that when a default vocabulary exists for a given attribute, it is preferred on dashboard codelist pages.

For iati-activity/sector/@code, that’s Sector:
Screenshot 2019-11-23 at 14 30 28

For iati-activity/default-aid-type/@code, that’s AidType:
Screenshot 2019-11-23 at 14 31 27

It’s worth noting that for a small number of IATI attributes, there is no default codelist. For example, iati-activity/tag/@code. In such cases, we use the codelist for the first mapping for that attribute found in the mapping file.

Fixes #567.

@andylolz andylolz changed the title Ignore non-default mappings Prefer default codelists (if a default exists) Nov 23, 2019
@andylolz andylolz changed the title Prefer default codelists (if a default exists) Prefer default vocabulary (if a default exists) Nov 23, 2019
@stevieflow
Copy link
Contributor

Interesting, thanks @andylolz

In terms of knowing the default vocabulary, my understanding is that this must be something you've inferred from the standard, as it's not a flat or explicit reference? If so, did you make a lookup table, or similar? It strikes me that would be a useful resource for the standard/users

@andylolz
Copy link
Contributor Author

andylolz commented Nov 24, 2019

In terms of knowing the default vocabulary, my understanding is that this must be something you've inferred from the standard, as it's not a flat or explicit reference? If so, did you make a lookup table, or similar? It strikes me that would be a useful resource for the standard/users

Good question, @stevieflow! Apologies in advance for the very long answer…

There’s a mapping.xml file that is part of the Single Source of Truth (it lives in the IATI-Codelists repository), and defines the relationship between IATI attributes and IATI codelists. The dashboard and reference site both use this mapping file.

For instance, the mapping file states that iati-activity/recipient-country/@code should always contain a value from the Country codelist (ref):

<mapping>
    <path>//iati-activity/recipient-country/@code</path>
    <codelist ref="Country" />
</mapping>

When the code used depends on the @vocabulary, the mapping includes a condition element. For instance, the CashandVoucherModalities codelist can be used for iati-activity/default-aid-type/@code, but only when iati-activity/default-aid-type/@vocabulary is set to "4" (ref):

<mapping>
    <path>//iati-activity/default-aid-type/@code</path>
    <codelist ref="CashandVoucherModalities" />
    <condition>@vocabulary = '4'</condition>
</mapping>

In cases where multiple vocabularies can be used, there’s usually a default vocabulary. So for example, if no iati-activity/default-aid-type/@vocabulary is declared, the default vocabulary for iati-activity/default-aid-type/@code is the AidType codelist. This is shown in the mapping file by a not(@vocabulary) condition (ref):

<mapping>
    <path>//iati-activity/default-aid-type/@code</path>
    <codelist ref="AidType" />
    <condition>@vocabulary = '1' or not(@vocabulary)</condition>
</mapping>

So this pull request ensures the dahboard preferentially uses these default vocabularies (shown by a not(@vocabulary) condition) over any non-default vocabularies.

@andylolz andylolz closed this Nov 24, 2019
@andylolz andylolz reopened this Nov 24, 2019
Default mappings should be preferred.
@andylolz
Copy link
Contributor Author

andylolz commented Jan 4, 2021

Doesn’t look like this will be merged; closing.

@andylolz andylolz closed this Jan 4, 2021
@andylolz andylolz deleted the 567-default-mapping branch January 4, 2021 21:58
@andylolz andylolz restored the 567-default-mapping branch March 25, 2021 17:11
@andylolz andylolz deleted the 567-default-mapping branch March 25, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default-aid-type defaults to CashandVoucherModalities vocabulary
2 participants