Class org.xmlmiddleware.xmldbms.maps.utils.MapInverter

Invert the database-centric or XML-centric map objects in an XMLDBMSMap.

An XMLDBMSMap is the root of a graph of map objects. ClassMap, PropertyMap,
InlineClassMap, and RelatedClassMap objects form an XML-centric view of the map.
That is, they map XML elements, attributes, and PCDATA to database structures.
ClassTableMap, PropertyTableMap, ColumnMap, ElementInsertionList, ElementInsertionMap,
and RelatedClassTableMap objects form a database-centric view of the map. That is,
they map tables and columns to XML structures.

The primary users of MapInverter are map factories, which usually create one
view and use the MapInverter to create the other view. For example, MapFactory_MapDocument
and MapFactory_DTD create XML-centric objects, then use MapInverter to create the
database-centric objects. MapFactory_Database creates database-centric objects, then
uses MapInverter to create the XML-centric objects.

The correspondence between the XML-centric and database-centric objects is as
follows. ClassMap corresponds to ClassTableMap. PropertyMap corresponds to ColumnMap
and PropertyTableMap. InlineClassMap corresponds to ElementInsertionList and
ElementInsertionMap. And RelatedClassMap corresponds to RelatedClassTableMap.

Warning: This method deletes any existing objects that form part of the
database-centric view of the map.

Warning: If one ClassMap uses another ClassMap, this information is partially
lost in the inversion process. The reason for this is that there is no place to
store this information in a ClassTableMap. For example, suppose element types Book
and Essay both use the ClassMap for element type Writing, which is mapped to the
Writings table. A ClassTableMap can only be mapped to a single element type, so it
is mapped to Writing, not Book or Essay.

Fortunately, this is not as bad as it sounds. If an element type that uses the
ClassMap for another element type is mapped as a related class, then the usage
information is retained. The reason for this is that the RelatedClassMap is inverted
to a RelatedClassTableMap and the RelatedClassTableMap can store the name of the
mapped element type.

Thus, the only real drawback at a mapping level is that used ClassMaps can't
be round-tripped. That is, calling createDatabaseView() and then calling
createXMLView() results in the loss of these ClassMaps. Fortunately, there
seems to be no reason to round-trip such maps.

(At a data level, this means that root elements that use the ClassMaps of other
elements can't be reconstructed -- the element type of the used ClassMap is reconstructed
instead -- but that child elements that use the ClassMaps of other element types
can be reconstructed.)