public IIR Execute(IIR predecessorIR) { AstIR astIR = predecessorIR as AstIR; if (astIR == null) { return(null); } // Initialize Lowering Engine InitializeLoweringEngine(); PhysicalIR physicalIR = new PhysicalIR(astIR); foreach (Task.AstPackageNode packageNode in astIR.AstRootNode.Packages) { if (packageNode.Emit) { var root = physicalIR.InitializePackage(packageNode.Name); PhysicalLoweringProcessor.Lower(packageNode, new TaskLoweringContext(root)); } } return(physicalIR); }
public VulcanEngine.IR.IIR Execute(VulcanEngine.IR.IIR PredecessorIR) { // TODO: Enhance the PluginLoader so we can use it as the type store. We're currently missing all types that lack a friendly name. XmlIR xmlIR = PredecessorIR as XmlIR; if (xmlIR == null) { // TODO: Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } AstIR astIR = new AstIR(xmlIR); astIR.AstRootNode = new AstRootNode(); foreach (XmlIRDocumentType docType in astIR.XDocuments.Keys) { foreach (XDocument xDocument in astIR.XDocuments[docType]) { parseElement(xDocument.Root, astIR.AstRootNode, docType); } } HashSet <string> processedIncludeFiles = new HashSet <string>(); List <string> newIncludeFiles = new List <string>(); bool bContinue; do { bContinue = false; var newFiles = from file in astIR.AstRootNode.IncludedFiles where !processedIncludeFiles.Contains(file.IncludedFile) select file.IncludedFile; List <string> newFileList = new List <string>(); newFileList.AddRange(newFiles); foreach (var xmlFile in newFileList) { XDocument xDocument = astIR.AddXml(xmlFile, XmlIRDocumentType.INCLUDE); if (xDocument != null) { bContinue = true; parseElement(xDocument.Root, astIR.AstRootNode, XmlIRDocumentType.INCLUDE); processedIncludeFiles.Add(xmlFile); } } } while (bContinue); ProcessLateBindingQueue(); ProcessNewObjectQueue(xmlIR); return(astIR); }
public IIR Execute(IIR predecessorIR) { var xmlIR = predecessorIR as XmlIR; if (xmlIR == null) { // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } var astIR = new AstIR(xmlIR) { AstRootNode = new AstRootNode(null) }; var unboundReferences = new UnboundReferences(); var languageSettings = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode)); foreach (BimlFile bimlFile in astIR.BimlFiles) { if (bimlFile.XDocument.Root != null) { AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings); } } unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable); CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences); if (unboundReferences.Count > 0) { foreach (var unboundReference in unboundReferences) { string filename = unboundReference.BimlFile.Name; string refName = unboundReference.XValue; string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name; string xml = unboundReference.XObject.ToString(); int line = ((IXmlLineInfo)unboundReference.XObject).LineNumber; int offset = ((IXmlLineInfo)unboundReference.XObject).LinePosition; var friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false); if (friendlyNames != null && friendlyNames.Length > 0) { refTypeFriendlyName = friendlyNames[0].FriendlyName; } // TODO: Fatal Error MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml); } throw new InvalidOperationException("Parsing was unsuccessful."); } return(astIR); }
public VulcanEngine.IR.IIR Execute(VulcanEngine.IR.IIR PredecessorIR) { AstIR ir = (AstIR)PredecessorIR; /*foreach (AstPackageNode p in ir.AstRootNode.Packages) * { * foreach (AstTaskNode t in p) * { * Console.WriteLine("Task! {0}", t.Name); * } * } */ return(ProcessTableQuerySources(ir)); //return ir; }
public VulcanEngine.IR.IIR Execute(VulcanEngine.IR.IIR PredecessorIR) { // TODO: Enhance the PluginLoader so we can use it as the type store. We're currently missing all types that lack a friendly name. XmlIR xmlIR = PredecessorIR as XmlIR; if (xmlIR == null) { // TODO: Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } AstIR astIR = new AstIR(xmlIR); astIR.AstRootNode = new AstRootNode(); foreach (XmlIRDocumentType docType in astIR.XDocuments.Keys) { foreach (XDocument xDocument in astIR.XDocuments[docType]) { parseElement(xDocument.Root, astIR.AstRootNode,docType); } } HashSet<string> processedIncludeFiles = new HashSet<string>(); List<string> newIncludeFiles = new List<string>(); bool bContinue; do { bContinue = false; var newFiles = from file in astIR.AstRootNode.IncludedFiles where !processedIncludeFiles.Contains(file.IncludedFile) select file.IncludedFile; List<string> newFileList = new List<string>(); newFileList.AddRange(newFiles); foreach (var xmlFile in newFileList) { XDocument xDocument = astIR.AddXml(xmlFile, XmlIRDocumentType.INCLUDE); if (xDocument != null) { bContinue = true; parseElement(xDocument.Root, astIR.AstRootNode, XmlIRDocumentType.INCLUDE); processedIncludeFiles.Add(xmlFile); } } } while (bContinue); ProcessLateBindingQueue(); ProcessNewObjectQueue(xmlIR); return astIR; }
public IIR Execute(IIR predecessorIR) { var xmlIR = predecessorIR as XmlIR; if (xmlIR == null) { // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } var astIR = new AstIR(xmlIR) { AstRootNode = new AstRootNode(null) }; var unboundReferences = new UnboundReferences(); var languageSettings = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode)); foreach (BimlFile bimlFile in astIR.BimlFiles) { if (bimlFile.XDocument.Root != null) { AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings); } } unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable); CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences); if (unboundReferences.Count > 0) { foreach (var unboundReference in unboundReferences) { string filename = unboundReference.BimlFile.Name; string refName = unboundReference.XValue; string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name; string xml = unboundReference.XObject.ToString(); int line = ((IXmlLineInfo)unboundReference.XObject).LineNumber; int offset = ((IXmlLineInfo)unboundReference.XObject).LinePosition; var friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false); if (friendlyNames != null && friendlyNames.Length > 0) { refTypeFriendlyName = friendlyNames[0].FriendlyName; } // TODO: Fatal Error MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml); } throw new InvalidOperationException("Parsing was unsuccessful."); } return astIR; }
public PhysicalIR(AstIR astIR) : base(astIR) { _emittableNodes = new List <PhysicalObject>(); }
private AstIR ProcessTableQuerySources(AstIR astIR) { List <AstTableNode> tables = new List <AstTableNode>(); tables.AddRange(astIR.AstRootNode.Dimensions.Cast <AstTableNode>()); tables.AddRange(astIR.AstRootNode.Facts.Cast <AstTableNode>()); tables.AddRange(astIR.AstRootNode.Tables); foreach (AstTableNode table in tables) { foreach (AstTableQuerySourceNode querySource in table.Sources.OfType <AstTableQuerySourceNode>()) { AstPackageNode package = new AstPackageNode(); package.ConstraintMode = ContainerConstraintMode.Linear; package.DefaultPlatform = PlatformType.SSIS08; package.Log = false; package.Name = querySource.Name; package.Type = "ETL"; AstStagingContainerTaskNode staging = new AstStagingContainerTaskNode(); staging.ConstraintMode = ContainerConstraintMode.Linear; staging.Log = false; staging.Name = querySource.Name; staging.CreateAs = String.Format("__Staging_{0}_{1}", table.Name, querySource.Name); staging.StagingConnection = table.Connection; staging.Table = table; AstETLRootNode etl = new AstETLRootNode(); etl.Name = String.Format("__ETL_Staging_{0}_{1}", table.Name, querySource.Name); etl.DelayValidation = true; AstQuerySourceNode source = new AstQuerySourceNode(); source.Connection = querySource.Connection; source.Name = String.Format("__ETL_Staging_Source_{0}_{1}", table.Name, querySource.Name); source.Query = querySource.Query; etl.Transformations.Add(source); AstDestinationNode destination = new AstDestinationNode(); destination.AccessMode = DestinationAccessModeFacet.TableFastLoad; destination.CheckConstraints = true; destination.TableLock = true; destination.Connection = table.Connection; destination.Name = String.Format("__ETL_Staging_Destination_{0}_{1}", table.Name, querySource.Name); destination.TableName = staging.CreateAs; destination.ValidateExternalMetadata = false; etl.Transformations.Add(destination); staging.Tasks.Add(etl); AstMergeTaskNode merge = new AstMergeTaskNode(); merge.Connection = table.Connection; merge.Name = String.Format("__Staging_Merge_{0}_{1}", table.Name, querySource.Name); merge.SourceName = staging.CreateAs; merge.TargetConstraint = table.PreferredKey; staging.Tasks.Add(merge); package.Tasks.Add(staging); astIR.AstRootNode.Packages.Add(package); } } return(astIR); }
private AstIR ProcessCustomLookups(AstIR astIR) { throw new NotImplementedException(); }
public PhysicalIR(AstIR astIR) : base(astIR) { this._physicalRootNodes = new List <Ssis2008Emitter.IR.Common.LogicalObject>(); }
public VulcanEngine.IR.IIR Execute(VulcanEngine.IR.IIR predecessorIR) { AstIR astIR = predecessorIR as AstIR; if (astIR == null) { // TODO: Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } PhysicalIR physicalIR = new PhysicalIR(astIR); try { foreach (Task.AstPackageNode packageNode in astIR.AstRootNode.Packages) { if (packageNode.Emit && !packageNode.AsClassOnly) { Package package = packageNode.Lower(); if (String.IsNullOrEmpty(package.Type)) { package.Type = "ETL"; } physicalIR.PhysicalNodes.Add(package); } } foreach (Dimension.AstDimensionNode dimensionNode in astIR.AstRootNode.Dimensions) { if (dimensionNode.Emit && !dimensionNode.AsClassOnly) { Package package = dimensionNode.Lower().Lower(); package.Type = "Dimension"; physicalIR.PhysicalNodes.Add(package); } } foreach (Fact.AstFactNode factNode in astIR.AstRootNode.Facts) { if (factNode.Emit && !factNode.AsClassOnly) { Package package = factNode.Lower().Lower(); package.Type = "FactTable"; physicalIR.PhysicalNodes.Add(package); } } foreach (Connection.AstConnectionNode connectionNode in astIR.AstRootNode.Connections) { physicalIR.PhysicalNodes.Add(connectionNode.Lower()); } foreach (Table.AstTableNode tableNode in astIR.AstRootNode.Tables) { if (tableNode.Emit && !tableNode.AsClassOnly) { Package package = tableNode.Lower().Lower(); package.Type = "Table"; physicalIR.PhysicalNodes.Add(package); foreach (Table.AstTableSourceBaseNode sourceNode in tableNode.Sources) { Table.AstTableDynamicSourceNode dynamicSource = sourceNode as Table.AstTableDynamicSourceNode; if (dynamicSource != null) { Package sourcePackage = dynamicSource.Package.Lower(); sourcePackage.Type = "ETL"; physicalIR.PhysicalNodes.Add(sourcePackage); } } } } } catch (Ssis2008Emitter.SSISEmitterException EmitterException) { StringBuilder err = new StringBuilder(); err.Append("\r\nCompiling "); Exception e = EmitterException; bool bIsNullException = false; while (e != null) { err.AppendFormat("{0}\r\n", e.Message); if (e.InnerException != null) { e = (e.InnerException); err.AppendFormat("-->\t"); } else { if (e is NullReferenceException) { bIsNullException = true; } e = null; } } MessageEngine.Global.Trace(Severity.Error, err.ToString()); if (bIsNullException) { MessageEngine.Global.Trace(Severity.Warning, "Possible reason: an attribute or element is referencing undefined code." + "To solve this issue, fix the mismatched reference or use <Using> to include the definition."); } } return(physicalIR); }
private AstIR ProcessTableQuerySources(AstIR astIR) { List<AstTableNode> tables = new List<AstTableNode>(); tables.AddRange(astIR.AstRootNode.Dimensions.Cast<AstTableNode>()); tables.AddRange(astIR.AstRootNode.Facts.Cast<AstTableNode>()); tables.AddRange(astIR.AstRootNode.Tables); foreach (AstTableNode table in tables) { foreach (AstTableQuerySourceNode querySource in table.Sources.OfType<AstTableQuerySourceNode>()) { AstPackageNode package = new AstPackageNode(); package.ConstraintMode = ContainerConstraintMode.Linear; package.DefaultPlatform = PlatformType.SSIS08; package.Log = false; package.Name = querySource.Name; package.Type = "ETL"; AstStagingContainerTaskNode staging = new AstStagingContainerTaskNode(); staging.ConstraintMode = ContainerConstraintMode.Linear; staging.Log = false; staging.Name = querySource.Name; staging.CreateAs = String.Format("__Staging_{0}_{1}", table.Name, querySource.Name); staging.StagingConnection = table.Connection; staging.Table = table; AstETLRootNode etl = new AstETLRootNode(); etl.Name = String.Format("__ETL_Staging_{0}_{1}", table.Name, querySource.Name); etl.DelayValidation = true; AstQuerySourceNode source = new AstQuerySourceNode(); source.Connection = querySource.Connection; source.Name = String.Format("__ETL_Staging_Source_{0}_{1}", table.Name, querySource.Name); source.Query = querySource.Query; etl.Transformations.Add(source); AstDestinationNode destination = new AstDestinationNode(); destination.AccessMode = DestinationAccessModeFacet.TableFastLoad; destination.CheckConstraints = true; destination.TableLock = true; destination.Connection = table.Connection; destination.Name = String.Format("__ETL_Staging_Destination_{0}_{1}", table.Name, querySource.Name); destination.TableName = staging.CreateAs; destination.ValidateExternalMetadata = false; etl.Transformations.Add(destination); staging.Tasks.Add(etl); AstMergeTaskNode merge = new AstMergeTaskNode(); merge.Connection = table.Connection; merge.Name = String.Format("__Staging_Merge_{0}_{1}", table.Name, querySource.Name); merge.SourceName = staging.CreateAs; merge.TargetConstraint = table.PreferredKey; staging.Tasks.Add(merge); package.Tasks.Add(staging); astIR.AstRootNode.Packages.Add(package); } } return astIR; }
public AstIR(AstIR astIR) : base(astIR) { this._astRootNode = astIR._astRootNode; }