Mapping Post Processing
The mapping works by using a single source message field value and specifying what to do with it. This approach does not work with multiple fields, such as the concatenation of two fields, or either A or B.
To use this logic, the Dynamic Message Mapper supports post processors. As the name suggests, these are processors that are executed once all the mapping has been completed. This allows you to work with the completed target message and parameters (for both input and output) to perform any other changes or validation.
This example shows a post processing definition:
postProcessors:
- name: "Traffic Routing Data"
className: "com.matrixx.example.mapping.postprocessors.NonsenseMappingPostProcessor"
prefix: "ABC"
This example shows definition of a mapping post processor named "Traffic Routing Data" (for
display reasons only). The post processor is a Java class specified by the
className
attribute, which must extend
MappingPostProcessor
. A numeric priority attribute can also be
specified to specify the order of your post processors, if you have more than one
defined. Post processors are executed in numerical order, from lowest to highest, and
they have a default value of 100.
As with the custom field value mapper, any other attributes that you specify must correspond to setters in the Java class, which take a single string argument. For example, the prefix attribute
means that a setPrefix
, with a string value, must exist in the implementation class.
This example shows implementation of a mapping post processor in Java:
public class NonsenseMappingPostProcessor extends MappingPostProcessor {
private String m_prefix;
@Override
public void postProcess(final Object targetMessage, final MappingContext mappingContext)
{
final DataContainer dataContainer = (DataContainer) targetMessage;
final String paramOne = (String) mappingContext.getParameters().get("Param1");
final Integer fieldTwo = dataContainer.getInt16(dataContainer.lookupKey("Field2"));
// additional validation
if (fieldTwo == null || fieldTwo.intValue() < 1) {
mappingContext.declareValidationIssue(new FieldValidationIssue()
.setPosition("Field2")
.setMessage("Field2 must have a value greater than 0")
.setType(FieldValidationIssueType.INVALID_FIELD_VALUE));
}
else {
// Change the message in some way using multiple fields / parameters
final String field3Value = String.format("%s:Field2:%d-Param1:%s", prefix, field2.intValue(), paramOne);
mappingContext.trace(() -> String.format("\tWe're changing the value of Field3 to %s", field3Value));
dataContainer.set(dataContainer.lookupKey("Field3"), field3Value);
}
}
public void setPrefix(final String prefix)
{
m_prefix = prefix;
}
}
This example is hypothetical but demonstrates several important concepts and capabilities:
- Retrieving values from the parameters and the target message.
- Performing custom validation and declaring issues.
- Providing tracing for debugging purposes.
- Updating the target message with a new value calculated from multiple fields or parameters.
- Using extra attributes provided to the mapping post processor at configuration time.
The mapping post process assumes the target message is a DataContainer
. If
mapping in the other direction, then the target message is a
JsonNode
.
UE Timezone Post Processor
An UE timezone post processor is available that enables pricing features like Time-of-Day charging and Happy Hour charging to be used, for example:
postProcessors:
- name: "UE TimeZone Processor"
className: "com.matrixx.sba.gateway.mapping.postprocessors.UETimezonePostProcessor"
This post processor is enabled by default.
The post processor enables the InvocationTimeStamp
field in a Mtx5GChargingDataRequest to be derived based on the pDUSessionChargingInformation.uetimeZone
.
Suppose InvocationTimestamp
is "2022-03-15T21:30:00Z" (9:30 PM) and pDUSessionChargingInformation.uetimeZone is "-07:00+1" (that is, adding +1 for DST to what is
normally UTC-8 to make it UTC-7). The post processor derives an invocation timestamp like "2022-03-15T14:30:00-07:00" (2:30 PM).
The post processor also supports 5G deferred triggers. When a network event triggers reporting to MATRIXX, rather than immediately invoking a ChargingDataRequest to report that event, the network can collect several events and defer reporting the collection to MATRIXX until it later invokes a ChargingDataRequest. This collection includes the timestamps of those events, and these must be converted from UTC time to UE time. The general structure is:
ChargingDataRequest
multipleUnitUsage (array)
usedUnitContainer (array)
pDUContainerInformation
uetimeZone (the UE UTC offset)
Using this structure, there is one usedUnitContainer
per triggering event, with several timestamps within the container. The post processor supports the following
triggers and timestamps:
- triggerTimestamp
- eventTimeStamps
- pDUContainerInformation/timeofFirstUsage and timeofLastUsage (not used)
invocationTimestamp
property is converted to UTC format in the response by default. All other timestamp fields remain in the format returned by the
engine. The mtxtimestamp.utcstring
field value mapper is available to convert timestamps to UTC in the response if needed.