Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.79 KB | None | 0 0
  1.  
  2. import java.sql.Connection;
  3. import java.sql.ResultSet;
  4. import java.sql.Statement;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Calendar;
  9. import java.util.Date;
  10. import java.util.Enumeration;
  11. import java.util.GregorianCalendar;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Properties;
  15. import java.util.Vector;
  16.  
  17. import javax.activation.DataHandler;
  18. import javax.activation.DataSource;
  19. import javax.activation.FileDataSource;
  20. import javax.mail.Message;
  21. import javax.mail.MessagingException;
  22. import javax.mail.Multipart;
  23. import javax.mail.Session;
  24. import javax.mail.Transport;
  25. import javax.mail.internet.InternetAddress;
  26. import javax.mail.internet.MimeBodyPart;
  27. import javax.mail.internet.MimeMessage;
  28. import javax.mail.internet.MimeMultipart;
  29.  
  30. import mshtml.IHTMLElement;
  31. import mshtml.IHTMLInputElement;
  32. import mshtml.IHTMLTextAreaElement;
  33.  
  34. import org.apache.poi.hssf.usermodel.HSSFCell;
  35. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  36. import org.apache.poi.hssf.usermodel.HSSFFont;
  37. import org.apache.poi.hssf.usermodel.HSSFRichTextString;
  38. import org.apache.poi.hssf.usermodel.HSSFRow;
  39. import org.apache.poi.hssf.usermodel.HSSFSheet;
  40. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  41. import org.apache.poi.hssf.util.HSSFColor;
  42.  
  43. import yodlee.gather.ClassArgs;
  44. import yodlee.gather.IYodRobot;
  45. import yodlee.gather.LoginInfo;
  46. import yodlee.gather.RequestItem;
  47. import yodlee.gather.Script;
  48. import yodlee.gather.User;
  49. import yodlee.gather.content.Site;
  50. import yodlee.gather.exceptions.GeneralException;
  51. import yodlee.util.JavaComBridgeHelper;
  52.  
  53.  
  54.  
  55. public class TestScraping1 extends Script {
  56.  
  57. private final boolean revisedEta = false;
  58.  
  59. static HSSFCellStyle styleHeader;
  60. static HSSFCellStyle styleHeader_formula;
  61. static HSSFCellStyle styleHeader_row = null;
  62. static HSSFWorkbook wb = new HSSFWorkbook();
  63. static SimpleDateFormat sdf = new SimpleDateFormat(ScriptConstants.DATEFORMAT_MM_SL_DD_SL_YYYY);
  64. static Date date = new Date();
  65. Date yestdate;
  66. String strLine;
  67. static Connection connection = null;
  68. static Statement st;
  69. static ResultSet result = null;
  70. static int rownumber=0;
  71.  
  72. static String attachedFileName = null;
  73. List<Bug> freshBugList = new ArrayList<Bug>();
  74. List<Bug> revisedETABugList = new ArrayList<Bug>();
  75. List<Bug> reopenedETABugList = new ArrayList<Bug>();
  76.  
  77. List<Bug> freshBugListFI = new ArrayList<Bug>();
  78. List<Bug> revisedETABugListFI = new ArrayList<Bug>();
  79. List<Bug> reopenedETABugListFI = new ArrayList<Bug>();
  80.  
  81. List<Bug> freshBugListNW = new ArrayList<Bug>();
  82. List<Bug> revisedETABugListNW = new ArrayList<Bug>();
  83. List<Bug> reopenedETABugListNW = new ArrayList<Bug>();
  84.  
  85. List<Bug> freshBugListNDD = new ArrayList<Bug>();
  86. List<Bug> revisedETABugListNDD = new ArrayList<Bug>();
  87. List<Bug> reopenedETABugListNDD = new ArrayList<Bug>();
  88.  
  89. List<Bug> freshBugListWL = new ArrayList<Bug>();
  90. List<Bug> revisedETABugListWL = new ArrayList<Bug>();
  91. List<Bug> reopenedETABugListWL = new ArrayList<Bug>();
  92.  
  93. static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ScriptConstants.DATEFORMAT_DD_HYP_MM_HYP_YYYY);
  94. private final String triageDate = simpleDateFormat.format(date);
  95.  
  96.  
  97.  
  98. public int login(LoginInfo loginInfo, User user, ClassArgs args, IYodRobot pRobot) throws Exception{
  99.  
  100. pRobot.get("https://blrbugzilla.yodlee.com/");
  101. ScriptUtil.sleep(3);
  102. IHTMLElement loginEle = HTMLUtils.getElementWithAttribute(pRobot, ScriptConstants.HREF_TAG, ScriptConstants.INNERTEXT_ATB, "Log In", false);
  103. pRobot.clickWithEvents(loginEle, false);
  104.  
  105. ScriptUtil.setInputAny(pRobot,"Bugzilla_login","mmanjunath");
  106. ScriptUtil.setInputAny(pRobot,"Bugzilla_password","Ivbgod@bz");
  107.  
  108. pRobot.click(ScriptConstants.INPUT_TAG,ScriptConstants.VALUE_ATB,"Log in");
  109. pRobot.checkFailString(loginInfo);
  110. ScriptUtil.sleep(3);
  111. if(pRobot.isTextFoundOnPage("I18N- YI CURRENT", false)){
  112. pRobot.clickLinkWithText("Open Bugs I18N- YI");
  113. }else{
  114. pRobot.clickLinkWithText("Open Bugs I18N- YI");
  115. }
  116. ScriptUtil.sleep(6);
  117. pRobot.clickLinkWithText("Change Columns");
  118.  
  119. pRobot.selectOptionWithEvents(ScriptConstants.NAME_ATB, "available_columns", ScriptConstants.VALUE_ATB, "cf_workflow_status");
  120. IHTMLElement clickStatusElement1 = HTMLUtils.getElementWithAttribute(pRobot, "button", "id", "select_button", false);
  121. YDataLogger.out("2^^^loginEle : "+clickStatusElement1.getInnerText());
  122. pRobot.click(clickStatusElement1, false);
  123. pRobot.selectOptionWithEvents(ScriptConstants.NAME_ATB, "available_columns", ScriptConstants.VALUE_ATB, "cf_rca");
  124. IHTMLElement clickStatusElement2 = HTMLUtils.getElementWithAttribute(pRobot, "button", "id", "select_button", false);
  125. pRobot.click(clickStatusElement2, false);
  126. pRobot.selectOptionWithEvents(ScriptConstants.NAME_ATB, "available_columns", ScriptConstants.VALUE_ATB, "status_whiteboard");
  127. IHTMLElement clickStatusElement3 = HTMLUtils.getElementWithAttribute(pRobot, "button", "id", "select_button", false);
  128. pRobot.click(clickStatusElement3, false);
  129. pRobot.selectOptionWithEvents(ScriptConstants.NAME_ATB, "available_columns", ScriptConstants.VALUE_ATB, "short_desc");
  130. IHTMLElement clickStatusElement4 = HTMLUtils.getElementWithAttribute(pRobot, "button", "id", "select_button", false);
  131. pRobot.click(clickStatusElement4, false);
  132.  
  133. pRobot.clickInputWithValue("Change Columns");
  134. ScriptUtil.sleep(16);
  135. ScriptUtil.sleep(16);
  136. ScriptUtil.sleep(16);
  137. return RequestItem.RETURN_CODE_SUCCESS;
  138.  
  139.  
  140. }
  141.  
  142. protected List<HashMap<String, String>> scrapBugList(IYodRobot pRobot) throws Exception{
  143. ScriptUtil.sleep(5);
  144. Enumeration tableEnum = pRobot.getInnermostTablesContainingText("ID", false, -1);
  145. if(tableEnum.hasMoreElements()){
  146. IHTMLElement tableElement = JavaComBridgeHelper.toIHTMLElement(tableEnum.nextElement());
  147. //YDataLogger.out("2^^^innertext : "+tableElement.getInnerText());
  148. String[][] columnHeaders = new String[][] {{"ID"},{"Whiteboard"},{"Summary"},{"Workflow Status"},{"RCA IAE"}};
  149. String [] valueHeaders = new String[]{"ID", "Whiteboard","Summary", "Workflow Status", "RCA IAE"};
  150. int [] valueHeaderCellType = new int [] {HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT};
  151.  
  152. return HTMLUtils.getTableData(pRobot,tableElement,"ID",columnHeaders,null,new boolean[]{false,false,false,false,false},1,0, valueHeaderCellType, valueHeaders);
  153. }else{
  154. throw new GeneralException("Table identifier is changed");
  155. }
  156. }
  157.  
  158. protected List getRevisedBugsList(IYodRobot pRobot) throws Exception{
  159. List<Bug> bugList = new ArrayList<Bug>();
  160.  
  161. List<HashMap<String, String>> list = scrapBugList(pRobot);
  162. for(HashMap<String,String> prop :list){
  163. String bugID =prop.get("ID");
  164. String rcaIAE =prop.get("RCA IAE");
  165. String workFlowStatus = prop.get("Workflow Status");
  166. String whiteboard = prop.get("Whiteboard");
  167. //YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  168. if(!workFlowStatus.equalsIgnoreCase("Analyzed") || !whiteboard.toLowerCase().contains("triage")){
  169. continue;
  170. }
  171.  
  172. if(whiteboard.contains("ETA") && whiteboard.contains("Triage")){
  173. //YDataLogger.out("2^^^revised ETA : "+whiteboard+" ^^^bugID : "+bugID);
  174. String oldEtaDate = whiteboard.substring(whiteboard.lastIndexOf(":")+1);
  175. YDataLogger.out("2^^^^^^^oldEtaDate::"+oldEtaDate);
  176. Date etaDate = simpleDateFormat.parse(oldEtaDate);
  177. Date newTriagDate = simpleDateFormat.parse(triageDate);
  178. if(etaDate.before(newTriagDate)){
  179. YDataLogger.out("2^^^^reviseETAbugID : "+bugID);
  180. Bug bug = new Bug();
  181. bug.setBugid(bugID);
  182. bug.setRcaIae(rcaIAE);
  183. bug.setWhiteBoard(whiteboard);
  184. bug.setWorkFlowStatus(workFlowStatus);
  185. bugList.add(bug);
  186. }
  187. }
  188. }
  189. return bugList;
  190. }
  191.  
  192. /**
  193. * This method is used to scrape the accounts summary table.
  194. * @param pRobot
  195. * @return accountsList
  196. */
  197. protected void getBugsList(IYodRobot pRobot) throws Exception{
  198. List<HashMap<String, String>> list = scrapBugList(pRobot);
  199. for(HashMap<String,String> prop :list){
  200. String bugID =prop.get("ID");
  201. String rcaIAE =prop.get("RCA IAE");
  202. String workFlowStatus = prop.get("Workflow Status");
  203. String whiteBoard = prop.get("Whiteboard");
  204. YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  205.  
  206. Bug bug = new Bug();
  207. /*
  208. * Those bugs which contains "reopened eta" is reopen bug triaged by the team on the current date
  209. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  210. * */
  211. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("reopened eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  212. || whiteBoard.toLowerCase().contains("triaged:"+triageDate) || whiteBoard.toLowerCase().contains("triage:"+triageDate))){
  213. bug.setBugid(bugID);
  214. reopenedETABugList.add(bug);
  215. continue;
  216. }
  217.  
  218. if(!workFlowStatus.equalsIgnoreCase("Analyzed") || rcaIAE.equals("---")){
  219. continue;
  220. }
  221.  
  222. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("triage" )){
  223. continue;
  224. }
  225.  
  226. YDataLogger.out("2^^^^freshbugID : "+bugID);
  227. bug.setBugid(bugID);
  228. bug.setRcaIae(rcaIAE);
  229. bug.setWhiteBoard(whiteBoard);
  230. bug.setWorkFlowStatus(workFlowStatus);
  231. freshBugList.add(bug);
  232. }
  233. }
  234.  
  235. protected void getBugsListCommon(IYodRobot pRobot, String teamName) throws Exception{
  236. YDataLogger.out("2^^^^date : "+triageDate);
  237. YDataLogger.out("2^^^teamName : "+teamName);
  238. Enumeration tableEnum = pRobot.getInnermostTablesContainingText("ID", false, -1);
  239. while(tableEnum.hasMoreElements()){
  240. IHTMLElement tableElement = JavaComBridgeHelper.toIHTMLElement(tableEnum.nextElement());
  241. YDataLogger.out("2^^^innertext : "+tableElement.getInnerText());
  242. String[][] columnHeaders = new String[][] {{"ID"},{"Whiteboard"},{"Summary"},{"Workflow Status"},{"RCA IAE"}};
  243. String [] valueHeaders = new String[]{"ID", "Whiteboard","Summary", "Workflow Status", "RCA IAE"};
  244. int [] valueHeaderCellType = new int [] {HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT};
  245.  
  246. List<HashMap<String, String>> list = HTMLUtils.getTableData(pRobot,tableElement,"ID",columnHeaders,null,new boolean[]{false,false,false,false,false},1,0, valueHeaderCellType, valueHeaders);
  247. for(HashMap<String,String> prop :list){
  248. String bugID =prop.get("ID");
  249. String rcaIAE =prop.get("RCA IAE");
  250. String workFlowStatus = prop.get("Workflow Status");
  251. String whiteBoard = prop.get("Whiteboard");
  252. YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  253.  
  254. Bug bug = new Bug();
  255.  
  256. /*
  257. * Those bugs which contains "reopened eta" is reopen bug triaged by the team on the current date
  258. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  259. * */
  260. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("reopened eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  261. || whiteBoard.toLowerCase().contains("triaged:"+triageDate) || whiteBoard.toLowerCase().contains("triaged – "+triageDate))){
  262. YDataLogger.out("inside it ropened");
  263. bug.setBugid(bugID);
  264. if(teamName.equals("YI")){
  265. reopenedETABugList.add(bug);
  266. }else if(teamName.equals("FI")){
  267. reopenedETABugListFI.add(bug);
  268. }else if(teamName.equals("NW")){
  269. reopenedETABugListNW.add(bug);
  270. }else if(teamName.equals("NDD")){
  271. reopenedETABugListNDD.add(bug);
  272. }else if(teamName.equals("WEALTH")){
  273. reopenedETABugListWL.add(bug);
  274. }
  275. continue;
  276. }
  277.  
  278. /*
  279. * Those bugs which contains "revised eta" is revised eta bug triaged by the team on the current date
  280. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  281. * */
  282. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("revised eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  283. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  284. YDataLogger.out("inside it revised");
  285. bug.setBugid(bugID);
  286. if(teamName.equals("YI")){
  287. revisedETABugList.add(bug);
  288. }else if(teamName.equals("FI")){
  289. revisedETABugListFI.add(bug);
  290. }else if(teamName.equals("NW")){
  291. revisedETABugListNW.add(bug);
  292. }else if(teamName.equals("NDD")){
  293. revisedETABugListNDD.add(bug);
  294. }else if(teamName.equals("WEALTH")){
  295. revisedETABugListWL.add(bug);
  296. }
  297.  
  298. continue;
  299. }
  300.  
  301. //Those bugs which contains "triage - currentdate" is freshed bug triaged by the team on the current date
  302. if(ScriptUtil.isNullValue(whiteBoard) || (!ScriptUtil.isNullValue(whiteBoard) && !whiteBoard.toLowerCase().contains("triaged – "+triageDate) && !whiteBoard.toLowerCase().contains("triaged - "+triageDate))){
  303. YDataLogger.out("inside it fresh");
  304. continue;
  305. }
  306.  
  307. bug.setBugid(bugID);
  308. if(teamName.equals("YI")){
  309. freshBugList.add(bug);
  310. }else if(teamName.equals("FI")){
  311. freshBugListFI.add(bug);
  312. }else if(teamName.equals("NW")){
  313. freshBugListNW.add(bug);
  314. }else if(teamName.equals("NDD")){
  315. freshBugListNDD.add(bug);
  316. }else if(teamName.equals("WEALTH")){
  317. freshBugListWL.add(bug);
  318. }
  319. }
  320. }
  321. YDataLogger.out("2^^^freshBugListNW : "+freshBugListNW.size()+" ^^^reopenedETABugListNW : "+reopenedETABugListNW);
  322. }
  323.  
  324. protected void getYIDomesticBugsList(IYodRobot pRobot) throws Exception{
  325. YDataLogger.out("2^^^^date : "+triageDate);
  326.  
  327. Enumeration tableEnum = pRobot.getInnermostTablesContainingText("ID", false, -1);
  328. while(tableEnum.hasMoreElements()){
  329. IHTMLElement tableElement = JavaComBridgeHelper.toIHTMLElement(tableEnum.nextElement());
  330. //YDataLogger.out("2^^^innertext : "+tableElement.getInnerText());
  331. String[][] columnHeaders = new String[][] {{"ID"},{"Whiteboard"},{"Summary"},{"Workflow Status"},{"RCA IAE"}};
  332. String [] valueHeaders = new String[]{"ID", "Whiteboard","Summary", "Workflow Status", "RCA IAE"};
  333. int [] valueHeaderCellType = new int [] {HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT};
  334.  
  335. List<HashMap<String, String>> list = HTMLUtils.getTableData(pRobot,tableElement,"ID",columnHeaders,null,new boolean[]{false,false,false,false,false},1,0, valueHeaderCellType, valueHeaders);
  336. for(HashMap<String,String> prop :list){
  337. String bugID =prop.get("ID");
  338. String rcaIAE =prop.get("RCA IAE");
  339. String workFlowStatus = prop.get("Workflow Status");
  340. String whiteBoard = prop.get("Whiteboard");
  341. //YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  342.  
  343. Bug bug = new Bug();
  344.  
  345. /*
  346. * Those bugs which contains "reopened eta" is reopen bug triaged by the team on the current date
  347. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  348. * */
  349. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("reopened eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  350. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  351. YDataLogger.out("inside it");
  352. bug.setBugid(bugID);
  353. reopenedETABugList.add(bug);
  354. continue;
  355. }
  356.  
  357. /*
  358. * Those bugs which contains "revised eta" is revised eta bug triaged by the team on the current date
  359. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  360. * */
  361. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("revised eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  362. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  363. YDataLogger.out("inside it");
  364. bug.setBugid(bugID);
  365. revisedETABugList.add(bug);
  366. continue;
  367. }
  368.  
  369. //Those bugs which contains "triage - currentdate" is freshed bug triaged by the team on the current date
  370. if(ScriptUtil.isNullValue(whiteBoard) || (!ScriptUtil.isNullValue(whiteBoard) && !whiteBoard.toLowerCase().contains("triaged – "+triageDate))){
  371. continue;
  372. }
  373.  
  374. bug.setBugid(bugID);
  375. freshBugList.add(bug);
  376. }
  377. }
  378. }
  379.  
  380.  
  381. private void setKeyWords(IYodRobot pRobot)
  382. {
  383. IHTMLElement elem=HTMLUtils.getElementWithAttribute(pRobot,ScriptConstants.INPUT_TAG,ScriptConstants.NAME_ATB,"keywords",false);
  384. IHTMLInputElement inputEle=JavaComBridgeHelper.toIHTMLInputElement(elem);
  385. inputEle.setValue("I18N_Sites");
  386. }
  387.  
  388. //method to set RevisedEta of a bug
  389. public void setRevisedEta(IYodRobot pRobot, String whiteboard, Bug bug) throws ParseException{
  390. String triagedDay=simpleDateFormat.parse(triageDate).toString();
  391. YDataLogger.out("2^^^^^^^triagedDay::"+triagedDay);
  392. int days = 1;
  393. if(triagedDay.indexOf("Fri")>=0){
  394. days+=2;
  395. }
  396. Date newTriagDate = simpleDateFormat.parse(triageDate);
  397.  
  398. Calendar calendar = Calendar.getInstance();
  399. calendar.setTime(newTriagDate);
  400. calendar.add(Calendar.DAY_OF_MONTH, days);
  401. Date eta = calendar.getTime();
  402. String newEtaDate = simpleDateFormat.format(eta);
  403. //updating new ETA
  404. //whiteboard = YUtilities.removeAndReplace(whiteboard, oldEtaDate, newEtaDate);
  405. whiteboard = whiteboard + ",Revised ETA: "+newEtaDate;
  406. String URL="https://blrbugzilla.yodlee.com/show_bug.cgi?id=";
  407. pRobot.get(URL+bug.getBugid());
  408.  
  409. IHTMLElement elem=HTMLUtils.getElementWithAttribute(pRobot,ScriptConstants.INPUT_TAG,ScriptConstants.NAME_ATB,"status_whiteboard", false);
  410. IHTMLInputElement inputEle=JavaComBridgeHelper.toIHTMLInputElement(elem);
  411. inputEle.setValue(whiteboard);
  412.  
  413. //variable to get the count of revised eta bug
  414. revisedETABugList.add(bug);
  415.  
  416. this.setKeyWords(pRobot);
  417.  
  418. IHTMLElement sameEle = HTMLUtils.getElementWithAttribute(pRobot, "b", ScriptConstants.INNERTEXT_ATB, "Additional Comments", false);
  419. sameEle = HTMLUtils.getNextHTMLElement(sameEle, ScriptConstants.TEXTAREA_TAG, 1);
  420. IHTMLTextAreaElement commentEle = JavaComBridgeHelper.toIHTMLTextAreaElement(sameEle);
  421. commentEle.setValue("Updating ETA");
  422.  
  423. pRobot.clickInputWithValue("Save Changes");
  424. }
  425.  
  426. //method to set ETA of a bug
  427. public void setETA(IYodRobot pRobot, String rcaIAE) throws ParseException{
  428.  
  429. Calendar calendar = Calendar.getInstance();
  430. calendar.setTime(date);
  431. String etaDate = null;
  432.  
  433. String triagedDay=simpleDateFormat.parse(triageDate).toString();
  434. YDataLogger.out("2^^^^^^^triagedDay::"+triagedDay);
  435. int days = 0;
  436. if(rcaIAE.contains("Information Only") || rcaIAE.contains("Feed Issue") || rcaIAE.contains("Site Temporary Issue") || rcaIAE.contains("MFA Quality")){
  437. days = 2;
  438. if(triagedDay.indexOf("Thu")>=0 || triagedDay.indexOf("Fri")>=0)
  439. {
  440. days+=2;
  441. }
  442. calendar.add(Calendar.DAY_OF_MONTH, days);
  443. Date eta = calendar.getTime();
  444. etaDate = simpleDateFormat.format(eta);
  445. }else if(rcaIAE.contains("New Variation") || rcaIAE.contains("Unhandled Condition") || rcaIAE.contains("Missing Acct") || rcaIAE.contains("Duplicate Acct")
  446. || rcaIAE.contains("Incorrect Acct Details") || rcaIAE.contains("Duplicate Transaction") || rcaIAE.contains("Incorrect Transaction Details") || rcaIAE.contains("Duplicate Acct")
  447. || rcaIAE.contains("Missing Transaction") || rcaIAE.contains("Site Change") || rcaIAE.contains("Site temporary message handling")
  448. || rcaIAE.contains("Quality Other")){
  449. days = 3;
  450. if(triagedDay.indexOf("Wed")>=0 || triagedDay.indexOf("Thu")>=0 || triagedDay.indexOf("Fri")>=0)
  451. {
  452. days+=2;
  453. }
  454. calendar.add(Calendar.DAY_OF_MONTH, days);
  455. Date eta = calendar.getTime();
  456. etaDate = simpleDateFormat.format(eta);
  457. }else{
  458. return;
  459. }
  460. YDataLogger.out("2^^^^triageDate : "+triageDate+" ^^^etaDate : "+etaDate);
  461.  
  462. IHTMLElement elem=HTMLUtils.getElementWithAttribute(pRobot,ScriptConstants.INPUT_TAG,ScriptConstants.NAME_ATB,"status_whiteboard", false);
  463. IHTMLInputElement inputEle=JavaComBridgeHelper.toIHTMLInputElement(elem);
  464. String input = inputEle.getValue();
  465. if(!ScriptUtil.isNullValue(input)){
  466. input = input.trim()+",";
  467. }
  468.  
  469. inputEle.setValue(input + "Triaged – "+triageDate+" ,ETA : "+etaDate);
  470. }
  471.  
  472. private static String getDate() {
  473. GregorianCalendar c = new GregorianCalendar();
  474. String month = String.valueOf(c.get(GregorianCalendar.MONTH) + 1);
  475. String day = String.valueOf(c.get(GregorianCalendar.DATE));
  476. String year = String.valueOf(c.get(GregorianCalendar.YEAR));
  477. String returnVal = day + "-" + month + "-" + year;
  478. return returnVal;
  479. }
  480.  
  481. private static HSSFCellStyle getStyle(HSSFCellStyle styleHeader2) {
  482. styleHeader = wb.createCellStyle();
  483. HSSFFont font = wb.createFont();
  484. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  485. font.setColor(HSSFColor.WHITE.index);
  486. styleHeader.setFont(font);
  487. styleHeader.setFillForegroundColor(HSSFColor.BLUE.index);
  488. styleHeader.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  489. styleHeader.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
  490. styleHeader.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
  491. styleHeader.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
  492. styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  493.  
  494. return styleHeader;
  495. }
  496.  
  497. private static HSSFCellStyle getStyle_row(HSSFCellStyle styleHeader) {
  498. styleHeader = wb.createCellStyle();
  499. HSSFFont font = wb.createFont();
  500. styleHeader.setFillForegroundColor(HSSFColor.BLUE.index);
  501. styleHeader.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  502. styleHeader.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
  503. styleHeader.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
  504. styleHeader.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
  505.  
  506. return styleHeader;
  507. }
  508.  
  509. private static HSSFCellStyle getStyle_formula(HSSFCellStyle styleHeader) {
  510. styleHeader = wb.createCellStyle();
  511. HSSFFont font = wb.createFont();
  512. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  513. font.setColor(HSSFColor.BLACK.index);
  514. styleHeader.setFont(font);
  515. styleHeader.setFillForegroundColor(HSSFColor.YELLOW.index);
  516. styleHeader.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  517. styleHeader.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
  518. styleHeader.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
  519. styleHeader.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
  520. styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  521.  
  522. return styleHeader;
  523. }
  524.  
  525.  
  526. protected void getNonWealthBugList(IYodRobot pRobot) throws Exception{
  527. YDataLogger.out("2^^^^date : "+triageDate);
  528.  
  529. Enumeration tableEnum = pRobot.getInnermostTablesContainingText("ID", false, -1);
  530. while(tableEnum.hasMoreElements()){
  531. IHTMLElement tableElement = JavaComBridgeHelper.toIHTMLElement(tableEnum.nextElement());
  532. //YDataLogger.out("2^^^innertext11 : "+tableElement.getInnerText());
  533. String[][] columnHeaders = new String[][] {{"ID"},{"Whiteboard"},{"Summary"},{"Workflow Status"},{"RCA IAE"}};
  534. String [] valueHeaders = new String[]{"ID", "Whiteboard","Summary", "Workflow Status", "RCA IAE"};
  535. int [] valueHeaderCellType = new int [] {HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT};
  536.  
  537. List<HashMap<String, String>> list = HTMLUtils.getTableData(pRobot,tableElement,"ID",columnHeaders,null,new boolean[]{false,false,false,false,false},1,0, valueHeaderCellType, valueHeaders);
  538. for(HashMap<String,String> prop :list){
  539. String bugID =prop.get("ID");
  540. String rcaIAE =prop.get("RCA IAE");
  541. String workFlowStatus = prop.get("Workflow Status");
  542. String whiteBoard = prop.get("Whiteboard");
  543.  
  544. Bug bug = new Bug();
  545.  
  546. /*
  547. * Those bugs which contains "reopened eta" is reopen bug triaged by the team on the current date
  548. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  549. * */
  550. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("reopened eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  551. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  552. YDataLogger.out("inside it");
  553. bug.setBugid(bugID);
  554. reopenedETABugListNW.add(bug);
  555. continue;
  556. }
  557.  
  558. /*
  559. * Those bugs which contains "revised eta" is revised eta bug triaged by the team on the current date
  560. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  561. * */
  562. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("revised") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  563. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  564. YDataLogger.out("inside it");
  565. bug.setBugid(bugID);
  566. revisedETABugListNW.add(bug);
  567. continue;
  568. }
  569. YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  570. //Those bugs which contains "triaged - currentdate" is freshed bug triaged by the team on the current date
  571. if(ScriptUtil.isNullValue(whiteBoard) || (!ScriptUtil.isNullValue(whiteBoard) && !whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  572. && !whiteBoard.toLowerCase().contains("triaged : "+triageDate) && !whiteBoard.toLowerCase().contains("triaged û "+triageDate))){
  573. YDataLogger.out("inside it continue");
  574. continue;
  575. }
  576.  
  577. //YDataLogger.out("2^^^^YIDomesticID : "+bugID);
  578.  
  579. bug.setBugid(bugID);
  580. freshBugListNW.add(bug);
  581. }
  582. }
  583. }
  584.  
  585. protected void getI18NFIBugList(IYodRobot pRobot) throws Exception{
  586.  
  587. YDataLogger.out("2^^^^date : "+triageDate);
  588.  
  589. Enumeration tableEnum = pRobot.getInnermostTablesContainingText("ID", false, -1);
  590. while(tableEnum.hasMoreElements()){
  591. IHTMLElement tableElement = JavaComBridgeHelper.toIHTMLElement(tableEnum.nextElement());
  592. //YDataLogger.out("2^^^innertext11 : "+tableElement.getInnerText());
  593. String[][] columnHeaders = new String[][] {{"ID"},{"Whiteboard"},{"Summary"},{"Workflow Status"},{"RCA IAE"}};
  594. String [] valueHeaders = new String[]{"ID", "Whiteboard","Summary", "Workflow Status", "RCA IAE"};
  595. int [] valueHeaderCellType = new int [] {HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT,HTMLUtils.TABLE_CELL_TEXT};
  596.  
  597. List<HashMap<String, String>> list = HTMLUtils.getTableData(pRobot,tableElement,"ID",columnHeaders,null,new boolean[]{false,false,false,false,false},1,0, valueHeaderCellType, valueHeaders);
  598. for(HashMap<String,String> prop :list){
  599. String bugID =prop.get("ID");
  600. String rcaIAE =prop.get("RCA IAE");
  601. String workFlowStatus = prop.get("Workflow Status");
  602. String whiteBoard = prop.get("Whiteboard");
  603.  
  604. Bug bug = new Bug();
  605.  
  606. /*
  607. * Those bugs which contains "reopened eta" is reopen bug triaged by the team on the current date
  608. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  609. * */
  610. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("reopened eta") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  611. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  612. YDataLogger.out("inside it");
  613. bug.setBugid(bugID);
  614. reopenedETABugListFI.add(bug);
  615. continue;
  616. }
  617.  
  618. /*
  619. * Those bugs which contains "revised eta" is revised eta bug triaged by the team on the current date
  620. * For revised ETA we have to update the old Triaged Date with New Triaged Date
  621. * */
  622. if(!ScriptUtil.isNullValue(whiteBoard) && whiteBoard.toLowerCase().contains("revised") && (whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  623. || whiteBoard.toLowerCase().contains("triaged:"+triageDate))){
  624. YDataLogger.out("inside it");
  625. bug.setBugid(bugID);
  626. revisedETABugListFI.add(bug);
  627. continue;
  628. }
  629. YDataLogger.out("2^^^^^^^^bugID::"+bugID+" ^^^^rcaIAE : " +rcaIAE +" ^^workFlowStatus : "+ workFlowStatus+" ^^^whiteBoard : "+whiteBoard);
  630. //Those bugs which contains "triaged - currentdate" is freshed bug triaged by the team on the current date
  631. if(ScriptUtil.isNullValue(whiteBoard) || (!ScriptUtil.isNullValue(whiteBoard) && !whiteBoard.toLowerCase().contains("triaged – "+triageDate)
  632. && !whiteBoard.toLowerCase().contains("triaged : "+triageDate) && !whiteBoard.toLowerCase().contains("triaged û "+triageDate))){
  633. YDataLogger.out("inside it continue");
  634. continue;
  635. }
  636.  
  637. //YDataLogger.out("2^^^^YIDomesticID : "+bugID);
  638.  
  639. bug.setBugid(bugID);
  640. freshBugListFI.add(bug);
  641. }
  642. }
  643. }
  644.  
  645. @Override
  646. public int execute(RequestItem item, ClassArgs arg1, IYodRobot pRobot) throws Exception {
  647. Site site = new Site("TestDD");
  648. this.getBugsList(pRobot);
  649. YDataLogger.out("2^^freshBugList size() : "+freshBugList.size());
  650. return RequestItem.RETURN_CODE_SUCCESS;
  651. }
  652.  
  653. private void createConsolidatedList( HSSFSheet sheetname, String teamName, int rowid, String date){
  654. List<Bug> tempFreshBugList = new ArrayList<Bug>();
  655. List<Bug> tempRevisedETABugList = new ArrayList<Bug>();
  656. List<Bug> tempReopenedETABugList = new ArrayList<Bug>();
  657.  
  658. if(teamName.equals("YI")){
  659. YDataLogger.out("2^^^^inside it");
  660. tempFreshBugList = freshBugList;
  661. tempRevisedETABugList = revisedETABugList;
  662. tempReopenedETABugList = reopenedETABugList;
  663. }else if(teamName.equals("FI")){
  664. YDataLogger.out("2^^^^inside it else");
  665. tempFreshBugList = freshBugListFI;
  666. tempRevisedETABugList = revisedETABugListFI;
  667. tempReopenedETABugList = reopenedETABugListFI;
  668. }else if(teamName.equals("NW")){
  669. YDataLogger.out("2^^^^inside it else if1");
  670. tempFreshBugList = freshBugListNW;
  671. tempRevisedETABugList = revisedETABugListNW;
  672. tempReopenedETABugList = reopenedETABugListNW;
  673. }else if(teamName.equals("NDD")){
  674. YDataLogger.out("2^^^^inside it else if2");
  675. tempFreshBugList = freshBugListNDD;
  676. tempRevisedETABugList = revisedETABugListNDD;
  677. tempReopenedETABugList = reopenedETABugListNDD;
  678. }else if(teamName.equals("WEALTH")){
  679. YDataLogger.out("2^^^^inside it else if3");
  680. tempFreshBugList = freshBugListWL;
  681. tempRevisedETABugList = revisedETABugListWL;
  682. tempReopenedETABugList = reopenedETABugListWL;
  683. }
  684.  
  685. HSSFRow rownum = sheetname.createRow((short) (rowid+1));
  686. rownum.createCell((short) 0).setCellValue(new HSSFRichTextString(date));
  687. rownum.createCell((short) 1).setCellValue(new Integer((tempFreshBugList.size()+tempReopenedETABugList.size())));
  688. rownum.createCell((short) 2).setCellValue(new Integer(tempFreshBugList.size()));
  689. rownum.createCell((short) 3).setCellValue(new Integer(tempRevisedETABugList.size()));
  690. rownum.createCell((short) 4).setCellValue(new Integer(tempReopenedETABugList.size()));
  691. YDataLogger.out("2^^^total : "+(tempFreshBugList.size()+tempReopenedETABugList.size())+" ^^^"+tempRevisedETABugList.size());
  692. }
  693.  
  694. private void createBugList( HSSFSheet sheetname, boolean flag, String teamName){
  695. List<Bug> tempFreshBugList = new ArrayList<Bug>();
  696. List<Bug> tempRevisedETABugList = new ArrayList<Bug>();
  697. List<Bug> tempReopenedETABugList = new ArrayList<Bug>();
  698.  
  699. if(teamName.equals("YI")){
  700. YDataLogger.out("2^^^^inside it");
  701. tempFreshBugList = freshBugList;
  702. tempRevisedETABugList = revisedETABugList;
  703. tempReopenedETABugList = reopenedETABugList;
  704. }else if(teamName.equals("FI")){
  705. YDataLogger.out("2^^^^inside it else");
  706. tempFreshBugList = freshBugListFI;
  707. tempRevisedETABugList = revisedETABugListFI;
  708. tempReopenedETABugList = reopenedETABugListFI;
  709. }else if(teamName.equals("NW")){
  710. YDataLogger.out("2^^^^inside it else if1");
  711. tempFreshBugList = freshBugListNW;
  712. tempRevisedETABugList = revisedETABugListNW;
  713. tempReopenedETABugList = reopenedETABugListNW;
  714. }else if(teamName.equals("NDD")){
  715. YDataLogger.out("2^^^^inside it else if2");
  716. tempFreshBugList = freshBugListNDD;
  717. tempRevisedETABugList = revisedETABugListNDD;
  718. tempReopenedETABugList = reopenedETABugListNDD;
  719. }else if(teamName.equals("WEALTH")){
  720. YDataLogger.out("2^^^^inside it else if3");
  721. tempFreshBugList = freshBugListWL;
  722. tempRevisedETABugList = revisedETABugListWL;
  723. tempReopenedETABugList = reopenedETABugListWL;
  724. }
  725.  
  726. rownumber = 0;
  727. for(Bug bug :tempFreshBugList){
  728. String bug_id = bug.getBugid();
  729.  
  730. if(rownumber == 0){
  731. rownumber++;
  732. }
  733. HSSFRow rownum = sheetname.createRow((short) rownumber);
  734. rownum.createCell((short) 0).setCellValue(new HSSFRichTextString(bug_id));
  735.  
  736. rownumber++;
  737. flag = false;
  738. }
  739.  
  740. //code to set revised ETA bug
  741. rownumber = 0;
  742. YDataLogger.out("2^^^revisedETABugList : "+revisedETABugList.size());
  743. for(Bug bug :tempRevisedETABugList){
  744. String bug_id = bug.getBugid();
  745.  
  746. if(rownumber == 0){
  747. rownumber++;
  748. }
  749. HSSFRow rownum = sheetname.createRow((short) rownumber);
  750. rownum.createCell((short) 1).setCellValue(new HSSFRichTextString(bug_id));
  751.  
  752. rownumber++;
  753. flag = false;
  754. }
  755.  
  756. //code to add reopened bug
  757. rownumber = 0;
  758. YDataLogger.out("2^^^reopenedETABugList : "+reopenedETABugList.size());
  759. for(Bug bug :tempReopenedETABugList){
  760. String bug_id = bug.getBugid();
  761.  
  762. if(rownumber == 0){
  763. rownumber++;
  764. }
  765. HSSFRow rownum = sheetname.createRow((short) rownumber);
  766. rownum.createCell((short) 2).setCellValue(new HSSFRichTextString(bug_id));
  767.  
  768. rownumber++;
  769. flag = false;
  770. }
  771. }
  772.  
  773. private void createCellHeaderConsolidate(HSSFSheet sheetname, HSSFRow row){
  774. HSSFCell Date_header = row.createCell((short) 0);
  775. HSSFCell Count_Incoming_bugs_header = row.createCell((short) 1);
  776. HSSFCell Count_Fresh_bug_Traiged_header = row.createCell((short) 2);
  777. HSSFCell Count_Revised_ETA_Bugs_Header = row.createCell((short) 3);
  778. HSSFCell Count_Reopen_bug_Traiged_Header = row.createCell((short) 4);
  779.  
  780. Date_header.setCellValue(new HSSFRichTextString("Date"));
  781. Count_Incoming_bugs_header.setCellValue(new HSSFRichTextString("Incoming_bugs"));
  782. Count_Fresh_bug_Traiged_header.setCellValue(new HSSFRichTextString("Fresh_bug_Traiged"));
  783. Count_Revised_ETA_Bugs_Header.setCellValue(new HSSFRichTextString("Revised_ETA_Bugs"));
  784. Count_Reopen_bug_Traiged_Header.setCellValue(new HSSFRichTextString("Reopen_bug_Traiged"));
  785.  
  786. Date_header.setCellStyle(styleHeader);
  787. Count_Incoming_bugs_header.setCellStyle(styleHeader);
  788. Count_Fresh_bug_Traiged_header.setCellStyle(styleHeader);
  789. Count_Revised_ETA_Bugs_Header.setCellStyle(styleHeader);
  790. Count_Reopen_bug_Traiged_Header.setCellStyle(styleHeader);
  791. }
  792.  
  793. private void createCellHeader(HSSFSheet sheetname, HSSFRow row){
  794. int lastRowNumber = sheetname.getLastRowNum();
  795. for(int i=1; i<=lastRowNumber; i++){
  796. try{
  797. sheetname.removeRow(sheetname.getRow(i));
  798. }catch(NullPointerException e){
  799. e.printStackTrace();
  800. }
  801. }
  802.  
  803. HSSFCell Fresh_bugs_header = row.createCell((short) 0);
  804. HSSFCell Revised_ETA_Bugs_header = row.createCell((short) 1);
  805. HSSFCell Reopen_bug_Traiged_header = row.createCell((short) 2);
  806. HSSFCell Non_Traige_Closed_Bugs_Header = row.createCell((short) 3);
  807.  
  808. Fresh_bugs_header.setCellValue(new HSSFRichTextString("Fresh_bugs"));
  809. Revised_ETA_Bugs_header.setCellValue(new HSSFRichTextString("Revised_ETA_Bugs"));
  810. Reopen_bug_Traiged_header.setCellValue(new HSSFRichTextString("Reopen_bug_Traiged"));
  811. Non_Traige_Closed_Bugs_Header.setCellValue(new HSSFRichTextString("Non_Traige_Closed_Bugs"));
  812.  
  813. Fresh_bugs_header.setCellStyle(styleHeader);
  814. Revised_ETA_Bugs_header.setCellStyle(styleHeader);
  815. Reopen_bug_Traiged_header.setCellStyle(styleHeader);
  816. Non_Traige_Closed_Bugs_Header.setCellStyle(styleHeader);
  817. }
  818.  
  819. private void sendMail(String attacmentLocation,String fileNm) throws Exception {
  820. Properties props = new Properties();
  821. //props.put("mail.smtp.host","192.168.234.200");
  822. props.put("mail.smtp.host","192.168.211.175");
  823. Session session = Session.getInstance(props, null);
  824. String from = "ckalita@yodlee.com";
  825.  
  826. Vector<String> aliasHolder = new Vector<String>();
  827. aliasHolder.add("ckalita@yodlee.com");
  828. aliasHolder.add("nkumar4@yodlee.com");
  829. aliasHolder.add("akumar7@yodlee.com");
  830. aliasHolder.add("ggupta@yodlee.com");
  831. aliasHolder.add("ptiwari@yodlee.com");
  832. aliasHolder.add("kshubham@yodlee.com");
  833. aliasHolder.add("dsingh1@yodlee.com");
  834. aliasHolder.add("bsingh1@yodlee.com");
  835. aliasHolder.add("rraghuva@yodlee.com");
  836. aliasHolder.add("kshubham@yodlee.com");
  837. aliasHolder.add("VMuddana@yodlee.com");
  838. aliasHolder.add("VMarisetti@yodlee.com");
  839. aliasHolder.add("malam@yodlee.com");
  840.  
  841. Vector<String> aliasHolderCC = new Vector<String>();
  842. aliasHolderCC.add("ckalita@yodlee.com");
  843.  
  844. InternetAddress fromAddress = null;
  845. MimeMessage msg = new MimeMessage(session);
  846. for (int i = 0; i < aliasHolder.size(); i++) {
  847. System.out.println("2^^^^^^^aliasHolder:"+aliasHolder.elementAt(i));
  848. String add = aliasHolder.get(i);
  849. InternetAddress to = new InternetAddress(add);
  850. msg.addRecipient(Message.RecipientType.TO, to);
  851. }
  852. for (int i = 0; i < aliasHolderCC.size(); i++) {
  853. System.out.println("2^^^^^^^aliasHolderCC:"+aliasHolderCC.elementAt(i));
  854. String add = aliasHolderCC.get(i);
  855. InternetAddress cc = new InternetAddress(add);
  856. msg.addRecipient(Message.RecipientType.CC, cc);
  857. }
  858.  
  859. try {
  860. msg.setFrom();
  861. fromAddress = new InternetAddress(from);
  862. msg.setFrom(fromAddress);
  863. //msg.addRecipient(Message.RecipientType.CC, to);
  864. msg.setSubject("Bug Triaging Report_"+ sdf.format(date));
  865. msg.setSentDate(new Date());
  866. msg.setText("Attachment");
  867. /*
  868. * ************************Test for
  869. * attachment*************************
  870. */
  871. String fileAttachment = attacmentLocation;
  872. // create the message part
  873. MimeBodyPart messageBodyPart = new MimeBodyPart();
  874. MimeBodyPart attachmentBodyPart = new MimeBodyPart();
  875.  
  876. String tableBodytext = "";
  877. String bodytext = "Hi Team,<br>";
  878. bodytext = bodytext +"<br>";
  879. bodytext = bodytext
  880. + "Bugs triaged for today. Please check and update the ETA as applicable. PFA of bugs for the same (Consolidated list)."
  881. + date + ".";
  882. bodytext = bodytext +"<br>"+"<br>";
  883.  
  884. /*bodytext = bodytext + "<h3>"+"YI Domestic and YI-I18N : "+"</h3>";
  885. bodytext = bodytext + "<html><head><meta content=\"text/html; charset=ISO-8859-1\"http-equiv=\"content-type\"><title></title></head><body>";
  886. bodytext = bodytext + "<table style=\"width: 100px; height: 60px; text-align: left; margin-left: auto; margin-right: auto;\"border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
  887. bodytext = bodytext + "<tbody><tr>";
  888. bodytext = bodytext + "<td>Date</td>";
  889. bodytext = bodytext + "<td>Incoming_bugs</td>";
  890. bodytext = bodytext + "<td>Fresh_bug_Traiged</td>";
  891. bodytext = bodytext + "<td style=\"text-align: center;\">Revised_ETA_Bugs</td>";
  892. bodytext = bodytext + "<td>Reopen_bug_Traiged</td>";
  893. bodytext = bodytext + "</tr>";
  894. bodytext = bodytext + "<tr>";
  895. bodytext = bodytext + "<td>"+sdf.format(date)+"</td>";
  896. bodytext = bodytext + "<td>"+(freshBugList.size()+reopenedETABugList.size())+"</td>";
  897. bodytext = bodytext + "<td>"+freshBugList.size()+"</td>";
  898. bodytext = bodytext + "<td>"+revisedETABugList.size()+"</td>";
  899. bodytext = bodytext + "<td>"+reopenedETABugList.size()+"</td>";
  900. bodytext = bodytext + "</tr></tbody></table><br></body></html>";
  901.  
  902. bodytext = bodytext + "<h3>"+"FI-I18N : "+"</h3>";
  903. bodytext = bodytext + "<html><head><meta content=\"text/html; charset=ISO-8859-1\"http-equiv=\"content-type\"><title></title></head><body>";
  904. bodytext = bodytext + "<table style=\"width: 100px; height: 60px; text-align: left; margin-left: auto; margin-right: auto;\"border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
  905. bodytext = bodytext + "<tbody><tr>";
  906. bodytext = bodytext + "<td>Date</td>";
  907. bodytext = bodytext + "<td>Incoming_bugs</td>";
  908. bodytext = bodytext + "<td>Fresh_bug_Traiged</td>";
  909. bodytext = bodytext + "<td style=\"text-align: center;\">Revised_ETA_Bugs</td>";
  910. bodytext = bodytext + "<td>Reopen_bug_Traiged</td>";
  911. bodytext = bodytext + "</tr>";
  912. bodytext = bodytext + "<tr>";
  913. bodytext = bodytext + "<td>"+sdf.format(date)+"</td>";
  914. bodytext = bodytext + "<td>"+(freshBugListFI.size()+reopenedETABugListFI.size())+"</td>";
  915. bodytext = bodytext + "<td>"+freshBugListFI.size()+"</td>";
  916. bodytext = bodytext + "<td>"+revisedETABugListFI.size()+"</td>";
  917. bodytext = bodytext + "<td>"+reopenedETABugListFI.size()+"</td>";
  918. bodytext = bodytext + "</tr></tbody></table><br></body></html>";
  919.  
  920. bodytext = bodytext + "<h3>"+"FI DDT : "+"</h3>";
  921. bodytext = bodytext + "<html><head><meta content=\"text/html; charset=ISO-8859-1\"http-equiv=\"content-type\"><title></title></head><body>";
  922. bodytext = bodytext + "<table style=\"width: 100px; height: 60px; text-align: left; margin-left: auto; margin-right: auto;\"border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
  923. bodytext = bodytext + "<tbody><tr>";
  924. bodytext = bodytext + "<td>Date</td>";
  925. bodytext = bodytext + "<td>Incoming_bugs</td>";
  926. bodytext = bodytext + "<td>Fresh_bug_Traiged</td>";
  927. bodytext = bodytext + "<td style=\"text-align: center;\">Revised_ETA_Bugs</td>";
  928. bodytext = bodytext + "<td>Reopen_bug_Traiged</td>";
  929. bodytext = bodytext + "</tr>";
  930. bodytext = bodytext + "<tr>";
  931. bodytext = bodytext + "<td>"+sdf.format(date)+"</td>";
  932. bodytext = bodytext + "<td>"+(freshBugListNW.size()+reopenedETABugListNW.size())+"</td>";
  933. bodytext = bodytext + "<td>"+freshBugListNW.size()+"</td>";
  934. bodytext = bodytext + "<td>"+revisedETABugListNW.size()+"</td>";
  935. bodytext = bodytext + "<td>"+reopenedETABugListNW.size()+"</td>";
  936. bodytext = bodytext + "</tr></tbody></table><br></body></html>";
  937. */
  938.  
  939. tableBodytext = tableBodytext + this.createTable("YI Domestic and YI-I18N :");
  940. tableBodytext = tableBodytext + this.createTable("FI-I18N :");
  941. tableBodytext = tableBodytext + this.createTable("FI DDT :");
  942. tableBodytext = tableBodytext + this.createTable("WEALTH :");
  943. tableBodytext = tableBodytext + this.createTable("NDD :");
  944.  
  945. bodytext = bodytext + tableBodytext;
  946.  
  947. bodytext = bodytext +"<br>"+"<br>";
  948.  
  949. bodytext = bodytext +"Thanks & Regards"+"<br>"+"Chandan";
  950.  
  951. messageBodyPart.setContent(bodytext , "text/html");
  952.  
  953. // Part two is attachment
  954. DataSource source = new FileDataSource(fileNm);
  955. attachmentBodyPart.setDataHandler(new DataHandler(source));
  956. attachmentBodyPart.setFileName(attachedFileName);
  957.  
  958. // Put parts in message
  959. Multipart multipart = new MimeMultipart();
  960. multipart.addBodyPart(messageBodyPart);
  961. multipart.addBodyPart(attachmentBodyPart);
  962. msg.setContent(multipart);
  963. /* ******************************************************************** */
  964. Transport.send(msg);
  965.  
  966. System.out.println("2^^^^^^^fileAttachment "+fileNm);
  967. //System.out.println("2^^^^^^^bodytext "+bodytext);
  968. } catch (MessagingException mex) {
  969. System.out.println("2^^^^^^^^^^^^^^^^^^^send failed, exception: "+ mex);
  970. }
  971. }
  972. //}
  973.  
  974. protected String createTable(String teamName){
  975. List<Bug> tempFreshBugList = new ArrayList<Bug>();
  976. List<Bug> tempRevisedETABugList = new ArrayList<Bug>();
  977. List<Bug> tempReopenedETABugList = new ArrayList<Bug>();
  978.  
  979. if(teamName.equals("YI Domestic and YI-I18N :")){
  980. YDataLogger.out("2^^^^inside it");
  981. tempFreshBugList = freshBugList;
  982. tempRevisedETABugList = revisedETABugList;
  983. tempReopenedETABugList = reopenedETABugList;
  984. }else if(teamName.equals("FI-I18N :")){
  985. YDataLogger.out("2^^^^inside it else");
  986. tempFreshBugList = freshBugListFI;
  987. tempRevisedETABugList = revisedETABugListFI;
  988. tempReopenedETABugList = reopenedETABugListFI;
  989. }else if(teamName.equals("FI DDT :")){
  990. YDataLogger.out("2^^^^inside it else if2");
  991. tempFreshBugList = freshBugListNW;
  992. tempRevisedETABugList = revisedETABugListNW;
  993. tempReopenedETABugList = reopenedETABugListNW;
  994. }else if(teamName.equals("NDD :")){
  995. YDataLogger.out("2^^^^inside it else if2");
  996. tempFreshBugList = freshBugListNDD;
  997. tempRevisedETABugList = revisedETABugListNDD;
  998. tempReopenedETABugList = reopenedETABugListNDD;
  999. }else if(teamName.equals("WEALTH :")){
  1000. YDataLogger.out("2^^^^inside it else if2");
  1001. tempFreshBugList = freshBugListWL;
  1002. tempRevisedETABugList = revisedETABugListWL;
  1003. tempReopenedETABugList = reopenedETABugListWL;
  1004. }
  1005.  
  1006. String bodytext = "";
  1007. bodytext = bodytext + "<h3>"+teamName+"</h3>";
  1008. bodytext = bodytext + "<html><head><meta content=\"text/html; charset=ISO-8859-1\"http-equiv=\"content-type\"><title></title></head><body>";
  1009. bodytext = bodytext + "<table style=\"width: 100px; height: 60px; text-align: left; margin-left: auto; margin-right: auto;\"border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
  1010. bodytext = bodytext + "<tbody><tr>";
  1011. bodytext = bodytext + "<td>Date</td>";
  1012. bodytext = bodytext + "<td>Incoming_bugs</td>";
  1013. bodytext = bodytext + "<td>Fresh_bug_Traiged</td>";
  1014. bodytext = bodytext + "<td style=\"text-align: center;\">Revised_ETA_Bugs</td>";
  1015. bodytext = bodytext + "<td>Reopen_bug_Traiged</td>";
  1016. bodytext = bodytext + "</tr>";
  1017. bodytext = bodytext + "<tr>";
  1018. bodytext = bodytext + "<td>"+sdf.format(date)+"</td>";
  1019. bodytext = bodytext + "<td>"+(tempFreshBugList.size()+tempReopenedETABugList.size())+"</td>";
  1020. bodytext = bodytext + "<td>"+tempFreshBugList.size()+"</td>";
  1021. bodytext = bodytext + "<td>"+tempRevisedETABugList.size()+"</td>";
  1022. bodytext = bodytext + "<td>"+tempReopenedETABugList.size()+"</td>";
  1023. bodytext = bodytext + "</tr></tbody></table><br></body></html>";
  1024.  
  1025. return bodytext;
  1026. }
  1027.  
  1028. @Override
  1029. public int logout(IYodRobot pRobot) {
  1030. return 0;//LogoutUtil.logout(pRobot);
  1031. }
  1032.  
  1033. @Override
  1034. public double getSupportedVersion() {
  1035. return 5.0;
  1036. }
  1037.  
  1038.  
  1039. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement