Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 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:

...

Code Block
languagejava
themeEclipse
MetadataMapperFactory mmFactory = new MetadataMapperFactory(this);

...

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

...

Code Block
languagejava
themeEclipse
mmFactory.initialize(config);

...

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

...

Code Block
languagejava
themeEclipse
  MetadataMapper mm = mmFactory.getNewMapper();
   /* loop through your metadata values */ {
     // Map each one (only stores it)
     mm.map(name, value);
   }
   
   // Now, compute the mappings and write them to the AspireDocument
   mm.writeMappingsToDocument(doc);

...

Default Mappings

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

Code Block
languagejava
themeEclipse
    // 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);

...