setting up 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>
</form>

In my java class:

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 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 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() && 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) {
}
}
}

}

Let me know what has gone wrong here. very urgent

1 answer

1 accepted

0 votes
Answer accepted
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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events