/
Developing a Query Response Transformer
Developing a Query Response Transformer
Prerequisites
- Understand the desired component for development as described in the DDF Catalog section.
- Review existing implementations in the source code and application documentation.
- Have an IDE and the ability to create OSGi bundles.
- Understand the Use of the Whiteboard Design Pattern section and how to publish services to the OSGi service registry.
Overview
A QueryResponseTransformer
is used to transform a List
of Result
s from a SourceResponse
. Query Response Transformers can be used through the Catalog transform
convenience method or requested from the OSGi Service Registry by Endpoints or other bundles. See Included Query Response Transformers for examples.
Creating a new Query Response Transformer
Create a new Java class that implements
ddf.catalog.transform.QueryResponseTransformer.
public class SampleResponseTransformer implements ddf.catalog.transform.QueryResponseTransformer
Implement the
transform
method.public BinaryContent transform(SourceResponse upstreamResponse, Map<String, Serializable> arguments) throws CatalogTransformerException
Import the DDF interface packages to the bundle manifest (in addition to any other required packages).
Import-Package: ddf.catalog, ddf.catalog.transform
Create an OSGi descriptor file to communicate with the OSGi Service Registry (described in the Working with OSGi section). Export the service to the OSGi registry and declare service properties.
Blueprint descriptor example... <service ref="[[SampleResponseTransformer]]" interface="ddf.catalog.transform.QueryResponseTransformer"> <service-properties> <entry key="shortname" value="[[sampletransform]]" /> <entry key="title" value="[[Sample Response Transformer]]" /> <entry key="description" value="[[A new transformer for response queues.]]" /> </service-properties> </service> ...
- Deploy OSGi Bundle to OSGi runtime.
Variable Descriptions
Blueprint Service properties
Key | Description of Value | Example |
---|---|---|
shortname | An abbreviation for the return-type of the BinaryContent being sent to the user. | atom |
title | A user-readable title that describes (in greater detail than the shortname) the service. | Atom Entry Transformer Service |
description | A short, human-readable description that describes the functionality of the service and the output. | This service converts a single metacard xml document to an atom entry element. |
Additional Reading
, multiple selections available,