Public:BWmeta service/Transformers

From YaddaWiki

(Difference between revisions)
Jump to: navigation, search
(MetadataTransformerFactory and transformer interfaces)
(Unified interface (under construction))
Line 33: Line 33:
== Unified interface (under construction) ==
== Unified interface (under construction) ==
-
Three different transformer types are present: readers, writers and converters.  Each type has a corresponding interface:
+
Four different transformer types are present: readers, writers and model converters and format converters.  Each type has a corresponding interface:
* <code>IMetadataReader&lt;T&gt;</code> deserializes an object of type <code>T</code> from a <code>String</code> or a <code>Reader</code>
* <code>IMetadataReader&lt;T&gt;</code> deserializes an object of type <code>T</code> from a <code>String</code> or a <code>Reader</code>
* <code>IMetadataWriter&lt;T&gt;</code> serializes an object of type <code>T</code> to a <code>String</code> or a <code>Writer</code>
* <code>IMetadataWriter&lt;T&gt;</code> serializes an object of type <code>T</code> to a <code>String</code> or a <code>Writer</code>
-
* <code>IMetadataConverter&lt;S, T&gt;</code> converts an object of type <code>S</code> to an object of type <code>T</code>
+
* <code>IMetadataModelConverter&lt;S, T&gt;</code> converts an object of type <code>S</code> to an object of type <code>T</code>
 +
* <code>IMetadataFormatConverter</code>  
<code>MetadataTransformerFactory</code> maintains a list of available "atomic" transformers
<code>MetadataTransformerFactory</code> maintains a list of available "atomic" transformers
and is able to combine the atomic transformers into more complex ones.
and is able to combine the atomic transformers into more complex ones.
 +
 +
Public constructors provided by <code>MetadataTransformerFactory</code>:
 +
* <code>MetadataTransformerFactory(List&lt;IMetadataReaders&gt;, List&lt;IMetadataWriters&gt;, List&lt;IMetadataModelConverters&gt;, List&lt;IMetadataFormatConverters&gt;)</code> -- builds a MetadataTransformerFactory from given lists of atomic transformers,
 +
* <code>MetadataTransformerFactory(MetadataTransformerFactory, List&lt;IMetadataReaders&gt;, List&lt;IMetadataWriters&gt;, List&lt;IMetadataModelConverters&gt;, List&lt;IMetadataFormatConverters&gt;)</code> -- creates a new MetadataTransformerFactory from an existing one, which contains joined lists of atomic transformers.
 +
 +
Public methods of <code>MetadataTransformerFactory</code>, that return return transformer built from atomic transformers given in object constructor:
 +
* &lt;T&gt; IMetadataReader&lt;T&gt; getReader(MetadataModel&lt;T&gt;, MetadataFormat)
 +
* &lt;T&gt; IMetadataWriter&lt;T&gt; getWriter(MetadataModel&lt;T&gt;, MetadataFormat)
 +
* &lt;S, T&gt; IMetadataModelConverter&lt;S, T&gt; getModelConverter(MetadataModel&lt;S&gt;, MetadataModel&lt;T&gt;)
 +
* IMetadataFormatConverter getFormatConverter(MetadataFormat, MetadataFormat)
 +
 +
<code>MetadataTransformerFactory</code> also contains a set of static methods <code>compose()</code>, that return a complex transformer built from two given transformers:
 +
* IMetadataReader compose(IMetadataFormatConverter, IMetadataReader)
 +
* IMetadataReader compose(IMetadataReader, IMetadataModelConverter)
 +
* IMetadataWriter compose(IMetadataWriter, IMetadataFormatConverter)
 +
* IMetadataWriter compose(IMetadataModelConverter, IMetadataWriter)
 +
* IMetadataFormatConverter compose(IMetadataFormatConverter, IMetadataFormatConverter)
 +
* IMetadataFormatConverter compose(IMetadataReader, IMetadataWriter)
 +
* IMetadataModelConverter compose(IMetadataModelConverter, IMetadataModelConverter)
 +
* IMetadataModelConverter compose(IMetadataWriter, IMetadataReader)

Revision as of 11:32, 13 December 2010

Service details
NameBWmeta
Code location
(relative to SVN root)
projects/dir/bwmeta-core
Javadoc
Contact personJakub Jurkiewicz

Background and motivation

As of 2010Q4, three versions of BWmeta format and at least three Java models of BWmeta are used in YADDA. See here for details. Serialization and deserialization is implemented for the following pairs:

Repo DL Y
1.0.5 Image:Tick.png Image:Tick.png
1.2.0 Image:Tick.png
2.0.0 Image:Tick.png

There are also converters between selected models:

  • Y ↔ DL

Serialization of Y model to BWmeta 1.0.5 is therefore possible through the following chain of transformations:

  • Y model → DL model → BWmeta 1.0.5

Conversion from DL model to Repo model is possible through:

  • DL model → BWmeta 1.0.5 → Repo model

Unfortunately, many mutually-incompatible transformation interfaces are present. It is difficult to understand which transformations are possible, how to combine them, which classes should be used for that end and how to instantiate the classes.

A unified interface to all the transformations would be very helpful.

Unified interface (under construction)

Four different transformer types are present: readers, writers and model converters and format converters. Each type has a corresponding interface:

  • IMetadataReader<T> deserializes an object of type T from a String or a Reader
  • IMetadataWriter<T> serializes an object of type T to a String or a Writer
  • IMetadataModelConverter<S, T> converts an object of type S to an object of type T
  • IMetadataFormatConverter

MetadataTransformerFactory maintains a list of available "atomic" transformers and is able to combine the atomic transformers into more complex ones.

Public constructors provided by MetadataTransformerFactory:

  • MetadataTransformerFactory(List<IMetadataReaders>, List<IMetadataWriters>, List<IMetadataModelConverters>, List<IMetadataFormatConverters>) -- builds a MetadataTransformerFactory from given lists of atomic transformers,
  • MetadataTransformerFactory(MetadataTransformerFactory, List<IMetadataReaders>, List<IMetadataWriters>, List<IMetadataModelConverters>, List<IMetadataFormatConverters>) -- creates a new MetadataTransformerFactory from an existing one, which contains joined lists of atomic transformers.

Public methods of MetadataTransformerFactory, that return return transformer built from atomic transformers given in object constructor:

  • <T> IMetadataReader<T> getReader(MetadataModel<T>, MetadataFormat)
  • <T> IMetadataWriter<T> getWriter(MetadataModel<T>, MetadataFormat)
  • <S, T> IMetadataModelConverter<S, T> getModelConverter(MetadataModel<S>, MetadataModel<T>)
  • IMetadataFormatConverter getFormatConverter(MetadataFormat, MetadataFormat)

MetadataTransformerFactory also contains a set of static methods compose(), that return a complex transformer built from two given transformers:

  • IMetadataReader compose(IMetadataFormatConverter, IMetadataReader)
  • IMetadataReader compose(IMetadataReader, IMetadataModelConverter)
  • IMetadataWriter compose(IMetadataWriter, IMetadataFormatConverter)
  • IMetadataWriter compose(IMetadataModelConverter, IMetadataWriter)
  • IMetadataFormatConverter compose(IMetadataFormatConverter, IMetadataFormatConverter)
  • IMetadataFormatConverter compose(IMetadataReader, IMetadataWriter)
  • IMetadataModelConverter compose(IMetadataModelConverter, IMetadataModelConverter)
  • IMetadataModelConverter compose(IMetadataWriter, IMetadataReader)
Personal tools