Skip to content
Tool to find method mapping between two APIs by mining existing API Migration
HTML Java Python
Branch: master
Clone or download
hussien alrubaye
hussien alrubaye support LD in SA approch
Latest commit b58d134 Nov 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
APIMapper support LD in SA approch Nov 24, 2019
Database APIMapper first fork Nov 22, 2019
python-service support LD in SA approch Nov 24, 2019
LICENSE.md
README.md Update ReadME Nov 22, 2019

README.md

APIMappper

APIMappper is an open source tool that provides the developer with easy-to-use and comprehensive way of extracting, from given list of input projects, existing method mapping between two third-party libraries using program analysis based on Abstract Syntax Tree (AST) code representation. In a nutshell, MigrationMiner (i) detects, (ii) extracts, (iii) filters, and (iv) collects code changes related to any performed migration. (iiv) mapping which detects mapping between two APIs methods

When you use this tool, please cite this paper.

@inproceedings{alrubaye2019use,
  title={On the use of information retrieval to automate the detection of third-party Java library migration at the method level},
  author={Alrubaye, Hussein and Mkaouer, Mohamed Wiem and Ouni, Ali},
  booktitle={Proceedings of the 27th International Conference on Program Comprehension},
  pages={347--357},
  year={2019},
  organization={IEEE Press}
}

Prerequisites

  • Install java JKD from here.
  • Install Eclipse IDE for Java Developers from here.
  • Install MYSQL Server from here.
  • Install Python 3.8 or later from here.

How to install and run the tool

To run the project on your local machine you can follow one of these two tutorials:

A- Setup database

  • First you need to build the dataset, by running the following script Database/APIMapperDBSQL.sql. Open a terminal and run the following commands
 mysql -u root -p
 source ./APIMapperDBSQL.sql

After running the commands, the database should be created with all tables and views.

B- Setup Python server

  • Install the following packages
% pip install Django
% pip install jellyfish
% pip install --user -U nltk
% pip install numpy
  • download NLP words
% python3

>>> import nltk 
>>> nltk.download('punkt')
>>> nltk.download('stopwords')
>>> nltk.download('wordnet')
  • Run python server for NLP text processing by going to folder 'python-service' and run
% python3 manage.py runserver

C- Setup APIMapper Java tool

  • Open eclipse IDE then go to File-> import-> Maven-> existing Maven Projects-> Select MigrationMiner directory.
  • Set your local MYSQL username and password in this file DatabaseLogin.java.
  • Update MigrationMiner/data/gitRepositories.csv with the list of git repositories that you want to use as input (they will be searched for potential library migrations).
  • Go to your github account under Settings > Developer Settings > Personal Access Tokens, add new token. Use token to set your GitHub token in this file GithubLogin.java. Your token will be used so that Migration Miner can search a large number of GitHub projects without authentication issues.
  • (Optional) We print alot of logs, to avoid console buffer overflow. In eclipse IDE go to preferences-> console-> limit console buffer size to small number such as 10000.
  • Run the Main.java.

Tool output

A- Ouput as Relational Database
  • After running Main.java, the database Tables will be filled with any migration infomation found. For each potential migration, the following information can be found in database, whose schema is as follows:

    • Repositories: Has the list of projects that scanned by the tool.
    • AppCommits: Has the list of projects' commits information (Commit Id, developer name, Commit text, and commit date).
    • ProjectLibraries: List of libraries that were added or removed at every commit.
    • MigrationRules: List of migration Rules that were detected from the Dataset.
    • MigrationSegments: List Of migration Fragments that were extract from software migration.
    • LibraryDocumenation: Library documentation associated with every library version that has been involved in any migration.
    • MigrationMapping: List of method mapping between two APIs.
B- Ouput as HTML

There will be a generated HTML file named "APIMapperOutput.html" that has the summary of all migrations detected, and for each migration, all its corresponding method mapping along with their Library documentation. An illutrative example of this file is in the following picture:

main

C- Ouput as Objects

After running Main.java, You could read the output as objects by writing the following code. or run TestClient.java. That could help you to integrate the tool with your code.

 
//Return list of migrations between two pairs of libraries( added/removed)
LinkedList<MigrationRule> migrationRules= new MigrationRuleDB().getMigrationRulesWithoutVersion(1);

for (MigrationRule migrationRule : migrationRules) {
 System.out.println("== Migration Rule "+ migrationRule.FromLibrary +
      " <==> "+  migrationRule.ToLibrary +"==");

 /*
 *  For every migrations, retrieve list of detected Method mapping
 *  Between Two APIs
 */
 ArrayList<Segment> segmentList = new MigrationMappingDB().getFunctionMapping(String.valueOf(migrationRule.ID), false, false);

 for (Segment segment : segmentList) {

  segment.print();

  // Print all removed method signatures With Docs
  printMethodWithDocs( migrationRule.FromLibrary,segment.removedCode);  

  // Print all added method signatures With Docs
  printMethodWithDocs( migrationRule.ToLibrary,segment.addedCode);

 } // End fragment for every migration

}  // End library migration


/* 
* This method takes list of methods signatures with library that methods belong to.
* It will print the signatures and Docs for every method
*/
void printMethodWithDocs(String libraryName,ArrayList<String> listOfMethods ) {

 // For every add method print the Docs
 for(String methodSignature: listOfMethods){

  // Convert  method signatures as String to Object
  MethodObj methodFormObj= MethodObj.GenerateSignature(methodSignature);

  //retrieve Docs from the library for method has that name
  ArrayList<MethodDocs>  toLibrary = new LibraryDocumentationDB()
                                           .getDocs( libraryName,methodFormObj.methodName);

  //Map method signatures to docs
  MethodDocs methodFromDocs = MethodDocs.GetObjDocs(toLibrary, methodFormObj);

  if(methodFromDocs.methodObj== null) {
   System.err.println("Cannot find Docs for: "+ methodSignature);
   continue;
  }
  methodFromDocs.print();      
 }
}

APIMapper has been used so far in the following papers:

License

This software is licensed under the MIT license.

You can’t perform that action at this time.