imeji-community / imeji

imeji source code can now be found on https://github.com/MPDL/imeji.
https://github.com/MPDL/imeji
13 stars 15 forks source link

API: How to link to an existing profile when creating a collection #1118

Closed ioverka closed 8 years ago

ioverka commented 8 years ago

Context: DokDisTool (MPDL Information)

I'm not able to reuse an existing metadata profile while creating a new collection. It looks like the profile ID provided as part of th ecollection json is ignored. The new collection is created with a new/empty profile, see details below:

Request:

{
  "title": "Stats - MPI Test",
  "description": "Anbieter-Nutzungsstatistiken für das MPI Test",
  "contributors": [
    {
      "familyName": "MPDL Team",
      "givenName": "",
      "completeName": "MPDL Team",
       "organizations": [
        {
          "name": "Max Planck Digital Library"
        }
      ]
    }
  ],
  "profile": {
    "id": "0_nYxnEEp_1Z_6JO"
  }
} 

Content body of response: Response Body

{
  "id": "N6jHySqzSvGWQaJ2",
  "createdBy": {
    "fullname": "Overkamp, Inga",
    "userId": "KjWGb2P6UepED9L1"
  },
  "modifiedBy": {
    "fullname": "Overkamp, Inga",
    "userId": "KjWGb2P6UepED9L1"
  },
  "createdDate": "2015-09-03T23:47:01 +0200",
  "modifiedDate": "2015-09-03T23:47:01 +0200",
  "versionDate": "",
  "status": "PENDING",
  "version": 0,
  "discardComment": "",
  "title": "Stats - MPI Test",
  "description": "Anbieter-Nutzungsstatistiken für das MPI Test",
  "contributors": [
    {
      "id": "5MKXYupGz2j9y4XP",
      "familyName": "MPDL Team",
      "givenName": "",
      "completeName": "MPDL Team",
      "alternativeName": "",
      "role": "author",
      "identifiers": [
        {
          "type": "imeji",
          "value": "5MKXYupGz2j9y4XP"
        }
      ],
      "organizations": [
        {
          "id": "_wGx6BAlaD8D0EMI",
          "name": "Max Planck Digital Library",
          "description": "",
          "identifiers": [
            {
              "type": "imeji",
              "value": "_wGx6BAlaD8D0EMI"
            }
          ],
          "city": "",
          "country": ""
        }
      ]
    }
  ],
  "profile": {
    "id": "NL_s_h0I_tQU4l26",
    "method": ""
  }
}

What am I doing wrong?

xrotwang commented 8 years ago

AFAIK you cannot actually use the same profile across collections (which may be desirable, I guess). You can just create a collection with a copy of an existing profile, i.e. a profile with the same metadata fields and types - alas with different IDs for all fields as well as for the profile itself. To do so, I think you have to specify "method": "copy" in the request JSON.

To be honest, I think this behaviour is mis-guided. If the idea of imeji was to enable searches across collections, it should be possible to actually re-use (i.e. keep the ID of) at least metadata fields, if not whole profiles. What's implemented now basically conceals the intent of a collection creator to reuse a metadata field.

xrotwang commented 8 years ago

The behaviour as implemented also means that creating a collection and items programmatically is really complicated, even if you already know the profile you want to re-use:

  1. Create collection.
  2. Retrieve the new profile to get its ID.
  3. Loop through the fields in the profile to get the IDs and map them to the names/IDs of the profile you wanted to re-use.
  4. Create correct metadata records for the items you want to create, using the mapping from 3.
  5. Create items.
bastiensaquet commented 8 years ago

Yes, you should can. The request should be: { ... "profile": { "id": "NL_s_h0I_tQU4l26", "method": "reference" } }

The profile is then only referenced. Meanings, it might be changed by its owner (if not you), and affect your data.

xrotwang commented 8 years ago

@bastiensaquet Is this feature documented somewhere? And what does "affect your data" mean? I find it difficult to reconcile the rigidity implied by a schema or profile with the ability to edit it unilaterally.

Maybe single metadata fields may provide a better level for sharing? In this scenario, all metadata fields defined in any profile would contribute to a shared vocabulary which could be re-used in other profiles?

ioverka commented 8 years ago

In our context it is convenient to reference a complete profile, because we "own" this particular profile. If there is ever a need to extend/revise the profile, this change will automatically been applied to all of our collections.

But I agree that shareable metadata fields would bring some benefits as well, e.g. I guess that all profiles include a "title" element, but Spot won't be able to offer a title search spanning collections using different md profiles.

ioverka commented 8 years ago

@bastiensaquet ahhhh... adding some details of the meaning and possible values of "method" would really improve the API documentation from my point of view, see https://github.com/imeji-community/imeji/wiki/Collections:-Create-a-new-collection.

natasab commented 8 years ago

I have updated the documentation, did not notice it was not there, see https://github.com/imeji-community/imeji/wiki/Collections:-Create-a-new-collection.

We have discussed in team already on several occasions the potential of shared vocabularies - indeed this is something which can even allow for matching metadata fields across different profiles and different ontologies - matching concepts from different ontologies would be a very good benefit from it.

ioverka commented 8 years ago

@natasab .. perfect, that was fast :)

natasab commented 8 years ago

please close this ticket if its more clear now. Other topics discussed throughout this ticket should be opened separately if necessary.