org.openadaptor.adaptor.standard
Class AliasingPipeSegment

java.lang.Object
  extended by org.openadaptor.adaptor.SimpleComponent
      extended by org.openadaptor.adaptor.AbstractSimplePipe
          extended by org.openadaptor.adaptor.standard.AliasingPipeSegment
All Implemented Interfaces:
CallbackProvider, Component, Configurable, IbafTransactionalResource, Sink, DOMessageReaderDelegate
Direct Known Subclasses:
DOFactoryPipe

public class AliasingPipeSegment
extends AbstractSimplePipe

Creates a new DataObject array from the supplied DataObject array with certain attributes 'aliased' - that is, renamed as directed by the configuration (properties) file.

Aliases are to be supplied in the config file as follows:

   xxx.Alias1 = inName outName
   xxx.Alias2 = inName outName
 

or (for explicit type aliasing)

          xxx.Type1 = inType outType

          xxx.Type1.Alias1 = inName outName [SDO Type name]
          xxx.Type1.Alias2 = inName outName [SDO Type name]
 

or (for predicate based aliasing type/attribute values), this uses SimpleDOPredicate objects.

           xxx.Type1                  = outType
    xxx.Type1.Type             = inType
    xxx.Type1.AttName1         = att name
    xxx.Type1.AttValue1        = att value
 

or xxx.Type1.AttRegExprValue1 = att reg expression

           xxx.Type1.Alias1           = inName outName [SDO Type name]
           xxx.Type1.Alias2           = inName outName [SDO Type name]
 

the optional third parameter is a class name for the value object created. If the incoming value is not of the class specified the pipe will attempt to instantiate a new value of the specified class using

Also support dataObjectType caching (rather then creating simple data type everytime. use following property but be careful that no down stream components do not modify types directly by calling addAttributeValue().

   xxx.CacheTypes = [false | true] default is false
 

Author:
Gary Casey, Fred Perry

Nested Class Summary
 class AliasingPipeSegment.AliasMapping
          structure class to hold all the stuff needed for aliasing
 class AliasingPipeSegment.AliasParser
           
 
Nested classes/interfaces inherited from class org.openadaptor.adaptor.SimpleComponent
SimpleComponent.StateHolder
 
Field Summary
protected  java.util.Hashtable _alias_mappings
          The hashtable use to map incoming dataobjects an AliasMapping object.
protected  java.util.Hashtable _mapping_keys
          hashtable for lookup on "Type1", "Type2" etc.
protected  boolean _old_style_alias
          flag to denote really old style alias that do nor require you to define a type or predicate mapping
protected  DOPredicate[] _predicates
          The array of DOPredicates to check
protected  java.util.Hashtable _type_cache
          cache of Simple data object types, index on predicate or type name
(package private) static org.apache.log4j.Logger log
           
 
Fields inherited from class org.openadaptor.adaptor.AbstractSimplePipe
_continue_on_exception, _deepCopy, _deepCopyOnlySDO, _disruptive
 
Fields inherited from class org.openadaptor.adaptor.SimpleComponent
_controller, _formatter, _name, _propsPrefix, _readerDelegate, _textEncoding, MESSAGE_WRITER_PREFIX, MESSAGEID_ATTR, TEXT_ENCODING_ATTR
 
Constructor Summary
AliasingPipeSegment()
           
 
Method Summary
protected  void checkAlias(DataObject outDob)
          Check the integrity of the aliased DataObject This is an empty implementation, it will never throw an exception.
protected  DataObject createAlias(DataObject inDob)
          Deprecated.  
protected  DataObject createAlias(DataObject inDob, java.lang.Object key)
          Return alias dataobject type for given type Override this if you want to create your own outgoing dataobjects
protected  java.util.Vector getAliasAttributes(DataObject dob)
          Deprecated.  
protected  java.util.Vector getAliasAttributes(DataObject inDob, java.lang.Object key)
          Returns a vector of alias attributes
protected  java.util.Hashtable getAttributeMappings(DataObject dob)
          Deprecated.  
protected  java.util.Hashtable getAttributeMappings(DataObject inDob, java.lang.Object key)
          Returns a hashtable of attribute mappings
protected  java.util.Hashtable getAttributeTypes(DataObject inDob, java.lang.Object key)
          Returns a hashtable of attribute mappings
protected  java.lang.Object getMapKey(DataObject dob)
          return key for AliasMapping object
 void init(java.lang.String name, java.util.Properties props, java.lang.String prefix, Controller controller)
          Calls super.init(), then gets all the aliasing information from the supplied properties
protected  void setAliasAttributeValue(java.lang.String attName, java.lang.String aliasAttName, DataObject inDob, DataObject aliasDob)
          Deprecated.  
protected  void setAliasAttributeValue(java.lang.String attName, java.lang.String aliasAttName, DataObject inDob, DataObject aliasDob, java.lang.Object map_key)
          set attribute value of AliasDO Override this if you want to do translations
protected  DataObject[] transformDataObjects(DataObject[] inDobs)
          Creates a new array of DataObjects, identical to the supplied array except that attribute names are aliased according to the configuration information.
 void txnCommitWithExceptions(Message m)
          this enables component to commit a transaction where exceptions have been thrown but trapped and marked in the message, component is stateless so this is fine
 
Methods inherited from class org.openadaptor.adaptor.AbstractSimplePipe
canUpdateWhileRunning, getAsProperties, postProcessMessage, processHospitalException, processMessage, setDeepCopy, setDeepCopyUnlessSet, setDisruptive, setFromProperties
 
Methods inherited from class org.openadaptor.adaptor.SimpleComponent
addCallback, cleanUp, customControl, didReceiveMessage, getCallbackManager, getCurrentState, getCustomControlProperties, getLastUID, getName, getProperty, getProperty, getPropsPrefix, getRequestedState, getSecurityManager, getStatus, getTextEncoding, getXMLFormatter, notifyEvent, pause, removeCallback, resume, setCallbackManager, setCallbackManager, setCurrentState, setFromProperties, setFromResource, setName, setPropsPrefix, setRequestedState, terminate, txnBegin, txnCommit, txnRollback, txnRollback, waitForRequestedStateChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openadaptor.adaptor.Component
cleanUp, customControl, getName, getPropsPrefix, getRequestedState, getStatus, pause, resume, setName, setPropsPrefix, terminate
 
Methods inherited from interface org.openadaptor.adaptor.IbafTransactionalResource
txnBegin, txnCommit, txnRollback, txnRollback
 
Methods inherited from interface org.openadaptor.adaptor.Configurable
setFromProperties
 
Methods inherited from interface org.openadaptor.adaptor.CallbackProvider
addCallback, getCallbackManager, notifyEvent, removeCallback, setCallbackManager, setCallbackManager
 

Field Detail

log

static org.apache.log4j.Logger log

_alias_mappings

protected java.util.Hashtable _alias_mappings
The hashtable use to map incoming dataobjects an AliasMapping object. The key for this hash table can be any of the following... 1) "Any" - used if users just defined att mappings 2) the type name of the incoming DataObject 3) a DOPredicate object that matches the incoming DataObject


_mapping_keys

protected java.util.Hashtable _mapping_keys
hashtable for lookup on "Type1", "Type2" etc. Useful for subclasses that what to intialise other properties.


_old_style_alias

protected boolean _old_style_alias
flag to denote really old style alias that do nor require you to define a type or predicate mapping


_predicates

protected DOPredicate[] _predicates
The array of DOPredicates to check


_type_cache

protected java.util.Hashtable _type_cache
cache of Simple data object types, index on predicate or type name

Constructor Detail

AliasingPipeSegment

public AliasingPipeSegment()
Method Detail

init

public void init(java.lang.String name,
                 java.util.Properties props,
                 java.lang.String prefix,
                 Controller controller)
          throws IbafException
Calls super.init(), then gets all the aliasing information from the supplied properties

Specified by:
init in interface Component
Overrides:
init in class AbstractSimplePipe
Parameters:
name - The name to be given to the component
props - The properties object from which the component can glean its config information
prefix - The component's property prefix
controller - The component's controller object
Throws:
IbafException - if initialization fails
See Also:
AbstractSimpleSink.init(String,Properties,String,Controller), CheckMandatory.init(String,Properties,String,Controller)

getMapKey

protected java.lang.Object getMapKey(DataObject dob)
return key for AliasMapping object


createAlias

protected DataObject createAlias(DataObject inDob)
                          throws PipelineException
Deprecated. 

Return alias dataobject type for given type

Throws:
PipelineException

createAlias

protected DataObject createAlias(DataObject inDob,
                                 java.lang.Object key)
                          throws PipelineException
Return alias dataobject type for given type Override this if you want to create your own outgoing dataobjects

Throws:
PipelineException

getAliasAttributes

protected java.util.Vector getAliasAttributes(DataObject dob)
                                       throws PipelineException
Deprecated. 

Returns a vector of alias attributes

Throws:
PipelineException

getAliasAttributes

protected java.util.Vector getAliasAttributes(DataObject inDob,
                                              java.lang.Object key)
                                       throws PipelineException
Returns a vector of alias attributes

Throws:
PipelineException

getAttributeMappings

protected java.util.Hashtable getAttributeMappings(DataObject dob)
                                            throws PipelineException
Deprecated. 

Returns a hastable of attribute mappings

Throws:
PipelineException

getAttributeMappings

protected java.util.Hashtable getAttributeMappings(DataObject inDob,
                                                   java.lang.Object key)
                                            throws PipelineException
Returns a hashtable of attribute mappings

Throws:
PipelineException

getAttributeTypes

protected java.util.Hashtable getAttributeTypes(DataObject inDob,
                                                java.lang.Object key)
                                         throws PipelineException
Returns a hashtable of attribute mappings

Throws:
PipelineException

setAliasAttributeValue

protected void setAliasAttributeValue(java.lang.String attName,
                                      java.lang.String aliasAttName,
                                      DataObject inDob,
                                      DataObject aliasDob)
                               throws PipelineException
Deprecated. 

set attribute value of AliasDO

Throws:
PipelineException

setAliasAttributeValue

protected void setAliasAttributeValue(java.lang.String attName,
                                      java.lang.String aliasAttName,
                                      DataObject inDob,
                                      DataObject aliasDob,
                                      java.lang.Object map_key)
                               throws PipelineException
set attribute value of AliasDO Override this if you want to do translations

Throws:
PipelineException

checkAlias

protected void checkAlias(DataObject outDob)
                   throws PipelineException
Check the integrity of the aliased DataObject This is an empty implementation, it will never throw an exception. override this if you want to perform your own checks

Throws:
PipelineException

transformDataObjects

protected DataObject[] transformDataObjects(DataObject[] inDobs)
                                     throws PipelineException
Creates a new array of DataObjects, identical to the supplied array except that attribute names are aliased according to the configuration information. This new array is what's passed on down the pipeline.

Specified by:
transformDataObjects in class AbstractSimplePipe
Throws:
PipelineException - if any part of the aliasing fails
See Also:
AbstractSimplePipe.processMessage(Message)

txnCommitWithExceptions

public void txnCommitWithExceptions(Message m)
                             throws IbafException
this enables component to commit a transaction where exceptions have been thrown but trapped and marked in the message, component is stateless so this is fine

Specified by:
txnCommitWithExceptions in interface IbafTransactionalResource
Overrides:
txnCommitWithExceptions in class SimpleComponent
Throws:
IbafException - If fails to commit the transaction
See Also:
Controller.txnCommit(Source)