/
Developing a Metacard Transformer

Developing a Metacard 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

In general a MetacardTransformer is used to transform a Metacard into some desired format useful to the end user or as input to another process. Programmatically a MetacardTransformer transforms a Metacard into a BinaryContent instance, which contains the translated Metacard into the desired final format. Metacard Transformers can be used through the Catalog Framework transform convenience method or requested from the OSGi Service Registry by Endpoints or other bundles. See Included Metacard Transformers for examples.

Creating a new Metacard Transformer 

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

    public class SampleMetacardTransformer implements ddf.catalog.transform.MetacardTransformer
    
  2. Implement the transform method.

    public BinaryContent transform(Metacard metacard, 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="[[SampleMetacardTransformer]]" interface="ddf.catalog.transform.MetacardTransformer">
        <service-properties>
            <entry key="shortname" value="[[sampletransform]]" />
            <entry key="title" value="[[Sample Metacard Transformer]]" />
            <entry key="description" value="[[A new transformer for metacards.]]" />
        </service-properties>
    </service>
    ... 
  5. Deploy OSGi Bundle to OSGi runtime.

Variable Descriptions

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