Class ItemAPI


  • public class ItemAPI
    extends BaseAPI
    Items are entries in an app. If you think of app as a table, items will be the rows in the table. Items consists of some basic information as well values for each of the fields in the app. For each field there can be multiple values (F.ex. there can be multiple links to another app) and multiple types of values (F.ex. a field of type date field consists of both a start date and an optional end date). The type is denoted by an string id called a sub_id. Most types of fields have only one type, which is denoted by the sub_id values. Others have multiple sub_ids.
    • Method Detail

      • addItem

        public int addItem​(int appId,
                           ItemCreate create,
                           boolean silent)
        Adds a new item to the given app.
        Parameters:
        appId - The id of the app the item should be added to
        create - The data for the new item
        silent - True if the create should be silten, false otherwise
        Returns:
        The id of the newly created item
      • getItem

        public Item getItem​(int itemId)
        Gets the item with the given id
        Parameters:
        itemId - The id of the item
        Returns:
        The item with given id
      • updateItem

        public void updateItem​(int itemId,
                               ItemUpdate update,
                               boolean silent,
                               boolean hook)
        Updates the entire item. Only fields which have values specified will be updated. To delete the contents of a field, pass an empty array for the value.
        Parameters:
        itemId - The id of the item to update
        update - The data for the update
        silent - True if the update should be silent, false otherwise
        hook - True if hooks should be executed for the change, false otherwise
      • updateItemValues

        public void updateItemValues​(int itemId,
                                     List<FieldValuesUpdate> values,
                                     boolean silent,
                                     boolean hook)
        Updates all the values for an item
        Parameters:
        itemId - The id of the item
        values - The values for the fields
        silent - True if the update should be silent, false otherwise
        hook - True if hooks should be executed for the change, false otherwise
      • updateItemFieldValues

        public void updateItemFieldValues​(int itemId,
                                          int fieldId,
                                          List<Map<String,​String>> values,
                                          boolean silent,
                                          boolean hook)
        Update the item values for a specific field.
        Parameters:
        itemId - The id of the item
        fieldId - The id of the field
        values - The new values for the field
        silent - True if the update should be silent, false otherwise
        hook - True if hooks should be executed for the change, false otherwise
      • deleteItem

        public void deleteItem​(int itemId,
                               boolean silent)
        Deletes an item and removes it from all views. The data can no longer be retrieved.
        Parameters:
        itemId - The id of the item
        silent - True if the deletion should be silent, false otherwise
      • getItemFieldValues

        public List<Map<String,​Object>> getItemFieldValues​(int itemId,
                                                                 int fieldId)
        Returns the values for a specified field on an item
        Parameters:
        itemId - The id of the item
        fieldId - The id of the field
        Returns:
        The values on the field on the item
      • getItemValues

        public List<FieldValuesView> getItemValues​(int itemId)
        Returns all the values for an item, with the additional data provided by the get item operation.
        Parameters:
        itemId - The id of the item
        Returns:
        The values on the item
      • getItemsByFieldAndTitle

        public List<ItemMini> getItemsByFieldAndTitle​(int fieldId,
                                                      String text,
                                                      List<Integer> notItemIds,
                                                      Integer limit)
        Used to find possible items for a given application field. It searches the relevant items for the title given.
        Parameters:
        fieldId - The id of app reference field to search for
        text - The text to search for in the items title
        notItemIds - If supplied the items with these ids will not be returned
        limit - The maximum number of results to return. Default value: 13
        Returns:
        The items that were valid for the field and with text matching
      • getItemReference

        public List<ItemReference> getItemReference​(int itemId)
        Returns the items that have a reference to the given item. The references are grouped by app. Both the apps and the items are sorted by title.
        Parameters:
        itemId - The id of the item
        Returns:
        The references to the given item
      • getItemRevision

        public ItemRevision getItemRevision​(int itemId,
                                            int revisionId)
        Returns the data about the specific revision on an item
        Parameters:
        itemId - The id of the item
        revisionId - The running revision number, starts at 0 for the initial revision
        Returns:
        The revision
      • getItemRevisionDifference

        public List<ItemFieldDifference> getItemRevisionDifference​(int itemId,
                                                                   int revisionFrom,
                                                                   int revisionTo)
        Returns the difference in fields values between the two revisions.
        Parameters:
        itemId - The id of the item
        revisionFrom - The from revision
        revisionTo - The to revision
        Returns:
        The difference between the two revision
      • getItemRevisions

        public List<ItemRevision> getItemRevisions​(int itemId)
        Returns all the revisions that have been made to an item
        Parameters:
        itemId - The id of the item
        Returns:
        All the revisions
      • getItems

        public ItemsResponse getItems​(int appId,
                                      Integer limit,
                                      Integer offset,
                                      SortBy sortBy,
                                      Boolean sortDesc,
                                      FilterByValue<?>... filters)
        Returns the items on app matching the given filters.
        Parameters:
        appId - The id of the app
        limit - The maximum number of items to receive, defaults to 20
        offset - The offset from the start of the items returned, defaults to 0
        sortBy - How the items should be sorted. For the possible options, see the filter area.
        sortDesc - true or leave out to sort descending, use false to sort ascending
        filters - The filters to apply
        Returns:
        The items matching the filters
      • getItemsByExternalId

        public ItemsResponse getItemsByExternalId​(int appId,
                                                  String externalId)
        Utility method to get items matching an external id
        Parameters:
        appId - The id of the app
        externalId - The external id
        Returns:
        The items matching the app and external id