Class DcatDocumentFormatter
java.lang.Object
org.odpi.openmetadata.frameworks.integration.dcat.DcatDocumentFormatter
DcatDocumentFormatter reads and writes DCAT documents. The documents are in JSON-LD format, which is the
serialization of DCAT that is also valid JSON. Any arrangement of a JSON-LD document can be read (nested, flattened,
with prefixes or with full IRIs). Documents written by this class embed their context and nest the description of a
dataset's distributions, publisher and contact points inside the dataset. The class is stateless and its methods are
thread-safe. Parsing problems are reported as IOException so that callers do not need the Jackson libraries on
their classpath.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TfromJSONFragment(String json, Class<T> beanClass) Read a single bean from a JSON fragment written by toJSONFragment.static <T> List<T> fromJSONFragmentList(String json, Class<T> beanClass) Read a list of beans from a JSON fragment written by toJSONFragment.fromJSONFragmentMap(String json) Read a map of strings from a JSON fragment written by toJSONFragment.Read a map of lists of strings from a JSON fragment written by toJSONFragment.static booleanhasContent(DcatDocument document) Return whether a document describes at least one catalog, dataset or data service.static DcatDocumentparseDocument(String rawDocument) Parse a DCAT document.static StringtoJSONFragment(Object bean) Write any DCAT bean (or list of beans) as plain JSON.static StringtoJSONLD(DcatDocument document) Write a DCAT document as JSON-LD.toJSONLDStructure(DcatDocument document) Convert a DCAT document into the structure of a JSON-LD document.
-
Method Details
-
parseDocument
Parse a DCAT document.- Parameters:
rawDocument- document in JSON-LD format- Returns:
- bean version of the document
- Throws:
IOException- the document is not valid JSON-LD
-
hasContent
Return whether a document describes at least one catalog, dataset or data service.- Parameters:
document- bean version of the document- Returns:
- boolean
-
toJSONLDStructure
Convert a DCAT document into the structure of a JSON-LD document. This structure can be embedded in another JSON document, such as the response to a REST API call.- Parameters:
document- bean version of the document- Returns:
- map that serializes to the JSON-LD document
-
toJSONLD
Write a DCAT document as JSON-LD.- Parameters:
document- bean version of the document- Returns:
- JSON-LD string
- Throws:
IOException- problem serializing the document
-
toJSONFragment
Write any DCAT bean (or list of beans) as plain JSON. This is used to keep fragments of a document, such as the details of its publisher, losslessly in the additional properties of an open metadata element.- Parameters:
bean- bean or list of beans- Returns:
- JSON string
- Throws:
IOException- problem serializing the bean
-
fromJSONFragment
Read a single bean from a JSON fragment written by toJSONFragment.- Type Parameters:
T- bean type- Parameters:
json- JSON string (may be null)beanClass- class of the bean- Returns:
- bean or null if the fragment is absent
- Throws:
IOException- problem parsing the JSON
-
fromJSONFragmentList
Read a list of beans from a JSON fragment written by toJSONFragment.- Type Parameters:
T- bean type- Parameters:
json- JSON string (may be null)beanClass- class of the list elements- Returns:
- list of beans or null if the fragment is absent
- Throws:
IOException- problem parsing the JSON
-
fromJSONFragmentMapOfLists
Read a map of lists of strings from a JSON fragment written by toJSONFragment.- Parameters:
json- JSON string (may be null)- Returns:
- map or null if the fragment is absent
- Throws:
IOException- problem parsing the JSON
-
fromJSONFragmentMap
Read a map of strings from a JSON fragment written by toJSONFragment.- Parameters:
json- JSON string (may be null)- Returns:
- map or null if the fragment is absent
- Throws:
IOException- problem parsing the JSON
-