create issue via plugin

asmaa salmaoui August 16, 2013

hi,

i need to developpe a plugin that can import data from my table exesting in my database and present very row in this table as an issue please i need your help

4 answers

0 votes
asmaa salmaoui August 18, 2013

Think's Onkar, i have an other request please do you have any idea about using API like create jira issue in a programme externe developping in eclipse??

0 votes
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2013

Hi Asmaa,

With the help from External System Import in JIRA the below link is useful for you.

https://confluence.atlassian.com/display/JIRA/Importing+Data+from+CSV

Cheers

Onkar Ahire

0 votes
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2013

Hi Asmaa,

You have to write your own migrator for it or you should use some tricks like below

Database to >> CSV and CSV to >> JIRA's CSV importer and map the fields and import.

below Java code will convert table data to csv file.

Cheers

Onkar Ahire

public static void main(String[] args) {
          
          //usual database connection part
          Connection con = null;
          String url = "jdbc:mysql://localhost:3306/";
          String db = "db_name";
          String driver = "com.mysql.jdbc.Driver";
          String user = "username";
          String pass = "password";
          FileWriter fw ;
          try{
          Class.forName(driver);
          con = DriverManager.getConnection(url+db, user, pass);
          Statement st = con.createStatement();
           
          //this query gets all the tables in your database(put your db name in the query)
          ResultSet res = st.executeQuery("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name' ");
           
          //Preparing List of table Names
          List <String> tableNameList = new ArrayList<String>();
          while(res.next())
          {
              tableNameList.add(res.getString(1));
          }
           
          //path to the folder where you will save your csv files
          String filename = "D:/db2csv/";
           
          //star iterating on each table to fetch its data and save in a .csv file
          for(String tableName:tableNameList)
            {
                int k=0;
                 
                int j=1;
                 
                System.out.println(tableName);
                 
                List<String> columnsNameList  = new ArrayList<String>();
                 
                //select all data from table
                res = st.executeQuery("select * from xcms."+tableName);
                 
                //colunm count is necessay as the tables are dynamic and we need to figure out the numbers of columns
                int colunmCount = getColumnCount(res);
                 
                 try {
                    fw = new FileWriter(filename+""+tableName+".csv");
                     
                     
                    //this loop is used to add column names at the top of file , if you do not need it just comment this loop
                    for(int i=1 ; i<= colunmCount ;i++)
                    {
                        fw.append(res.getMetaData().getColumnName(i));
                        fw.append(",");
             
                    }
                     
                    fw.append(System.getProperty("line.separator"));
                     
                    while(res.next())
                    {
                        for(int i=1;i<=colunmCount;i++)
                        {
                             
                            //you can update it here by using the column type but i am fine with the data so just converting 
                            //everything to string first and then saving
                            if(res.getObject(i)!=null)
                            {
                            String data= res.getObject(i).toString();
                            fw.append(data) ;
                            fw.append(",");
                            }
                            else
                            {
                                String data= "null";
                                fw.append(data) ;
                                fw.append(",");
                            }
                             
                        }
                        //new line entered after each row
                        fw.append(System.getProperty("line.separator"));
                    }
                     
                     fw.flush();
                      fw.close();
                     
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                 
            }
                 
          con.close();
          }
          catch (ClassNotFoundException e){
          System.err.println("Could not load JDBC driver");
          e.printStackTrace();
          }
          catch(SQLException ex){
          System.err.println("SQLException information");
          }
 }
     
    //to get numbers of rows in a result set 
    public static int  getRowCount(ResultSet res) throws SQLException
    {
          res.last();
          int numberOfRows = res.getRow();
          res.beforeFirst();
          return numberOfRows;
    }
 
    //to get no of columns in result set
     
    public static int  getColumnCount(ResultSet res) throws SQLException
    {
        return res.getMetaData().getColumnCount();
    }

asmaa salmaoui August 18, 2013

Hi Onkar, think you very very much for your help, you i didn't know that there is a difference between a simple csv and jira csv importer, i have two question in this point: 1-actually i have an evaluation version of jira i found a problem in the step Map fields i can't move to the next step, the second question the csv field can got a lot of lignes and each ligne associate them to an issue jira , think you again Onkar

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 17, 2013

That's quite a vagues question, you don't really tell us where you are stuck.

However, I'd look at the Jira importers - some of them can read data direct from a database and import the lines as issues.

asmaa salmaoui August 18, 2013

In first, thinks for your answer, this is what i really need read data direcr from a database and import the lines as issues, i didn't find a tutorial or an answer for this question, please Nic if you have something to help please give it to me, think you, i forget i have a mysql table and each row i want present it as an issue

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 18, 2013

I'm not sure we can tell you a lot more.

You have a database table with issues in it - you need to convert that to a format Jira can read, and then you need to import it into Jira (then probably throw the database table away, as you've migrated it to Jira and don't need it any more)

Jira has some importers which can help you with it. The most simple approach really is to run simple SQL to get the data into a CSV format and import that.

Suggest an answer

Log in or Sign up to answer