private void GenerateLoadDimInterface(StringBuilder sb, DimensionALInterface ifa) { sb.Append($"-- Load DimensionInterface {ifa.Name}\n"); sb.Append($"insert into {ifa.Name} (\n"); foreach (var attr in ifa.Attributes) { sb.Append($"{attr.Name}".Indent(1)); if (attr != ifa.Attributes.Last()) { sb.Append(","); } sb.Append("\n"); } sb.Append(") \n"); sb.Append("select \n"); foreach (var attr in ifa.Attributes) { sb.Append($"{GetBTName(attr.BTAttribute)} as {attr.Name}".Indent(1)); if (attr != ifa.Attributes.Last()) { sb.Append(","); } sb.Append("\n"); } sb.Append($"from {ifa.BTInterface.FullName}\n\n"); }
public void TestDimensionALInterface_GetName() { // Daten einlesen... var fileName = @"..\..\..\..\Test\Data\al_tests.ceusdl"; var data = new ParsableData(System.IO.File.ReadAllText(fileName), fileName); var p = new FileParser(data); var result = p.Parse(); var model = new CoreModel(result); var bt = new BT.BTModel(model); var alModel = new AL.ALModel(bt); var refBt = (BT.RefBTAttribute)bt.Interfaces[3].Attributes.Where(a => a is BT.RefBTAttribute).FirstOrDefault(); var dim = new DimensionALInterface(alModel, refBt); Assert.IsNotNull(refBt); Assert.AreEqual("ARC_D_Term_1_Term", dim.Name); }
public StarDimensionTable(DimensionALInterface dim) { this.dim = dim; joinIdx = 0; var currentJoinAlias = $"t{joinIdx}"; InterfaceReferences = new List <DimensionInterfaceReference>(); Config = dim.Model.Config; Attributes = new List <IALAttribute>(); // Basis-Attribute var baseAttrs = dim.Attributes.Where(a => a is BaseALAttribute); foreach (var baseAttr in baseAttrs) { baseAttr.JoinAlias = currentJoinAlias; } Attributes.AddRange(baseAttrs); // Referenz-Attribute var refAttrs = dim.Attributes.Where(a => a is RefALAttribute) .Select(a => (RefALAttribute)a); foreach (var refAttr in refAttrs) { joinIdx += 1; var temp = RecurseDimensions(refAttr); var joinAlias = temp.First().JoinAlias; InterfaceReferences.Add(new DimensionInterfaceReference() { ParentBTInterface = refAttr.ParentInterface.BTInterface, ReferencedBTInterface = ((BT.RefBTAttribute)refAttr.BTAttribute).ReferencedBTInterface, JoinAlias = joinAlias, ParentJoinAlias = currentJoinAlias, ParentRefColumnName = ((BT.RefBTAttribute)refAttr.BTAttribute).IdAttribute.Name, ReferencedRefColumnName = ((BT.BaseBTAttribute)((BT.RefBTAttribute)refAttr.BTAttribute).ReferencedBTAttribute).Name }); Attributes.AddRange(temp); } // InterfaceReferences nach Alias sortieren! InterfaceReferences = InterfaceReferences.OrderBy(i => $"{i.JoinAlias.Length}{i.JoinAlias}").ToList(); }
private void GenerateDimensionInterface(StringBuilder sb, DimensionALInterface i) { sb.Append($"create table {i.Name} (\n"); foreach (var a in i.Attributes) { sb.Append($"{a.Name} {a.SqlType}".Indent(1)); if (a == i.IdColumn) { sb.Append(" primary key not null"); } if (a != i.Attributes.Last()) { sb.Append(","); } sb.Append("\n"); } sb.Append(");\n"); sb.Append("\n"); }
private void GenerateTruncateDimInterface(StringBuilder sb, DimensionALInterface ifa) { sb.Append($"-- Inhalt von {ifa.Name} löschen\n"); sb.Append($"truncate table {ifa.Name};\n\n"); }