Tuesday, March 2, 2010

Liferay JIRA with my own JIRA installation.

Although I was able to configure the jira portlet to work with my own JIRA installation (You can find all the steps at my previous post) there was a serious issue with that. When I logged in as a valid user to my Running JIRA (on http://localhost:8090) I can create new projects(only if logged in as administrator), and create new issues to any of projects. In JIRA there is a unique ID for each project. (Eg: 10000, 10010 etc) When you create a new project, JIRA will assign an new unused ID for that and that ID is used everywhere within the database in order to identify the project. Project details are stored in jiradb/project table and issue details are stored in jiradb/jiraissue table. You can go to your database and see them if you want.

The problem with World of Liferay -JIRA portlet was it uses some constant project IDs and names in order to display the issue summery to the user. It stores this constants values in JIRAConstants.java interface. The view_jira.jspf file uses these constant IDs when creating the objects for the projects to display. So in order to change this, I had to change this view_jira.jspf completely.

I connected to the database of JIRA (jiradb) and select all the project IDs, their name and keys from the table project. Then I created the Jiraproject objects according to these data. The code is shown in below.

String[] prjIDs = new String[20];
String[] prjNames = new String[20];
String[] prjKeys = new String[20];
int meme =0;

Connection conn = null;
String myurl = "jdbc:mysql://127.0.0.1:3306/";
String mydbName = "jiradb";
String mydriver = "com.mysql.jdbc.Driver";
String myuserName = "root";
String mypassword = "";
try {
Class.forName(mydriver).newInstance();
conn = DriverManager.getConnection(myurl+mydbName,myuserName,mypassword);
Statement s = conn.createStatement ();
ResultSet resultset = s.executeQuery ("SELECT ID, pname, pkey FROM project");

while (resultset.next() )
{
String myID = resultset.getString("ID");
String myName = resultset.getString("pname");
String myKey = resultset.getString("pkey");

prjIDs[meme] = myID;
prjNames[meme] = myName;
prjKeys[meme] = myKey;
meme = meme+1;
}
} catch (Exception e) {
e.printStackTrace();
}
for (int i = 0; i <>
Object[] jiraProject = new Object[] {Integer.parseInt(prjIDs[i]), prjKeys[i], prjNames[i]};
int projectId = (Integer)jiraProject[0];
String projectKey = (String)jiraProject[1];
String projectName = (String)jiraProject[2];

No comments:

Post a Comment