/// <summary> /// Gets the opa transformation path for. /// </summary> /// <param name="thisRulebase">this rulebase.</param> /// <returns> /// the path to the transformation file /// </returns> public string GetOPATransformationPathFor(IRulebaseConfiguration thisRulebase) { var operatingYear = thisRulebase.OperatingYear.AsString(); var workingFolder = thisRulebase.PointerToZip; var candidatePath = Path.Combine(workingFolder, Asset.FolderNames.OPARules, thisRulebase.ShortName); var files = GetFileInformationFor(candidatePath, EasyOPAConstant.TransformationFileSearchPattern); if (!files.Any()) { workingFolder = Path.Combine(Location.OfAssets, operatingYear, Asset.Locations.Production); candidatePath = Path.Combine(workingFolder, Asset.FolderNames.OPARules, thisRulebase.ShortName); files = GetFileInformationFor(candidatePath, EasyOPAConstant.TransformationFileSearchPattern); } var failedCount = !It.HasCountOf(files, 1); failedCount. AsGuard <ArgumentException>(Format.String(fileCountFailedMsg, "transformation", thisRulebase.ShortName)); var candidate = files.First(); var fileName = Path.GetFileName(candidate); var failedMatch = It.IsDifferent(fileName, thisRulebase.OPATransform); failedMatch .AsGuard <ArgumentException>(Format.String(matchFailedMsg, "transformation", fileName, thisRulebase.ShortName)); return(candidate); }
public ICollection <string> AddTableKeyColumnsSQL() { var sql = Collection.Empty <string>(); Tables.ForEach(table => { var tableName = table.Name; var foreignKeys = table.Keys.Where(x => It.IsDifferent(x.Table.Name, table.Name)); if (foreignKeys.Any()) { var keys = foreignKeys.AsString(); var statement = table.HasPrimaryKey() ? $"alter table [{tableName}] add constraint [PK_{tableName}] primary key clustered ({keys})" : $"create index [IX_{tableName}] on [{tableName}] ({keys})"; sql.Add(statement); } }); return(sql); }
/// <summary> /// Gets the opa configuration for. /// </summary> /// <param name="thisRulebase">this rulebase.</param> /// <returns> /// the cleansed and detokenised configuration file /// </returns> public string GetOPAConfigurationFor(IRulebaseConfiguration thisRulebase) { var operatingYear = thisRulebase.OperatingYear.AsString(); var workingFolder = thisRulebase.PointerToZip; var candidatePath = Path.Combine(workingFolder, Asset.FolderNames.OPAConfig, thisRulebase.ShortName); var files = GetFileInformationFor(candidatePath, EasyOPAConstant.ConfigurationFileSearchPattern); if (!files.Any()) { workingFolder = Path.Combine(Location.OfAssets, operatingYear, Asset.Locations.Production); candidatePath = Path.Combine(workingFolder, Asset.FolderNames.OPAConfig, thisRulebase.ShortName); files = GetFileInformationFor(candidatePath, EasyOPAConstant.ConfigurationFileSearchPattern); } var failedCount = !It.HasCountOf(files, 1); failedCount. AsGuard <ArgumentException>(Format.String(fileCountFailedMsg, "configuration", thisRulebase.ShortName)); var candidate = files.First(); var fileName = Path.GetFileName(candidate); var failedMatch = It.IsDifferent(fileName, thisRulebase.OPAConfiguration); failedMatch .AsGuard <ArgumentException>(Format.String(matchFailedMsg, "configuration", fileName, thisRulebase.ShortName)); var schema = Schema.GetSchema(thisRulebase.OperatingYear); // regardless of where the configuration files are, // we always set the location of the zip file to the pointer return(File .ReadAllText(candidate) .Replace(Token.ForWorkingFolder, thisRulebase.PointerToZip) .Replace(Token.ForPeriodStartDate, schema.PeriodStartDate)); }
/// <summary> /// Condition met. /// </summary> /// <param name="thisDelivery">this delivery.</param> /// <returns> /// true if any any point the conditions are met /// </returns> public bool ConditionMet(ILearningDelivery thisDelivery) { return(It.Has(thisDelivery) ? It.IsDifferent(thisDelivery.LearnAimRef, TypeOfAim.References.IndustryPlacement) : true); }
private void AddTablesToBulkLoadSchema(XmlNode currentSchemaNode, XmlNode currentTableNode, Dictionary <string, string> TableRelationships) { foreach (XmlElement tableElement in currentTableNode.ChildNodes) { XmlElement schemaElement = currentSchemaNode.OwnerDocument.CreateElement("xsd", "element", "http://www.w3.org/2001/XMLSchema"); schemaElement.SetAttribute("name", tableElement.Name); if (!Tables.Get(tableElement.Name).Columns.Any()) { var isConstant = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "is-constant", "urn:schemas-microsoft-com:mapping-schema"); isConstant.Value = "1"; schemaElement.Attributes.Append(isConstant); } else { var sqlRelation = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "relation", "urn:schemas-microsoft-com:mapping-schema"); sqlRelation.Value = tableElement.Name; schemaElement.Attributes.Append(sqlRelation); if (TableRelationships.ContainsKey(tableElement.Name)) { var sqlRelationship = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "relationship", "urn:schemas-microsoft-com:mapping-schema"); sqlRelationship.Value = TableRelationships[tableElement.Name]; schemaElement.Attributes.Append(sqlRelationship); } } currentSchemaNode.AppendChild(schemaElement); var complexType = currentSchemaNode.OwnerDocument.CreateElement("xsd", "complexType", "http://www.w3.org/2001/XMLSchema"); schemaElement.AppendChild(complexType); var sequence = currentSchemaNode.OwnerDocument.CreateElement("xsd", "sequence", "http://www.w3.org/2001/XMLSchema"); complexType.AppendChild(sequence); var foreignKeyColumns = Tables.Get(tableElement.Name).Keys.Where(x => It.IsDifferent(x.Table.Name, tableElement.Name)); foreignKeyColumns.ForEach(column => sequence.AppendChild(ConvertColumnToElement(column, currentSchemaNode))); var tableColumns = Tables.Get(tableElement.Name).Columns; tableColumns.ForEach(column => sequence.AppendChild(ConvertColumnToElement(column, currentSchemaNode))); AddTablesToBulkLoadSchema(sequence, tableElement, TableRelationships); } }