Class MetadataService

java.lang.Object
com.gooddata.sdk.service.AbstractService
com.gooddata.sdk.service.md.MetadataService

public class MetadataService
extends AbstractService
Query, create and update project metadata - attributes, facts, metrics, reports,...
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.gooddata.sdk.service.AbstractService

    AbstractService.OutputStreamResponseExtractor
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static org.springframework.web.util.UriTemplate OBJ_TEMPLATE  

    Fields inherited from class com.gooddata.sdk.service.AbstractService

    mapper, restTemplate
  • Constructor Summary

    Constructors 
    Constructor Description
    MetadataService​(org.springframework.web.client.RestTemplate restTemplate, GoodDataSettings settings)  
  • Method Summary

    Modifier and Type Method Description
    <T extends com.gooddata.sdk.model.md.Obj>
    T
    createObj​(com.gooddata.sdk.model.project.Project project, T obj)
    Create metadata object in given project
    <T extends com.gooddata.sdk.model.md.Queryable>
    java.util.Collection<com.gooddata.sdk.model.md.Entry>
    find​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
    Find metadata by restrictions like identifier, title or summary.
    java.util.Collection<java.lang.String> findUris​(com.gooddata.sdk.model.project.Project project, com.gooddata.sdk.model.md.Restriction... restrictions)
    Find metadata URIs by restrictions.
    <T extends com.gooddata.sdk.model.md.Queryable>
    java.util.Collection<java.lang.String>
    findUris​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
    Find metadata URIs by restrictions like identifier, title or summary.
    java.util.List<com.gooddata.sdk.model.md.AttributeElement> getAttributeElements​(com.gooddata.sdk.model.md.Attribute attribute)
    Fetches attribute elements for given attribute using default display form.
    java.util.List<com.gooddata.sdk.model.md.AttributeElement> getAttributeElements​(com.gooddata.sdk.model.md.DisplayForm displayForm)
    Fetches attribute elements by given display form.
    <T extends com.gooddata.sdk.model.md.Queryable>
    T
    getObj​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
    Get metadata object by restrictions like identifier, title or summary.
    <T extends com.gooddata.sdk.model.md.Obj>
    T
    getObjById​(com.gooddata.sdk.model.project.Project project, java.lang.String id, java.lang.Class<T> cls)
    Get metadata object by id.
    <T extends com.gooddata.sdk.model.md.Obj>
    T
    getObjByUri​(java.lang.String uri, java.lang.Class<T> cls)
    Get metadata object by URI (format is /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})
    java.util.Collection<com.gooddata.sdk.model.md.Obj> getObjsByUris​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> uris)
    Retrieves a collection of objects corresponding to the supplied collection of URIs.
    <T extends com.gooddata.sdk.model.md.Queryable>
    java.lang.String
    getObjUri​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
    Get metadata object URI by restrictions like identifier, title or summary.
    java.util.Map<java.lang.String,​java.lang.String> identifiersToUris​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> identifiers)
    Find metadata URIs for given identifiers.
    void removeObj​(com.gooddata.sdk.model.md.Obj obj)
    Remove metadata object URI
    void removeObjByUri​(java.lang.String uri)
    Remove metadata object by URI (format is /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})
    <T extends com.gooddata.sdk.model.md.Updatable>
    T
    updateObj​(T obj)
    Update given metadata object.
    java.util.Collection<com.gooddata.sdk.model.md.Entry> usedBy​(com.gooddata.sdk.model.project.Project project, com.gooddata.sdk.model.md.Obj obj, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
    Find all objects which use the given object.
    java.util.Collection<com.gooddata.sdk.model.md.Entry> usedBy​(com.gooddata.sdk.model.project.Project project, java.lang.String uri, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
    Find all objects which use the given object.
    java.util.Collection<com.gooddata.sdk.model.md.Usage> usedBy​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> uris, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
    Find all objects which use the given objects.

    Methods inherited from class com.gooddata.sdk.service.AbstractService

    extractData

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OBJ_TEMPLATE

      public static final org.springframework.web.util.UriTemplate OBJ_TEMPLATE
  • Constructor Details

  • Method Details

    • createObj

      public <T extends com.gooddata.sdk.model.md.Obj> T createObj​(com.gooddata.sdk.model.project.Project project, T obj)
      Create metadata object in given project
      Type Parameters:
      T - type of the object to be created
      Parameters:
      project - project
      obj - metadata object to be created
      Returns:
      new metadata object
      Throws:
      ObjCreateException - if creation failed
      ObjNotFoundException - if new metadata object not found after creation
      com.gooddata.sdk.common.GoodDataRestException - if GoodData REST API returns unexpected status code when getting the new object
      com.gooddata.sdk.common.GoodDataException - if no response from API or client-side HTTP error when getting the new object
    • getObjByUri

      public <T extends com.gooddata.sdk.model.md.Obj> T getObjByUri​(java.lang.String uri, java.lang.Class<T> cls)
      Get metadata object by URI (format is /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})
      Type Parameters:
      T - type of the object to be returned
      Parameters:
      uri - URI in format /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID}
      cls - class of the resulting object
      Returns:
      the metadata object
      Throws:
      ObjNotFoundException - if metadata object not found
      com.gooddata.sdk.common.GoodDataRestException - if GoodData REST API returns unexpected status code
      com.gooddata.sdk.common.GoodDataException - if no response from API or client-side HTTP error
    • getObjsByUris

      public java.util.Collection<com.gooddata.sdk.model.md.Obj> getObjsByUris​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> uris)
      Retrieves a collection of objects corresponding to the supplied collection of URIs.
      Parameters:
      project - project that contains the objects to be retrieved
      uris - collection of URIs
      Returns:
      collection of metadata objects corresponding to the supplied URIs
    • updateObj

      public <T extends com.gooddata.sdk.model.md.Updatable> T updateObj​(T obj)
      Update given metadata object.
      Type Parameters:
      T - type of the updated object
      Parameters:
      obj - object to update
      Returns:
      updated metadata object
      Throws:
      ObjUpdateException - in case of error
    • removeObj

      public void removeObj​(com.gooddata.sdk.model.md.Obj obj)
      Remove metadata object URI
      Parameters:
      obj - metadata object to remove
      Throws:
      ObjNotFoundException - if metadata object not found
      com.gooddata.sdk.common.GoodDataRestException - if GoodData REST API returns unexpected status code
      com.gooddata.sdk.common.GoodDataException - if no response from API or client-side HTTP error
    • removeObjByUri

      public void removeObjByUri​(java.lang.String uri)
      Remove metadata object by URI (format is /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})
      Parameters:
      uri - URI in format /gdc/md/{PROJECT_ID}/obj/{OBJECT_ID}
      Throws:
      ObjNotFoundException - if metadata object not found
      com.gooddata.sdk.common.GoodDataRestException - if GoodData REST API returns unexpected status code
      com.gooddata.sdk.common.GoodDataException - if no response from API or client-side HTTP error
    • getObjById

      public <T extends com.gooddata.sdk.model.md.Obj> T getObjById​(com.gooddata.sdk.model.project.Project project, java.lang.String id, java.lang.Class<T> cls)
      Get metadata object by id.
      Type Parameters:
      T - type of the object to be returned
      Parameters:
      project - project where to search for the object
      id - id of the object
      cls - class of the resulting object
      Returns:
      the metadata object
      Throws:
      ObjNotFoundException - if metadata object not found
      com.gooddata.sdk.common.GoodDataRestException - if GoodData REST API returns unexpected status code
      com.gooddata.sdk.common.GoodDataException - if no response from API or client-side HTTP error
    • getObjUri

      public <T extends com.gooddata.sdk.model.md.Queryable> java.lang.String getObjUri​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
      Get metadata object URI by restrictions like identifier, title or summary.
      Type Parameters:
      T - type of the object to be returned
      Parameters:
      project - project where to search for the object
      cls - class of the resulting object
      restrictions - query restrictions
      Returns:
      the URI of metadata object
      Throws:
      ObjNotFoundException - if metadata object not found
      NonUniqueObjException - if more than one object corresponds to search restrictions
    • getObj

      public <T extends com.gooddata.sdk.model.md.Queryable> T getObj​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
      Get metadata object by restrictions like identifier, title or summary.
      Type Parameters:
      T - type of the object to be returned
      Parameters:
      project - project where to search for the object
      cls - class of the resulting object
      restrictions - query restrictions
      Returns:
      metadata object
      Throws:
      ObjNotFoundException - if metadata object not found
      NonUniqueObjException - if more than one object corresponds to search restrictions
    • find

      public <T extends com.gooddata.sdk.model.md.Queryable> java.util.Collection<com.gooddata.sdk.model.md.Entry> find​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
      Find metadata by restrictions like identifier, title or summary.
      Type Parameters:
      T - type of the metadata referenced in returned entries
      Parameters:
      project - project where to search for the metadata
      cls - class of searched metadata
      restrictions - query restrictions
      Returns:
      the collection of metadata entries
      Throws:
      com.gooddata.sdk.common.GoodDataException - if unable to query metadata
    • findUris

      public <T extends com.gooddata.sdk.model.md.Queryable> java.util.Collection<java.lang.String> findUris​(com.gooddata.sdk.model.project.Project project, java.lang.Class<T> cls, com.gooddata.sdk.model.md.Restriction... restrictions)
      Find metadata URIs by restrictions like identifier, title or summary.
      Type Parameters:
      T - type of the metadata referenced by returned URIs
      Parameters:
      project - project where to search for the metadata
      cls - class of searched metadata
      restrictions - query restrictions
      Returns:
      the collection of metadata URIs
      Throws:
      com.gooddata.sdk.common.GoodDataException - if unable to query metadata
    • usedBy

      public java.util.Collection<com.gooddata.sdk.model.md.Entry> usedBy​(com.gooddata.sdk.model.project.Project project, com.gooddata.sdk.model.md.Obj obj, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
      Find all objects which use the given object.
      Parameters:
      project - project
      obj - object to find using objects for
      nearest - find nearest objects only
      types - what types (categories) to search for (for example 'reportDefinition', 'report', 'tableDataLoad', 'table'...)
      Returns:
      objects using given objects.
    • usedBy

      public java.util.Collection<com.gooddata.sdk.model.md.Entry> usedBy​(com.gooddata.sdk.model.project.Project project, java.lang.String uri, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
      Find all objects which use the given object.
      Parameters:
      project - project
      uri - URI of object to find using objects for
      nearest - find nearest objects only
      types - what types (categories) to search for (for example 'reportDefinition', 'report', 'tableDataLoad', 'table'...)
      Returns:
      objects using given objects.
      See Also:
      usedBy(Project, Collection, boolean, Class[])
    • usedBy

      public java.util.Collection<com.gooddata.sdk.model.md.Usage> usedBy​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> uris, boolean nearest, java.lang.Class<? extends com.gooddata.sdk.model.md.Obj>... types)
      Find all objects which use the given objects. Batch alternative to usedBy(Project, String, boolean, Class[])
      Parameters:
      project - project
      uris - URIs of object to find using objects for
      nearest - find nearest objects only
      types - what types (categories) to search for (for example 'reportDefinition', 'report', 'tableDataLoad', 'table'...), returns all objects if no type is provided
      Returns:
      objects usages
      See Also:
      usedBy(Project, String, boolean, Class[])
    • findUris

      public java.util.Collection<java.lang.String> findUris​(com.gooddata.sdk.model.project.Project project, com.gooddata.sdk.model.md.Restriction... restrictions)
      Find metadata URIs by restrictions. Identifier is the only supported restriction.
      Parameters:
      project - project where to search for the metadata
      restrictions - query restrictions
      Returns:
      the collection of metadata URIs
      Throws:
      com.gooddata.sdk.common.GoodDataException - if unable to query metadata
    • identifiersToUris

      public java.util.Map<java.lang.String,​java.lang.String> identifiersToUris​(com.gooddata.sdk.model.project.Project project, java.util.Collection<java.lang.String> identifiers)
      Find metadata URIs for given identifiers.
      Parameters:
      project - project where to search for the metadata
      identifiers - query restrictions
      Returns:
      the map of identifiers as keys and metadata URIs as values
      Throws:
      com.gooddata.sdk.common.GoodDataException - if unable to query metadata
      See Also:
      findUris(Project, Restriction...)
    • getAttributeElements

      public java.util.List<com.gooddata.sdk.model.md.AttributeElement> getAttributeElements​(com.gooddata.sdk.model.md.Attribute attribute)
      Fetches attribute elements for given attribute using default display form.
      Parameters:
      attribute - attribute to fetch elements for
      Returns:
      attribute elements or empty set if there is no link for elements in default display form
    • getAttributeElements

      public java.util.List<com.gooddata.sdk.model.md.AttributeElement> getAttributeElements​(com.gooddata.sdk.model.md.DisplayForm displayForm)
      Fetches attribute elements by given display form.
      Parameters:
      displayForm - display form to fetch attributes for
      Returns:
      attribute elements or empty set if there is no link for elements