Ejemplo n.º 1
0
        private static void ComputeRootsAndSuccessors(IEnumerable <AstTransformationNode> unsortedTransformations, HashSet <AstTransformationNode> roots, Dictionary <AstTransformationNode, ICollection <AstTransformationNode> > successors)
        {
            AstTransformationNode previousTransformation = null;

            foreach (var transformation in unsortedTransformations)
            {
                HashSet <AstTransformationNode> predecessors = FindPredecessors(transformation, previousTransformation);

                if (predecessors.Count == 0)
                {
                    roots.Add(transformation);
                }

                foreach (var predecessor in predecessors)
                {
                    if (!successors.ContainsKey(predecessor))
                    {
                        successors.Add(predecessor, new HashSet <AstTransformationNode>());
                    }

                    successors[predecessor].Add(transformation);
                }

                previousTransformation = transformation;
            }
        }
Ejemplo n.º 2
0
        public static void ValidateEtlFragment(AstEtlFragmentNode etlFragment)
        {
            var graph = new TransformationGraph(etlFragment.Transformations);

            AstTransformationNode root = null;

            foreach (var rootNode in graph.RootNodes)
            {
                if (!(rootNode.Item is AstSourceTransformationNode))
                {
                    if (root != null)
                    {
                        MessageEngine.Trace(etlFragment, Severity.Error, "V0120", "Etl Fragments cannot have more than one root node with InputPaths");
                    }

                    root = rootNode.Item;
                }
            }

            AstTransformationNode leaf = null;

            foreach (var leafNode in graph.LeafNodes)
            {
                if (!(leafNode.Item is AstDestinationNode))
                {
                    if (leaf != null)
                    {
                        MessageEngine.Trace(etlFragment, Severity.Error, "V0121", "Etl Fragments cannot have more than one leaf node with OutputPaths");
                    }

                    leaf = leafNode.Item;
                }
            }
        }
Ejemplo n.º 3
0
        public static void Replace(AstTransformationNode item, IEnumerable <AstTransformationNode> replacements)
        {
            var transformations = GetParentTransformationCollection(item);

            if (transformations != null)
            {
                transformations.Replace(item, replacements);
            }
        }
Ejemplo n.º 4
0
        protected Transformation(LoweringContext context, AstTransformationNode astTransformationNode)
            : base(astTransformationNode.Name)
        {
            var dflc = context as DataflowLoweringContext;

            Dataflow = dflc.Dataflow;
            ValidateExternalMetadata = astTransformationNode.ValidateExternalMetadata;
            BindingList            = new Collection <Binding>();
            _astTransformationNode = astTransformationNode;
        }
Ejemplo n.º 5
0
        private static HashSet <AstTransformationNode> FindPredecessors(AstTransformationNode transformation, AstTransformationNode previousTransformation)
        {
            var predecessors = new HashSet <AstTransformationNode>();

            var multipleIn = transformation as AstMultipleInTransformationNode;

            if (multipleIn != null)
            {
                foreach (var inputPath in multipleIn.InputPaths)
                {
                    var predecessorNode = inputPath.OutputPath.ParentItem as AstTransformationNode;
                    predecessors.Add(predecessorNode);
                }
            }

            var singleIn = transformation as AstSingleInTransformationNode;

            if (singleIn != null && singleIn.InputPath != null && singleIn.InputPath.OutputPath != null)
            {
                var predecessorNode = singleIn.InputPath.OutputPath.ParentItem as AstTransformationNode;
                if (predecessorNode != null)
                {
                    predecessors.Add(predecessorNode);
                }
            }

            if (predecessors.Count == 0 && previousTransformation != null)
            {
                bool foundOutputPath = false;
                foreach (var outputPath in previousTransformation.StaticOutputPaths)
                {
                    if (outputPath.References.Count > 0)
                    {
                        foundOutputPath = true;
                        break;
                    }
                }

                if (!foundOutputPath)
                {
                    predecessors.Add(previousTransformation);
                }
            }

            return(predecessors);
        }
Ejemplo n.º 6
0
        public static VulcanCollection <AstTransformationNode> GetParentTransformationCollection(AstTransformationNode item)
        {
            var parent = item.ParentItem;

            if (parent != null)
            {
                PropertyInfo propertyInfo = parent.GetType().GetProperty("Transformations");
                if (propertyInfo != null)
                {
                    return(propertyInfo.GetValue(parent, null) as VulcanCollection <AstTransformationNode>);
                }
            }

            return(null);
        }
Ejemplo n.º 7
0
 protected SingleOutTransformation(LoweringContext context, AstTransformationNode astTransformationNode) : base(context, astTransformationNode)
 {
 }