Class MetadataService


  • public class MetadataService
    extends AbstractService
    Query, create and update project metadata - attributes, facts, metrics, reports,...
    • Constructor Detail

      • MetadataService

        public MetadataService​(org.springframework.web.client.RestTemplate restTemplate,
                               GoodDataSettings settings)
      • MetadataService

        @Deprecated
        public MetadataService​(org.springframework.web.client.RestTemplate restTemplate)
        Deprecated.
        use MetadataService(RestTemplate, GoodDataSettings) constructor instead
    • Method Detail

      • createObj

        public <T extends Obj> T createObj​(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.GoodDataRestException - if GoodData REST API returns unexpected status code when getting the new object
        com.gooddata.GoodDataException - if no response from API or client-side HTTP error when getting the new object
      • getObjByUri

        public <T extends Obj> T getObjByUri​(String uri,
                                             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.GoodDataRestException - if GoodData REST API returns unexpected status code
        com.gooddata.GoodDataException - if no response from API or client-side HTTP error
      • getObjsByUris

        public Collection<Obj> getObjsByUris​(Project project,
                                             Collection<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 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​(Obj obj)
        Remove metadata object URI
        Parameters:
        obj - metadata object to remove
        Throws:
        ObjNotFoundException - if metadata object not found
        com.gooddata.GoodDataRestException - if GoodData REST API returns unexpected status code
        com.gooddata.GoodDataException - if no response from API or client-side HTTP error
      • removeObjByUri

        public void removeObjByUri​(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.GoodDataRestException - if GoodData REST API returns unexpected status code
        com.gooddata.GoodDataException - if no response from API or client-side HTTP error
      • getObjById

        public <T extends Obj> T getObjById​(Project project,
                                            String id,
                                            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.GoodDataRestException - if GoodData REST API returns unexpected status code
        com.gooddata.GoodDataException - if no response from API or client-side HTTP error
      • getObjUri

        public <T extends QueryableString getObjUri​(Project project,
                                                      Class<T> cls,
                                                      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 Queryable> T getObj​(Project project,
                                              Class<T> cls,
                                              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 QueryableCollection<Entry> find​(Project project,
                                                            Class<T> cls,
                                                            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.GoodDataException - if unable to query metadata
      • findUris

        public <T extends QueryableCollection<String> findUris​(Project project,
                                                                 Class<T> cls,
                                                                 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.GoodDataException - if unable to query metadata
      • usedBy

        public Collection<Entry> usedBy​(Project project,
                                        Obj obj,
                                        boolean nearest,
                                        Class<? extends 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 Collection<Entry> usedBy​(Project project,
                                        String uri,
                                        boolean nearest,
                                        Class<? extends 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[])
      • findUris

        public Collection<String> findUris​(Project project,
                                           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.GoodDataException - if unable to query metadata
      • identifiersToUris

        public Map<String,​String> identifiersToUris​(Project project,
                                                          Collection<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.GoodDataException - if unable to query metadata
        See Also:
        findUris(Project, Restriction...)
      • getAttributeElements

        public List<AttributeElement> getAttributeElements​(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 List<AttributeElement> getAttributeElements​(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