Changeset 5364
- Timestamp:
- 2003-08-29T14:41:08+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/StatusHTML.java
r5313 r5364 2 2 3 3 import java.io.*; 4 import java.util.*; 4 5 5 6 public class StatusHTML { 6 7 7 static final private String FOOTER = " <TR><TD> </TD></TR>\n</TABLE>\n<TABLE bgcolor=\"#FFFFFF\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n <TR>\n <TD align=\"center\">Written by John Thompson. Any comments, bug reports email <A href=\"mailto:[email protected]\">here</A>.</TD>\n </TR>\n</TABLE>\n</BODY>\n</HTML>"; 8 static final private String HEADER = "<HTML>\n<HEAD>\n<TITLE>GLI Project Status</TITLE>\n</HEAD>\n<BODY bgcolor=\"#CCCCCC\">\n<TABLE bgcolor=\"#FFFFFF\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n <!-- Header -->\n <TR bgcolor=\"#B0D0B0\">\n <TD align=\"center\" colspan=\"7\"><FONT size=\"4\"><STRONG>Greenstone Librarian Interface (GLI) version 2.3 beta</STRONG></FONT></TD>\n </TR>\n <TR>\n <TD colspan=\"7\">This page lists the features planned for the Greenstone Librarian Interface in its next release. It also details the various bugs that have been found and reported in this version of the GLI. You can also review the status reports for these other versions:</TD>\n </TR>\n <TR bgcolor=\"#B0D0B0\">\n <TD align=\"center\">Status v2.3 beta</TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23c.html\">Status v2.3c</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23b.html\">Status v2.3b</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23a.html\">Status v2.3a</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_22b.html\">Status v2.2b</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_21.html\">Status v2.1</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_20.html\">Status v2.0</A></TD>\n </TR>\n</TABLE>\n<BR/>\n<TABLE border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <!-- Header -->\n <TR bgcolor=\"#B0D0B0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">GLI v2.3 beta - Current Status Report</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order recieved. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\"> </TD>\n </TR>\n"; 9 static final private String[] PREFIX = { " <TR><TD bgcolor=\"#B0D0B0\">ID#</TD> <TD bgcolor=\"#B0D0B0\">"," <TR><TD bgcolor=\"#B0D0B0\">Description</TD> <TD bgcolor=\"#E0F0E0\">"," <TR><TD bgcolor=\"#B0D0B0\">Reported By</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#B0D0B0\">Platform</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#B0D0B0\">Test Item#</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#B0D0B0\">Status</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#B0D0B0\">Proposed Solution</TD><TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#B0D0B0\">Solution</TD><TD bgcolor=\"#FFFFFF\">"," <TR><TD> "}; 8 static final private String DARK_GREEN = "B0D0B0"; 9 static final private String DARK_RED = "D0B0B0"; 10 static final private String LIGHT_GREEN = "E0F0E0"; 11 static final private String LIGHT_RED = "F0E0E0"; 10 12 11 static final private String SUFFIX = "</TD></TR>\n"; 13 static final private String FIXED_STR = "Fixed"; 14 static final private String NOTHING_STR = "Nothing"; 12 15 13 static public void main(String[] args) { 14 try { 15 BufferedReader in = new BufferedReader(new FileReader(new File("status.txt"))); 16 FileOutputStream out = new FileOutputStream(new File("status.html")); 17 out.write(HEADER.getBytes()); 18 int line_count = 0; 19 boolean is_fixed = false; 20 String line = null; 21 while((line = in.readLine()) != null) { 22 if(line_count == 6) { 23 if(is_fixed) { 24 out.write(PREFIX[line_count + 1].getBytes()); 25 } 26 else { 27 out.write(PREFIX[line_count].getBytes()); 28 } 29 line_count++; 30 } 31 else { 32 out.write(PREFIX[line_count].getBytes()); 33 } 34 line = line.replaceAll("<", "<"); 35 line = line.replaceAll(">", ">"); 36 // If we encounter a status entry, we must base the prefix of the solution tag on whether it is fixed or not. 37 if(line_count == 5) { 38 if(line.indexOf("Fixed") != -1) { 39 is_fixed = true; 40 } 41 else { 42 is_fixed = false; 43 } 44 } 45 out.write(line.getBytes()); 46 out.write(SUFFIX.getBytes()); 47 out.write('\n'); 48 line_count++; 49 if(line_count == PREFIX.length) { 50 out.write('\n'); 51 line_count = 0; 52 } 53 } 54 in.close(); 55 in = null; 56 out.write(FOOTER.getBytes()); 57 out.close(); 58 out = null; 16 static final private String FIXED = " <!-- Header -->\n <TR bgcolor=\"#B0D0B0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">GLI v2.3 beta - Closed Reports</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order recieved. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\"> </TD>\n </TR>\n"; 17 18 static final private String FOOTER = " <TR><TD> </TD></TR>\n</TABLE>\n<TABLE bgcolor=\"#FFFFFF\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n <TR>\n <TD align=\"center\">Written by John Thompson. Any comments, bug reports email <A href=\"mailto:[email protected]\">here</A>.</TD>\n </TR>\n</TABLE>\n</BODY>\n</HTML>"; 19 static final private String HEADER = "<HTML>\n<HEAD>\n<TITLE>GLI Project Status</TITLE>\n</HEAD>\n<BODY bgcolor=\"#CCCCCC\">\n<TABLE bgcolor=\"#FFFFFF\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n <!-- Header -->\n <TR bgcolor=\"#B0D0B0\">\n <TD align=\"center\" colspan=\"7\"><FONT size=\"4\"><STRONG>Greenstone Librarian Interface (GLI) version 2.3 beta</STRONG></FONT></TD>\n </TR>\n <TR>\n <TD colspan=\"7\">This page lists the features planned for the Greenstone Librarian Interface in its next release. It also details the various bugs that have been found and reported in this version of the GLI. You can also review the status reports for these other versions:</TD>\n </TR>\n <TR bgcolor=\"#B0D0B0\">\n <TD align=\"center\">Status v2.3 beta</TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23c.html\">Status v2.3c</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23b.html\">Status v2.3b</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_23a.html\">Status v2.3a</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_22b.html\">Status v2.2b</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_21.html\">Status v2.1</A></TD>\n <TD align=\"center\"><A href=\"http://www.greenstone.org/gatherer/status_20.html\">Status v2.0</A></TD>\n </TR>\n</TABLE>\n<BR/>\n<TABLE border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n"; 20 21 static final private String PENDING = " <!-- Header -->\n <TR bgcolor=\"#D0B0B0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">GLI v2.3 beta - Current Status Report</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order recieved. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\"> </TD>\n </TR>\n"; 22 23 static final private String[] PREFIX = { " <TR><TD bgcolor=\"#DARK_COLOR\">ID#</TD> <TD bgcolor=\"#DARK_COLOR\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Description</TD> <TD bgcolor=\"#LIGHT_COLOR\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Reported By</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Platform</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Test Item#</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Status</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Proposed Solution</TD><TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\">Solution</TD><TD bgcolor=\"#FFFFFF\">", "<TR><TD bgcolor=\"#CCCCCC\"> "}; 24 25 static final private String SUFFIX = "</TD></TR>\n"; 26 27 static public void main(String[] args) { 28 File in_file = null; 29 File out_file = null; 30 if(args.length == 2) { 31 in_file = new File(args[0]); 32 if(!in_file.exists()) { 33 System.out.println("Can't find source file: " + in_file.getAbsolutePath()); 34 in_file = null; 35 } 36 out_file = new File(args[1]); 37 } 38 if(in_file != null && out_file != null) { 39 new StatusHTML(in_file, out_file); 40 } 41 else { 42 System.out.println("Usage: java org.greenstone.gatherer.util.StatusHTML <input_file> <output_file>"); 43 } 44 } 45 46 public StatusHTML(File in_file, File out_file) { 47 LinkedList reports = new LinkedList(); 48 try { 49 BufferedReader in = new BufferedReader(new FileReader(in_file)); 50 // Read in the entire file, building report objects. 51 String line = null; 52 while((line = in.readLine()) != null) { 53 // We may of course end up with several nulls, but thats hardly our fault. 54 reports.add(new Report(line, in.readLine(), in.readLine(), in.readLine(), in.readLine(), in.readLine(), in.readLine())); 55 // Throw away a line 56 in.readLine(); 57 } 58 in.close(); 59 in = null; 60 61 // Create and start writing the output file 62 FileOutputStream out = new FileOutputStream(out_file); 63 out.write(HEADER.getBytes()); 64 65 // Write out all the pending jobs 66 out.write(PENDING.getBytes()); 67 for(int i = 0; i < reports.size(); i++) { 68 Report report = (Report) reports.get(i); 69 if(!report.isFixed()) { 70 out.write(report.getBytes(DARK_RED, LIGHT_RED)); 59 71 } 60 catch(Exception error) { 61 error.printStackTrace(); 72 report = null; 73 } 74 75 // Write out everything else 76 out.write(FIXED.getBytes()); 77 for(int i = 0; i < reports.size(); i++) { 78 Report report = (Report) reports.get(i); 79 if(report.isFixed()) { 80 out.write(report.getBytes(DARK_GREEN, LIGHT_GREEN)); 62 81 } 82 report = null; 83 } 84 85 // Write the footer and close the file 86 out.write(FOOTER.getBytes()); 87 out.close(); 88 out = null; 63 89 } 90 catch(Exception error) { 91 error.printStackTrace(); 92 } 93 } 94 95 private class Report { 96 public String bug_id; 97 public String description; 98 public String platform; 99 public String reported_by; 100 public String status; 101 public String solution; 102 public String test_item; 103 104 public Report(String bug_id, String description, String reported_by, String platform, String test_item, String status, String solution) { 105 if(bug_id != null) this.bug_id = bug_id.replaceAll("<", "<").replaceAll(">", ">"); 106 if(description != null) this.description = description.replaceAll("<", "<").replaceAll(">", ">"); 107 if(platform != null) this.platform = platform.replaceAll("<", "<").replaceAll(">", ">"); 108 if(reported_by != null) this.reported_by = reported_by.replaceAll("<", "<").replaceAll(">", ">"); 109 if(solution != null) this.solution = solution.replaceAll("<", "<").replaceAll(">", ">"); 110 if(status != null) this.status = status.replaceAll("<", "<").replaceAll(">", ">"); 111 if(test_item != null) this.test_item = test_item.replaceAll("<", "<").replaceAll(">", ">"); 112 } 113 114 public boolean isFixed() { 115 return (status != null && (status.startsWith(FIXED_STR) || status.startsWith(NOTHING_STR))); 116 } 117 118 public byte[] getBytes(String dark_color, String light_color) { 119 StringBuffer text_buffer = new StringBuffer(); 120 text_buffer.append(PREFIX[0]); 121 text_buffer.append(bug_id); 122 text_buffer.append(SUFFIX); 123 text_buffer.append(PREFIX[1]); 124 text_buffer.append(description); 125 text_buffer.append(SUFFIX); 126 text_buffer.append(PREFIX[2]); 127 text_buffer.append(reported_by); 128 text_buffer.append(SUFFIX); 129 text_buffer.append(PREFIX[3]); 130 text_buffer.append(platform); 131 text_buffer.append(SUFFIX); 132 text_buffer.append(PREFIX[4]); 133 text_buffer.append(test_item); 134 text_buffer.append(SUFFIX); 135 text_buffer.append(PREFIX[5]); 136 text_buffer.append(status); 137 text_buffer.append(SUFFIX); 138 if(isFixed()) { 139 text_buffer.append(PREFIX[6]); 140 } 141 else { 142 text_buffer.append(PREFIX[7]); 143 } 144 text_buffer.append(solution); 145 text_buffer.append(SUFFIX); 146 text_buffer.append(PREFIX[8]); 147 text_buffer.append(SUFFIX); 148 text_buffer.append("\n"); 149 String text = text_buffer.toString(); 150 text = text.replaceAll("DARK_COLOR", dark_color); 151 text = text.replaceAll("LIGHT_COLOR", light_color); 152 return text.getBytes(); 153 } 154 } 64 155 }
Note:
See TracChangeset
for help on using the changeset viewer.