Exemple #1
0
        static void Main()
        {
            /*This class would connect program with MySQL to:
             * 1:get target database schema's information
             * 2:save information into table classes and method classes we defined;*/
            var theDB = new dataSchemer(myConnectionString);
            Console.WriteLine("Connecting database success!");
            Console.WriteLine();

            /*This class would go through all the methods in your target project to:
             * 1:find out all the sql statements;
             * 2:build call graph;
             * 3:generate method descriptions for methods with local sql invocations.*/
            var extractor = new ExtractMethodSQL(testLoc, SrcmlLoc, theDB);
            extractor.run();
            Console.WriteLine("Building callGraph and extracting SQL sequences success!");
            Console.WriteLine();

            /*This class would:
             * 1:save methods information into tables class and column class;
             * 2:generate methods description for methods without local sql but still in call graph.*/
            var mapper = new dbMethodMapper(extractor, theDB);
            mapper.run();
            Console.WriteLine("Mapping database with methods success!");
            Console.WriteLine();

            //This class would generate reports according to all table classes and column classes.
            var reporter = new infoCollector(extractor, theDB,reportLoc);
            reporter.run();
            Console.WriteLine("Report has been generated! Press any key to exit..");
            Console.ReadKey(true);

            //PS: the details about each class would be described in the manual I submit.
        }
Exemple #2
0
 public void generateDescription(dataSchemer db)
 {
     attribute += "This column belongs to Table: " + tableName +". It contains data with type <b>" + TakeSpaceOff(db.GetOneColumnInfo(tableName ,name, "DATA_TYPE"))+"</b>. ";
     string length = db.GetOneColumnInfo(tableName, name, "CHARACTER_MAXIMUM_LENGTH");
     if (length != " ") attribute += "The max length of data is " + TakeSpaceOff(length) + ". ";
     if (directMethods.Count == 0)
     {
         methodsDes = "<br><b>No method interacts with this column directly.</b>";
         return;
     }
     methodsDes = "<br><b>Methods directly access this column:</b>";
     foreach (var m in directMethods)
     {
         methodsDes += m.getHtmlDescribe(getRelationships(m.name), "column", "directly");
     }
     if (followMehtods.Count > 0)
     {
         methodsDes += "<br><br> <b>Methods might access this column:</b>";
         foreach (var m in followMehtods)
         {
             methodsDes += m.getHtmlDescribe(getRelationships(m.name), "column", "via delegation");
         }
     }
     if (finalMethods.Count > 0)
     {
         methodsDes += "<br><br> <b>Methods might access this column and in the highest level:</b>";
         foreach (var m in finalMethods)
         {
             methodsDes += m.getHtmlDescribe(getRelationships(m.name), "column", "via delegation");
         }
     }
 }
 public infoCollector(ExtractMethodSQL ex, dataSchemer dbsche, string reportLoc)
 {
     this.AllTableSummary = new HashSet<SingleSummary>();
     this.AllColumnSummary = new HashSet<SingleSummary>();
     this.extractor = ex;
     this.db = dbsche;
     this.outputLoc = reportLoc;
 }
 public ExtractMethodSQL(string localProj, string srcmlloc, dataSchemer databases)
 {
     this.LocalProj = localProj;
     this.SrcmlLoc = srcmlloc;
     this.methodsInfo = new List<desMethod>();
     this.db = databases;
     this.allDirectMethods = new List<desMethod>();
     this.sqlCount = 0;
 }
Exemple #5
0
 //This function would generate the description about this table and the description is saved in attribute.
 public void generateDescription(dataSchemer db)
 {
     attribute = "This table contains columns: ";
     foreach (var col in this.columns)
     {
         if (col.directMethods.Count == 0) continue;
         attribute += "<a href=\"#" + col.title + "\">" + col.name + "</a>" + ", ";
     }
     attribute += " etc. ";
     attribute += " This table is created at" + TakeSpaceOff(db.GetOneTableInfo(name, "CREATE_TIME")) + ". ";
     attribute += "It contails " + db.GetOneTableInfo(name, "TABLE_ROWS") + " items totally. ";
     if (directMethods.Count==0)
     {
         methodsDes = "<br><b>No method interacts with this table directly.</b>";
         return;
     }
     methodsDes = "<br><b>Methods directly access this table:</b>";
             foreach (var m in directMethods)
             {
                 methodsDes += m.getHtmlDescribe(getRelationships(m.name),"table", "directly");
             }
             if (followMehtods.Count>0)
             {
                 methodsDes += "<br><br><b>Methods might access this table:</b>";
                 foreach (var m in followMehtods)
                 {
                     methodsDes += m.getHtmlDescribe(getRelationships(m.name), "table", "via delegation");
                 }
             }
             if (finalMethods.Count > 0)
             {
                 methodsDes += "<br><br><b>Methods might access this table and in the highest level:</b>";
                 foreach (var m in finalMethods)
                 {
                     methodsDes += m.getHtmlDescribe(getRelationships(m.name), "table", "via delegation");
                 }
             }
 }
 public dbMethodMapper(ExtractMethodSQL ex, dataSchemer dbsche)
 {
     this.extractor = ex;
     this.db = dbsche;
     this.tablesInfo = db.tablesInfo;
 }