Trying to link items automatically

Hello,

I’ve installed Omeka S and the CSV import module, which works fine.
Now I need to link an item A to an item B automatically, i.e. add in A metadata an Omeka resource instead of a text or URI value. Thus, B should appear as “linked resources” in A metadata, and the link should be established using unique identifiers.

I’ve found a way to do this directly in the database (see the details below), but can we do it via a module or some built-in function ? Anyone interested in developing a module ?

Many thanks in advance
Vincent

============
Item A is a printed ornament, and Item B is a book in which A is printed on page x or y.
We can express this relationship with Dublin Core property “isPartOf”.

Let’s express this as triples (where ex: stands for URI <http://example. org>).

ex:itemA a ex:PrintedOrnament .

ex:itemA dcterms:IsPartOf ex:itemB .

ex:itemB a ex:Book .

ex:itemB dcterms:identifier "my_Unique_Name_For_Item_B" .

Now, suppose we have in our database, in the “value” table, for item A :

dcterms:isPartOf “my_Unique_Name_For_Item_B” .

We can add B as linked resource to A using this query :

UPDATE

    value

SET

    value.value_resource_id =(

    SELECT resource_id FROM (select * FROM value) as value2  

    WHERE

        value2.property_id = "10"  ##### <= the id for dcterms:identifier in table 'property'

        AND

        value2.value = "my_Unique_Name_For_Item_B"

), 

    value.value = NULL,

    value.type = resource

WHERE

    value.property_id = "33" ##### <= the id for dcterms:isPartOf in table 'property'

   AND 

   value.value = "my_Unique_Name_For_Item_B";

We can then make a script to use this query for other properties : suppose all our identifiers begin with the same prefix, then we can find all the occurrences of an identifier and the corresponding property in ‘value’ table like this :

SELECT property_id, value FROM `value` 

WHERE value LIKE "my_prefix%" 

AND NOT ( property_id = "10" )  ##### <= ignore dcterms:identifier

And then loop on the results to re-write the first query string.

.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.