protected EdtLabelInfo getTableFieldLabel(BaseField tableField, EdtLabelInfo labelInfo) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(tableField.Label) == false) { // find the label here labelInfo.Label = tableField.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(tableField.HelpText) == false) { // find the help label here labelInfo.HelpLabel = tableField.HelpText; } if (labelInfo.RequiresDigging() && String.IsNullOrEmpty(tableField.ExtendedDataType) == false) { AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(tableField.ExtendedDataType); labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); } if (labelInfo.RequiresDigging() && tableField is FieldEnum) { FieldEnum tableFieldEnum = tableField as FieldEnum; var axEnum = Common.CommonUtil.GetModelSaveService().GetEnum(tableFieldEnum.EnumType); if (axEnum != null) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(axEnum.Label) == false) { // find the label here labelInfo.Label = axEnum.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(axEnum.HelpText) == false) { // find the help label here labelInfo.HelpLabel = axEnum.HelpText; } } } return(labelInfo); }
protected EdtLabelInfo getEdtBaseLabel(AxEdt edtBase, EdtLabelInfo labelInfo) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(edtBase.Label) == false) { // find the label here labelInfo.Label = edtBase.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(edtBase.HelpText) == false) { // find the help label here labelInfo.HelpLabel = edtBase.HelpText; } if (labelInfo.RequiresDigging() == true && (String.IsNullOrEmpty(edtBase.Extends) == false || edtBase is AxEdtEnum) ) { // if there is a extended data type to this then move it to the next one var edtExt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(edtBase.Extends); if (edtExt != null) { labelInfo = this.getEdtBaseLabel(edtExt, labelInfo); } else if (edtExt == null) { // if this is null then chances are that this extends an enum if (edtBase is AxEdtEnum) { AxEdtEnum edtBaseEnum = edtBase as AxEdtEnum; var axEnum = Common.CommonUtil.GetModelSaveService().GetEnum(edtBaseEnum.EnumType); if (axEnum != null) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(axEnum.Label) == false) { // find the label here labelInfo.Label = axEnum.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(axEnum.HelpText) == false) { // find the help label here labelInfo.HelpLabel = axEnum.HelpText; } } } } } return(labelInfo); }
protected EdtLabelInfo getDataEntityFieldLabel(IDataEntityViewField tableField, EdtLabelInfo labelInfo) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(tableField.Label) == false) { // find the label here labelInfo.Label = tableField.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(tableField.HelpText) == false) { // find the help label here labelInfo.HelpLabel = tableField.HelpText; } if (labelInfo.RequiresDigging()) { // This means we need to find the underlying table / field and find the label from there } //if (labelInfo.RequiresDigging() // && String.IsNullOrEmpty(tableField.ExtendedDataType) == false) //{ // AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(tableField.ExtendedDataType); // labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); //} //if (labelInfo.RequiresDigging() // && tableField is FieldEnum) //{ // FieldEnum tableFieldEnum = tableField as FieldEnum; // var axEnum = Common.CommonUtil.GetModelSaveService().GetEnum(tableFieldEnum.EnumType); // if (axEnum != null) // { // if (String.IsNullOrEmpty(labelInfo.Label) == true // && String.IsNullOrEmpty(axEnum.Label) == false) // { // // find the label here // labelInfo.Label = axEnum.Label; // } // if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true // && String.IsNullOrEmpty(axEnum.HelpText) == false) // { // // find the help label here // labelInfo.HelpLabel = axEnum.HelpText; // } // } //} return(labelInfo); }
protected EdtLabelInfo getDataEntityFieldLabel(IDataEntityViewField field, EdtLabelInfo labelInfo) { if (String.IsNullOrEmpty(labelInfo.Label) == true && String.IsNullOrEmpty(field.Label) == false) { // find the label here labelInfo.Label = field.Label; } if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true && String.IsNullOrEmpty(field.HelpText) == false) { // find the help label here labelInfo.HelpLabel = field.HelpText; } if (labelInfo.RequiresDigging()) { /* * if(field.DataEntityViewExtension != null) * { * var extensionEntity = field.DataEntityViewExtension.RootElement as DataEntityViewExtension; * } * else*/ if (field is DataEntityViewUnmappedField) { DataEntityViewUnmappedField unmapeddField = field as DataEntityViewUnmappedField; AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(unmapeddField.ExtendedDataType); labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); if (labelInfo.RequiresDigging() && field is DataEntityViewUnmappedFieldEnum) { var unmapeddFieldEnum = field as DataEntityViewUnmappedFieldEnum; labelInfo = this.getEnumLabel(unmapeddFieldEnum.EnumType, labelInfo); } } // This means we need to find the underlying table / field and find the label from there else if (field is DataEntityViewMappedField) { string tableName = string.Empty; var metaModelService = Common.CommonUtil.GetModelSaveService(); var mappedField = field as DataEntityViewMappedField; if (field.DataEntityViewExtension != null) { // Find the dataEntityView based on the name var entityName = field.DataEntityViewExtension.Name; entityName = entityName.Substring(0, entityName.IndexOf(".")); var dataEntity = metaModelService.GetDataEntityView(entityName); dataEntity.ViewMetadata.DataSources.ToList().ForEach(ds => { if (ds.Name.Equals(mappedField.DataSource, StringComparison.InvariantCultureIgnoreCase)) { tableName = ds.Table; } else { var ee = ds.DataSources.GetEnumerator(); while (ee.MoveNext()) { tableName = this.findDataSoruceName_DataEntity(ee.Current, mappedField.DataSource); if (String.IsNullOrEmpty(tableName) == false) { break; } //if (ee.Current.Name.Equals(mappedField.DataSource, StringComparison.InvariantCultureIgnoreCase)) //{ //TODO: what if there are even more nested data sources found ? // tableName = ee.Current.Table; // break; //} //else //{ //} } } }); } else { var dataSources = field.DataEntity.DataContractViewMetadata.DataContractDataSources; var dsEnum = dataSources.VisualChildren.GetEnumerator(); while (dsEnum.MoveNext()) { QueryRootDataSource ds = dsEnum.Current as QueryRootDataSource; if (ds.Name.Equals(mappedField.DataSource, StringComparison.InvariantCultureIgnoreCase)) { tableName = ds.Table; //Tables.TableHelper.GetFirstExtension // var metaModelProviders = ServiceLocator.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders; break; // we dont need to continue the while loop of the data sources anymore } } } var table = metaModelService.GetTable(tableName); var tableField = table.Fields.Where(f => f.Name.Equals(mappedField.DataField)).FirstOrDefault(); if (labelInfo.RequiresDigging() && String.IsNullOrEmpty(tableField.ExtendedDataType) == false) { AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(tableField.ExtendedDataType); labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); } if (labelInfo.RequiresDigging() && tableField is AxTableFieldEnum) { var tableFieldEnum = tableField as AxTableFieldEnum; labelInfo = this.getEnumLabel(tableFieldEnum.EnumType, labelInfo); } } } //if (labelInfo.RequiresDigging() // && String.IsNullOrEmpty(tableField.ExtendedDataType) == false) //{ // AxEdt axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(tableField.ExtendedDataType); // labelInfo = this.getEdtBaseLabel(axEdt, labelInfo); //} //if (labelInfo.RequiresDigging() // && tableField is FieldEnum) //{ // FieldEnum tableFieldEnum = tableField as FieldEnum; // var axEnum = Common.CommonUtil.GetModelSaveService().GetEnum(tableFieldEnum.EnumType); // if (axEnum != null) // { // if (String.IsNullOrEmpty(labelInfo.Label) == true // && String.IsNullOrEmpty(axEnum.Label) == false) // { // // find the label here // labelInfo.Label = axEnum.Label; // } // if (String.IsNullOrEmpty(labelInfo.HelpLabel) == true // && String.IsNullOrEmpty(axEnum.HelpText) == false) // { // // find the help label here // labelInfo.HelpLabel = axEnum.HelpText; // } // } //} return(labelInfo); }