Class DataMapping
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.core.FoundationObject
com.northconcepts.datapipeline.foundations.datamapping.DataMappingObject
com.northconcepts.datapipeline.foundations.datamapping.DataMappingPart
com.northconcepts.datapipeline.foundations.datamapping.DataMapping
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,DataMappingProblemsSupplier,JavaCodeGenerator,Serializable
public class DataMapping
extends DataMappingPart
implements JavaCodeGenerator, DataMappingProblemsSupplier
The top-level abstraction to map a set of values from source to target using the DataPipeline Expression Language or custom implementation.
- See Also:
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
internalId, internalName, log, TIMESTAMP_FORMATFields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCondition(Collection<LogicalExpression> conditions) Adds conditions that must all be true for a record to be mapped; otherwise the result has no target record.addCondition(LogicalExpression condition) Adds a condition that must be true for a record to be mapped; otherwise the result has no target record.addExceptionProperties(DataException exception) Adds this object's current state to aDataException.addExcludedFields(String... excludedFields) Adds fields to be removed from the target.addExcludedFields(Collection<String> excludedFields) Adds fields to be removed from the target.addFieldMapping(IFieldMapping fieldMapping) addFieldMapping(String targetFieldName, String sourceExpression) addFieldMapping(Collection<IFieldMapping> fieldMappings) fromJson(InputStream inputStream) Loads this object's state from the UTF-8 encoded JSON in the stream.Loads this object's state from the given JSON text.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXml(InputStream inputStream) Parses the XML in the stream and loads this object's state from its root element.fromXmlElement(Element dataMappingElement) voidAppends Java source code representing this object to the given builder.List<LogicalExpression> Returns the conditions that must all be true for a record to be mapped; otherwise the result has no target record.Returns the data mapping containing this part (itself for aDataMapping) or null if it is not known.Returns the data mapping part containing this one or null if there is none.Returns the name identifying this part: the data mapping's name or a field mapping's target field name.Returns the kind of part this is, such asDataMappingPartType.FieldMapping.voidgetDataMappingProblems(List<DataMappingProblem> problems, boolean includeChildren) Adds this element's problems to the list, plus those of its children whenincludeChildrenis true; the default adds none.The set of fields to be removed from the target.Returns the field mappings, applied in order to build the target record.getName()DefaultExpressionContextReturns the context holding the constants added withsetValue(String, Object); it is the parent of the context used to evaluate expressions.longReturns the number ofmap(ExpressionContext)calls so far, also available to expressions asrownum.The schema entity used to convert and validate incoming data before this mapping is performed (defaultnull).The schema entity used to convert and validate outgoing data after this mapping is performed (defaultnull).Deprecated.booleanIndicates if incoming source fields should be mapped automatically without the need for explicitFieldMappings (defaultfalse).map(ExpressionContext expressionContext) Maps the record in the given context; exceptions thrown by individual field mappings are collected in the returned result instead of being thrown.setAutoMapping(boolean autoMapping) Indicates if incoming source fields should be mapped automatically without the need for explicitFieldMappings (defaultfalse).setDescription(String description) setSourceEntity(EntityDef sourceEntity) The schema entity used to convert and validate incoming data before this mapping is performed (defaultnull).setTargetEntity(EntityDef targetEntity) The schema entity used to convert and validate outgoing data after this mapping is performed (defaultnull).setTargetValidationEntity(EntityDef targetValidationEntity) Deprecated.Add a constant for this mapping to use when evaluating expressions like theFieldMapping.getSourceExpression(),AbstractFieldMapping.getCondition(), andgetConditions().Add a constant for this mapping to use when evaluating expressions like theFieldMapping.getSourceExpression(),AbstractFieldMapping.getCondition(), andgetConditions().toJson()Writes this object as JSON to the writer, then closes the writer.Writes this object as JSON to the writer, closing the writer afterwards ifcloseWriteris true.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.Writes this object as indented XML, without a declaration, to the writer and then closes it.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.Methods inherited from class com.northconcepts.datapipeline.foundations.datamapping.DataMappingPart
getDataMappingName, getDataMappingPartContainerName, getDataMappingPartContainerTypeMethods inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
assertValid, assertValid, clone, exception, exception, exception, getInternalId, getInternalName, resetInternalIdMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionPropertiesMethods inherited from interface com.northconcepts.datapipeline.foundations.datamapping.DataMappingProblemsSupplier
getDataMappingProblems, getDataMappingProblemsMethods inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
toXml, toXml, toXml, toXml
-
Constructor Details
-
DataMapping
public DataMapping()
-
-
Method Details
-
getDataMappingProblems
Description copied from interface:DataMappingProblemsSupplierAdds this element's problems to the list, plus those of its children whenincludeChildrenis true; the default adds none.- Specified by:
getDataMappingProblemsin interfaceDataMappingProblemsSupplier
-
getName
-
setName
-
getDescription
-
setDescription
-
isAutoMapping
public boolean isAutoMapping()Indicates if incoming source fields should be mapped automatically without the need for explicitFieldMappings (defaultfalse). -
setAutoMapping
Indicates if incoming source fields should be mapped automatically without the need for explicitFieldMappings (defaultfalse). -
getRootExpressionContext
public DefaultExpressionContext getRootExpressionContext()Returns the context holding the constants added withsetValue(String, Object); it is the parent of the context used to evaluate expressions. -
setValue
Add a constant for this mapping to use when evaluating expressions like theFieldMapping.getSourceExpression(),AbstractFieldMapping.getCondition(), andgetConditions(). -
setValue
Add a constant for this mapping to use when evaluating expressions like theFieldMapping.getSourceExpression(),AbstractFieldMapping.getCondition(), andgetConditions(). -
getSourceEntity
The schema entity used to convert and validate incoming data before this mapping is performed (defaultnull). No type conversions and validations are performed whennull. -
setSourceEntity
The schema entity used to convert and validate incoming data before this mapping is performed (defaultnull). No type conversions and validations are performed whennull. -
getTargetEntity
The schema entity used to convert and validate outgoing data after this mapping is performed (defaultnull). No type conversions and validations are performed whennull. -
setTargetEntity
The schema entity used to convert and validate outgoing data after this mapping is performed (defaultnull). No type conversions and validations are performed whennull. -
getTargetValidationEntity
Deprecated.UsegetTargetEntity()instead. -
setTargetValidationEntity
Deprecated.UsesetTargetEntity(EntityDef)instead. -
getConditions
Returns the conditions that must all be true for a record to be mapped; otherwise the result has no target record. -
addCondition
Adds a condition that must be true for a record to be mapped; otherwise the result has no target record. -
addCondition
Adds conditions that must all be true for a record to be mapped; otherwise the result has no target record. -
getConditionsSource
-
getFieldMappings
Returns the field mappings, applied in order to build the target record. -
addFieldMapping
-
addFieldMapping
-
addFieldMapping
-
getExcludedFields
The set of fields to be removed from the target. Removal is performed after the mapping, but before the mapped data is converted and validated by the optional targetEntityDefand returned. -
addExcludedFields
Adds fields to be removed from the target. Removal is performed after the mapping, but before the mapped data is converted and validated by the optional targetEntityDefand returned. -
addExcludedFields
Adds fields to be removed from the target. Removal is performed after the mapping, but before the mapped data is converted and validated by the optional targetEntityDefand returned. -
getRownum
public long getRownum()Returns the number ofmap(ExpressionContext)calls so far, also available to expressions asrownum. -
map
Maps the record in the given context; exceptions thrown by individual field mappings are collected in the returned result instead of being thrown. -
generateJavaCode
Description copied from interface:JavaCodeGeneratorAppends Java source code representing this object to the given builder.- Specified by:
generateJavaCodein interfaceJavaCodeGenerator
-
addExceptionProperties
Description copied from class:FoundationObjectAdds this object's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Specified by:
addExceptionPropertiesin interfaceDataExceptionContributor- Overrides:
addExceptionPropertiesin classFoundationObject
-
getDataMapping
Description copied from class:DataMappingPartReturns the data mapping containing this part (itself for aDataMapping) or null if it is not known.- Specified by:
getDataMappingin classDataMappingPart
-
getDataMappingPartContainer
Description copied from class:DataMappingPartReturns the data mapping part containing this one or null if there is none.- Specified by:
getDataMappingPartContainerin classDataMappingPart
-
getDataMappingPartType
Description copied from class:DataMappingPartReturns the kind of part this is, such asDataMappingPartType.FieldMapping.- Specified by:
getDataMappingPartTypein classDataMappingPart
-
getDataMappingPartName
Description copied from class:DataMappingPartReturns the name identifying this part: the data mapping's name or a field mapping's target field name.- Specified by:
getDataMappingPartNamein classDataMappingPart
-
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-
toJson
- Specified by:
toJsonin interfaceJsonSerializable- Specified by:
toJsonin interfaceRecordSerializable
-
toJson
Description copied from interface:JsonSerializableWrites this object as JSON to the writer, then closes the writer.- Specified by:
toJsonin interfaceJsonSerializable- Specified by:
toJsonin interfaceRecordSerializable
-
toJson
Description copied from interface:JsonSerializableWrites this object as JSON to the writer, closing the writer afterwards ifcloseWriteris true.- Specified by:
toJsonin interfaceJsonSerializable- Specified by:
toJsonin interfaceRecordSerializable
-
toXml
Description copied from interface:XmlSerializableWrites this object as indented XML, without a declaration, to the writer and then closes it.- Specified by:
toXmlin interfaceXmlSerializable
-
fromJson
Description copied from interface:JsonSerializableLoads this object's state from the given JSON text.- Specified by:
fromJsonin interfaceJsonSerializable- Specified by:
fromJsonin interfaceRecordSerializable
-
fromJson
Description copied from interface:JsonSerializableLoads this object's state from the UTF-8 encoded JSON in the stream.- Specified by:
fromJsonin interfaceJsonSerializable- Specified by:
fromJsonin interfaceRecordSerializable
-
fromXml
Description copied from interface:XmlSerializableParses the XML in the stream and loads this object's state from its root element.- Specified by:
fromXmlin interfaceXmlSerializable
-
fromXml
- Specified by:
fromXmlin interfaceXmlSerializable
-
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException.- Specified by:
toXmlElementin interfaceXmlSerializable
-
fromXmlElement
- Specified by:
fromXmlElementin interfaceXmlSerializable
-