source: trunk/gli/src/org/greenstone/gatherer/util/StatusHTML.java@ 6663

Last change on this file since 6663 was 6663, checked in by jmt12, 20 years ago

Corrected version number for the brand new, all shiney and improved, GLI 2.50 (I'd put lots of explaination marks but CVS doesn't like them for some reason. Or perhaps its Unix. Oh well)

  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1package org.greenstone.gatherer.util;
2
3import java.io.*;
4import java.util.*;
5
6public class StatusHTML {
7
8 static final private String GLI_VERSION = "GLI v2.50";
9
10 static final private String DARK_GREEN = "B0D0B0";
11 static final private String DARK_RED = "D0B0B0";
12 static final private String LIGHT_GREEN = "E0F0E0";
13 static final private String LIGHT_RED = "F0E0E0";
14
15 static final private String DARK_BLUE = "B0B0D0";
16 static final private String LIGHT_BLUE = "E0E0F0";
17
18 static final private String FIXED_STR = "Fixed";
19 static final private String NOTHING_STR = "Nothing";
20
21 static final private String FEATURES = " <!-- Header -->\n <TR bgcolor=\"#B0B0D0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">"+GLI_VERSION+" - Feature Requests [FEATURE_COUNT total]</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order received. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\">&#160;</TD>\n </TR>\n";
22
23 static final private String FIXED = " <!-- Header -->\n <TR bgcolor=\"#B0D0B0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">"+GLI_VERSION+" - Closed Reports [FIXED_COUNT total]</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order received. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\">&#160;</TD>\n </TR>\n";
24
25 static final private String FOOTER = " <TR><TD>&nbsp;</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>";
26 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+")</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.</TD>\n </TR>\n</TABLE>\n<BR/>\n<TABLE border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n";
27
28 static final private String PENDING = " <TR><TD bgcolor=\"#CCCCCC\">&nbsp;</TD></TR>\n <!-- Header -->\n <TR bgcolor=\"#D0B0B0\">\n <TD colspan=\"2\"><STRONG><A name=\"23b\">"+GLI_VERSION+" - Current Reports [PENDING_COUNT total]</A></STRONG></TD>\n </TR>\n <TR>\n <TD bgcolor=\"#FFFFFF\" colspan=\"2\">In order received. Similar problems only mentioned once, with descriptions combined where possible.</TD>\n </TR>\n <TR>\n <TD colspan=\"2\">&#160;</TD>\n </TR>\n";
29
30 static final private String[] PREFIX = { " <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">ID#</TD> <TD bgcolor=\"#DARK_COLOR\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Description</TD> <TD bgcolor=\"#LIGHT_COLOR\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Reported By</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Platform</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Test Item#</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Status</TD> <TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Proposed Solution</TD><TD bgcolor=\"#FFFFFF\">"," <TR><TD bgcolor=\"#DARK_COLOR\" valign=\"top\">Solution</TD><TD bgcolor=\"#FFFFFF\">", " <TR><TD bgcolor=\"#CCCCCC\">&nbsp;"};
31
32 static final private String SUFFIX = "</TD></TR>\n";
33
34 static public void main(String[] args) {
35 File in_file = null;
36 File out_file = null;
37 if(args.length == 2) {
38 in_file = new File(args[0]);
39 if(!in_file.exists()) {
40 System.out.println("Can't find source file: " + in_file.getAbsolutePath());
41 in_file = null;
42 }
43 out_file = new File(args[1]);
44 }
45 if(in_file != null && out_file != null) {
46 new StatusHTML(in_file, out_file);
47 }
48 else {
49 System.out.println("Usage: java org.greenstone.gatherer.util.StatusHTML <input_file> <output_file>");
50 }
51 }
52
53 public StatusHTML(File in_file, File out_file) {
54 LinkedList reports = new LinkedList();
55 try {
56 int feature_count = 0;
57 int fixed_count = 0;
58 int pending_count = 0;
59 BufferedReader in = new BufferedReader(new FileReader(in_file));
60 // Read in the entire file, building report objects.
61 String line = null;
62 while((line = in.readLine()) != null) {
63 // We may of course end up with several nulls, but thats hardly our fault.
64 Report report = new Report(line, in.readLine(), in.readLine(), in.readLine(), in.readLine(), in.readLine(), in.readLine());
65 if(report.isFixed()) {
66 fixed_count++;
67 }
68 else if (report.isFeatureRequest()) {
69 feature_count++;
70 }
71 else {
72 pending_count++;
73 }
74 reports.add(report);
75 report = null;
76 // Throw away a line
77 in.readLine();
78 }
79 in.close();
80 in = null;
81
82 // Create and start writing the output file
83 FileOutputStream out = new FileOutputStream(out_file);
84 out.write(HEADER.getBytes());
85
86 // Write out all the pending jobs
87 out.write((PENDING.replaceAll("PENDING_COUNT", String.valueOf(pending_count))).getBytes());
88
89 // Write out the bugs
90 for (int i = 0; i < reports.size(); i++) {
91 Report report = (Report) reports.get(i);
92 if (!report.isFixed() && !report.isFeatureRequest()) {
93 out.write(report.getBytes(DARK_RED, LIGHT_RED));
94 }
95 }
96
97 // Write out all the feature requests
98 out.write((FEATURES.replaceAll("FEATURE_COUNT", String.valueOf(feature_count))).getBytes());
99
100 // Write out the feature requests
101 for (int i = 0; i < reports.size(); i++) {
102 Report report = (Report) reports.get(i);
103 if (!report.isFixed() && report.isFeatureRequest()) {
104 out.write(report.getBytes(DARK_BLUE, LIGHT_BLUE));
105 }
106 report = null;
107 }
108
109 // Write out everything else
110 out.write((FIXED.replaceAll("FIXED_COUNT", String.valueOf(fixed_count))).getBytes());
111 for(int i = 0; i < reports.size(); i++) {
112 Report report = (Report) reports.get(i);
113 if(report.isFixed()) {
114 out.write(report.getBytes(DARK_GREEN, LIGHT_GREEN));
115 }
116 report = null;
117 }
118
119 // Write the footer and close the file
120 out.write(FOOTER.getBytes());
121 out.close();
122 out = null;
123 }
124 catch(Exception error) {
125 error.printStackTrace();
126 }
127 }
128
129 private class Report {
130 public String bug_id;
131 public String description;
132 public String platform;
133 public String reported_by;
134 public String status;
135 public String solution;
136 public String test_item;
137
138 public Report(String bug_id, String description, String reported_by, String platform, String test_item, String status, String solution) {
139 if(bug_id != null) this.bug_id = bug_id; //.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
140 if(description != null) this.description = description; //.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
141 if(platform != null) this.platform = platform; //.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
142 if(reported_by != null) this.reported_by = reported_by; //.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
143 if(solution != null) this.solution = solution; //.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
144 if(status != null) this.status = status; // status.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
145 if(test_item != null) this.test_item = test_item; // test_item.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
146 }
147
148 public boolean isFixed() {
149 return (status != null && (status.startsWith(FIXED_STR) || status.startsWith(NOTHING_STR)));
150 }
151
152 public boolean isFeatureRequest() {
153 return (bug_id.indexOf("F") != -1);
154 }
155
156 public byte[] getBytes(String dark_color, String light_color) {
157 StringBuffer text_buffer = new StringBuffer();
158 text_buffer.append(PREFIX[0]);
159 text_buffer.append(bug_id);
160 text_buffer.append(SUFFIX);
161 text_buffer.append(PREFIX[1]);
162 text_buffer.append(description);
163 text_buffer.append(SUFFIX);
164 text_buffer.append(PREFIX[2]);
165 text_buffer.append(reported_by);
166 text_buffer.append(SUFFIX);
167 text_buffer.append(PREFIX[3]);
168 text_buffer.append(platform);
169 text_buffer.append(SUFFIX);
170 text_buffer.append(PREFIX[4]);
171 text_buffer.append(test_item);
172 text_buffer.append(SUFFIX);
173 text_buffer.append(PREFIX[5]);
174 text_buffer.append(status);
175 text_buffer.append(SUFFIX);
176 if(isFixed()) {
177 text_buffer.append(PREFIX[6]);
178 }
179 else {
180 text_buffer.append(PREFIX[7]);
181 }
182 text_buffer.append(solution);
183 text_buffer.append(SUFFIX);
184 text_buffer.append(PREFIX[8]);
185 text_buffer.append(SUFFIX);
186 text_buffer.append("\n");
187 String text = text_buffer.toString();
188 text = text.replaceAll("DARK_COLOR", dark_color);
189 text = text.replaceAll("LIGHT_COLOR", light_color);
190 return text.getBytes();
191 }
192 }
193}
Note: See TracBrowser for help on using the repository browser.