Class DefaultAutoMappingPolicy
- All Implemented Interfaces:
AutoMappingPolicy,Serializable
DefaultAutoMappingPolicy maps arguments to columns with a template-based approach and an extractor operator.
If the extractor returns a non-null value (policy applies to this argName), then a copy of the template with the adjusted argName will be returned.
Example: You want to map any structured argName varName.int to column XYZ of type SQL INTEGER with the qualifier column Q17
set to the argName. Then you can configure a predicate like s -> s.endsWith(".int") ? s.substring(0, s.length()-4 : null and configure the
target column with the filter column value set to ${argName.local}, see "${argName.local}".
The convenience variable ${argName.local} covers the very common demand to decode a single identifier from the argName.
However, if you need advanced extraction (e.g., you want to extract multiple variables from an argName like "org7.section9.dep34.int"), then you can subclass
DefaultAutoMappingPolicy and overwrite prepareVariables(String, ConversionSettings).
This way you can map a whole category of variables to columns without knowing and listing them beforehand.
- Author:
- Karl Eilebrecht
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface to ensure this part of the configuration remains serializable -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringReference to the variable "argName.local"protected final ArgColumnAssignmentAt runtime we return the same mapping for all matching argNames, argMetaInfo updated with the current argNameprotected final DefaultAutoMappingPolicy.LocalArgNameExtractorThe function that extracts the "${argName.local}" from the argNamestatic final AutoMappingPolicyConfiguration element if no policy is defined to avoid nullstatic final StringDynamic variable that can be specified as a filterValue to tell the system to replace it at runtime with the value of the global variableargName.local(if present). -
Constructor Summary
ConstructorsConstructorDescriptionDefaultAutoMappingPolicy(DefaultAutoMappingPolicy.LocalArgNameExtractor extractorFunction, ArgColumnAssignment assignmentTemplate) -
Method Summary
Modifier and TypeMethodDescriptionbooleanisApplicable(String argName) Returns whether this mapping policy can map the given argument to a columnReturns the column assignment for the given argNameprotected voidprepareVariables(String argName, de.calamanari.adl.ProcessContext ctx) This TEMPLATE METHOD allows sub-classes to compute and set further global variables which can then be referenced inside the mapping process.
-
Field Details
-
VAR_ARG_NAME_LOCAL
Dynamic variable that can be specified as a filterValue to tell the system to replace it at runtime with the value of the global variableargName.local(if present). By default this value will be set by this policy right before processing the filter condition setup (parameter creation), so the value will be the result of this instances extractor function.- See Also:
-
ARG_NAME_LOCAL_PLACEHOLDER
Reference to the variable "argName.local"- See Also:
-
NONE
Configuration element if no policy is defined to avoid null -
assignmentTemplate
At runtime we return the same mapping for all matching argNames, argMetaInfo updated with the current argName -
extractorFunction
The function that extracts the "${argName.local}" from the argName
-
-
Constructor Details
-
DefaultAutoMappingPolicy
public DefaultAutoMappingPolicy(DefaultAutoMappingPolicy.LocalArgNameExtractor extractorFunction, ArgColumnAssignment assignmentTemplate) - Parameters:
extractorFunction- function that extracts the "${argName.local}" from the argNameassignmentTemplate- configured assignment with a placeholder name- See Also:
-
-
Method Details
-
isApplicable
Description copied from interface:AutoMappingPolicyReturns whether this mapping policy can map the given argument to a column- Specified by:
isApplicablein interfaceAutoMappingPolicy- Parameters:
argName-- Returns:
- true if the policy is applicable
-
prepareVariables
This TEMPLATE METHOD allows sub-classes to compute and set further global variables which can then be referenced inside the mapping process.Example: Let the argName be structured
org.section.departmentand you want to pass the department as a filter column value.
Simply extract (parse) the qualifier from the argName in this method and put it as a global variable department into the settings.
Now you can reference it in a filter column value, e.g.,SEC/${department}like any other variable.By default this method calls the extractor function and sets the global variable "${argName.local}" to the value extracted from the argName.
- Parameters:
argName-ctx- to obtain and set variables
-
map
Description copied from interface:AutoMappingPolicyReturns the column assignment for the given argName- Specified by:
mapin interfaceAutoMappingPolicy- Parameters:
argName-ctx-- Returns:
- column assignment
-