|
Lines 15-20
Link Here
|
| 15 |
import java.io.IOException; |
15 |
import java.io.IOException; |
| 16 |
import java.io.OutputStreamWriter; |
16 |
import java.io.OutputStreamWriter; |
| 17 |
import java.io.Writer; |
17 |
import java.io.Writer; |
|
|
18 |
import java.util.ArrayList; |
| 19 |
import java.util.HashMap; |
| 18 |
import java.util.Hashtable; |
20 |
import java.util.Hashtable; |
| 19 |
import java.util.Iterator; |
21 |
import java.util.Iterator; |
| 20 |
import java.util.List; |
22 |
import java.util.List; |
|
Lines 89-101
Link Here
|
| 89 |
.append(",").append("sourceComponentId_location").append(",").append("sourceComponentId_locationType") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
91 |
.append(",").append("sourceComponentId_location").append(",").append("sourceComponentId_locationType") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
| 90 |
.append(",").append("sourceComponentId_processId").append(",").append("sourceComponentId_subComponent") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
92 |
.append(",").append("sourceComponentId_processId").append(",").append("sourceComponentId_subComponent") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
| 91 |
.append(",").append("sourceComponentId_threadId") //$NON-NLS-1$ //$NON-NLS-2$ |
93 |
.append(",").append("sourceComponentId_threadId") //$NON-NLS-1$ //$NON-NLS-2$ |
| 92 |
.append(",").append("situation_categoryName").append(",").append("situation_reasoningScope") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
94 |
.append(",").append("situation_categoryName").append(",").append("situation_reasoningScope"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
| 93 |
.append(",").append("extendedProperties_name") //$NON-NLS-1$ //$NON-NLS-2$ |
95 |
// ExtendedDataElements will be appended dynamically later on |
| 94 |
.append(newLine); |
96 |
//.append(",").append("extendedProperties_name") //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
97 |
//.append(newLine); |
| 95 |
|
98 |
|
| 96 |
// Write out the CBEs |
99 |
// Write out the CBEs |
| 97 |
if (events!=null) { |
100 |
if (events!=null) { |
| 98 |
|
101 |
|
|
|
102 |
ArrayList edeNames = new ArrayList(); |
| 103 |
for (int idx=0; idx<events.size(); idx++) |
| 104 |
{ |
| 105 |
Object event = events.get(idx); |
| 106 |
if (event instanceof CBECommonBaseEvent) { |
| 107 |
CBECommonBaseEvent cbe = (CBECommonBaseEvent)event; |
| 108 |
//prepare a list of extended properties to help create the report structure |
| 109 |
//Bugzilla 166098 |
| 110 |
listExtendedDataElements(cbe.getExtendedProperties(),null,edeNames); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
for(Iterator ite = edeNames.iterator();ite.hasNext();) |
| 115 |
{ |
| 116 |
buffer.append(",").append("extendedProperties-" + ite.next());//$NON-NLS-1$ //$NON-NLS-2$ |
| 117 |
} |
| 118 |
|
| 119 |
buffer.append(newLine); |
| 120 |
|
| 121 |
|
| 99 |
for (int idx=0; idx<events.size(); idx++) |
122 |
for (int idx=0; idx<events.size(); idx++) |
| 100 |
{ |
123 |
{ |
| 101 |
Object event = events.get(idx); |
124 |
Object event = events.get(idx); |
|
Lines 146-165
Link Here
|
| 146 |
buffer.append(",").append(","); //$NON-NLS-1$ //$NON-NLS-2$ |
169 |
buffer.append(",").append(","); //$NON-NLS-1$ //$NON-NLS-2$ |
| 147 |
} |
170 |
} |
| 148 |
|
171 |
|
| 149 |
//extended properties |
172 |
HashMap edeMap = new HashMap(); |
| 150 |
Iterator iterator = cbe.getExtendedProperties().iterator(); |
173 |
//For each event retrieve the complete list of extended properties |
| 151 |
while(iterator.hasNext()) |
174 |
//Bugzilla 166098 |
| 152 |
{ |
175 |
retrieveExtendedDataElements(cbe.getExtendedProperties(),null,edeMap); |
| 153 |
Object obj = iterator.next(); |
176 |
|
| 154 |
if(obj != null && obj instanceof CBEDefaultElement) |
177 |
// Append the extended properties information to the report based on |
| 155 |
{ |
178 |
// the format/order required in the report. refer Bugzilla 166098 |
| 156 |
CBEDefaultElement ev = (CBEDefaultElement)obj; |
179 |
for(Iterator ite = edeNames.iterator();ite.hasNext();) |
| 157 |
buffer.append(",").append(getCSVFormat(ev.getName())); //$NON-NLS-1$ |
180 |
{ |
| 158 |
} |
181 |
buffer.append(",").append(edeMap.get(ite.next())); //$NON-NLS-1$ //$NON-NLS-2$ |
| 159 |
} |
182 |
} |
| 160 |
|
183 |
|
| 161 |
buffer.append(newLine); |
184 |
buffer.append(newLine); |
| 162 |
|
|
|
| 163 |
} |
185 |
} |
| 164 |
} |
186 |
} |
| 165 |
} |
187 |
} |
|
Lines 173-184
Link Here
|
| 173 |
} |
195 |
} |
| 174 |
} |
196 |
} |
| 175 |
|
197 |
|
|
|
198 |
/* |
| 199 |
* This method is used to create a list of the extended properties |
| 200 |
* available in the list of events supplied to the report generator. |
| 201 |
* Bugzilla 166098 |
| 202 |
*/ |
| 203 |
private void listExtendedDataElements(List edes,String parent,ArrayList edeNames) |
| 204 |
{ |
| 205 |
for(Iterator iterator = edes.iterator();iterator.hasNext();) |
| 206 |
{ |
| 207 |
Object obj = iterator.next(); |
| 208 |
if(obj != null && obj instanceof CBEDefaultElement) |
| 209 |
{ |
| 210 |
CBEDefaultElement ev = (CBEDefaultElement)obj; |
| 211 |
|
| 212 |
String edeName = parent == null?ev.getName():parent + "." + ev.getName();//$NON-NLS-1$ //$NON-NLS-2$ |
| 213 |
|
| 214 |
if(!ev.getValues().isEmpty()) |
| 215 |
{ |
| 216 |
if(!edeNames.contains(edeName)) |
| 217 |
{ |
| 218 |
edeNames.add(edeName); |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
if(ev.getChildren() != null) |
| 223 |
{ |
| 224 |
listExtendedDataElements(ev.getChildren(),edeName,edeNames); |
| 225 |
} |
| 226 |
} |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
/* |
| 231 |
* retrieve all extendedDataElements for an event and store them in the HashMap so that it can be used |
| 232 |
* later on to display based on the order in which it needs to be displayed |
| 233 |
* Bugzilla 166098 |
| 234 |
*/ |
| 235 |
private void retrieveExtendedDataElements(List edes,String parent,HashMap edeMap) |
| 236 |
{ |
| 237 |
for(Iterator iterator = edes.iterator();iterator.hasNext();) |
| 238 |
{ |
| 239 |
Object obj = iterator.next(); |
| 240 |
if(obj != null && obj instanceof CBEDefaultElement) |
| 241 |
{ |
| 242 |
CBEDefaultElement ev = (CBEDefaultElement)obj; |
| 243 |
|
| 244 |
String edeName = parent == null?ev.getName():parent + "." + ev.getName();//$NON-NLS-1$ //$NON-NLS-2$ |
| 245 |
|
| 246 |
if(!ev.getValues().isEmpty()) |
| 247 |
{ |
| 248 |
edeMap.put(edeName, getCSVFormat(getListStringRepresentation(ev.getValues()))); |
| 249 |
} |
| 250 |
|
| 251 |
if(ev.getChildren() != null) |
| 252 |
{ |
| 253 |
retrieveExtendedDataElements(ev.getChildren(),edeName,edeMap); |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
private String getListStringRepresentation(List lst) |
| 260 |
{ |
| 261 |
if(lst.size()==1) |
| 262 |
{ |
| 263 |
return lst.get(0).toString(); |
| 264 |
} |
| 265 |
return lst.toString(); |
| 266 |
} |
| 267 |
|
| 176 |
private String getCSVFormat(String text) |
268 |
private String getCSVFormat(String text) |
| 177 |
{ |
269 |
{ |
| 178 |
if(text == null) |
270 |
if(text == null) |
| 179 |
return text; |
271 |
return text; |
| 180 |
|
272 |
// '\n' and '\r' need to be added here to display multi-line records correctly |
| 181 |
if(text.indexOf(",") == -1 && text.indexOf("\"") == -1) //$NON-NLS-1$ //$NON-NLS-2$ |
273 |
if(text.indexOf(",") == -1 && text.indexOf("\"") == -1 && text.indexOf('\n') == -1 && text.indexOf('\r') == -1) //$NON-NLS-1$ //$NON-NLS-2$ |
| 182 |
return text; |
274 |
return text; |
| 183 |
|
275 |
|
| 184 |
text = text.replaceAll("\"", "\"\""); //$NON-NLS-1$ //$NON-NLS-2$ |
276 |
text = text.replaceAll("\"", "\"\""); //$NON-NLS-1$ //$NON-NLS-2$ |