public void FinishSuccess(RouteContext routeContext, SchemaMetaData schemaMetaData) { foreach (var routingHook in routingHooks) { routingHook.FinishSuccess(routeContext, schemaMetaData); } }
/// <summary> /// Retrieves names of all contact custom fields from the Act! Database /// </summary> /// <returns>Array list with names of the custom fields</returns> /// <remarks> /// Getting custom contact fields /// This sample retrieves names of the custom contact fields and puts them into an Array list. /// The sample shows the following tasks: /// - Using the SDK to get Contact field descriptors. /// - Getting the table of each contact field descriptor using the TableByName property of SchemaMetadata. /// - If column in the table is custom (IsCustom = true), adding the field name to the Array list. /// </remarks> public /*override*/ ArrayList GetContactCustomFields() { ActFramework ACTFM = new ActFramework(); ACTFM.LogOn("C:\\Documents and Settings\\Administrator\\My Documents\\ACT\\Act for Win 8\\Databases\\Act8Demo.pad", "Chris Huffman", ""); SchemaMetaData smd = ACTFM.SchemaMetaData; ReadOnlyHashtable tblByName = smd.TableByName; ArrayList customFieldArray = new ArrayList(); ContactFieldDescriptor[] cfdList = ACTFM.Contacts.GetContactFieldDescriptors(); ContactFieldDescriptor cfd; Table tContact; Column col; for (int i = 0; i < cfdList.Length; i++) { cfd = cfdList[i]; tContact = (Act.Framework.MetaData.Table)tblByName[cfd.TableName]; col = (Column)tContact.ColumnByDisplayName[cfd.DisplayName]; if (col != null) { if (col.IsCustom) { customFieldArray.Add(col.Name); } } } return(customFieldArray); }
/** * Load schema Meta data. * * @param databaseType database type * @return schema Meta data * @throws SQLException SQL exception */ public SchemaMetaData Load(IDatabaseType databaseType) { SchemaMetaData result = LoadShardingSchemaMetaData(databaseType); result.Merge(LoadDefaultSchemaMetaData(databaseType)); return(result); }
public InsertCommandContext(SchemaMetaData schemaMetaData, ParameterContext parameterContext, InsertCommand insertCommand) : base(insertCommand) { _tablesContext = new TablesContext(insertCommand.Table); _columnNames = insertCommand.UseDefaultColumns() ? schemaMetaData.GetAllColumnNames(insertCommand.Table.GetTableName().GetIdentifier().GetValue()) : insertCommand.GetColumnNames(); _insertValueContexts = GetInsertValueContexts(parameterContext); _generatedKeyContext = new GeneratedKeyContextEngine(schemaMetaData).CreateGenerateKeyContext(parameterContext, insertCommand); }
protected override List <MemoryQueryResultRow> Init(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders) { ICollection <MemoryQueryResultRow> result = new LinkedList <MemoryQueryResultRow>(); var tableNames = new HashSet <string>(); foreach (var streamDataReader in streamDataReaders) { while (streamDataReader.Read()) { MemoryQueryResultRow memoryResultSetRow = new MemoryQueryResultRow(streamDataReader); var actualTableName = memoryResultSetRow.GetCell(0).ToString(); var tableRule = rule.FindTableRuleByActualTable(actualTableName); if (tableRule == null) { if (rule.TableRules.IsEmpty() || schemaMetaData.ContainsTable(actualTableName) && tableNames.Add(actualTableName)) { result.Add(memoryResultSetRow); } } else if (tableNames.Add(tableRule.LogicTable)) { memoryResultSetRow.SetCell(1, tableRule.LogicTable); SetCellValue(memoryResultSetRow, tableRule.LogicTable, actualTableName); result.Add(memoryResultSetRow); } } } return(result.ToList()); }
public SelectCommandContext(SchemaMetaData schemaMetaData, string sql, ParameterContext parameterContext, SelectCommand sqlCommand) : base(sqlCommand) { _tablesContext = new TablesContext(sqlCommand.GetSimpleTableSegments()); _groupByContext = new GroupByContextEngine().CreateGroupByContext(sqlCommand); _orderByContext = new OrderByContextEngine().CreateOrderBy(sqlCommand, _groupByContext); _projectionsContext = new ProjectionsContextEngine(schemaMetaData).CreateProjectionsContext(sql, sqlCommand, _groupByContext, _orderByContext); _paginationContext = new PaginationContextEngine().CreatePaginationContext(sqlCommand, _projectionsContext, parameterContext); _containsSubQuery = ContainsSubQuery(); }
public static SchemaMetaData Decorate <T>(SchemaMetaData schemaMetaData, T rule, ITableMetaDataDecorator <T> tableMetaDataDecorator) where T : IBaseRule { IDictionary <string, TableMetaData> result = new Dictionary <string, TableMetaData>(schemaMetaData.GetAllTableNames().Count); foreach (var tableName in schemaMetaData.GetAllTableNames()) { var tableMetaData = tableMetaDataDecorator.Decorate(schemaMetaData.Get(tableName), tableName, rule); result.Add(tableName, tableMetaData); } return(new SchemaMetaData(result)); }
protected MemoryMergedDataReader(T rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders) { // ReSharper disable once VirtualMemberCallInConstructor var memoryQueryResultRowList = Init(rule, schemaMetaData, sqlCommandContext, streamDataReaders); _memoryResultSetRows = memoryQueryResultRowList.GetEnumerator(); if (memoryQueryResultRowList.Any()) { _currentSetResultRow = memoryQueryResultRowList.First(); } }
/// <summary> /// 通过元信息获取表名 /// </summary> /// <param name="columnName"></param> /// <param name="schemaMetaData"></param> /// <returns></returns> private string FindTableNameFromMetaData(string columnName, SchemaMetaData schemaMetaData) { foreach (var table in _tables) { if (schemaMetaData.ContainsColumn(table.GetTableName().GetIdentifier().GetValue(), columnName)) { return(table.GetTableName().GetIdentifier().GetValue()); } } return(null); }
/// <summary> /// 创建数据库元数据信息 /// </summary> /// <param name="dataSourceMap"></param> /// <param name="databaseType"></param> /// <returns></returns> private ShardingConnectorMetaData CreateMetaData(IDictionary <string, IDataSource> dataSourceMap, IDatabaseType databaseType) { long start = UtcTime.CurrentTimeMillis(); DataSourceMetas dataSourceMetas = new DataSourceMetas(databaseType, GetDatabaseAccessConfigurationMap(dataSourceMap)); SchemaMetaData schemaMetaData = LoadSchemaMetaData(dataSourceMap); ShardingConnectorMetaData result = new ShardingConnectorMetaData(dataSourceMetas, schemaMetaData); var costMillis = UtcTime.CurrentTimeMillis() - start; _logger.LogInformation($"Meta data load finished, cost {costMillis} milliseconds."); return(result); }
protected override SchemaMetaData[] GetSchemaMetaData() { SchemaMetaData data = new SchemaMetaData() { SchemaTable = "Tables", SchemaColumn = "TABLE_SCHEMA", NameColumn = "TABLE_NAME", TableTypeColumn = "TABLE_TYPE", ValidTableTypes = new string[] { "VIEW", "BASE TABLE" }, InvalidSchemas = null }; return(new SchemaMetaData[] { data }); }
public string FindTableName(ColumnSegment column, SchemaMetaData schemaMetaData) { if (1 == _tables.Count) { return(_tables.First().GetTableName().GetIdentifier().GetValue()); } if (null != column.GetOwner()) { return(FindTableNameFromSQL(column.GetOwner().GetIdentifier().GetValue())); } return(FindTableNameFromMetaData(column.GetIdentifier().GetValue(), schemaMetaData)); }
protected virtual SchemaMetaData[] GetSchemaMetaData() { // A bare minimum set of things that should vaguely work for all databases SchemaMetaData data = new SchemaMetaData() { SchemaTable = "Tables", SchemaColumn = null, NameColumn = "TABLE_NAME", TableTypeColumn = null, ValidTableTypes = null, InvalidSchemas = null }; return(new SchemaMetaData[] { data }); }
public SqlRewriteContext(SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, string sql, ParameterContext parameterContext) { this._schemaMetaData = schemaMetaData; this._sqlCommandContext = sqlCommandContext; this._sql = sql; this._parameterContext = parameterContext; AddSqlTokenGenerators(new DefaultTokenGeneratorBuilder().GetSqlTokenGenerators()); if (sqlCommandContext is InsertCommandContext insertCommandContext) { _parameterBuilder = new GroupedParameterBuilder(insertCommandContext.GetGroupedParameters()); } else { _parameterBuilder = new StandardParameterBuilder(parameterContext); } }
protected override SchemaMetaData[] GetSchemaMetaData() { // Note, in older iterations of the code there seemed to be // cases when we also need to look in the "views" table // but I do not see that in my test cases SchemaMetaData data = new SchemaMetaData() { SchemaTable = "Tables", SchemaColumn = "TABLE_SCHEMA", NameColumn = "TABLE_NAME", TableTypeColumn = "TABLE_TYPE", ValidTableTypes = new string[] { "VIEW", "TABLE" }, InvalidSchemas = null }; return(new SchemaMetaData[] { data }); }
private bool GetValueCaseSensitiveFromTables(IStreamDataReader streamDataReader, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData, int columnIndex) { foreach (var simpleTableSegment in selectCommandContext.GetAllTables()) { String tableName = simpleTableSegment.GetTableName().GetIdentifier().GetValue(); TableMetaData tableMetaData = schemaMetaData.Get(tableName); IDictionary <String, ColumnMetaData> columns = tableMetaData.GetColumns(); String columnName = streamDataReader.GetColumnName(columnIndex); if (columns.ContainsKey(columnName)) { return(columns[columnName].CaseSensitive); } } return(false); }
protected override List <MemoryQueryResultRow> Init(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders) { var selectCommandContext = (SelectCommandContext)sqlCommandContext; IDictionary <GroupByValue, MemoryQueryResultRow> dataMap = new Dictionary <GroupByValue, MemoryQueryResultRow>(1024); IDictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> > aggregationMap = new Dictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> >(1024); foreach (var streamDataReader in streamDataReaders) { while (streamDataReader.Read()) { GroupByValue groupByValue = new GroupByValue(streamDataReader, selectCommandContext.GetGroupByContext().GetItems()); InitForFirstGroupByValue(selectCommandContext, streamDataReader, groupByValue, dataMap, aggregationMap); Aggregate(selectCommandContext, streamDataReader, groupByValue, aggregationMap); } } SetAggregationValueToMemoryRow(selectCommandContext, dataMap, aggregationMap); List <bool> valueCaseSensitive = streamDataReaders.IsEmpty() ? new List <bool>(0) : GetValueCaseSensitive(streamDataReaders.First(), selectCommandContext, schemaMetaData); return(GetMemoryResultSetRows(selectCommandContext, dataMap, valueCaseSensitive)); }
//Inherited from RelationalDatabase //public string DatabaseType { get; set; } //MySQL, SQLite, MS SQL Server, Act!, etc... //public string LoginPath { get; set; } //Must-implements for Act_DatabaseInterface //NOTE: *******************loginpath and image path MUST be compatible with each other *************************************** //public void CreateConnection(string login, string password) //todo: add argument for database public void CreateConnection(string login, string password, string database) { DatabaseType = ("Act!"); //LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottyPPv16Web3.pad"; //LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\OptomiLADellv2.pad"; //Dell laptop remote DB //LoginPath = "C:\\Users\\zenkutsu64\\My Documents\\ACT\\ACT Data\\Databases\\PivotPointWebv16.pad"; //jamporium.com (Rackspace) //LoginPath = "C:\\Users\\zenkutsu64\\Documents\\ACT\\ACT Data\\Databases\\OptomiLA.pad"; //bizexpedite.com (Azure) if (database == "PPSearch") LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottPivotPoint2point0.pad"; //todo: conditional to select login path else if (database == "PPTalent") LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottPivotPointTalent.pad"; else if (database == "GladPixGarden") LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottGladPixGarden.pad"; //todo: conditional to select login path //LoginPath = "C:\\Users\\zenkutsu64\\Documents\\ACT\\ACT Data\\Databases\\PivotPoint2point0.pad"; //bizexpedite.com (Azure) theFramework = new ActFramework(); try { theFramework.LogOn(LoginPath, login, password); //Test block here to investigate details of the db SchemaMetaData smd = theFramework.SchemaMetaData; ReadOnlyHashtable tblByName = smd.TableByName; ArrayList customFieldArray = new ArrayList(); ContactFieldDescriptor[] cfdList = theFramework.Contacts.GetContactFieldDescriptors(); //inspect cfdList in the debugger to get info } catch (InvalidLogonException e){ Console.WriteLine(e.Message); } catch (TargetInvocationException e) { Console.WriteLine(e.Message); } catch (PADObjectException e) { Console.WriteLine(e.Message); } }
protected override SchemaMetaData[] GetSchemaMetaData() { // The following may fail for Oracle ODBC, need to test that... SchemaMetaData data1 = new SchemaMetaData() { SchemaTable = "Tables", SchemaColumn = "TABLE_SCHEM", NameColumn = "TABLE_NAME", TableTypeColumn = "TABLE_TYPE", ValidTableTypes = new string[] { "TABLE", "SYSTEM TABLE" }, InvalidSchemas = null }; SchemaMetaData data2 = new SchemaMetaData() { SchemaTable = "Views", SchemaColumn = "TABLE_SCHEM", NameColumn = "TABLE_NAME", TableTypeColumn = "TABLE_TYPE", ValidTableTypes = new string[] { "VIEW" }, InvalidSchemas = new string[] { "sys", "INFORMATION_SCHEMA" } }; return(new SchemaMetaData[] { data1, data2 }); }
private bool GetOrderValuesCaseSensitiveFromTables(SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData, OrderByItem eachOrderByItem) { foreach (var simpleTableSegment in selectCommandContext.GetAllTables()) { var tableName = simpleTableSegment.GetTableName().GetIdentifier().GetValue(); var tableMetaData = schemaMetaData.Get(tableName); IDictionary <String, ColumnMetaData> columns = tableMetaData.GetColumns(); var orderByItemSegment = eachOrderByItem.GetSegment(); if (orderByItemSegment is ColumnOrderByItemSegment columnOrderByItemSegment) { String columnName = columnOrderByItemSegment.GetColumn().GetIdentifier().GetValue(); if (columns.ContainsKey(columnName)) { return(columns[columnName].CaseSensitive); } } else if (orderByItemSegment is IndexOrderByItemSegment indexOrderByItemSegment) { int columnIndex = indexOrderByItemSegment.GetColumnIndex(); String columnName = _streamDataReader.GetColumnName(columnIndex); if (columns.ContainsKey(columnName)) { return(columns[columnName].CaseSensitive); } } else { return(false); } } return(false); }
private void CopySchema(IEnumerable <SchemaData> sourceSchemaDataList, TaxonomyInfo newTaxonomy, bool isAppend = false) { foreach (var srcSchemaData in sourceSchemaDataList) { var newSchemaInfo = newTaxonomy.SchemaInfos.SingleOrDefault(p => p.AttributeID == srcSchemaData.SchemaInfo.AttributeID) ?? new SchemaInfo { AttributeID = srcSchemaData.SchemaInfo.AttributeID, TaxonomyID = newTaxonomy.ID }; //copy LOVs srcSchemaData.SchemaInfo.ActiveListOfValues.ForEach(aLov => newSchemaInfo.ListOfValues.Add(new ListOfValue { Active = true, Value = aLov, SchemaID = newSchemaInfo.ID })); //copy active schema data var newSchemaData = new SchemaData { SchemaID = newSchemaInfo.ID, InSchema = srcSchemaData.InSchema, DisplayOrder = isAppend ? ( newTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Any(si => si.SchemaData.DisplayOrder >= 500) ? newTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Max(si => si.SchemaData.DisplayOrder) + 1 : 500 ) : srcSchemaData.DisplayOrder, NavigationOrder = isAppend ? 0 : srcSchemaData.NavigationOrder, DataType = srcSchemaData.DataType, Active = true }; //copy schema meta info foreach (var srcSchemaMetaInfo in srcSchemaData.SchemaInfo.SchemaMetaInfos) { var newSchemaMetaInfo = new SchemaMetaInfo { SchemaID = newSchemaInfo.ID, MetaAttributeID = srcSchemaMetaInfo.MetaAttributeID }; //copy active schema meta data if it exists if (srcSchemaMetaInfo.SchemaMetaData != null) { var newSchemaMetaData = new SchemaMetaData { Active = true, MetaID = newSchemaMetaInfo.ID, Value = srcSchemaMetaInfo.SchemaMetaData.Value }; newSchemaMetaInfo.SchemaMetaDatas.Add(newSchemaMetaData); } newSchemaInfo.SchemaMetaInfos.Add(newSchemaMetaInfo); } newSchemaInfo.SchemaDatas.Add(newSchemaData); newTaxonomy.SchemaInfos.Add(newSchemaInfo); } }
public LogicTablesMergedDataReader(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders) : base(rule, schemaMetaData, sqlCommandContext, streamDataReaders) { }
public WhereClauseShardingConditionEngine(ShardingRule shardingRule, SchemaMetaData schemaMetaData) { this.shardingRule = shardingRule; this.schemaMetaData = schemaMetaData; }
public OrderByValue(IStreamDataReader streamDataReader, ICollection <OrderByItem> orderByItems, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { this._streamDataReader = streamDataReader; this.orderByItems = orderByItems; this.orderValuesCaseSensitive = GetOrderValuesCaseSensitive(selectCommandContext, schemaMetaData); }
public ShardingTableBroadcastRoutingEngine(SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext) { this.schemaMetaData = schemaMetaData; this.sqlCommandContext = sqlCommandContext; }
private void OrderResultSetsToQueue(List <IStreamDataReader> streamDataReaders, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { foreach (var queryResult in streamDataReaders) { OrderByValue orderByValue = new OrderByValue(queryResult, OrderByItems, selectCommandContext, schemaMetaData); if (orderByValue.MoveNext()) { OrderByValuesQueue.Offer(orderByValue); } } SetCurrentStreamDataReader(OrderByValuesQueue.IsEmpty() ? streamDataReaders[0] : OrderByValuesQueue.Peek().GetStreamDataReader()); }
public OrderByStreamMergedDataReader(List <IStreamDataReader> streamDataReaders, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { this.OrderByItems = selectCommandContext.GetOrderByContext().GetItems(); this.OrderByValuesQueue = new PriorityQueue <OrderByValue>(streamDataReaders.Count); OrderResultSetsToQueue(streamDataReaders, selectCommandContext, schemaMetaData); IsFirstNext = true; }
private List <bool> GetOrderValuesCaseSensitive(SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData) { List <bool> result = new List <bool>(orderByItems.Count); foreach (var orderByItem in orderByItems) { result.Add(GetOrderValuesCaseSensitiveFromTables(selectCommandContext, schemaMetaData, orderByItem)); } return(result); }
public IStreamDataReader Merge(List <IStreamDataReader> streamDataReaders, ISqlCommandContext <ISqlCommand> sqlCommandContext, SchemaMetaData schemaMetaData) { return(new TransparentMergedDataReader(streamDataReaders[0])); }
public MergeEngine(ICollection <IBaseRule> rules, ConfigurationProperties properties, IDatabaseType databaseType, SchemaMetaData metaData) { this.rules = rules; merger = new MergeEntry(databaseType, metaData, properties); }