Package com.gooddata.sdk.service.md
Class MetadataService
java.lang.Object
com.gooddata.sdk.service.AbstractService
com.gooddata.sdk.service.md.MetadataService
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
FieldsModifier and TypeFieldDescriptionstatic final org.springframework.web.util.UriTemplateFields inherited from class com.gooddata.sdk.service.AbstractService
mapper, restTemplate -
Constructor Summary
ConstructorsConstructorDescriptionMetadataService(org.springframework.web.client.RestTemplate restTemplate, GoodDataSettings settings) -
Method Summary
Modifier and TypeMethodDescription<T extends Obj>
TCreate metadata object in given project<T extends Queryable>
Collection<Entry>find(Project project, Class<T> cls, Restriction... restrictions) Find metadata by restrictions like identifier, title or summary.findUris(Project project, Restriction... restrictions) Find metadata URIs by restrictions.<T extends Queryable>
Collection<String>findUris(Project project, Class<T> cls, Restriction... restrictions) Find metadata URIs by restrictions like identifier, title or summary.getAttributeElements(Attribute attribute) Fetches attribute elements for given attribute using default display form.getAttributeElements(DisplayForm displayForm) Fetches attribute elements by given display form.<T extends Queryable>
TgetObj(Project project, Class<T> cls, Restriction... restrictions) Get metadata object by restrictions like identifier, title or summary.<T extends Obj>
TgetObjById(Project project, String id, Class<T> cls) Get metadata object by id.<T extends Obj>
TgetObjByUri(String uri, Class<T> cls) Get metadata object by URI (format is/gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})getObjsByUris(Project project, Collection<String> uris) Retrieves a collection of objects corresponding to the supplied collection of URIs.getObjUri(Project project, Class<T> cls, Restriction... restrictions) Get metadata object URI by restrictions like identifier, title or summary.getTimezone(Project project) Get project/workspace timezone.identifiersToUris(Project project, Collection<String> identifiers) Find metadata URIs for given identifiers.voidRemove metadata object URIvoidremoveObjByUri(String uri) Remove metadata object by URI (format is/gdc/md/{PROJECT_ID}/obj/{OBJECT_ID})voidsetTimezone(Project project, String timezone) Set project/workspace timezone.<T extends Updatable>
TupdateObj(T obj) Update given metadata object.Find all objects which use the given object.Find all objects which use the given object.Find all objects which use the given objects.Methods inherited from class com.gooddata.sdk.service.AbstractService
extractData
-
Field Details
-
OBJ_TEMPLATE
public static final org.springframework.web.util.UriTemplate OBJ_TEMPLATE
-
-
Constructor Details
-
MetadataService
public MetadataService(org.springframework.web.client.RestTemplate restTemplate, GoodDataSettings settings)
-
-
Method Details
-
createObj
Create metadata object in given project- Type Parameters:
T- type of the object to be created- Parameters:
project- projectobj- metadata object to be created- Returns:
- new metadata object
- Throws:
ObjCreateException- if creation failedObjNotFoundException- if new metadata object not found after creationcom.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status code when getting the new objectcom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error when getting the new object
-
getObjByUri
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 foundcom.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status codecom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error
-
getObjsByUris
Retrieves a collection of objects corresponding to the supplied collection of URIs.- Parameters:
project- project that contains the objects to be retrieveduris- collection of URIs- Returns:
- collection of metadata objects corresponding to the supplied URIs
-
updateObj
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
Remove metadata object URI- Parameters:
obj- metadata object to remove- Throws:
ObjNotFoundException- if metadata object not foundcom.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status codecom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error
-
removeObjByUri
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 foundcom.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status codecom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error
-
getObjById
Get metadata object by id.- Type Parameters:
T- type of the object to be returned- Parameters:
project- project where to search for the objectid- id of the objectcls- class of the resulting object- Returns:
- the metadata object
- Throws:
ObjNotFoundException- if metadata object not foundcom.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status codecom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error
-
getObjUri
public <T extends Queryable> String 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 objectcls- class of the resulting objectrestrictions- query restrictions- Returns:
- the URI of metadata object
- Throws:
ObjNotFoundException- if metadata object not foundNonUniqueObjException- if more than one object corresponds to search restrictions
-
getObj
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 objectcls- class of the resulting objectrestrictions- query restrictions- Returns:
- metadata object
- Throws:
ObjNotFoundException- if metadata object not foundNonUniqueObjException- if more than one object corresponds to search restrictions
-
find
public <T extends Queryable> Collection<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 metadatacls- class of searched metadatarestrictions- query restrictions- Returns:
- the collection of metadata entries
- Throws:
com.gooddata.sdk.common.GoodDataException- if unable to query metadata
-
findUris
public <T extends Queryable> Collection<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 metadatacls- class of searched metadatarestrictions- query restrictions- Returns:
- the collection of metadata URIs
- Throws:
com.gooddata.sdk.common.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- projectobj- object to find using objects fornearest- find nearest objects onlytypes- 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- projecturi- URI of object to find using objects fornearest- find nearest objects onlytypes- what types (categories) to search for (for example 'reportDefinition', 'report', 'tableDataLoad', 'table'...)- Returns:
- objects using given objects.
- See Also:
-
usedBy
public Collection<Usage> usedBy(Project project, Collection<String> uris, boolean nearest, Class<? extends Obj>... types) Find all objects which use the given objects. Batch alternative tousedBy(Project, String, boolean, Class[])- Parameters:
project- projecturis- URIs of object to find using objects fornearest- find nearest objects onlytypes- 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:
-
findUris
Find metadata URIs by restrictions. Identifier is the only supported restriction.- Parameters:
project- project where to search for the metadatarestrictions- query restrictions- Returns:
- the collection of metadata URIs
- Throws:
com.gooddata.sdk.common.GoodDataException- if unable to query metadata
-
identifiersToUris
Find metadata URIs for given identifiers.- Parameters:
project- project where to search for the metadataidentifiers- 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:
-
getAttributeElements
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
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
-
getTimezone
Get project/workspace timezone.- Parameters:
project- project from what to return the timezone- Returns:
- string identifier of the timezone (see IANA/Olson tz database for possible values)
- Throws:
com.gooddata.sdk.common.GoodDataRestException- if GoodData REST API returns unexpected status codecom.gooddata.sdk.common.GoodDataException- if no response from API or client-side HTTP error
-
setTimezone
Set project/workspace timezone.- Parameters:
project- the project/workspace where to set the timezonetimezone- the timezone to be set (see IANA/Olson tz database for possible values)
-