private Relations BindRelations() { Relations relation = new Relations(); if (DSDomainData != null) { //Binding tables if (DSDomainData.OnClauses == null || DSDomainData.OnClauses.Items.Count <= 0 || DSDomainData.TableRelations.Rows.Items.Count <= 0) { return(null); } foreach (DSOnClause table in DSDomainData.OnClauses.Items) { relation.TableNames.Add(table.Alias); } //Binding Metrix foreach (DSRelationRow row in DSDomainData.TableRelations.Rows.Items) { relation.Matrix.Add(row.Name, row.Data); } //Binding MappInfo DSDomainData.MetaData.Items.RemoveAt(0); foreach (DSTreeView field in DSDomainData.MetaData.Items) { Mapping map = new Mapping(); map.BizName = field.Text; if (field.Type == DSIconType.Field || field.Type == DSIconType.Condition || field.Type == DSIconType.UDF) { int itemIndex = System.Math.Max(field.TableIndex, 0); DSOnClause table = DSDomainData.OnClauses.Items[itemIndex]; map.TableName = table.Alias; } if (field.Type == DSIconType.SystemInfo || field.Type == DSIconType.RenderXY) { if (relation != null) { map.TableName = relation.TableNames[0]; } } if (relation != null && !relation.MapInfos.ContainsKey(field.Text)) { relation.MapInfos.Add(field.Text, map); } } } return(relation); }
private void GenSelectClauseForField(InternalBookmarkItem bmItem, ref GenOsqlParamInfo paramInfo) { string itemName = BaseMarkupUtilities.GetOriginalBizName(bmItem.Key, bmItem.BizName); DSTreeView item = paramInfo.DomainInfo.GetField(itemName); DSIconType type = (DSIconType)Enum.Parse(typeof(DSIconType), bmItem.ItemType); double i = Math.Log((double)bmItem.TableIndex, (double)2); DSOnClause table = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[bmItem.TableIndex]; string tableName = table.Alias; paramInfo.PutSelectedTable(tableName, false); paramInfo.SelectedTableIndexes.Add(item.TableIndex); UpdateSelectedColumns(ref paramInfo, tableName, itemName); InternalBookmarkItem existedItem = paramInfo.DataTagFields.FirstOrDefault(a => a.TableIndex == item.TableIndex && a.DSIconType == DSIconType.Field); bool isImageTrunc = bmItem.IsTruncImage(); if (isImageTrunc && existedItem != null && existedItem.BizName == bmItem.BizName && !paramInfo.TablesHasField.Contains(item.TableIndex)) { // this table has only image that is chunked then we need to add one default column GenSelectClauseItem(DSIconType.Field, item.TechName, string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo); paramInfo.TablesHasField.Add(item.TableIndex); paramInfo.HasImage = true; } GenSelectClauseItem(type, bmItem.TechName, item.JavaClause, itemName, bmItem.IsTruncImage(), true, ref paramInfo); if (!string.IsNullOrEmpty(item.RenderXYOrder)) { List <string> renderParam = item.RenderXYOrder.Split(';').ToList <string>(); for (int j = 0; j < renderParam.Count; j++) { AddItemToListJParameters((renderParam[j] == "1") ? FrameworkConstants.RenderArgumentX : FrameworkConstants.RenderArgumentY, ref paramInfo, OracleQueryConstants.DicSelectClauseParamName); } } #region Build Extra field if (existedItem == null && !string.IsNullOrEmpty(item.OrginalField) && !paramInfo.TablesHasField.Contains(item.TableIndex)) { GenSelectClauseItem(DSIconType.Field, item.OrginalField, string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo); paramInfo.TablesHasField.Add(item.TableIndex); return; } #endregion }
private int GetTableIndexForUSC(InternalBookmarkItem ibmItem, ref GenOsqlParamInfo paramInfo) { if (paramInfo.UscItems == null || paramInfo.UscItems.Count <= 0) { return(-1); } string itemName = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName); USCItem item = paramInfo.UscItems[itemName]; int maxIndex = -1; if (item.Fields.Count > 0) { foreach (USCItem subField in item.Fields) { if (paramInfo.DomainInfo.Fields.Keys.Contains(subField.BusinessName)) { if (maxIndex < paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex) { maxIndex = paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex; item.BaseOnField = string.IsNullOrWhiteSpace(paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField) ? paramInfo.DomainInfo.Fields[subField.BusinessName].Text : paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField; } } } } ibmItem.TableIndex = maxIndex; item.TableIndex = maxIndex; //Update to Relation DSOnClause table = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[maxIndex]; string tableName = table.Alias; if (!paramInfo.DomainInfo.Relations.MapInfos.ContainsKey(itemName)) { paramInfo.DomainInfo.Relations.MapInfos.Add(itemName, new Mapping(itemName, tableName, itemName)); } else { paramInfo.DomainInfo.Relations.MapInfos[itemName].TableName = tableName; } return(maxIndex); }
/// <summary> /// check internal bookmark is match with domain data in datasegment or no /// = 0: match (that mean same where clause and all field (biz name and unique name)) /// > 0: number of field in internal not match with datasegment /// < 0: where clause is not match /// </summary> /// <param name="ibmDomain"></param> /// <param name="domainName"></param> /// <returns> /// </returns> private DomainMatchItem IsMatchWithDataSegment(InternalBookmarkDomain ibmDomain, string domainName) { DataSegmentHelper.LoadDomainData(domainName); DomainMatchItem matchResult = new DomainMatchItem(domainName); matchResult.IsMatchWhereClause = true; DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName); if (domainInfo == null || domainInfo.DSDomainData == null) { return(null); } #region 1. Compare fields #region 1.2. get internal bookmark item collection from internal bookmark object List <InternalBookmarkItem> iItems = GetInternalBookmarkItemCollection(ibmDomain); #endregion #region 1.3. compare datasegment's field collection with internal bookmark's field collection foreach (InternalBookmarkItem item in iItems) { if (IsMatchWithDataSegment(item, domainInfo.Fields)) { matchResult.MatchedFields.Add(item.BizName); } else { matchResult.NotMatchFields.Add(item.BizName); if (item.Type == XsltType.Select) { matchResult.SetSingleBiz(item.Key); } else { matchResult.SetDoubleBiz(item.Key); } } } #endregion if (!matchResult.IsMatch) { return(matchResult); } #endregion #region 2. Compare RelationOn foreach (RelationOn relationOn in ibmDomain.RelationOns) { DSOnClause item = domainInfo.DSDomainData.OnClauses.Items.FirstOrDefault(c => string.Equals(relationOn.UniqueName, c.UniqueName) && string.Equals(relationOn.OnClause, c.ExClause)); if (item == null) { matchResult.IsMatchRelationOn = false; return(matchResult); } } #endregion #region 3. compare where clause if (ibmDomain.WhereClause != domainInfo.DSDomainData.WhereClause.Clause) { matchResult.IsMatchWhereClause = false; } #endregion return(matchResult); }