Programming Components to use the Metadata Mapper (Aspire 2)

Jump to: navigation, search

For Information on Aspire 3.1 Click Here

How to Use It In Your Component Source Code

There are two classes for the Metadata Mapper. The MetadataMapperFactory reads in the configuration during your initialize method and prepares for mapping. It is then used to produce MetadataMapper objects which can be used (one per thread) to map the fields for a single document.

1. Add the following member variable to your component class:

 MetadataMapperFactory mmFactory = new MetadataMapperFactory(this);

2 Put the following into your Component.initialize() method:


3. Map some metadata (this goes in the Stage.process() method):

   MetadataMapper mm = mmFactory.getNewMapper();
   /* loop through your metadata values */ {
     // Map each one (only stores it), value);
   // Now, compute the mappings and write them to the AspireDocument

Default Mappings

If you want to have default mappings, these must be defined in your initialize() method:

   // Add a mapping with no name transformation - ie "title -> "title"
   mmFactory.addDefault(String fromTo);
   // Add a mapping with only a name transformation - ie "DC.title -> "title"
   mmFactory.addDefault(String from, String to);
   // Add a mapping with name transformation and date/time pasing - ie "title -> "title"
   mmFactory.addDefault(String from, String to, String dateFmt, String dateTimeFmt);