/
Developing a Query Response Transformer

Developing a Query Response Transformer

Prerequisites

  1. Understand the desired component for development as described in the DDF Catalog section.
  2. Have an IDE and the ability to create OSGi bundles.
  3. 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 Results 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 

  1. Create a new Java class that implements ddf.catalog.transform.QueryResponseTransformer.

    public class SampleResponseTransformer implements ddf.catalog.transform.QueryResponseTransformer
    
  2. Implement the transform method.

    public BinaryContent transform(SourceResponse upstreamResponse, Map<String, Serializable> arguments) throws CatalogTransformerException
    
  3. Import the DDF interface packages to the bundle manifest (in addition to any other required packages).

    Import-Package: ddf.catalog, ddf.catalog.transform
    
  4. 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>
    ... 
  5. Deploy OSGi Bundle to OSGi runtime.

Variable Descriptions

Blueprint Service properties
KeyDescription of ValueExample
shortnameAn abbreviation for the return-type of the BinaryContent being sent to the user.atom
titleA user-readable title that describes (in greater detail than the shortname) the service.Atom Entry Transformer Service
descriptionA 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