Class: Resolver

template_resolver.Resolver(sourceDataObject)

new Resolver(sourceDataObject)

Resolver. Is used inside this repository. It could also be used outside.

Parameters:
Name Type Description
sourceDataObject *

The properties of this object will be used to replace the placeholders in the template.

Source:

Members

sourceDataObject

The properties of this source data object will be used to replace the placeholders in the template.

Source:

Methods

replaceResolvableFields(stringContainingVariables, resolvableFields)

Replaces all variables in double curly brackets, e.g. {{property}}, with the value of that property from the resolvableProperties.

Supported property types: string, number, boolean

Parameters:
Name Type Description
stringContainingVariables string
resolvableFields Array.<object>

(name=value)

Source:

resolvableFieldsOfAll(…varArgs) → {object}

Returns a map like object, that contains all resolvable fields and their values as properties. This function takes a variable count of input parameters, each containing an object that contains resolvable fields to extract from.

The recursion depth is limited to 3, so that an object, that contains an object can contain another object (but not further).

Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.

Parameters:
Name Type Attributes Description
varArgs object <repeatable>

variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.

Source:
Returns:

object with resolvable field names and their values.

Type
object

resolveTemplate(template) → {string}

Resolves the given template.

The template may contain variables in double curly brackets. Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}". Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}" Parts of the index can be inserted by using e.g. "{{index[1]}}".

Parameters:
Name Type Description
template string
Source:
Returns:

resolved template

Type
string

(protected, static) addFieldsPerGroup(object) → {object}

Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content. For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".

Parameters:
Name Type Description
object object

with resolvable field names and their values.

Source:
Returns:

object with resolvable field names and their values.

Type
object

(protected, static) addToFilteredMapObject(elements, mapObject, filterMatchesFunction)

Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like). Example: {name: "accountNumber", value: "12345"} becomes mapObject["accountNumber"]="12345".

Parameters:
Name Type Description
elements Array.<NameValuePair>

flattened array of name-value-pairs

mapObject object

container to collect the results. Needs to be created before e.g. using {}.

filterMatchesFunction function

takes the property name as string argument and returns true (include) or false (exclude).

Source:

(protected, static) getPropertyNameInfos(fullPropertyName) → {Object}

Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.

Parameters:
Name Type Description
fullPropertyName String
Source:
Returns:

Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).

Type
Object