TSF.UmlToolingFramework.Wrappers.EA.Model.getAttributesByQuery C# (CSharp) Method

getAttributesByQuery() public method

public getAttributesByQuery ( string SQLQuery ) : List
SQLQuery string
return List
        public List<Attribute> getAttributesByQuery(string SQLQuery)
        {
            // get the nodes with the name "ea_guid"
              XmlDocument xmlAttributeIDs = this.SQLQuery(SQLQuery);
              XmlNodeList attributeIDNodes = xmlAttributeIDs.SelectNodes(formatXPath("//ea_guid"));
              List<Attribute> attributes = new List<Attribute>();

              foreach( XmlNode attributeIDNode in attributeIDNodes )
              {
            Attribute attribute = this.getAttributeWrapperByGUID(attributeIDNode.InnerText) as Attribute;
            if (attribute != null)
            {
            attributes.Add(attribute);
            }
              }
              return attributes;
        }

Usage Example

        public static List <EDDTable> createColumns(TSF_EA.Model model, List <DataItem> dataItems, GlossaryManagerSettings settings)
        {
            //get the columns based on the given data items
            var    guidString    = string.Join(",", dataItems.Select(x => "'" + x.GUID + "'"));
            string sqlGetColumns = @"select a.[ea_guid] from(t_attribute a
                                    inner join[t_attributetag] tv on(tv.[ElementID] = a.[ID]
                                                                      and tv.[Property] = 'EDD::dataitem'))
                                    where tv.VALUE in (" + guidString + ")";
            List <TSF_EA.Attribute> attributes = model.getAttributesByQuery(sqlGetColumns);
            var tables = new Dictionary <string, EDDTable>();

            foreach (var attribute in attributes)
            {
                var classElement = attribute.owner as TSF_EA.Class;
                if (classElement != null)
                {
                    //for each attribute create the column
                    var dbColumn = DB_EA.DatabaseFactory.createColumn(attribute);
                    if (dbColumn != null)
                    {
                        EDDTable ownerTable = tables.ContainsKey(classElement.uniqueID) ?
                                              tables[classElement.uniqueID]
                                              : new EDDTable((DB_EA.Table)dbColumn.ownerTable, settings);
                        var newColumn = new EDDColumn(dbColumn, ownerTable, settings);
                        ownerTable.addColumn(newColumn);
                        tables[ownerTable.uniqueID] = ownerTable;
                    }
                }
            }
            //return colums
            return(tables.Values.ToList());
        }