setting parameters

vishwas l November 21, 2011

How to set the velocity macro file values like $firstPassYield etc when action is passed from java class:

<form>
<div>
<table cellpadding="5">
<b>Management Review Data</b>
<tr><td>
1. First Pass Yield:</td>
<td>$firstPassYield
</tr>
<tr><td>
2. Defect Density: <br /></td>
<td>$defectDensity</td>
</tr>
<tr><td>
3. Delivery Schedule Adherence: <br /></td>
</tr>
<tr><td>
4. Effort Estimation Conformance:</td>
<td>$pEffortEstimation</td>
</tr>
</table>
<table cellpadding="5">
<b>Subprocess Data</b>
<tr><td>
5. Test Case FPY:</td>
<td>$tcFirstPassYield</td>
</tr>
<tr><td>
6. Test Procedure FPY:</td>
<td>$tpFirstPassYield</td>
</tr>
<tr><td>
7. Test Result FPY:</td>
<td>$trFirstPassYield</td>
</tr>

<tr><td>
8. Test Case Defect Density:</td>
<td>$tcDefectDensity</td>
</tr>
<tr><td>
9. Test Procedure Defect Density:</td>
<td>$tpDefectDensity</td>
</tr>
<tr><td>
10. Test Result Defect Density:</td>
<td>$trDefectDensity</td>
</tr>

<tr><td>
11. Test Case Schedule Adherence:</td>
<td></td>
</tr>
<tr><td>
12. Test Procedure Schedule Adherence:</td>
<td></td>
</tr>
<tr><td>
13. Test Result Schedule Adherence:</td>
<td></td>
</tr>

<tr><td>
14. Test Case Effort Estimation Conformance:</td>
<td>$tcEffortEstimation</td>
</tr>
<tr><td>
15. Test Procedure Effort Estimation Conformance:</td>
<td>$tpEffortEstimation</td>
</tr>
<tr><td>
16. Test Result Effort Estimation Conformance:</td>
<td>$trEffortEstimation</td>
</tr>

<tr><td>
17. Test Case Rework Index:</td>
<td>$tcReworkIndex</td>
</tr>
<tr><td>
18. Test Procedure Rework Index:</td>
<td>$tpReworkIndex</td>
</tr>
<tr><td>
19. Test Result Rework Index:</td>
<td>$trReworkIndex</td>
</tr>

</table>
</div>

<form>

Reply me immediately

3 answers

0 votes
vishwas l November 22, 2011

Can somebody reply me immediately....I have created bean class which contains properties for the variables created in velocity. setter method is invoked in java class after obtaining particular value

0 votes
vishwas l November 21, 2011
package com.moog.jira.plugins;

import com.atlassian.jira.web.action.JiraWebActionSupport;
import net.sourceforge.jtds.jdbc.Driver;

import java.sql.*;

/**
 * Created by IntelliJ IDEA.
 * User: hsumathi
 * Date: Nov 11, 2011
 * Time: 8:58:34 AM
 * To change this template use File | Settings | File Templates.
 */
public class UpdateDataAction extends JiraWebActionSupport{

    Connection conn;
    private String dbLocation = "jdbc:jtds:sqlserver://10.91.3.210:1433/jiradb_new";
    //private String dbLocation = "jdbc:jtds:sqlserver://10.91.3.210:1433/jiradb_dev";
    private String dbuser = "jiraadmin";
    //private String dbuser = "sa";
    private String dbpassword = "jiraadmin";

    MonthlyDataBean mdb = new MonthlyDataBean();
    
    public String getFromDt() {
        return fromDt;
    }

    public void setFromDt(String fromDt) {
        this.fromDt = fromDt;
    }

    public String getToDt() {
        return toDt;
    }

    public void setToDt(String toDt) {
        this.toDt = toDt;
    }

    private String fromDt;
    private String toDt;

 
    public String getKeyHolder() {
        return keyHolder;
    }

    public void setKeyHolder(String keyHolder) {
        this.keyHolder = keyHolder;
    }

    private String keyHolder;

    public String doExecute() throws Exception{
        System.out.println("In DOEXECUTE");        
        String fromdate = getFromDt();
        String todate = getToDt();

        System.out.println(fromdate + " ~~~~~~~~~~~~~~~~~~ " + todate);
        return SUCCESS;
    }

     public String doUpload() throws Exception{
         System.out.println("In DODEFAULT");
         String fromdate = getFromDt();
         String todate = getToDt();
         String ikey = getKeyHolder();
         connect();

         System.out.println(fromdate + " #$#$#$#$#$# " + todate + " " + ikey);
         setValueForEffortEstimation(ikey);
         mdb.setpEffortEstimation("-");
         System.out.println(mdb.getpEffortEstimation() + " ###");
         setValueForTCEC(ikey);
         setValueForTPEC(ikey);
         setValueForTREC(ikey);

         setValueForFirstYield(ikey);
         setValueForTCFirstYield(ikey);
         setValueForTPFirstYield(ikey);
         setValueForTRFirstYield(ikey);

         setValueForDefectDensity(ikey);
         setValueForTCDefectDensity(ikey);
         setValueForTPDefectDensity(ikey);
         setValueForTRDefectDensity(ikey);

         return SUCCESS;
     }

    /**
     * Method which handles database connection
     */
    public Connection connect()
    {
        try
        {
            Class.forName("net.sourceforge.jtds.jdbc.Driver");
            DriverManager.registerDriver(new Driver());
            conn = DriverManager.getConnection(dbLocation, dbuser, dbpassword);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return conn;
    }

    public void setValueForEffortEstimation(String key){
        Statement st = null;
        ResultSet rs = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            Float f = new Float(0.0D);
            if (rs.next())
            {
                f = new Float(((double)(rs.getLong(1)-rs.getLong(2))/(double)rs.getLong(2)));
                mdb.setpEffortEstimation(Math.round(f.doubleValue()*100)+"%");
            }else{
                mdb.setpEffortEstimation(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTCEC(String key){
        Statement st = null;
        ResultSet rs = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            Float f = new Float(0.0D);
            if (rs.next())
            {
                f = new Float(((double)(rs.getLong(1)-rs.getLong(2))/(double)rs.getLong(2)));
                mdb.setTcEffortEstimation(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTcEffortEstimation(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTPEC(String key){
        Statement st = null;
        ResultSet rs = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            Float f = new Float(0.0D);
            if (rs.next())
            {
                f = new Float(((double)(rs.getLong(1)-rs.getLong(2))/(double)rs.getLong(2)));
                mdb.setTpEffortEstimation(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTpEffortEstimation(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTREC(String key){
        Statement st = null;
        ResultSet rs = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            Float f = new Float(0.0D);
            if (rs.next())
            {
                f = new Float(((double)(rs.getLong(1)-rs.getLong(2))/(double)rs.getLong(2)));
                mdb.setTrEffortEstimation(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTrEffortEstimation(Math.round(f.doubleValue())+"%");
            }

        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForFirstYield(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or "+
                    "customfield = 10250 or customfield = 10251) and issue in (select ID from jiraissue  "+
                    "where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10314 or customfield = 10313) "+
                    "and issue in (select ID from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs1.getLong(1)/(double)rs.getLong(1)));
                mdb.setFirstPassYield(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setFirstPassYield(Math.round(f)+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTCFirstYield(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where "+
                    "(customfield = 10225 or customfield = 10250 or customfield = 10251) and issue in "+
                    "(select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TC%' "+
                    "and created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10314 or customfield = 10313) "+
                    "and issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TC%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs1.getLong(1)/(double)rs.getLong(1)));
                mdb.setTcFirstPassYield(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTcFirstPassYield(Math.round(f)+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTPFirstYield(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) "+
                    "and issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TP%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10314 or customfield = 10313) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TP%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs1.getLong(1)/(double)rs.getLong(1)));
                mdb.setTpFirstPassYield(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTpFirstPassYield(Math.round(f)+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTRFirstYield(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TR%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10314 or customfield = 10313) "+
                    "and issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TR%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");

            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs1.getLong(1)/(double)rs.getLong(1)));
                mdb.setTrFirstPassYield(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTrFirstPassYield(Math.round(f)+"%");
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
                    ex.printStackTrace();
             }
        }
    }

    public void setValueForDefectDensity(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10310 or customfield = 10311) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setDefectDensity(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setDefectDensity(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTCDefectDensity(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10310 or customfield = 10311) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TC%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TC%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTcDefectDensity(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTcDefectDensity(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTPDefectDensity(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10310 or customfield = 10311) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TP%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TP%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTpDefectDensity(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTpDefectDensity(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTRDefectDensity(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10310 or customfield = 10311) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TR%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select sum(NUMBERVALUE) from customfieldvalue where (customfield = 10225 or customfield = 10250 or customfield = 10251) and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%_TR%' and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTrDefectDensity(Math.round(f.doubleValue() * 100)+"%");
            }else{
                mdb.setTrDefectDensity(Math.round(f.doubleValue())+"%");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTCReworkIndex(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select NUMBERVALUE from customfieldvalue where customfield = 10256 and issue in "+
                    "(select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%TC_R%' and issuestatus = '10017' "+
                    "and created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select count(ID) from jiraissue where pkey like '%" + key + "%' and summary like '%TC_R%' and "+
                    "issuestatus = '10017' and ID in (select ISSUE from customfieldvalue where customfield = 10256) and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTcReworkIndex(Math.round(f.doubleValue())+"");
            }else{
                mdb.setTcReworkIndex(Math.round(f.doubleValue())+"");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

    public void setValueForTPReworkIndex(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select NUMBERVALUE from customfieldvalue where customfield = 10256 and issue in "+
                    "(select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%TP_R%' and "+
                    "issuestatus = '10017' and created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select count(ID) from jiraissue where pkey like '%" + key + "%' and summary like '%TP_R%' "+
                    "and issuestatus = '10017' and ID in (select ISSUE from customfieldvalue where customfield = 10256) and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
           // rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTpReworkIndex(Math.round(f.doubleValue())+"");
            }else{
                mdb.setTpReworkIndex(Math.round(f.doubleValue())+"");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }

     public void setValueForTRReworkIndex(String key){
        Statement st = null;
        ResultSet rs = null;
        ResultSet rs1 = null;
        conn = null;
        try{
            conn = connect();
            st = conn.createStatement();
            rs = st.executeQuery("select NUMBERVALUE from customfieldvalue where customfield = 10256 and "+
                    "issue in (select ID from jiraissue  where pkey like '%" + key + "%' and summary like '%TR_R%' and "+
                    "issuestatus = '10017' and created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME))");
            st = null;
            st = conn.createStatement();
            rs1 = st.executeQuery("select count(ID) from jiraissue where pkey like '%" + key + "%' and summary like '%TR_R%' "+
                    "and issuestatus = '10017' and ID in (select ISSUE from customfieldvalue where customfield = 10256) and "+
                    "created between dateadd(month, -1, CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)) and CAST(CONVERT(CHAR(8)," +
                    "CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),112) AS DATETIME)");
            //rs.next();
            //rs1.next();
            Float f= new Float(0.0D);
            if (rs.next() &amp;&amp; rs1.next())
            {
                f = new Float(((double)rs.getLong(1)/(double)rs1.getLong(1)));
                mdb.setTrReworkIndex(Math.round(f.doubleValue())+"");
            }else{
                mdb.setTrReworkIndex(Math.round(f.doubleValue())+"");
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        finally{
             try {
                rs.close();
                rs1.close();
                st.close();
                conn.close();
             } catch (SQLException ex) {
        }
        }
    }
}

This is the way that I have set the values for velocity variables bu not sure what is wrong in this

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.
November 21, 2011

Your velocity variables are not being set - you're doing loads of stuff in java, but there's nothing in there that says "make these variables resulting from the calculation available to the velocity templates"

There should be a map object being built with them in a function like "getVelocityParameters"

JamieA
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.
November 21, 2011

Or a getThing() method for each $thing in velocity.

vishwas l November 21, 2011
package com.moog.jira.plugins;
public class MonthlyDataBean {
private String pEffortEstimation;
private String tcEffortEstimation;
private String tpEffortEstimation;
package com.moog.jira.plugins;

/**
 * Created by IntelliJ IDEA.
 * User: HSUMATHI
 * Date: Oct 7, 2011
 * Time: 10:45:34 AM
 * To change this template use File | Settings | File Templates.
 */
public class MonthlyDataBean {

    private String firstPassYield;

    public String getFirstPassYield() {
        return firstPassYield;
    }

    public void setFirstPassYield(String firstPassYield) {
        this.firstPassYield = firstPassYield;
    }


}

Setter method is given in bean and called from java class

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.
November 21, 2011

What are you doing in your java code? The variables should be added to the output "map" in there.

Suggest an answer

Log in or Sign up to answer