handlers.aggregation_across_relation

class AggregationAcrossRelation(handlers.eventhandler.EventHandler):

Aggregates information from child to parent.

Configuration:
relation: The relation across which you want to transfer information. Can be found in the Meta Model Configuration of your workspace. fields: List of fields that should be transferred. Can have one of the following attribute combinations:

name and priority: Transfers the named field across the relation, and if multiple fact sheets are linked, the priority is considered.
Example: Calculate the compliance of a parent application, and if one child application is non-compliant, the parent should be non-compliant as well.

name, source, mode and format: Can be used to calculate sums of fields on relations, e.g. cost fields on the relation are summed up on the fact sheet itself.
Example: Calculate the cost of an application by summing up the cost of its components.

name, source, distribution_key, mode and format: Same as above, but calculates cost shares and considers the distribution key accordingly.
Example: Calculate the cost split of an application based on the user numbers of the organizations that use the application.

tags: Aggregates tags instead of fields. Can be configured using the following settings:
group: Name of the tag group
mode: "priority" or "aggregation". If "aggregation", all tags in the group are aggregated onto the related fact sheet.
priority: If mode is "priority", this setting specifies the priority, ranked highest to lowest. Only the highest-prioritized tag is transferred.
Example: If at least one of the child applications is Non-Compliant, the parent should get the "Non-Compliant" tag as well.

name = 'Aggregation across Relation'
description = 'Aggregates information onto related fact sheets via specific rules.'
conditions = {'event_types': ['FactSheetUpdatedEvent']}
supports_initial_sync = True
config_template = {'relation': 'relDataObjectToApplication', 'fields': [{'name': 'security_compliance', 'priority': ['No', 'Yes']}, {'name': 'annualCost', 'source': 'rel:costTotalAnnual', 'mode': 'sum', 'format': '€ {:,.2f}'}, {'name': 'rel:costShare', 'source': 'annualCost', 'distribution_key': 'rel:numberOfUsers', 'mode': 'distribution', 'format': '€ {:,.2f}'}], 'tags': [{'group': 'security_compliance', 'mode': 'priority', 'priority': ['Non-Compliant', 'Compliant']}, {'group': 'security_characteristics', 'mode': 'aggregation'}]}
def handle(self, event, fs, **kwargs):

Called automatically whenever a FactSheetUpdated event comes in via webhook.