Skip to content

Collections

Mehmood Asghar edited this page Jul 24, 2021 · 2 revisions

Manage collections

The collections API allows the following actions:

  • Create new collection
  • Update collection options
  • Rename collection
  • Delete collection
  • Get studies by collection
  • Get owner collection and linked collections by studies
  • Set owner collection and link collections to studies

Create new collection

Parameters

  • repositoryid: Unique ID for the collection
  • title: Collection title
  • short_text: Short description for the collection
  • long_text: Long description for the collection
  • thumbnail: Path to the thumbnail file
  • weight: Weight to control the sort order
  • section: Section/Group type for collection - [2= Regional collection, 3=Specialized collection]
  • ispublished: Set publish status - valid values: [0=draft, 1=publish]
collection_add(repositoryid, title, short_text, long_text, ...)

Example - Create new collection

collection_add(
    repositoryid = 'demo',
    title='Demo collection',
    short_text = 'Mauris nec arcu ac lorem ornare semper',
    long_text = '<p>Mauris nec arcu ac lorem ornare semper. Duis eleifend purus scelerisque, varius justo eu, tempus velit. Vestibulum porta, quam non aliquam commodo, elit ligula finibus risus, eu lobortis felis nunc at mi. Pellentesque pharetra in tortor nec efficitur.</p>',
    ispublished = 1,
    thumbnail='path/to/thumbnail.jpg'
)

Update collection

Parameters: All parameters are optional except repositoryid

  • repositoryid: (REQUIRED) Unique ID for the collection
  • title: Collection title
  • short_text: Short description for the collection
  • long_text: Long description for the collection
  • thumbnail: Path to the thumbnail file
  • weight: Weight to control the sort order
  • section: Section/Group type for collection - [2= Regional collection, 3=Specialized collection]
  • ispublished: Set publish status - valid values: [0=draft, 1=publish]
collection_update(repositoryid, title, short_text, long_text, ...)

Example 1 - Update collection title only

collection_update(
    repositoryid = 'demo,
    title='Demo collection title'
)

Example 2 - Update collection title and thumbnail

collection_update(
    repositoryid = 'demo,
    title='Demo collection',
    thumbnail='path/to/thumbnail.jpg'
)

Delete collection

Parameters

  • repositoryid: (REQUIRED) Unique ID for the collection
collection_delete(repositoryid)

Example - Delete collection

collection_delete(
    repositoryid = 'demo'
)

Rename collection

Parameters

  • old_idno: (REQUIRED) Collection IDNo to be replaced
  • new_idno: (REQUIRED) New Collection IDNo
collection_rename(old_idno, new_idno)

Example - Rename collection

collection_rename(
    old_idno = 'demo',
    new_idno = 'demo-v2'
)

Set owner collection and link collections to studies

Use this function to set owner collection for a study and add a study to multiple collections for display

Parameters

  • study_idno: (REQUIRED) Study IDNo
  • owner_collection: Owner collection IDNo
  • link_collections: List of collections that should display the study
  • mode: (REQUIRED) Update or replace the linked collections. Valid values update or replace. Default is update
dataset_attach_collections( 
  study_idno,
  owner_collection=NULL,
  link_collections=list(),
  mode="update")

Example

dataset_attach_collections (
  study_idno='study-idno-001',
  owner_collection='demo',
  link_collections=list('collection1','collection2'),
  mode="update")
Clone this wiki locally