NODE
- as source TypeNODE_IDENTIFIER
- as the type used to identify the NODE being analyzed. Uses this using identifyNode(Object)
ENTITY
- as destination entity typepublic abstract class AbstractEntityTransformer<NODE,NODE_IDENTIFIER,ENTITY> extends EventAwareProcess implements ModeAware, IdempotentAware, org.apache.commons.collections.Transformer, Serializable
EventAwareProcess
, ModeAware
Transformer
Must call init if not used via Spring
,
Serialized FormProcess.Event, Process.EventPoint
Modifier and Type | Field and Description |
---|---|
protected Map<?,Mapper> |
columnFieldMapping
Mapper from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0 |
protected boolean |
idempotent
By default if run changes will propogate
|
protected Mode |
mode
Mode ; defaults to Mode.INSERT . |
protected List<Mode> |
modesSupported
What all modes does this Reader support
Default All defined in Mode |
protected Map<String,?> |
nestedObjectInitMap
(Optional) Map that allows to instantiate an object for a nested property in the main Entity.
|
protected List<Mapper> |
nonAssociatedMappers
Mapper that uses the tuple/Row to extract data to map to particular column |
listeners, processState
Constructor and Description |
---|
AbstractEntityTransformer() |
AbstractEntityTransformer(AbstractEntityTransformer t) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
consumeIntermediateObjects(NODE_IDENTIFIER nodeIdentifier,
Map<String,Object> intermediateObjects,
Mapper mapper,
Queue<NODE_IDENTIFIER> nodesForReProcessing)
For
Mapper s with IntermediateResultMapperBehavior , process and set them with the required intermediate objects |
Map<?,Mapper> |
getColumnFieldMapping()
Mapper from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0 |
org.apache.commons.collections.Transformer |
getEntityAccessTransformer()
Allow query sub-properties etc if provided (A clone of this is used in
getValue(Object, Object, Mapper) ) |
Mode |
getMode()
Mode ; defaults to Mode.INSERT . |
List<Mode> |
getModesSupported()
Get the
Mode s supported by the instance |
Map<String,?> |
getNestedObjectInitMap()
(Optional) Map that allows to instantiate an object for a nested property in the main Entity.
|
List<Mapper> |
getNonAssiciatedMappers()
Mapper that uses the tuple/Row to extract data to map to particular column |
List<Mapper> |
getNonAssociatedMappers()
Mapper that uses the tuple/Row to extract data to map to particular column |
protected Object |
getValue(Object propertyKey,
NODE e,
Mapper mapper)
Extract the value from the Entity.
If an EntityChainAccessTransformer is defined then that is used or else default PropertyUtils.getProperty(Object, String) is used. |
protected abstract String |
identifyNode(NODE_IDENTIFIER node)
Identify a node/cell that is being processed.
|
void |
init() |
protected abstract ENTITY |
init(NODE rawInput,
Map<String,Object> intermediateObjects)
Create the core Entity and also initialize intermediateObjects (nested objects) with core entities
|
boolean |
isIdempotent()
By default if run changes will propogate
|
protected void |
nestedInit(Object entity,
String fieldName,
Object value)
(Optional) Map that allows to instantiate an object for a nested property in the main Entity.
|
protected Object |
processValue(Mapper mapper,
Object value)
|
void |
setColumnFieldMapping(Map<?,Mapper> columnFieldMapping)
Mapper from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0 |
protected void |
setEntity(ENTITY entity,
Mapper mapper,
Object value)
Set the entity with the value for the field that is mapped
|
void |
setEntityAccessTransformer(org.apache.commons.collections.Transformer entityAccessTransformer)
Allow query sub-properties etc if provided (A clone of this is used in
getValue(Object, Object, Mapper) ) |
void |
setIdempotent(boolean idempotent) |
void |
setMode(Mode mode)
Mode ; defaults to Mode.INSERT . |
void |
setModesSupported(List<Mode> modesSupported) |
void |
setNestedObjectInitMap(Map<String,?> nestedObjectInitMap)
(Optional) Map that allows to instantiate an object for a nested property in the main Entity.
|
void |
setNonAssociatedMappers(List<Mapper> nonAssociatedMappers)
Mapper that uses the tuple/Row to extract data to map to particular column |
addListener, getListeners, onChangeHandler, setListeners
protected Map<?,Mapper> columnFieldMapping
Mapper
from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0protected List<Mapper> nonAssociatedMappers
Mapper
that uses the tuple/Row to extract data to map to particular columnprotected Map<String,?> nestedObjectInitMap
init(Object, Map)
. This is used when @ runtime we need a nested object created for a value being set.for the implementation
protected Mode mode
Mode
; defaults to Mode.INSERT
. Mapper
s that are ModeAware
will consult this field in derived implementations.protected boolean idempotent
public AbstractEntityTransformer()
public AbstractEntityTransformer(AbstractEntityTransformer t)
protected Object getValue(Object propertyKey, NODE e, Mapper mapper) throws Exception
EntityChainAccessTransformer
is defined then that is used or else default PropertyUtils.getProperty(Object, String)
is used.protected abstract String identifyNode(NODE_IDENTIFIER node)
type
- NODE_IDENTIFIER@PostConstruct public void init()
protected void setEntity(ENTITY entity, Mapper mapper, Object value) throws Exception
entity
- mapper
- as Mapper
for MapperBehavior
s and Mapper.getFieldName()
value
- Exception
- TODO: Add unit test case, for an Entity with Integer field type but passing Double field valueprotected boolean consumeIntermediateObjects(NODE_IDENTIFIER nodeIdentifier, Map<String,Object> intermediateObjects, Mapper mapper, Queue<NODE_IDENTIFIER> nodesForReProcessing)
Mapper
s with IntermediateResultMapperBehavior
, process and set them with the required intermediate objectsNODE
- type to represent the Column or CellintermediateObjects
- as Map
of intermediate object variable name and the Valuemapper
- as Mapper
nodesForReProcessing
- as Queue
that Q's up COLs/Cells that may not be ready for processing, since the dependent col is yet to be processedprotected Object processValue(Mapper mapper, Object value) throws BreakChainException, ContinueProcessingException
mapper
- as Mapper
value
- as ObjectBreakChainException,
- ContinueProcessingException
BreakChainException
ContinueProcessingException
protected abstract ENTITY init(NODE rawInput, Map<String,Object> intermediateObjects)
intermediateObjects
- the Map into which we can pre-initialize stuffprotected void nestedInit(Object entity, String fieldName, Object value) throws Exception
init(Object, Map)
. This is used when @ runtime we need a nested object created for a value being set.entity
- as the entity that contains the nested entity (immediate parent entity)fieldName
- String for the nested entity name. Example "a.b.c"value
- of the nested entity that will be set on the leaf/last nested part
TODO: Add unit test caseException
public Map<?,Mapper> getColumnFieldMapping()
Mapper
from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0public void setColumnFieldMapping(Map<?,Mapper> columnFieldMapping)
Mapper
from Tuple Column Index/Field Name to a particular field (one to one); index # starts @ 0public List<Mapper> getNonAssiciatedMappers()
Mapper
that uses the tuple/Row to extract data to map to particular columnpublic void setNonAssociatedMappers(List<Mapper> nonAssociatedMappers)
Mapper
that uses the tuple/Row to extract data to map to particular columnpublic List<Mapper> getNonAssociatedMappers()
Mapper
that uses the tuple/Row to extract data to map to particular columnpublic Map<String,?> getNestedObjectInitMap()
init(Object, Map)
. This is used when @ runtime we need a nested object created for a value being set.for the implementation
public void setNestedObjectInitMap(Map<String,?> nestedObjectInitMap)
init(Object, Map)
. This is used when @ runtime we need a nested object created for a value being set.for the implementation
public Mode getMode()
Mode
; defaults to Mode.INSERT
. Mapper
s that are ModeAware
will consult this field in derived implementations.public boolean isIdempotent()
isIdempotent
in interface IdempotentAware
public void setMode(Mode mode)
Mode
; defaults to Mode.INSERT
. Mapper
s that are ModeAware
will consult this field in derived implementations.
setColumnFieldMapping(Map)
and {setNonAssociatedMappers(List)
are set
public void setIdempotent(boolean idempotent)
setIdempotent
in interface IdempotentAware
public List<Mode> getModesSupported()
ModeAware
Mode
s supported by the instancegetModesSupported
in interface ModeAware
public org.apache.commons.collections.Transformer getEntityAccessTransformer()
getValue(Object, Object, Mapper)
)getValue(Object, Object, Mapper)
public void setEntityAccessTransformer(org.apache.commons.collections.Transformer entityAccessTransformer)
getValue(Object, Object, Mapper)
)getValue(Object, Object, Mapper)
Copyright © 2018. All rights reserved.