Skip to content

Commit

Permalink
Support for calculation groups
Browse files Browse the repository at this point in the history
  • Loading branch information
anakic committed Oct 30, 2024
1 parent 3814945 commit 5d45d0d
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions Packer2.Library/DataModel/FolderDatabaseStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,50 @@ protected override string GetFileExtension(JToken elem)
}
}

class CalculationItemMapping : JsonPropertyZone
{
protected override string PayloadContainingObjectJsonPath => "";

protected override string GetPayloadProperty(JToken obj) => "expression";

protected override string ContainingFolder => "Items";

protected override string ElementsSelector => ".calculationGroup.calculationItems[*]";

protected override string GetFileName(JToken elem) => (string)elem["name"]!;

protected override string GetFileExtension(JToken elem) => "dax";
}

class CalculationGroupMapping : JsonElementZone
{
protected override string ElementsSelector => ".model.tables[*]";

protected override string ContainingFolder => "CalculationGroups";

protected override string GetSubfolderForElement(JToken elem)
=> (string)elem["name"]!;

protected override string GetFileName(JToken elem) => "group";

protected override string GetFileExtension(JToken elem) => "json";

protected override IEnumerable<MappingZone> ChildMappings { get; }

protected override bool FilterSelectedElements(JToken element)
{
return element["calculationGroup"] != null;
}

public CalculationGroupMapping()
{
ChildMappings = new MappingZone[]
{
new CalculationItemMapping()
};
}
}

class TablesMapping : JsonElementZone
{
protected override string ElementsSelector => ".model.tables[*]";
Expand All @@ -123,13 +167,18 @@ protected override string GetSubfolderForElement(JToken elem)

protected override IEnumerable<MappingZone> ChildMappings { get; }

protected override bool FilterSelectedElements(JToken element)
{
return element["calculationGroup"] == null;
}

public TablesMapping()
{
ChildMappings = new MappingZone[]
{
new PartitionExpressionsMapping(),
new ColumnExpressionsMapping(),
new MeasureExpressionsMapping()
new MeasureExpressionsMapping(),
};
}
}
Expand All @@ -140,8 +189,9 @@ public BimMappedRepository()
{
Mappings = new MappingZone[]
{
new TablesMapping(),
new ModelExpressionsMapping()
new TablesMapping(),
new ModelExpressionsMapping(),
new CalculationGroupMapping(),
};
}

Expand Down

0 comments on commit 5d45d0d

Please sign in to comment.