eamena-project / eamena-arches-dev

development repository of the EAMENA Arches-powered database platform
https://eamena.org/home
GNU Affero General Public License v3.0
5 stars 3 forks source link

Creating HP <- relation -> INFO using the 'import_business_data_relations' function doesn't update the DB #53

Open zoometh opened 3 months ago

zoometh commented 3 months ago

The objective is to link a subset of HP (kites) to an INFORMATION resource (denoted as INFO, which represents bibliographic references) using the import_business_data_relations function. This setup will later enable the ability to search using this INFORMATION resource identifier and collect all related HP, thereby simplifying the search process.

I created the INFORMATION-0150083 resource to record this bibliographic reference: "Following the herds? A new distribution of hunting kites in Southwest Asia"

image

1. By hand

Adding the related resource INFORMATION-0150083 manually in the EAMENA-0194276 field 'Information Resource':

image

.. show that it works ✔️(EAMENA-0194276 ✔️), and the Advanced search return the HP when querying on INFORMATION-0150083:

image

2. Using the import_business_data_relations function

Now, I do the same, for another HP (EAMENA-0194279), using this file missing_info_hp_append_240517.relations

resourceinstanceidfrom resourceinstanceidto relationshiptype datestarted dateended notes
cbd7411e-733d-4ac6-a3f6-607c91bd0ab9 3cf10bdf-6bbb-4975-9342-5477a21cbcc7 http://www.cidoc-crm.org/cidoc-crm/P129i_is_subject_of

Hosted here /opt/arches/data_temp/missing_info_hp_append_240517.relations

Using this command:

(ENV) root@ip-172-31-39-197:/opt/arches/eamena# python manage.py packages -o import_business_data_relations -s /opt/arches/data_temp/missing_info_
hp_append_240517.relations

Gives:

operation: import_business_data_relations
No import errors

We can verify in the DB that the relationship btw EAMENA-0194279 and INFORMATION-0150083 has been created:

image

⚠️ However, in the Advanced search, only the first HP (EAMENA-0194276 ✔️) created by hand is returned (Results = 1). The other one (EAMENA-0194279 ❌) is not returned in the results

image

**Why?**

Troubleshooting

Postgres DB check

Your aim is to verify if the two records (EAMENA-0194276 and EAMENA-0194279) have similar structure, to understand why EAMENA-0194276 ✔️is returned in the Advanced search but not EAMENA-0194279 ❌

SELECT tiledata FROM tiles 
WHERE resourceinstanceid::text LIKE '5475893c-5ce3-41df-81d7-4ebaa6ad39d1' -- EAMENA-0194276
AND tiledata -> '34cfea34-c2c0-11ea-9026-02e7594ce0a0' IS NOT NULL

Gives (in the tiledata JSONB field):

{
  "34cfea34-c2c0-11ea-9026-02e7594ce0a0": [
    {
      "resourceId": "3cf10bdf-6bbb-4975-9342-5477a21cbcc7",
      "ontologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P129i_is_subject_of",
      "resourceXresourceId": "053a0f53-435b-4511-b2b6-0307989fc972",
      "inverseOntologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P129_is_about"
    }
  ],
  "a5eb59b4-0406-11eb-a11c-0a5a9a4f6ef7": null
}
SELECT tiledata FROM tiles 
WHERE resourceinstanceid::text LIKE 'cbd7411e-733d-4ac6-a3f6-607c91bd0ab9' -- EAMENA-0194279
AND tiledata -> '34cfea34-c2c0-11ea-9026-02e7594ce0a0' IS NOT NULL

Gives (in the tiledata JSONB field):

{
  "34cfea34-c2c0-11ea-9026-02e7594ce0a0": [],
  "a5eb59b4-0406-11eb-a11c-0a5a9a4f6ef7": null
}
**Why the field hasn't been updated?**

Notes

import_business_data_relations function documentation

ID Resource Instance ID
INFORMATION-0150083 3cf10bdf-6bbb-4975-9342-5477a21cbcc7
EAMENA-0194276 5475893c-5ce3-41df-81d7-4ebaa6ad39d1
EAMENA-0194279 cbd7411e-733d-4ac6-a3f6-607c91bd0ab9

**the 'Information Resource' field's UUID in the HP RM: 34cfea34-c2c0-11ea-9026-02e7594ce0a0 see:

python manage.py whatisthis 34cfea34-c2c0-11ea-9026-02e7594ce0a0

Advanced search to find all HP related to INFORMATION-0150083: https://database.eamena.org/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=377202&advanced-search=%5B%7B%22op%22%3A%22and%22%2C%2234cfea34-c2c0-11ea-9026-02e7594ce0a0%22%3A%7B%22op%22%3A%22%22%2C%22val%22%3A%223cf10bdf-6bbb-4975-9342-5477a21cbcc7%22%7D%2C%22a5eb59b4-0406-11eb-a11c-0a5a9a4f6ef7%22%3A%7B%22op%22%3A%22eq%22%2C%22val%22%3A%22%22%7D%7D%5D

In both cases (manually, and with the function), the relationship btw the HP and the INFO is P129i_is_subject_of

image