public ColumnTree GetTargetTree() // Convert all target paths into a column tree where the target table will be a root. The tree can contain non-existing elements if they are used in the mapping. { ColumnTree tree = new ColumnTree(TargetTab); Matches.ForEach(p => tree.AddPath(p.TargetPath)); return(tree); }
public void AddTargetToSchema(DcSchema schema = null) // Ensure that all target elements exist in the specified schema { // The mapping can reference new elements which are not in the schema yet so we try to find them and add if necessary if (schema == null) // Find the schema from the mapping elements { PathMatch match = Matches.FirstOrDefault(m => m.TargetPath.Output.IsPrimitive); schema = match != null ? match.TargetPath.Output.Schema : null; // We assume that primitive tables always have root defined (other tables might not have been added yet). } ColumnTree tree = GetTargetTree(); tree.AddToSchema(schema); }
public ColumnTree GetTargetTree(Table tab) // Convert all target paths into a column tree where the target table will be a root. The tree can contain non-existing elements if they are used in the mapping. { ColumnTree tree = new ColumnTree(tab); foreach (PathMatch m in Matches) { // if(m.TargetPath.Input != tab) continue; // Use this if we want to take into account only paths *starting* from this table (rather than crossing this tab) int index = m.TargetPath.IndexOfLesser(tab); if (index < 0) { continue; // The path does not cross this tab } tree.AddPath(m.TargetPath.SubPath(index)); } return(tree); }