source: other-projects/trunk/greenstone3-extension/mat/src/java/org/greenstone/gsdl3_extension/mat/servlet/PrintHTML.java@ 17365

Last change on this file since 17365 was 17365, checked in by cc108, 16 years ago

Updating Mat Source Code

File size: 146.2 KB
Line 
1package org.greenstone.gsdl3_extension.mat.servlet;
2
3import java.io.*;
4import java.text.SimpleDateFormat;
5import java.util.ArrayList;
6import java.util.Calendar;
7import java.util.Collection;
8import java.util.HashMap;
9import java.util.Iterator;
10import java.util.Map;
11import java.util.Set;
12
13import javax.xml.parsers.DocumentBuilder;
14import javax.xml.parsers.DocumentBuilderFactory;
15
16import org.w3c.dom.Document;
17import org.w3c.dom.Element;
18import org.w3c.dom.Node;
19import org.w3c.dom.NodeList;
20
21public class PrintHTML {
22
23 final String NORMAL = "normal";
24 final String WORST = "worst";
25 final String BEST = "best";
26 final String title1 ="Hide Empty Metadata ,";
27 final String title2 ="Hide Completed Metadata ,";
28 final String title3 ="Hide Documents with Empty Metadata ,";
29 final String title4 ="Hide Documents with Completed Metadata ,";
30 final String title5 ="No Available Graph";
31 final String metadataSet1 = "Dublin Core";
32 final String metadataSet2 = "Extracted";
33 final String spaceLeft = "<I>&laquo;";
34 final String spaceRight = "&raquo;</I>";
35 final String htmlSpace = "&nbsp;";
36 final String oddChar ="odd Character";
37 String linkIdentifier = "";
38 String cssString = "<link rel=\"stylesheet\" href=\"http://localhost:9090/greenstone3/mat/script/mat.css\" type=\"text/css\" >";
39 final String space ="space";
40 private HashMap url;
41 //servlet
42 //final String destination = "/research/cc108/greenstone3/web/mat/";
43 final String destination;
44 MetadataStats mds;
45 DataMaker dm;
46 Calendar cl;
47 SimpleDateFormat sdf;
48 PrintWriter printWriter;
49
50 public PrintHTML(MetadataStats ms, PrintWriter arg){
51 mds = ms;
52 printWriter = arg;
53 dm = new DataMaker(mds);
54 cl=Calendar.getInstance();
55 linkIdentifier = "dc.Identifier";
56 destination = mds.HTMLDirectory;
57 System.out.println(destination+" printhtml");
58 //linkIdentifier = "nzir_internal.Link";
59 sdf = new SimpleDateFormat(" dd MMM yyyy 'at' HH:mm:ss z 'GMT'Z");
60 setupMetadataLink("metadataElementURL");
61 }
62
63 private ArrayList getHideEmptyMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
64
65 printWriter.write("<!-- generating all possible page-->");
66 printWriter.flush();
67
68 if(id.length==0 || metadataName.length==0){return new ArrayList();}
69 ArrayList detailList = new ArrayList();
70 ArrayList alist = new ArrayList();
71 ArrayList nameList = new ArrayList();
72
73 for(int i = 0; i< metadataName.length; i++){
74 if(!dm.IsElementEmpty(metadataName[i])){
75 alist.add(dm.getMetadataRows(metadataName[i]));
76 nameList.add(metadataName[i]);
77 }
78 }
79
80 String[] metaDataElementName = new String[nameList.size()];
81
82 for(int i = 0; i< nameList.size(); i++){
83 metaDataElementName[i] = nameList.get(i).toString();
84 }
85
86 if(id.length==0 || metaDataElementName.length==0){return new ArrayList();}
87
88 detailList.add(alist);
89 detailList.add(id);
90 detailList.add(metaDataElementName);
91 printWriter.write("<!-- generating all possible page-->");
92 printWriter.flush();
93 return detailList;
94 }
95
96 private ArrayList getHideFullMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
97
98 printWriter.write("<!-- generating all possible page-->");
99 printWriter.flush();
100
101 if(id.length==0 || metadataName.length==0){return new ArrayList();}
102 ArrayList detailList = new ArrayList();
103 ArrayList alist = new ArrayList();
104 ArrayList nameList = new ArrayList();
105
106 for(int i = 0; i< metadataName.length; i++){
107 if(!dm.IsElementFull(metadataName[i])){
108 alist.add(dm.getMetadataRows(metadataName[i]));
109 nameList.add(metadataName[i]);
110 }
111 }
112
113 String[] metaDataElementName = new String[nameList.size()];
114
115 for(int i = 0; i< nameList.size(); i++){
116 metaDataElementName[i] = nameList.get(i).toString();
117 }
118
119 if(id.length==0 || metaDataElementName.length==0){return new ArrayList();}
120
121 detailList.add(alist);
122 detailList.add(id);
123 detailList.add(metaDataElementName);
124
125 printWriter.write("<!-- generating all possible page-->");
126 printWriter.flush();
127
128 return detailList;
129 }
130
131 private ArrayList getHideEmptyDocumentDetail(ArrayList dataset, String[] id, String[] metadataName){
132
133 printWriter.write("<!-- generating all possible page-->");
134 printWriter.flush();
135
136 if(id.length==0 || metadataName.length==0){return new ArrayList();}
137 ArrayList detailList = new ArrayList();
138 ArrayList alist = dm.removeDocument(dataset, id, 0);
139 ArrayList idList = dm.getRemovedID();
140 ArrayList newIDList = new ArrayList();
141
142 for(int i = 0; i< id.length; i++){
143 if(!idList.contains(id[i])){
144 newIDList.add(id[i]);
145 }
146 }
147 id = new String[newIDList.size()];
148 for(int i = 0; i<newIDList.size(); i++){
149 id[i] = newIDList.get(i).toString();
150 }
151
152 if(id.length==0 || metadataName.length==0){return new ArrayList();}
153
154 detailList.add(alist);
155 detailList.add(id);
156 detailList.add(metadataName);
157
158 printWriter.write("<!-- generating all possible page-->");
159 printWriter.flush();
160
161 return detailList;
162 }
163
164 private ArrayList getHideFullDocumentDetail(ArrayList dataset, String[] id, String[] metadataName){
165
166 printWriter.write("<!-- generating all possible page-->");
167 printWriter.flush();
168
169 if(id.length==0 || metadataName.length==0){return new ArrayList();}
170 ArrayList detailList = new ArrayList();
171 ArrayList alist = dm.removeDocument(dataset, id ,1);
172 ArrayList idList = dm.getRemovedID();
173 ArrayList newIDList = new ArrayList();
174
175 for(int i = 0; i< id.length; i++){
176 if(!idList.contains(id[i])){
177 newIDList.add(id[i]);
178 }
179 }
180 id = new String[newIDList.size()];
181 for(int i = 0; i<newIDList.size(); i++){
182 id[i] = newIDList.get(i).toString();
183 }
184
185 if(id.length==0 || metadataName.length==0){return new ArrayList();}
186
187 detailList.add(alist);
188 detailList.add(id);
189 detailList.add(metadataName);
190
191 printWriter.write("<!-- generating all possible page-->");
192 printWriter.flush();
193
194 return detailList;
195 }
196
197 /*
198 * private ArrayList getEmptyMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
199 ArrayList detailList = new ArrayList();
200 return detailList;
201 }
202 */
203
204 public void generateAllPossibleGraph(ArrayList Namelist,String[]ids,String[] names,String condition){
205 //System.out.println("I AM HERE");
206 /*
207 String condition = "";
208
209 if(conditionName.equalsIgnoreCase("dublin")){
210 condition = "dublin";
211 }
212 else{
213 condition = "other";
214 }
215 */
216 printWriter.write("<!-- generating all possible page-->");
217 printWriter.flush();
218
219 ArrayList dataList= Namelist;
220 String[] id = ids;
221 String[] metadataName = names;
222
223 ArrayList alist = new ArrayList();
224 ArrayList detailList = new ArrayList();
225 ArrayList new_dataList = new ArrayList();
226 String[] idList;
227 String[] metadataNameList;
228
229 //---------------------------------------------------------------------------------------------------------SS
230 //-----------------------------------------------------------------------SSSS
231 if(id.length==0 || metadataName.length==0){
232 //printWriter.write("generate SSSS empty");
233 generateEmptyGraph("SSSS",WORST,condition);
234 generateEmptyGraph("SSSS",BEST,condition);
235 }
236
237 else{
238 new_dataList = transformDataList(dataList,id);
239 //printWriter.write("generate SSSS");
240 //WriteHTML("SSSS",new_dataList,id,metadataName,NORMAL);
241 WriteHTML("SSSS",new_dataList,id,metadataName,WORST,"Show completed graph",condition);
242 WriteHTML("SSSS",new_dataList,id,metadataName,BEST,"Show completed graph",condition);
243 }
244 //-----------------------------------------------------------------------SSSH
245 //System.out.println("SSSH 1");
246 detailList = getHideFullDocumentDetail(dataList,id,metadataName);
247 //System.out.println("SSSH 2");
248 if(detailList.size()==0){
249 generateEmptyGraph("SSSH",WORST,condition);
250 generateEmptyGraph("SSSH",BEST,condition);
251 }
252 else{
253 alist = (ArrayList)detailList.get(0);
254 idList = (String[])detailList.get(1);
255 metadataNameList = (String[])detailList.get(2);
256 new_dataList = transformDataList(alist,idList);
257 //WriteHTML("SSSH",new_dataList,idList,metadataNameList,NORMAL);
258 WriteHTML("SSSH",new_dataList,idList,metadataNameList,WORST,title4,condition);
259 WriteHTML("SSSH",new_dataList,idList,metadataNameList,BEST,title4,condition);
260 }
261 //-----------------------------------------------------------------------SSHS
262 //System.out.println("SSSS");
263 detailList = getHideEmptyDocumentDetail(dataList,id,metadataName);
264 //System.out.println("SSSS");
265 if(detailList.size()==0){
266 generateEmptyGraph("SSHS",WORST,condition);
267 generateEmptyGraph("SSHS",BEST,condition);
268 generateEmptyGraph("SSHH",WORST,condition);
269 generateEmptyGraph("SSHH",BEST,condition);
270 }
271 else{
272 alist = (ArrayList)detailList.get(0);
273 idList = (String[])detailList.get(1);
274 metadataNameList = (String[])detailList.get(2);
275 new_dataList = transformDataList(alist,idList);
276 //WriteHTML("SSHS",new_dataList,idList,metadataNameList,NORMAL);
277 WriteHTML("SSHS",new_dataList,idList,metadataNameList,WORST,title3,condition);
278 WriteHTML("SSHS",new_dataList,idList,metadataNameList,BEST,title3,condition);
279 //-----------------------------------------------------------------------SSHH
280 detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
281 if(detailList.size()==0){
282 generateEmptyGraph("SSHH",WORST,condition);
283 generateEmptyGraph("SSHH",BEST,condition);
284 }
285 else{
286 alist = (ArrayList)detailList.get(0);
287 idList = (String[])detailList.get(1);
288 metadataNameList = (String[])detailList.get(2);
289 new_dataList = transformDataList(alist,idList);
290 //WriteHTML("SSHH",new_dataList,idList,metadataNameList,NORMAL);
291 WriteHTML("SSHH",new_dataList,idList,metadataNameList,WORST,title3+title4,condition);
292 WriteHTML("SSHH",new_dataList,idList,metadataNameList,BEST,title3+title4,condition);
293 }
294 }
295
296
297 //---------------------------------------------------------------------------------------------------------SH
298 ArrayList xList = new ArrayList();
299 String[] idListCopy;
300 String[] metadataNameListCopy;
301
302 //-----------------------------------------------------------------------SHSS
303 detailList = getHideFullMetadataDetail(dataList,id,metadataName);
304
305 if(detailList.size()==0){
306 generateEmptyGraph("SHSS",WORST,condition);
307 generateEmptyGraph("SHSS",BEST,condition);
308
309 generateEmptyGraph("SHSH",WORST,condition);
310 generateEmptyGraph("SHSH",BEST,condition);
311
312 generateEmptyGraph("SHHS",WORST,condition);
313 generateEmptyGraph("SHHS",BEST,condition);
314
315 generateEmptyGraph("SHHH",WORST,condition);
316 generateEmptyGraph("SHHH",BEST,condition);
317 }
318 else{
319 alist = (ArrayList)detailList.get(0);
320 idList = (String[])detailList.get(1);
321 metadataNameList = (String[])detailList.get(2);
322
323 xList = (ArrayList)alist.clone();
324 idListCopy = (String[]) idList.clone();
325 metadataNameListCopy = (String[])metadataNameList.clone();
326
327 new_dataList = transformDataList(alist,idList);
328 //WriteHTML("SHSS",new_dataList,idList,metadataNameList,NORMAL);
329 WriteHTML("SHSS",new_dataList,idList,metadataNameList,WORST,title2,condition);
330 WriteHTML("SHSS",new_dataList,idList,metadataNameList,BEST,title2,condition);
331
332 //-----------------------------------------------------------------------SHHS
333 detailList = getHideEmptyDocumentDetail((ArrayList)xList.clone(),(String[])idListCopy.clone(),(String[])metadataNameListCopy.clone());
334 //System.out.println("SHHS"+detailList.size());
335 if(detailList.size()==0){
336 generateEmptyGraph("SHHS",WORST,condition);
337 generateEmptyGraph("SHHS",BEST,condition);
338
339 generateEmptyGraph("SHHH",WORST,condition);
340 generateEmptyGraph("SHHH",BEST,condition);
341 }
342 else{
343 alist = (ArrayList)detailList.get(0);
344 idList = (String[])detailList.get(1);
345 metadataNameList = (String[])detailList.get(2);
346 //if(idList.length==0 || metadataName.length==0){}
347 new_dataList = transformDataList(alist,idList);
348 //WriteHTML("SHHS",new_dataList,idList,metadataNameList,NORMAL);
349 WriteHTML("SHHS",new_dataList,idList,metadataNameList,WORST,title2+title3,condition);
350 WriteHTML("SHHS",new_dataList,idList,metadataNameList,BEST,title2+title3,condition);
351 //step
352 //-----------------------------------------------------------------------SHHH
353 detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
354 if(detailList.size()==0){
355 generateEmptyGraph("SHHH",WORST,condition);
356 generateEmptyGraph("SHHH",BEST,condition);
357 }
358 else{
359 alist = (ArrayList)detailList.get(0);
360 idList = (String[])detailList.get(1);
361 metadataNameList = (String[])detailList.get(2);
362
363 new_dataList = transformDataList(alist,idList);
364 //WriteHTML("SHHH",new_dataList,idList,metadataNameList,NORMAL);
365 WriteHTML("SHHH",new_dataList,idList,metadataNameList,WORST,title2+title3+title4,condition);
366 WriteHTML("SHHH",new_dataList,idList,metadataNameList,BEST,title2+title3+title4,condition);
367 }
368 }
369
370 //-----------------------------------------------------------------------SHSH
371 detailList = getHideFullDocumentDetail((ArrayList)xList.clone(),(String[])idListCopy.clone(),(String[])metadataNameListCopy.clone());
372 if(detailList.size()==0){
373 generateEmptyGraph("SHSH",WORST,condition);
374 generateEmptyGraph("SHSH",BEST,condition);
375 }
376 else{
377 alist = (ArrayList)detailList.get(0);
378 idList = (String[])detailList.get(1);
379 metadataNameList = (String[])detailList.get(2);
380
381 new_dataList = transformDataList(alist,idList);
382 //WriteHTML("SHSH",new_dataList,idList,metadataNameList,NORMAL);
383 WriteHTML("SHSH",new_dataList,idList,metadataNameList,WORST,title2+title4,condition);
384 WriteHTML("SHSH",new_dataList,idList,metadataNameList,BEST,title2+title4,condition);
385 }
386 }
387
388 //---------------------------------------------------------------------------------------------------------HS
389 ArrayList xList1 = new ArrayList();
390 String[] idListCopy1;
391 String[] metadataNameListCopy1;
392
393 //-----------------------------------------------------------------------HSSS
394 detailList = getHideEmptyMetadataDetail(dataList,id,metadataName);
395
396 if(detailList.size()==0){
397 generateEmptyGraph("HSSS",WORST,condition);
398 generateEmptyGraph("HSSS",BEST,condition);
399
400 generateEmptyGraph("HSHS",WORST,condition);
401 generateEmptyGraph("HSHS",BEST,condition);
402
403 generateEmptyGraph("HSHH",WORST,condition);
404 generateEmptyGraph("HSHH",BEST,condition);
405
406 generateEmptyGraph("HSSH",WORST,condition);
407 generateEmptyGraph("HSSH",BEST,condition);
408 }
409 else{
410 alist = (ArrayList)detailList.get(0);
411 idList = (String[])detailList.get(1);
412 metadataNameList = (String[])detailList.get(2);
413
414 xList1 = (ArrayList)alist.clone();
415 idListCopy1 = (String[]) idList.clone();
416 metadataNameListCopy1 = (String[])metadataNameList.clone();
417
418 new_dataList = transformDataList(alist,idList);
419 //WriteHTML("HSSS",new_dataList,idList,metadataNameList,NORMAL);
420 WriteHTML("HSSS",new_dataList,idList,metadataNameList,WORST,title1,condition);
421 WriteHTML("HSSS",new_dataList,idList,metadataNameList,BEST,title1,condition);
422
423 //-----------------------------------------------------------------------HSHS
424 detailList = getHideEmptyDocumentDetail((ArrayList)xList1.clone(),(String[])idListCopy1.clone(),(String[])metadataNameListCopy1.clone());
425 if(detailList.size()==0){
426 generateEmptyGraph("HSHS",WORST,condition);
427 generateEmptyGraph("HSHS",BEST,condition);
428
429 generateEmptyGraph("HSHH",WORST,condition);
430 generateEmptyGraph("HSHH",BEST,condition);
431 }
432 else{
433 alist = (ArrayList)detailList.get(0);
434 idList = (String[])detailList.get(1);
435 metadataNameList = (String[])detailList.get(2);
436
437 new_dataList = transformDataList(alist,idList);
438 //WriteHTML("HSHS",new_dataList,idList,metadataNameList,NORMAL);
439 WriteHTML("HSHS",new_dataList,idList,metadataNameList,WORST,title1+title3,condition);
440 WriteHTML("HSHS",new_dataList,idList,metadataNameList,BEST,title1+title3,condition);
441
442 //-----------------------------------------------------------------------HSHH
443 detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
444 if(detailList.size()==0){
445 generateEmptyGraph("HSHH",WORST,condition);
446 generateEmptyGraph("HSHH",BEST,condition);
447 }
448 else{
449 alist = (ArrayList)detailList.get(0);
450 idList = (String[])detailList.get(1);
451 metadataNameList = (String[])detailList.get(2);
452
453 new_dataList = transformDataList(alist,idList);
454 //WriteHTML("HSHH",new_dataList,idList,metadataNameList,NORMAL);
455 WriteHTML("HSHH",new_dataList,idList,metadataNameList,WORST,title1+title3+title4,condition);
456 WriteHTML("HSHH",new_dataList,idList,metadataNameList,BEST,title1+title3+title4,condition);
457 }
458 }
459
460 //-----------------------------------------------------------------------HSSH
461 detailList = getHideFullDocumentDetail((ArrayList)xList1.clone(),(String[])idListCopy1.clone(),(String[])metadataNameListCopy1.clone());
462 if(detailList.size()==0){
463 generateEmptyGraph("HSSH",WORST,condition);
464 generateEmptyGraph("HSSH",BEST,condition);
465 }
466 else{
467 alist = (ArrayList)detailList.get(0);
468 idList = (String[])detailList.get(1);
469 metadataNameList = (String[])detailList.get(2);
470
471 new_dataList = transformDataList(alist,idList);
472 //WriteHTML("HSSH",new_dataList,idList,metadataNameList,NORMAL);
473 WriteHTML("HSSH",new_dataList,idList,metadataNameList,WORST,title1+title4,condition);
474 WriteHTML("HSSH",new_dataList,idList,metadataNameList,BEST,title1+title4,condition);
475 }
476 }
477
478 //---------------------------------------------------------------------------------------------------------HH
479 ArrayList xList2 = new ArrayList();
480 String[] idListCopy2;
481 String[] metadataNameListCopy2;
482
483 //-----------------------------------------------------------------------HHSS
484 detailList = getHideEmptyMetadataDetail(dataList,id,metadataName);
485 if(detailList.size()==0){
486 generateEmptyGraph("HHSS",WORST,condition);
487 generateEmptyGraph("HHSS",BEST,condition);
488
489 generateEmptyGraph("HHHS",WORST,condition);
490 generateEmptyGraph("HHHS",BEST,condition);
491
492 generateEmptyGraph("HHHH",WORST,condition);
493 generateEmptyGraph("HHHH",BEST,condition);
494
495 generateEmptyGraph("HHSH",WORST,condition);
496 generateEmptyGraph("HHSH",BEST,condition);
497 }
498 else{
499 alist = (ArrayList)detailList.get(0);
500 idList = (String[])detailList.get(1);
501 metadataNameList = (String[])detailList.get(2);
502
503 detailList = getHideFullMetadataDetail(alist,idList,metadataNameList);
504 //System.out.println(detailList.size());
505 if(detailList.size()==0){
506 generateEmptyGraph("HHSS",WORST,condition);
507 generateEmptyGraph("HHSS",BEST,condition);
508
509 generateEmptyGraph("HHHS",WORST,condition);
510 generateEmptyGraph("HHHS",BEST,condition);
511
512 generateEmptyGraph("HHHH",WORST,condition);
513 generateEmptyGraph("HHHH",BEST,condition);
514
515 generateEmptyGraph("HHSH",WORST,condition);
516 generateEmptyGraph("HHSH",BEST,condition);
517 }
518 else{
519 //System.out.println("bad"+detailList.size());
520 alist = (ArrayList)detailList.get(0);
521 //System.out.println("bad");
522 idList = (String[])detailList.get(1);
523 //System.out.println("bad");
524 metadataNameList = (String[])detailList.get(2);
525 //System.out.println("bad");
526
527 xList2 = (ArrayList)alist.clone();
528 idListCopy2 = (String[]) idList.clone();
529 metadataNameListCopy2 = (String[])metadataNameList.clone();
530
531 new_dataList = transformDataList(alist,idList);
532 //WriteHTML("HHSS",new_dataList,idList,metadataNameList,NORMAL);
533 WriteHTML("HHSS",new_dataList,idList,metadataNameList,WORST,title1+title2,condition);
534 WriteHTML("HHSS",new_dataList,idList,metadataNameList,BEST,title1+title2,condition);
535
536
537 //---------------------------------------------------------------------- HHSH
538 detailList = getHideFullDocumentDetail((ArrayList)xList2.clone(),(String[])idListCopy2.clone(),(String[])metadataNameListCopy2.clone());
539 if(detailList.size()==0){
540 generateEmptyGraph("HHSH",WORST,condition);
541 generateEmptyGraph("HHSH",BEST,condition);
542 }
543 else{
544 alist = (ArrayList)detailList.get(0);
545 idList = (String[])detailList.get(1);
546 metadataNameList = (String[])detailList.get(2);
547
548 new_dataList = transformDataList(alist,idList);
549 //WriteHTML("HHSH",new_dataList,idList,metadataNameList,NORMAL);
550 WriteHTML("HHSH",new_dataList,idList,metadataNameList,WORST,title1+title2+title4,condition);
551 WriteHTML("HHSH",new_dataList,idList,metadataNameList,BEST,title1+title2+title4,condition);
552 }
553 //----------------------------------------------------------------------HHHS
554 detailList = getHideEmptyDocumentDetail((ArrayList)xList2.clone(),(String[])idListCopy2.clone(),(String[])metadataNameListCopy2.clone());
555 if(detailList.size()==0){
556 generateEmptyGraph("HHHS",WORST,condition);
557 generateEmptyGraph("HHHS",BEST,condition);
558
559 generateEmptyGraph("HHHH",WORST,condition);
560 generateEmptyGraph("HHHH",BEST,condition);
561 }
562 else{
563 alist = (ArrayList)detailList.get(0);
564 idList = (String[])detailList.get(1);
565 metadataNameList = (String[])detailList.get(2);
566
567 new_dataList = transformDataList(alist,idList);
568 //WriteHTML("HHHS",new_dataList,idList,metadataNameList,NORMAL);
569 WriteHTML("HHHS",new_dataList,idList,metadataNameList,WORST,title1+title2+title3,condition);
570 WriteHTML("HHHS",new_dataList,idList,metadataNameList,BEST,title1+title2+title3,condition);
571
572 //----------------------------------------------------------------------HHHH
573 detailList = getHideFullDocumentDetail((ArrayList)alist.clone(),(String[])idList.clone(),(String[])metadataNameList.clone());
574 if(detailList.size()==0){
575 generateEmptyGraph("HHHH",WORST,condition);
576 generateEmptyGraph("HHHH",BEST,condition);
577 }
578 else{
579 alist = (ArrayList)detailList.get(0);
580 idList = (String[])detailList.get(1);
581 metadataNameList = (String[])detailList.get(2);
582
583 new_dataList = transformDataList(alist,idList);
584 //WriteHTML("HHHH",new_dataList,idList,metadataNameList,NORMAL);
585 WriteHTML("HHHH",new_dataList,idList,metadataNameList,WORST,title1+title2+title3+title4,condition);
586 WriteHTML("HHHH",new_dataList,idList,metadataNameList,BEST,title1+title2+title3+title4,condition);
587 }
588 }
589 }
590 }
591 }
592
593 private ArrayList transformDataList(ArrayList list, String[] ids){
594
595 printWriter.write("<!-- generating all possible page-->");
596 printWriter.flush();
597
598 //System.out.println("warning2");
599 ArrayList wholeList = new ArrayList();
600
601 for(int i = 0; i< ids.length; i++){
602 ArrayList idList = new ArrayList();
603 for(int j = 0; j<list.size();j++){
604 int[] datarows = (int[]) list.get(j);
605 idList.add(new Integer (datarows[i]));
606 }
607 wholeList.add(idList);
608 }
609
610 for(int i = 0; i< wholeList.size(); i++){
611 ArrayList alist = (ArrayList)wholeList.get(i);
612 int[] rows = new int[alist.size()];
613 for(int j = 0; j< alist.size(); j++){
614 rows[j] = ((Integer)alist.get(j)).intValue();
615 }
616 wholeList.remove(i);
617 wholeList.add(i,rows);
618 }
619 //System.out.println("warning3");
620
621 printWriter.write("<!-- generating all possible page-->");
622 printWriter.flush();
623
624 return wholeList;
625
626 }
627
628 private void generateEmptyGraph(String fileName,String condition,String suffix){
629 printWriter.write("<!-- generating all possible page-->");
630 printWriter.flush();
631 String suf = suffix;
632 if(!suffix.equalsIgnoreCase("dublin")){
633 suf = "other";
634 }
635 String cases = condition;
636 String collectionFolder = mds.getCollectionName();
637 //System.out.println(fileName+cases+" err");
638 try{
639 FileWriter fstream = new FileWriter(destination+"/"+suf+"_"+fileName+"_"+cases+".html");
640 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+"_"+cases+".html");
641 BufferedWriter out = new BufferedWriter(fstream);
642 out.write("<!-- This comment keeps IE6/7 in the reliable quirks mode -->\r\n");
643 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
644 out.write("<html>\r\n");
645 out.write("<head>\r\n<title> No Available Chart</title>\r\n");
646
647 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
648 out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
649
650 //out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
651 out.write("</head>\r\n");
652 out.write("<p><a href=\" Overall.html \">Summary</a></p>");
653 out.write("<body>\r\n");
654 out.write("<p>No data available to render chart.</p>\r\n");
655 out.write("<p>Reason: Document number is zero or Metadata element number is zero </p>\r\n");
656 out.write("</body></html>\r\n");
657 out.close();
658 fstream.close();
659
660 }catch(Exception e){}
661 printWriter.write("<!-- generating all possible page-->");
662 printWriter.flush();
663 }
664 private void WriteHTML(String fileName, ArrayList dataset, String[] ids, String[] metadataName, String condition, String title, String suffix){
665
666 int blueDot = 0;
667 String cases = condition;
668 String suf = suffix;
669 if(!suffix.equalsIgnoreCase("dublin")){
670 suf = "other";
671 }
672 try{
673 printWriter.write("<!-- generating all possible page-->");
674 printWriter.flush();
675
676 //String str = sdf.format(cl.getTime());
677 //DataMaker dmx = new DataMaker(mds);
678 //printWriter.write("before getting url");
679 //HashMap tempMap = mds.getMetadataSetMap();
680 //mds.get
681 //hjkh
682 ArrayList tempList = mds.getMetadataNameList();
683 ArrayList urlIDList;
684 if(tempList.contains("dc.Identifier") && linkIdentifier.equals("dc.Identifier")){
685 urlIDList = dm.getURLMap("dc.Identifier");
686 }
687 else if(tempList.contains("nzir_internal.Link") && linkIdentifier.equals("nzir_internal.Link")){
688 urlIDList = dm.getURLMap("nzir_internal.Link");
689 }
690 else{
691 urlIDList = new ArrayList();
692 }
693 //printWriter.write("after getting url");
694 String collectionFolder = mds.getCollectionName();
695 //int cols = (metadataName.length +2 )*100;
696 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+"_"+cases+".html");
697 FileWriter fstream = new FileWriter(destination+"/"+suf+"_"+fileName+"_"+cases+".html");
698
699 BufferedWriter out = new BufferedWriter(fstream);
700 out.write("<!-- This comment keeps IE6/7 in the reliable quirks mode -->\r\n");
701 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
702 out.write("<html>\r\n");
703 out.write("<head>\r\n<title>"+title+"</title>\r\n");
704
705 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
706 out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
707
708 out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
709 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");
710 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");
711 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");
712 //out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
713 // <script src="http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js"></script>
714 //<script src="http://yui.yahooapis.com/2.4.1/build/event/event-min.js"></script>
715 // <script src="http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js"></script>
716
717 out.write("</head>\r\n");
718 out.write ("<p><a href=\" Overall.html \">Summary</a></p>");
719 out.write("<body id=\""+mds.getCollectionName()+"\" onLoad=\"reconfig()\">\r\n");
720
721 out.write("<div id=\"container\">\r\n");
722 out.write("<div class=\"tableContainer\">\r\n");
723
724 out.write ("<table cellspacing=\"0\">\r\n");
725
726
727 out.write ("<thead>\r\n");
728 out.write ("<tr>\r\n");
729 out.write("<td class=\"qh\">Info\r\n");
730 out.write("<td class=\"qh\">URL\r\n");
731 for(int a = 0; a< metadataName.length; a++){
732 out.write("<td>"+ metadataName[a]+"\r\n");
733 }
734
735 out.write ("</thead>\r\n<tfoot>\r\n<tr>\r\n");
736
737 out.write("<td class=\"qh\">&nbsp;\r\n");
738 out.write("<td class=\"qh\">&nbsp;\r\n");
739 for(int a = 0; a< metadataName.length; a++){
740 out.write("<td>"+ dm.Mean(metadataName[a])+"%\r\n");
741 }
742
743 out.write ("</tfoot>\r\n<tbody>\r\n");
744
745 if(cases.equals("normal")){
746 for(int i = ids.length; i>0; i--){
747 out.write ("<tr>");
748 int[] datarows = (int[])dataset.get(i-1);
749
750 for(int j = 0; j<datarows.length; j++){
751
752 if(datarows[j]==1){
753 out.write ("<td class=\"b\">");
754 blueDot++;
755 }
756 else {
757 out.write ("<td>&nbsp;");
758 }
759 }
760 }
761 }
762 else{
763 ArrayList idList = new ArrayList();
764 for(int i = 0; i<ids.length;i++){
765 idList.add(ids[i]);
766 }
767
768
769 HashMap hp = new HashMap();
770
771 for(int i = ids.length; i>0; i--){
772 String idValue = ids[i-1];
773 int dots = 0;
774 int[] datarows = (int[])dataset.get(i-1);
775 for(int j = 0; j<datarows.length; j++){
776 if(datarows[j]==1){
777 dots++;
778 }
779 }
780 hp.put(idValue,new Integer(dots));
781
782 }
783 ArrayList alist = dm.sortMap(hp);
784 String[] idIntValue = new String[alist.size()];
785 for(int i = 0; i< alist.size(); i++){
786 Map.Entry entry = (Map.Entry) alist.get(i);
787 String idElement = ((String) entry.getKey());
788 idIntValue[i] = idElement;
789 }
790
791 if(cases.equals("worst")){
792
793 for(int i = 0; i<idIntValue.length; i++){
794
795 printWriter.write("<!-- generating all possible page -->");
796 printWriter.flush();
797
798
799 int value = idList.indexOf(idIntValue[i]);
800 int[] datarows = (int[])dataset.get(value);
801
802 out.write ("<tr id=\""+idIntValue[i].substring(4)+"\">\r\n");
803 out.write("<td class=\"E\" onclick=\"GD(this)\">&nbsp;\r\n");
804
805 if(urlIDList.contains(idIntValue[i])){
806
807 out.write("<td class=\"qh\" onclick=\"GX(this)\"><span title=\"open URL in new window\">open</span>\r\n");
808 }
809 else{
810 out.write("<td>\r\n");
811 }
812 for(int j = 0; j<datarows.length; j++){
813
814 if(datarows[j]==1){
815 out.write ("<td class=\"b\">\r\n");
816 blueDot++;
817 }
818 else {
819
820 out.write ("<td class=\"w\">\r\n");
821 }
822 }
823
824 //out.write ("</tr>\r\n");
825 }
826 }
827
828 if(cases.equals("best")){
829 for(int i = idIntValue.length; i>0; i--){
830
831
832 printWriter.write("<!-- generating all possible page -->");
833 printWriter.flush();
834
835 int value = idList.indexOf(idIntValue[i-1]);
836 int[] datarows = (int[])dataset.get(value);
837
838 out.write ("<tr id=\""+idIntValue[i-1].substring(4)+"\">\r\n");
839 out.write("<td class=\"E\" onclick=\"GD(this)\">&nbsp;\r\n");
840 //out.write("<td class=\"qh\" onclick=\"GX(this)\">URL\r\n");
841
842 if(urlIDList.contains(idIntValue[i-1])){
843 out.write("<td class=\"qh\" onclick=\"GX(this)\"><span title=\"open URL in new window\">open</span>\r\n");
844 }
845 else{
846
847 out.write("<td>\r\n");
848 }
849
850 //out.write("<td class=\"qh\" onclick=\"GX(this)\"><span title=\"open URL in new window\">open</span>\r\n");
851 for(int j = 0; j<datarows.length; j++){
852
853 if(datarows[j]==1){
854 out.write ("<td class=\"b\">\r\n");
855 blueDot++;
856 }
857 else {
858 out.write ("<td class=\"w\">\r\n");
859 }
860 }
861 //out.write("<td class=\"E\" onmousemove=\"GD(this)\">&nbsp;\r\n");
862 }
863 }
864 }
865 out.write ("</tbody>\r\n");
866
867 out.write ("</table>\r\n</div></div>\r\n");
868
869 int t1 = ids.length;
870 int t3 = metadataName.length;
871
872 int t4 = t1*t3;
873 out.write("<table>\r\n<tbody class=\"table1\">");
874 out.write("<tr>\r\n");
875 HashMap tempMap = mds.getMetadataSetMap();
876 MetadataSet ms = (MetadataSet)tempMap.get(suffix);
877 out.write("<td class=\"bfont\">This subset shows "+t1+" out of "+mds.getDocNum()+" documents");
878 //out.write("<td class=\"bfont\">This subset shows "+t1+" out of "+(ms.getIndexsList().size())+" documents");
879 out.write("<td class=\"bfont\">"+blueDot+" out of "+(mds.getDocNum()*t3)+" metadata items are defined");
880 out.write("<tr>\r\n");
881 //out.write("<td class=\"bfont\">This subset shows "+t3+" out of "+mds.metadataNameList.size()+" metadata elements");
882 out.write("<td class=\"bfont\">This subset shows "+t3+" out of "+(ms.getIndexsList().size())+" metadata elements");
883 out.write("<td class=\"bfont\">Subset completeness: "+dm.round((double)(blueDot*100/t4),5)+"%");
884 //out.write ("<p align=center> <a href=\" Overall.html \">Overall Statistics</a></p>");
885 out.write("</table>\r\n");
886 out.write ("<p> <a href=\"Overall.html \">Summary</a></p>");
887 out.write ("</body></html>");
888 //Close the output stream
889 out.close();
890 fstream.close();
891 }catch (Exception e){//Catch exception if any
892 e.printStackTrace(printWriter);
893 //System.err.println("Error: " + e.getMessage());
894 }
895
896 printWriter.write("<!-- generating all possible page-->");
897 printWriter.flush();
898 }
899
900
901 public void generateOverallStatisticsPage(HashMap MetadataSetMap){
902 //System.out.println("overall start");
903 String fileName = "Overall";
904
905 ArrayList wholeList = new ArrayList();
906 HashMap hp = mds.getMetadataSetMap();
907 Collection c = hp.values();
908 Iterator i = c.iterator();
909 int counter = 0;
910 String[][] MetadataData = new String[c.size()][2];
911 while(i.hasNext()){
912 MetadataSet mds = (MetadataSet)i.next();
913 wholeList.add(mds);
914 ArrayList newMDS = new ArrayList();
915 newMDS.add(mds);
916
917 MetadataData[counter][0] = mds.getName();
918 MetadataData[counter][1] = dm.getSingleMetadataSetCompleteness(newMDS)+"%";
919 //System.out.println(MetadataData[counter][0]+MetadataData[counter][1]);
920 counter++;
921 }
922
923 try{
924 printWriter.write("<!-- generating all possible page-->");
925 printWriter.flush();
926
927 String str = sdf.format(cl.getTime());
928 String collectionFolder = mds.getCollectionName();
929
930 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
931 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
932 BufferedWriter out = new BufferedWriter(fstream);
933
934 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
935 out.write("<html>\r\n");
936 out.write("<head><title>Summary</title>\r\n");
937 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
938 //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
939 out.write("<style type=\"text/css\">\r\n");
940 out.write(".tam{height:20; text-align:right}\r\n");
941 out.write("th{height:20; text-align:left}\r\n");
942 out.write("body{font-family: Arial;}\r\n");
943 out.write("</style>\r\n");
944 out.write("<script type=\"text/javascript\" src=\"../script/status3.js\"></script>\r\n");
945 out.write("</head>\r\n");
946
947 out.write("<body>\r\n");
948 out.write ("<td> <div style=\"float:left;\"> <a href=\"http://localhost:9090/greenstone3/mat\">Mat Home</a></div>");
949 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
950 // out.write("<p align=\"right\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Short feedback survey about the Mat tool</a></p>");
951 //out.write("<p> <a href=\"http://www.nzdl.org/greenstone3/mat\">Mat Home</a></p>");
952 out.write("<h3 align=\"center\">Summary</h3>\r\n");
953
954 out.write("<table border=1 align=\"center\">\r\n");
955 out.write("<colgroup width=\"300\" span=\"2\">\r\n");
956
957 /*
958 out.write("<tr>\r\n");
959 out.write("<th>Collection: </th>\r\n");
960 out.write("<td class=\"tam\">"+mds.getCollectionName()+"\r\n");
961 out.write("</tr>\r\n");
962 */
963
964 out.write("<tr>\r\n");
965 out.write("<th>OAI URL: </th>\r\n");
966 if(mds.getOAIURL().length()>50){
967 out.write("<td class=\"tam\"><font size=\"2px\"><a href=\""+mds.getOAIURL()+"\">"+mds.getOAIURL().substring(0,47)+"....</a></font>\r\n");
968 }
969 else{
970 out.write("<td class=\"tam\"><font size=\"2px\"><a href=\""+mds.getOAIURL()+"\">"+mds.getOAIURL()+"</a></font>\r\n");
971 }
972 out.write("</tr>\r\n");
973 /*
974 out.write("<tr>\r\n");
975 out.write("<th>Metadata Prefix:\r\n");
976 out.write("<td class=\"tam\">"+mds.getOaiPrefix()+"\r\n");
977 out.write("</tr>\r\n");
978 */
979 out.write("<tr>\r\n");
980 out.write("<th>Number of Records:\r\n");
981 out.write("<td class=\"tam\">"+mds.getDocNum()+"\r\n");
982 out.write("</tr>\r\n");
983
984 /*
985 out.write("<tr>\r\n");
986 out.write("<th>Number of Metadata Sets:\r\n");
987 out.write("<td class=\"tam\">"+mds.getMetadataSetMap().size()+"\r\n");
988 out.write("</tr>\r\n");
989
990 out.write("<tr>\r\n");
991 out.write("<th>Overall Metadata Completeness:\r\n");
992 out.write("<td class=\"tam\">"+dm.getSingleMetadataSetCompleteness(wholeList)+"%\r\n");
993 out.write("</tr>\r\n</table>");
994 */
995
996 out.write("<table border=1 align=\"center\">\r\n");
997 out.write("<colgroup width=\"300\" span=\"2\">\r\n");
998 out.write("<tr>\r\n");
999 out.write("<th>Metadata:\r\n");
1000 out.write("<td class=\"tam\"><b>Completeness</b>\r\n");
1001 out.write("</tr><br>\r\n");
1002
1003 for(int a = 0; a<MetadataData.length; a++){
1004 out.write ("<tr>\r\n");
1005 if(MetadataData[a][0].equalsIgnoreCase("dublin")){
1006 out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet1+"</a>");
1007 }
1008 else if (MetadataData[a][0].equalsIgnoreCase("extracted")){
1009 out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet2+"</a>");
1010 }
1011 else{
1012 out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+MetadataData[a][0]+"</a>");
1013 }
1014 //out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+MetadataData[a][0] +"</a>");
1015 out.write ("<td class=\"tam\"> "+MetadataData[a][1]);
1016 out.write ("</tr>\r\n");
1017 }
1018 out.write ("</table>");
1019 out.write("<br>\r\n");
1020 out.write("<FORM name=\"test\" onsubmit=\"checkStatus()\" action=\"\">");
1021 out.write("<table border=1 align=\"center\">\r\n");
1022 out.write ("<colgroup width=\"606\" span=\"1\">\r\n");
1023 out.write("<tr>\r\n<th>Customize Visualization");
1024 out.write("<tr>\r\n<td><LABEL FOR=\"H1\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H1\">Hide Empty Metadata Elements</LABEL>");
1025 out.write("<tr>\r\n<td><LABEL FOR=\"H2\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H2\">Hide Completed Metadata Elements</LABEL>");
1026 out.write("<tr>\r\n<td><LABEL FOR=\"H3\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H3\">Hide Documents with Empty Metadata Elements</LABEL>");
1027 out.write("<tr>\r\n<td><LABEL FOR=\"H4\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H4\">Hide Documents with Completed Metadata Elements</LABEL>");
1028 out.write("<tr>\r\n<th>Metadata: ");
1029
1030 ///////////////////////////////////////
1031
1032 //out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>Dublin Core</LABEL>");
1033 //out.write("<tr>\r\n<td><LABEL FOR=\"C2\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C2\" checked>Extracted</LABEL>");
1034 //out.write("<tr>\r\n<td><LABEL FOR=\"C3\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C3\" checked >Both</LABEL>");
1035
1036 if(MetadataData.length==1){
1037 //out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>"+MetadataData[0][0]+"</LABEL>");
1038 if(MetadataData[0][0].equalsIgnoreCase("dublin")){
1039 out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked> Dublin Core </LABEL>");
1040 }
1041 else {
1042 out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\" checked>"+MetadataData[0][0]+"</LABEL>");
1043 }
1044 }
1045 else{
1046 for(int a = 0; a<MetadataData.length; a++){
1047 if(a==0){
1048 if(MetadataData[a][0].equalsIgnoreCase("dublin")){
1049 out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>Dublin Core</LABEL>");
1050 }
1051 else {
1052 out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\" checked>"+MetadataData[a][0]+"</LABEL>");
1053 }
1054 }
1055 else{
1056 if(MetadataData[a][0].equalsIgnoreCase("dublin")){
1057 out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\">"+MetadataData[a][0]+"</LABEL>");
1058 }
1059 else{
1060 out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\">"+MetadataData[a][0]+"</LABEL>");
1061 }
1062
1063 }
1064 }
1065 }
1066
1067 ////////////////////////////////////////////////////////////////////////////////////////////////
1068 out.write("<tr>\r\n<th>Order By Completeness : ");
1069 out.write("<tr>\r\n<td><LABEL FOR=\"R1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"order\" ID=\"R1\">Best Case to Worst Case</LABEL>");
1070 out.write("<tr>\r\n<td><LABEL FOR=\"R2\"><INPUT align=\"left\" TYPE=\"radio\" name = \"order\" ID=\"R2\" checked >Worst Case to Best Case</LABEL>");
1071 out.write("</table><p align=\"center\"><INPUT TYPE=\"button\" VALUE=\"Show Visualization\" onClick=\"checkStatus()\"> </FORM>");
1072 //out.write("<p align=\"right\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Short feedback survey about the Mat tool</a></p>");
1073 out.write("<p align=\"center\">"+str+"</p>");
1074 //out.write("<p align=\"left\">Comments to <a href=\"http://www.cs.waikato.ac.nz/~daven/\">Dave Nichols</a></p>");
1075 out.write("</body></html>");
1076 //Close the output stream
1077 out.close();
1078 fstream.close();
1079 }catch (Exception e){//Catch exception if any
1080 //System.out.println("overall");
1081 System.err.println("Error: " + e.getMessage());
1082 }
1083 printWriter.write("<!-- generating all possible page-->");
1084 printWriter.flush();
1085 //System.out.println("overall ends");
1086
1087 }
1088
1089 /*
1090 public void generateMetadataSetDetailPage(HashMap MetadataSetMap){
1091
1092 Collection c = MetadataSetMap.values();
1093 Iterator i = c.iterator();
1094 while(i.hasNext()){
1095 MetadataSet mds = (MetadataSet)i.next();
1096
1097 }
1098 }
1099 */
1100
1101 public void WriteMetadataSetDetailHTML(MetadataSet mdset){
1102 String fileName = mdset.getName();
1103 //DataMaker dmx = new DataMaker(mds);
1104 //System.out.println("set start");
1105 try{
1106
1107 printWriter.write("<!-- generating all possible page-->");
1108 printWriter.flush();
1109
1110 String str = sdf.format(cl.getTime());
1111 String collectionFolder = mds.getCollectionName();
1112 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
1113 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
1114 BufferedWriter out = new BufferedWriter(fstream);
1115 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
1116 out.write("<html>\r\n");
1117 out.write("<head>\r\n<title>Metadata Detail</title>\r\n");
1118 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
1119 //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
1120 out.write("<style type=\"text/css\">\r\n");
1121 out.write("td{height:20;text-align:right;}\r\n");
1122 out.write("th{height:20;text-align:left;}\r\n");
1123 out.write("body{font-family: Arial;}\r\n");
1124 out.write("</style>\r\n");
1125 out.write( "</head>\r\n");
1126
1127 out.write ("<body>\r\n");
1128 //out.write ("<p> <a href=\" Overall.html \">Summary</a></p>");
1129 out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
1130 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
1131 if(fileName.equalsIgnoreCase("dublin")){
1132 //out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet1+"</a>");
1133 out.write ("<h3 align=\"center\">Metadata Detail: "+metadataSet1+"</h3>\r\n");
1134 }
1135 else if (fileName.equalsIgnoreCase("extracted")){
1136 //out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet2+"</a>");
1137 out.write ("<h3 align=\"center\">Metadata Detail: "+metadataSet2+"</h3>\r\n");
1138 }
1139 else{
1140 out.write ("<h3 align=\"center\">Metadata Detail: "+fileName+"</h3>\r\n");
1141 }
1142 out.write ("<table border=\"1\" align=\"center\">\r\n");
1143 out.write ("<colgroup width=\"200\" span=\"2\">\r\n");
1144
1145 out.write ("<tr>\r\n");
1146 out.write ("<th>Elements:\r\n");
1147 out.write ("<td><b>Completeness</b>\r\n");
1148 out.write ("</tr>\r\n");
1149
1150 ArrayList elementList = mdset.getIndexsList();
1151 HashMap hp = new HashMap();
1152 int num = elementList.size();
1153 for(int i = 0; i<num; i++){
1154 String elementName = (String)elementList.get(i);
1155 Double elementValue = new Double(dm.Mean(elementName));
1156 hp.put(elementName, elementValue);
1157 }
1158
1159 elementList = new ArrayList();
1160 elementList = dm.sortMap(hp);
1161 num = elementList.size();
1162 for(int i = 0; i<num; i++){
1163 Map.Entry entry = (Map.Entry) elementList.get(i);
1164 String elementName = (String) entry.getKey();
1165 out.write ("<tr>\r\n");
1166 out.write ("<th><a href=\""+ elementName +".html\">"+elementName+"</a>\r\n");
1167 out.write ("<td>"+ dm.Mean(elementName)+"%\r\n");
1168 out.write ("</tr>\r\n");
1169 }
1170
1171 out.write("</table>\r\n");
1172
1173 out.write ("<p align=\"center\"> <a href=\" Overall.html \">Summary</a></p>");
1174 out.write("<p align=\"center\">"+str+"</p>");
1175
1176 //out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Overall Statistics</a></div>");
1177 //out.write("<div style=\"float:right;\">"+str+"</div></td>");
1178 //<td><div style="float:left;">test</div><div style="float:right;">test</div></td>
1179 out.write ("</body></html>\r\n");
1180 //Close the output stream
1181 out.close();
1182 fstream.close();
1183 }catch (Exception e){//Catch exception if any
1184 //System.out.println("set");
1185 //System.err.println("Error: " + e.getMessage());
1186 e.printStackTrace(printWriter);
1187 }
1188
1189 printWriter.write("<!-- generating all possible page-->");
1190 printWriter.flush();
1191 //System.out.println("set ends");
1192 }
1193
1194 public void generateMetadataElementDetailPage(MetadataSet mds,PrintWriter out){
1195
1196 ArrayList nameList = mds.getIndexsList();
1197 for(int i = 0; i<nameList.size();i++){
1198 WriteMetadataElementDetailHTML((String)nameList.get(i),mds.getName(),out);
1199 }
1200 }
1201
1202 public void WriteMetadataElementDetailHTML(String name, String linkName,PrintWriter outx){
1203
1204 String fileName = name;
1205 //DataMaker dmx = new DataMaker(this.mds);
1206
1207 //System.out.println("detail start");
1208
1209 try{
1210 printWriter.write("<!-- generating all possible page-->");
1211 printWriter.flush();
1212 //String str = sdf.format(cl.getTime());
1213 String collectionFolder = mds.getCollectionName();
1214 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
1215 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
1216 BufferedWriter out = new BufferedWriter(fstream);
1217 //System.out.println("step0" + fileName);
1218 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
1219 out.write ("<html>\r\n");
1220 out.write("<head>\r\n<title> "+ name +" </title>\r\n");
1221 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
1222 //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
1223 out.write("<style type=\"text/css\">\r\n");
1224 out.write("td{height:20; text-align:left;}\r\n");
1225 out.write(".tam{height:20; text-align:center}\r\n");
1226 out.write("th{height:20; text-align:left;}\r\n");
1227 out.write("body{font-family: Arial;}\r\n");
1228 out.write("</style>\r\n");
1229 out.write("<script type=\"text/javascript\" src=\"http://localhost:9090/greenstone3/mat/script/status3.js\"></script>");
1230 out.write("</head>\r\n");
1231 out.write("<body>\r\n");
1232 //out.write("<p><a href=\" Overall.html \">Summary</a>");
1233 out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
1234 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td>");
1235
1236 out.write("&raquo;");
1237 //out.write("<a href=\""+linkName+".html\">Metadata Set Detail("+linkName+")</a></p>");
1238
1239
1240 ////////////////////////////////////////////////////////////////////////////////////
1241 if(linkName.equalsIgnoreCase("dublin")){
1242 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet1+")</a>");
1243 //out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet1+"</h1>\r\n");
1244 }
1245 else if (linkName.equalsIgnoreCase("extracted")){
1246 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet2+")</a>");
1247 //out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet2+"</h1>\r\n");
1248 }
1249 else{
1250 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+linkName+")</a>");
1251 }
1252 ///////////////////////////////////////////////////////////////////////////////////////////////
1253
1254 ///////////////////////////////////////////////////////////////////////////////////////////////////////
1255 if(name.startsWith("dc.")){
1256 int dot = name.lastIndexOf('.');
1257 dot++;
1258 String nameReplace = name.substring(dot);
1259 //System.out.println(nameReplace);
1260 if(url.containsKey(nameReplace)){
1261 out.write ("<h3 align=\"center\">Metadata Element Detail:<a href=\""+ url.get(nameReplace) +"\">"+ name +"</a></h3>\r\n");
1262 }
1263 else{
1264 out.write ("<h3 align=\"center\">Metadata Element Detail: "+ name +"</a></h3>\r\n");
1265 }
1266 }
1267
1268 else{
1269 out.write ("<h3 align=\"center\">Metadata Element Detail: "+ name +"</h3>\r\n");
1270 }
1271 ///////////////////////////////////////////////////////////////////////////////////////////////////////
1272
1273 out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
1274 out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
1275
1276 //System.out.println("step1");
1277 out.write ("<tr>\r\n");
1278 out.write ("<td><b>Total Number of Records</b>\r\n");
1279 out.write ("<td class=\"tam\">"+mds.getDocNum()+"\r\n");
1280 out.write ("</tr>\r\n");
1281
1282 //System.out.println("step2");
1283 out.write ("<tr>\r\n");
1284 out.write ("<td><b>Unique Values</b>\r\n");
1285 out.write ("<td class=\"tam\">"+dm.getDistinctNumber(name)+"\r\n");
1286 out.write ("</tr>\r\n");
1287
1288 //System.out.println("step3");
1289 out.write ("<tr>\r\n");
1290 out.write ("<td><b>Total times element used</b>\r\n");
1291 out.write ("<td class=\"tam\">"+dm.getFrequency(name) +"\r\n");
1292 out.write ("</tr>\r\n");
1293
1294 //System.out.println("step4");
1295 out.write ("<tr>\r\n");
1296 out.write ("<td><b>No. of records containing element</b>\r\n");
1297 out.write ("<td class=\"tam\"> "+dm.getDocumentUsedElement(name)+"\r\n");
1298 out.write ("</tr>\r\n");
1299
1300 //System.out.println("step5");
1301 out.write ("<tr>\r\n");
1302 //out.write ("<td><b>Completeness</b>\r\n");
1303 //out.write ("<td class=\"tam\"> "+dm.Mean(name) +"%\r\n");
1304 //out.write ("</tr>\r\n");
1305 double percentage = dm.Mean(name);
1306 //if(percentage<100){
1307 out.write ("<th title = \"The completeness means the arithmetic average \"> <div style=\"float:left;\"> Completeness</div>");
1308 //out.write ("<div style=\"float:right;\"><a href =\""+fileName+"_IncompletedList.html\">List</a></div></td>");
1309 //createIncompletedList(fileName,linkName,collectionFolder,outx);
1310 //}
1311 //else{
1312 //out.write ("<th title = \"The completeness means the arithmetic average \">Completeness\r\n");
1313 //}
1314
1315 out.write ("<td class=\"tam\"> "+dm.Mean(name) +"%\r\n");
1316 out.write ("</tr>\r\n");
1317 //System.out.println("step6");
1318 out.write ("<tr>\r\n");
1319 //out.write ("<th title=\" Minimum number of occurrence of a value\">Smallest Number\r\n");
1320 //out.write ("<th><div style=\"float:left;\">Smallest Number</div><div style=\"float:right;\" onClick=\"alert('Minimum "+name +" usage in any record')\">What it this?</div>\r\n");
1321 out.write ("<td><b><div style=\"float:left;\">Minimum "+name +" usage in any record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Minimum','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
1322 //out.write ("<td><b><div style=\"float:left;\">Minimun "+name +" usage in any record</div></b><div style=\"float:right;\"> onClick=\"helpWindow('Minimun','"+name+"')\">What's this?</div>\r\n");
1323 out.write ("<td class=\"tam\"> "+dm.getMinRange(name) +"\r\n");
1324 out.write ("</tr>\r\n");
1325
1326 //System.out.println("step7");
1327 out.write ("<tr>\r\n");
1328 //out.write ("<th title=\" Maximum number of occurrence of a value\">Largest Number\r\n");
1329 //out.write ("<th><div style=\"float:left;\">Largest Number</div><div style=\"float:right;\" onClick=\"alert('Maximum "+name +" usage in any record')\">What's this?</div>\r\n");
1330 out.write ("<td><b><div style=\"float:left;\">Maximum "+name +" usage in any record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Maximum','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
1331 out.write ("<td class=\"tam\"> "+dm.getMaxRange(name) +"\r\n");
1332 out.write ("</tr>\r\n");
1333
1334 //System.out.println("step8");
1335 out.write ("<tr>\r\n");
1336 //out.write ("<th title=\"(Total times element used / No. of records containing element)\">Average\r\n");
1337 //out.write ("<th><div style=\"float:left;\">Average</div><div style=\"float:right;\" onClick=\"alert('Average "+name +" usage/record')\">What's this?</div>\r\n");
1338 out.write ("<td><b><div style=\"float:left;\">Average "+name +" usage/record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Average','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
1339 out.write ("<td class=\"tam\"> "+dm.Average(name) +"\r\n");
1340 out.write ("</tr>\r\n");
1341
1342 //System.out.println("step9");
1343 out.write ("<tr>\r\n");
1344 //out.write ("<th title=\"The most frequent occurrence value in a group of values \"> Mode\r\n");
1345 //out.write ("<th><div style=\"float:left;\">Mode</div><div style=\"float:right;\" onClick=\"alert('Mode of "+ name +" usage/record')\">What's this?</div>\r\n");
1346 out.write ("<td><b><div style=\"float:left;\">Mode of "+name +" usage/record</div></b><div style=\"float:right;\"><a href=\"#\" onClick=\"helpWindow('Mode','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
1347 out.write ("<td class=\"tam\"> "+dm.getMode(name) +"\r\n");
1348 out.write ("</tr>\r\n");
1349
1350 //System.out.println("step10");
1351 out.write ("<tr>\r\n");
1352 //out.write ("<th>Mode Frequency\r\n");
1353 //out.write ("<th><div style=\"float:left;\">Mode Frequency</div><div style=\"float:right;\" onClick=\"alert('Coverage of the mode of "+ name +" usage/record')\">What's this?</div>\r\n");
1354 out.write ("<td><b><div style=\"float:left;\">Coverage of the mode of "+name +" usage/record</div></b><div style=\"float:right;\"><a href=\"#\" onClick=\"helpWindow('Mode Frequency','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
1355 out.write ("<td class=\"tam\">"+dm.ModeFrequency(name) +"%\r\n");
1356 out.write ("</tr>\r\n");
1357
1358
1359 if(mds.getOaiPrefix().equalsIgnoreCase("oai_dc")){
1360
1361 HashMap suggestionMap = generateMetadataElementSortList(fileName,"ASCII",linkName,outx);
1362
1363 if(suggestionMap.size()>0){
1364 boolean status = compareElement(fileName,collectionFolder,suggestionMap,linkName);
1365 if(status){
1366 out.write("<tr><td class=\"tam\"><a href =\""+fileName+"_Suggestion.html\">View Potential Duplicate List</a>");
1367 if(percentage<100){
1368 out.write ("<td class=\"tam\"><a href =\""+fileName+"_IncompletedList.html\">Records missing "+fileName+"</a></td>");
1369 createIncompletedList(fileName,linkName,collectionFolder,outx);
1370 }
1371 else{
1372 out.write("<td class=\"tam\">No Records Missing "+ fileName);
1373 }
1374 }
1375 else{
1376 out.write("<tr><td class=\"tam\">No Potential Duplicates");
1377 if(percentage<100){
1378 out.write ("<td class=\"tam\"><a href =\""+fileName+"_IncompletedList.html\">Records missing "+fileName+"</a></td>");
1379 createIncompletedList(fileName,linkName,collectionFolder,outx);
1380 }
1381 else{
1382 out.write("<td class=\"tam\">No Records Missing "+ fileName);
1383 }
1384 }
1385 }
1386 else{
1387 out.write("<tr><td class=\"tam\">No Potential Duplicates");
1388 if(percentage<100){
1389 out.write ("<td class=\"tam\"><a href =\""+fileName+"_IncompletedList.html\">Records missing "+fileName+"</a></td>");
1390 createIncompletedList(fileName,linkName,collectionFolder,outx);
1391 }
1392 else{
1393 out.write("<td class=\"tam\">No Records Missing "+ fileName);
1394 }
1395 }
1396 generateMetadataElementSortList(fileName,"Frequency-based",linkName,outx);
1397 }
1398 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1399 else{
1400
1401 HashMap suggestionMap = generateMetadataElementSortListNoIdentifier(fileName,"ASCII",linkName,outx);
1402 /*
1403 if(suggestionMap.size()>0){
1404 boolean status = compareElement(fileName,collectionFolder,suggestionMap,linkName);
1405 if(status){
1406 out.write("<tr><td class=\"tam\"><a href =\""+fileName+"_Suggestion.html\">View Potential Duplicate List</a>");
1407 }
1408 else{
1409 out.write("<tr><td class=\"tam\">No Potential Duplicates");
1410 }
1411 }
1412 else{
1413 out.write("<tr><td class=\"tam\">No Potential Duplicates");
1414 }
1415
1416 if(percentage<100){
1417 out.write ("<td class=\"tam\"><a href =\""+fileName+"_IncompletedList.html\">Records missing "+fileName+"</a></td>");
1418 }
1419 else{
1420 out.write("<td class=\"tam\">No Records Missing "+ fileName);
1421 }
1422 */
1423 generateMetadataElementSortListNoIdentifier(fileName,"Frequency-based",linkName,outx);
1424 }
1425 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1426 out.write ("<tr>\r\n");
1427 out.write ("<td class=\"tam\"><a href =\""+fileName+"_Frequency-based.html\">"+"View Full Frequency Sorted list</a>" +
1428 " <td class=\"tam\"><a href =\""+fileName+"_ASCII.html\">"+"View Full ASCII Sorted list</a></td>");
1429 out.write ("</tr>\r\n");
1430 out.write ("</table><br>\r\n");
1431
1432
1433 out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
1434 out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
1435 out.write ("<tr>\r\n");
1436 out.write ("<th>ASCII-Based\r\n");
1437 out.write ("<th>First Five\r\n");
1438 out.write ("</tr>\r\n");
1439
1440
1441 /////////////////////////////////////////////////////
1442
1443 //out.write ("<a href =\""+fileName+"_Frequency-based.html\">"+"View Frequency-based list</a>");
1444
1445 //out.write ("<a href =\""+fileName+"_ASCII.html\">"+"View ASCII list</a>");
1446 /*
1447 * out.write ("<a href =\""+fileName+"_ASCII.html\">"+"View ASCII list</a>");
1448 out.write ("<tr>\r\n");
1449 out.write ("<td><div style=\"float:left;\">test</div><div style=\"float:right;\">test</div></td>");
1450 out.write ("</tr>\r\n");
1451 */
1452 /////////////////////////////////////////////////////
1453 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1454 //{"ASCII","Frequency-based"};
1455
1456 String[] temp = dm.getSortList(name,"ASCII");
1457 String[] temp2 = {"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
1458 int length = 0;
1459 if(temp.length>=5){length=5;}
1460 else if(temp.length<5){length = temp.length;}
1461
1462 for(int i =0; i<length; i++){
1463 temp2[i] = temp[i];
1464 }
1465
1466
1467 int x = temp2.length;
1468 for(int a = 0; a<x; a++){
1469 out.write ("<tr>\r\n");
1470 //out.write ("<th>"+(a+1)+"\r\n");
1471 if(!temp2[a].equals("&nbsp;")){
1472 out.write ("<th>"+(a+1)+"\r\n");
1473 }
1474 else{
1475 out.write ("<th>&nbsp;\r\n");
1476 }
1477 if(temp2[a].startsWith("http://")){
1478 if(temp2[a].length()>60){
1479 out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a].substring(0, 60)+"...</a>");
1480 }
1481 else {
1482 out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a]+"</a>");
1483 }
1484 }
1485 else{
1486 char singleChar = temp2[a].charAt(0);
1487 if(temp2[a].length()>61 ){
1488 if(temp2[a].startsWith(" ") && ((int)singleChar!=65279)){
1489 temp2[a] = temp2[a].substring(1);
1490 out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
1491 }
1492 else if (((int)singleChar==65279)){
1493 temp2[a] = temp2[a].substring(1);
1494 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
1495 }
1496 else{
1497 out.write ("<td>"+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
1498 }
1499 }
1500 else {
1501 if(temp2[a].startsWith(" ")&& ((int)singleChar!=65279)){
1502 temp2[a] = temp2[a].substring(1);
1503 out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a]+"\r\n");
1504 }
1505 else if (((int)singleChar==65279)){
1506 temp2[a] = temp2[a].substring(1);
1507 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a]+"\r\n");
1508 }
1509 else{
1510 out.write ("<td>"+temp2[a]+"\r\n");
1511 }
1512 }
1513 }
1514 out.write ("</tr>\r\n");
1515 }
1516 String[] temp3 ={"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
1517 length = 0;
1518 int start = temp.length;
1519 if(temp.length>=5){length= 5;}
1520 else if(temp.length<5){length = temp.length;}
1521
1522 for(int i = length; i>0; i--){
1523 temp3[i-1] = temp[start-1];
1524 start--;
1525 }
1526 out.write ("<tr>\r\n");
1527 out.write ("<th>......\r\n");
1528 out.write ("<th>Last Five\r\n");
1529 out.write ("</tr>\r\n");
1530
1531 int counter = temp.length;
1532 start = temp.length;
1533 x = temp3.length;
1534 for(int a = 0; a<x; a++){
1535 out.write ("<tr>\r\n");
1536 //out.write ("<th>"+(a+1)+"\r\n");
1537 //out.write ("<th>"+(start-4-a)+"\r\n");
1538 if(!temp3[a].equals("&nbsp;")){
1539 out.write ("<th>"+(start-length+1+a));
1540 }
1541 else{
1542 out.write ("<th>&nbsp;");
1543 }
1544 if(temp3[a].startsWith("http://")){
1545 if(temp3[a].length()>60){
1546 out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a].substring(0, 60)+"...</a>");
1547 }
1548 else {
1549 out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a]+"</a>");
1550 }
1551 }
1552 else{
1553 char singleChar = temp3[a].charAt(0);
1554 if(temp3[a].length()>61){
1555 if(temp3[a].startsWith(" ") && (int)singleChar!=65279){
1556 temp3[a] = temp3[a].substring(1);
1557 out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
1558 }
1559 else if((int)singleChar==65279){
1560 temp3[a] = temp3[a].substring(1);
1561 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
1562
1563 }
1564 else{
1565 out.write ("<td>"+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
1566 }
1567
1568 }
1569 else{
1570 if(temp3[a].startsWith(" ")&& (int)singleChar!=65279){
1571 temp3[a] = temp3[a].substring(1);
1572 out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a]+"\r\n");
1573 }
1574 else if((int)singleChar==65279){
1575 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a]+"\r\n");
1576 }
1577 else{
1578 out.write ("<td>"+temp3[a]+"\r\n");
1579 }
1580 }
1581 out.write ("</tr>\r\n");
1582 }
1583 }
1584 out.write ("</table><br>\r\n");
1585 //////////////////////////////////////////////////////////////////////////////////////////////////////
1586 //////////////////////////////////////////////////////////////////////////////////////////////////////
1587 out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
1588 out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
1589 out.write ("<tr>\r\n");
1590 out.write ("<th>Frequency-Based:\r\n");
1591 //out.write ("<th>First Five (Minimum ->Maximum)\r\n");
1592 out.write ("<th>First Five\r\n");
1593 out.write ("</tr>\r\n");
1594
1595 HashMap xMap = dm.getDistinctValueMap(name);
1596 temp = dm.getSortList(name,"Frequency-based");
1597 temp2 = new String[] {"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
1598 length = 0;
1599
1600 if(temp.length>=5){length=5;}
1601 else if(temp.length<5){length = temp.length;}
1602
1603 for(int i =0; i<length; i++){
1604 temp2[i] = temp[i];
1605 }
1606
1607 ArrayList tempList = new ArrayList();
1608 for(int i =0; i<length; i++){
1609 if(((Integer)xMap.get(temp2[i])).intValue()==1){
1610 tempList.add(temp2[i]);
1611 }
1612 }
1613 //HashMap tempMap = dmx.getLinks(tempList, name);
1614 x = temp2.length;
1615 for(int a = 0; a<x; a++){
1616 out.write ("<tr>\r\n");
1617 //System.out.println("link map length"+tempMap.size());
1618 if(!temp2[a].equals("&nbsp;")){
1619 char singleChar = temp2[a].charAt(0);
1620 out.write ("<th>"+(a+1)+". (No. of occurrences: "+((Integer)xMap.get(temp2[a])).toString()+")\r\n");
1621 if(temp2[a].startsWith("http://") && (int)singleChar != 65279){
1622 if(temp2[a].length()>61){
1623 out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a].substring(0, 60)+"...</a>");
1624 }
1625 else {
1626 out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a]+"</a>");
1627 }
1628 }
1629
1630 else{
1631 if(temp2[a].length()>61){
1632
1633 if(temp2[a].startsWith(" ")){
1634 temp2[a] = temp2[a].substring(1);
1635 out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... </a>\r\n");
1636 }
1637
1638 else if((int)singleChar == 65279){
1639 temp2[a] = temp2[a].substring(1);
1640 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... </a>\r\n");
1641 }
1642 else{
1643 out.write ("<td>"+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... </a>\r\n");
1644 }
1645
1646 }
1647 else{
1648 if(temp2[a].startsWith(" ")){
1649 temp2[a] = temp2[a].substring(1);
1650 out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a]+"\r\n");
1651 }
1652 else if((int)singleChar == 65279){
1653 temp2[a] = temp2[a].substring(1);
1654 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a]+"\r\n");
1655 }
1656 else{
1657 out.write ("<td>"+temp2[a]+"\r\n");
1658 }
1659 }
1660 }
1661
1662 }
1663 else{
1664 //out.write ("<th>"+(a+1)+"\r\n");
1665 out.write ("<th>&nbsp;\r\n");
1666 out.write ("<td>\r\n");
1667 }
1668
1669
1670 out.write ("</tr>\r\n");
1671 }
1672
1673 temp3 = new String[]{"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
1674 length = 0;
1675 start = temp.length;
1676 if(temp.length>=5){length= 5;}
1677 else if(temp.length<5){length = temp.length;}
1678
1679 for(int i = length; i>0; i--){
1680 temp3[i-1] = temp[start-1];
1681 start--;
1682 }
1683
1684 out.write ("<tr>\r\n");
1685 out.write ("<th>......\r\n");
1686 //out.write ("<th>Last Five (Maximum -> Minimum)\r\n");
1687 out.write ("<th>Last Five\r\n");
1688 out.write ("</tr>\r\n");
1689
1690 x = temp3.length;
1691 start = temp.length;
1692 for(int a = 0; a<x; a++){
1693 out.write ("<tr>\r\n");
1694 if(!temp3[a].equals("&nbsp;")){
1695 //out.write ("<th>"+(a+1)+". (No. of occurrences: "+((Integer)xMap.get(temp3[a])).toString()+")\r\n");
1696
1697 out.write ("<th>"+(start-length+1+a)+". (No. of occurrences: "+((Integer)xMap.get(temp3[a])).toString()+")\r\n");
1698
1699 char singleChar = temp3[a].charAt(0);
1700 if(temp3[a].startsWith("http://")){
1701 if(temp3[a].length()>60){
1702 //out.write ("<td>"+temp2[a].substring(0, 60)+" ...\r\n");
1703 out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a].substring(0, 60)+"...</a>");
1704 }
1705 else {
1706 out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a]+"</a>");
1707 }
1708 }
1709 else{
1710 if(temp3[a].length()>61){
1711
1712 if(temp3[a].startsWith(" ")){
1713 temp3[a] = temp3[a].substring(1);
1714 out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#lastFive\"> ... </a>\r\n");
1715 }
1716 else if((int)singleChar == 65279){
1717 temp3[a] = temp3[a].substring(1);
1718 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#lastFive\"> ... </a>\r\n");
1719
1720 }
1721 else{
1722 out.write ("<td>"+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#lastFive\"> ... </a>\r\n");
1723 }
1724
1725 }
1726 else{
1727 if(temp3[a].startsWith(" ")){
1728 out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a]+"\r\n");
1729 }
1730
1731 else if((int)singleChar == 65279){
1732 temp3[a] = temp3[a].substring(1);
1733 out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a]+"\r\n");
1734
1735 }
1736
1737 else{
1738 out.write ("<td>"+temp3[a]+"\r\n");
1739 }
1740 }
1741 }
1742
1743 }
1744 else{
1745 //out.write ("<th>"+(a+1)+"\r\n");
1746 out.write ("<th>&nbsp;\r\n");
1747 out.write ("<th>\r\n");
1748 }
1749 out.write ("</tr>\r\n");
1750 }
1751
1752
1753 out.write ("</table>\r\n");
1754 /*
1755 generateMetadataElementSortList(fileName,"ASCII",linkName,outx);
1756 generateMetadataElementSortList(fileName,"Frequency-based",linkName,outx);
1757 */
1758 //out.write ("<p>");
1759 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1760 out.write ("<p> <a href=\" Overall.html \">Summary</a>");
1761 out.write ("&raquo;");
1762
1763 if(linkName.equalsIgnoreCase("dublin")){
1764 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet1+")</a>");
1765 //out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet1+"</h1>\r\n");
1766 }
1767 else if (linkName.equalsIgnoreCase("extracted")){
1768 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet2+")</a>");
1769 //out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet2+"</h1>\r\n");
1770 }
1771 else{
1772 out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+linkName+")</a>");
1773 }
1774 //out.write(str+"</p>");
1775 out.write ("</body></html>\r\n");
1776
1777 //Close the output stream
1778 out.close();
1779 fstream.close();
1780 }catch (Exception e){//Catch exception if any
1781 //System.out.println("detail");
1782 //System.err.println("Error: " + e.getMessage());
1783 e.printStackTrace(printWriter);
1784 }
1785
1786 printWriter.write("<!-- generating all possible page-->");
1787 printWriter.flush();
1788 //System.out.println("detail ends");
1789
1790 }
1791
1792
1793 private HashMap generateMetadataElementSortList(String title, String sort, String metadataSetName,PrintWriter outx){
1794 //String str = sdf.format(cl.getTime());
1795 //String collectionFolder = mds.getCollectionName();
1796 String fileName = title+"_"+sort;
1797 String collectionFolder = mds.getCollectionName();
1798 //String IDENTIFIER = "dc.Identifier";
1799 String IDENTIFIER = linkIdentifier;
1800 System.out.println("level 1");
1801 SearchLink sl = new SearchLink(mds.StatsDirectory);
1802 System.out.println("level 2");
1803 HashMap suggestionMap = new HashMap();
1804
1805 HashMap valueMap = sl.createValueMap(title,collectionFolder);
1806 //HashMap linkMap = sl.createLinkMap("dc.Identifier",collectionFolder);
1807 HashMap linkMap = sl.createLinkMap(IDENTIFIER,collectionFolder);
1808 HashMap internalIDMap = dm.getInternalIdentifier(title);
1809 boolean status = false;
1810 //DataMaker dmx = new DataMaker(this.mds);
1811 //outx.write("start");
1812 //outx.flush();
1813 /*
1814 if(title.equals("dc.Identifier")){
1815 generateIdentifierPage(title,sort,metadataSetName,outx);
1816 return;
1817 }
1818 */
1819 try{
1820 printWriter.write("<!-- generating all possible page-->");
1821 printWriter.flush();
1822 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
1823 //BufferedWriter out = new BufferedWriter(fstream);
1824
1825 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
1826 BufferedWriter out = new BufferedWriter(fstream);
1827
1828 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
1829 out.write ("<html>\r\n");
1830 out.write("<head>\r\n<title>Metadata Element Sort List</title>\r\n");
1831 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
1832 out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
1833 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");
1834 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");
1835 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");
1836 //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
1837 out.write("<style type=\"text/css\">\r\n");
1838 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
1839 out.write(".tam{height:20; text-align:center}\r\n");
1840 out.write("th{height:20; text-align:center;}\r\n");
1841 out.write("body{font-family: Arial;}\r\n");
1842 out.write("</style>\r\n");
1843 out.write("</head><body id=\""+collectionFolder+"\">\r\n");
1844
1845 out.write("<td><div style=\"float:left;\"><a href=\" Overall.html \">Summary</a>");
1846 out.write("&raquo;");
1847 ////////////////////////////////////////////////////////////////////////////////////
1848 if(metadataSetName.equalsIgnoreCase("dublin")){
1849 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
1850 }
1851 else if (metadataSetName.equalsIgnoreCase("extracted")){
1852 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
1853 }
1854 else{
1855 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
1856 }
1857 out.write("&raquo;");
1858 out.write("<a href=\""+title+".html\">"+title+"</a></div>");
1859
1860
1861 // out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
1862 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
1863
1864
1865 String[] list = dm.getSortList(title, sort);
1866 //String Link = "Link";
1867 //int MaxLinks = 2;
1868
1869
1870 if(list.length>=1){
1871
1872
1873 if(sort.equals("ASCII")){
1874
1875 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
1876 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
1877 out.write ("<th class=\"tam\">ASCII Sort\r\n");
1878 out.write ("<th class=\"tam\">Element Values\r\n");
1879 out.write ("<th class=\"tam\">Source Documents\r\n");
1880 out.write ("<th class=\"tam\">Internal Link\r\n");
1881
1882 out.write ("<a name='topFive'>\r\n");
1883
1884 int counter = 0;
1885
1886 for(int i = 0; i<list.length; i++){
1887 if(list.length<=5 && i==0){
1888 out.write ("<a name='lastFive'>\r\n");
1889 }
1890 else if((list.length>5) && (list.length-5==i)){
1891 out.write ("<a name='lastFive'>\r\n");
1892 }
1893
1894
1895 InternalLink il= (InternalLink)internalIDMap.get(list[i]);
1896 ArrayList alist2 = il.retrieveList();
1897 String id = (String)alist2.get(0);
1898 id = id.substring(4);
1899 out.write("<tr id=\""+id+"\" >\r\n");
1900
1901 //out.write("<tr>\r\n");
1902
1903 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder);
1904 //out.write("<td>"+"Length"+alist.size());
1905
1906 if(list[i].length()>=201){
1907 if(list[i].startsWith("http://")){
1908 //out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
1909 //if(title.equals("dc.Identifier")){
1910 if(title.equals(IDENTIFIER)){
1911 if(list[i].length()>=100){
1912 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
1913 //out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
1914 }
1915 else{
1916 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1917 }
1918 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
1919 }
1920 else{
1921 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
1922 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
1923
1924 if(list[i].length()>=100){
1925 /*
1926 if(alist.size()==1){
1927 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
1928 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
1929 }
1930 else if(alist.size()>1){
1931 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
1932 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1933 }
1934 else{
1935 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1936 out.write("<td>No Source Available\r\n");
1937 }
1938 */
1939 String url = (String)alist.get(0);
1940 if(alist.size()==1){
1941 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
1942 if(url.startsWith("http://")){
1943 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
1944 }else{
1945 out.write("<td>Source\r\n");
1946 }
1947 //suggestionMap.put(list[i], url);
1948 }
1949 else if(alist.size()>1){
1950 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
1951 //out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1952 if(url.startsWith("http://")){
1953 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1954 }else{
1955 out.write("<td>Source\r\n");
1956 }
1957 //suggestionMap.put(list[i], url);
1958 }
1959 else{
1960 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
1961 out.write("<td>No Source Available\r\n");
1962 }
1963 suggestionMap.put(list[i], url);
1964 }
1965 else{
1966 /*
1967 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1968 if(alist.size()==1){
1969 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1970 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
1971 }
1972 else if(alist.size()>1){
1973 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1974 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1975 }
1976 else{
1977 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1978 out.write("<td>No Source Available\r\n");
1979 }
1980 */
1981 String url = (String)alist.get(0);
1982 if(alist.size()==1){
1983 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1984 //out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
1985 if(url.startsWith("http://")){
1986 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
1987 }else{
1988 out.write("<td>Source\r\n");
1989 }
1990 }
1991 else if(alist.size()>1){
1992 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
1993 //out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1994 if(url.startsWith("http://")){
1995 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
1996 }else{
1997 out.write("<td>Source\r\n");
1998 }
1999 }
2000 else{
2001 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2002 out.write("<td>No Source Available\r\n");
2003 }
2004 suggestionMap.put(list[i], url);
2005 }
2006 }
2007 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0, 200)+"...</a>");
2008
2009
2010 }
2011 else{
2012 ///////////////////////////////////// adding links
2013 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
2014 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2015
2016 //////////////////////////////////////
2017
2018 if(list[i].startsWith(" ")){
2019 String elements = list[i];
2020 list[i] = list[i].substring(1);
2021
2022 if(alist.size()==1){
2023 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>"+
2024 "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2025 suggestionMap.put(elements, (String)alist.get(0));
2026 }
2027 else if(alist.size()>1){
2028 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>"+
2029 "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2030 suggestionMap.put(elements, (String)alist.get(0));
2031 }
2032 else{
2033 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>No Source Available \r\n");
2034 suggestionMap.put(elements, "No Source Available");
2035 }
2036 }
2037 else{
2038
2039 if(alist.size()==1){
2040 out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"...<td>" +
2041 "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2042 suggestionMap.put(list[i], (String)alist.get(0));
2043 }
2044 else if(alist.size()>1){
2045 out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"...<td>" +
2046 "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2047 suggestionMap.put(list[i], (String)alist.get(0));
2048 }
2049 else{
2050 out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... <td>No Source Available\r\n");
2051 suggestionMap.put(list[i],"No Source Available");
2052 }
2053 }
2054 }
2055
2056 }
2057 else{
2058 /*
2059 if(list[i].startsWith("http://")){
2060 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2061 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">1</a>");
2062
2063 if(list[i].length()>=100){
2064 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
2065 }
2066 else{
2067 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2068 }
2069
2070 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2071 }*/
2072
2073 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2074 if(list[i].startsWith("http://")){
2075 //out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
2076 //if(title.equals("dc.Identifier")){
2077 if(title.equals(IDENTIFIER)){
2078 if(list[i].length()>=100){
2079 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
2080 //out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2081 }
2082 else{
2083 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2084 }
2085 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2086 }
2087 else{
2088 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
2089 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2090
2091 if(list[i].length()>=100){
2092 if(alist.size()==1){
2093 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
2094 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2095 }
2096 else if(alist.size()>1){
2097 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
2098 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2099 }
2100 else{
2101 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2102 out.write("<td>No Source Available\r\n");
2103 }
2104 }
2105 else{
2106 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2107 if(alist.size()==1){
2108 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2109 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2110 suggestionMap.put(list[i], (String)alist.get(0));
2111 }
2112 else if(alist.size()>1){
2113 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2114 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2115 suggestionMap.put(list[i], (String)alist.get(0));
2116 }
2117 else{
2118 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2119 out.write("<td>No Source Available\r\n");
2120 suggestionMap.put(list[i],"No Source Available");
2121 }
2122 }
2123 }
2124 //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0, 200)+"...</a>");
2125
2126
2127 }
2128
2129 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2130
2131 else{
2132 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
2133 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2134
2135 if(list[i].startsWith(" ")){
2136 String elements = list[i];
2137 list[i] = list[i].substring(1);
2138
2139 if(alist.size()==1){
2140 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+
2141 "<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2142 suggestionMap.put(list[i], (String)alist.get(0));
2143 }
2144 else if(alist.size()>1){
2145 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+
2146 "<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2147 suggestionMap.put(list[i], (String)alist.get(0));
2148 }
2149 else{
2150 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
2151 suggestionMap.put(elements,"No Source Available");
2152 }
2153 //out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
2154 }
2155 else{
2156 if(alist.size()==1){
2157 out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td><a href=\""+alist.get(0)+"\">Source</a>\r\n");
2158 suggestionMap.put(list[i],(String)alist.get(0));
2159 }
2160 else if(alist.size()>1){
2161 out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
2162 suggestionMap.put(list[i],(String)alist.get(0));
2163 }
2164 else{
2165 out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td>No Source Available\r\n");
2166 suggestionMap.put(list[i],"No Source Available");
2167 }
2168 //out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
2169 }
2170 }
2171 }
2172 counter++;
2173 out.write("<td onclick=\"GD(this)\">View");
2174 }
2175 //if(suggestionMap.size()>1 && !title.equals("dc.Identifier")){
2176 if(suggestionMap.size()>1 && !title.equals(IDENTIFIER)){
2177 //return suggestionMap;
2178 //compareElement(title,collectionFolder,suggestionMap);
2179 status = true;
2180 }
2181 }
2182 else{
2183
2184
2185 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
2186 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
2187 out.write ("<th class=\"tam\">&nbsp;\r\n");
2188 out.write ("<th class=\"tam\">Frequency\r\n");
2189 out.write ("<th class=\"tam\">Element Values\r\n");
2190 out.write ("<th class=\"tam\">Source Documents\r\n");
2191 out.write ("<th class=\"tam\">Internal Link\r\n");
2192 out.write ("<a name='topFive'>\r\n");
2193
2194 HashMap xMap = dm.getDistinctValueMap(title);
2195 int counter = 0;
2196 for(int i = 0; i<list.length; i++){
2197 if(list.length<=5 && i==0){
2198 out.write ("<a name='lastFive'>\r\n");
2199 }
2200 else if((list.length>5) && (list.length-5==i)){
2201 out.write ("<a name='lastFive'>\r\n");
2202 }
2203 //out.write("<tr>\r\n");
2204 InternalLink il= (InternalLink)internalIDMap.get(list[i]);
2205 ArrayList alist2 = il.retrieveList();
2206 String id = (String)alist2.get(0);
2207 id = id.substring(4);
2208 out.write("<tr id=\""+id+"\" >\r\n");
2209
2210 out.write("<td>"+(counter+1)+"<th> "+((Integer)xMap.get(list[i])).toString()+"\r\n");
2211
2212 if(list[i].length()>=201){
2213
2214 if(list[i].startsWith("http://")){
2215 //out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,200)+"...</a>");
2216 //if(title.equals("dc.Identifier")){
2217 if(title.equals(IDENTIFIER)){
2218 if(list[i].length()>=100){
2219 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2220 }
2221 else{
2222 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2223 }
2224
2225 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2226 }
2227 else{
2228 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2229 if(list[i].length()>=100){
2230 if(alist.size()==1){
2231 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2232 out.write("<td><a href=\""+alist.get(0)+"\">Source</a>\r\n");
2233 }
2234 else if (alist.size()>1){
2235 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2236 out.write("<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
2237 }
2238 else{
2239 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2240 //out.write("<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
2241 out.write("<td>No Source Available\r\n");
2242 }
2243
2244 }
2245 else{
2246 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2247 }
2248
2249 //out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2250 }
2251 }
2252
2253
2254
2255
2256 else{
2257 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2258
2259 if(list[i].startsWith(" ")){
2260 list[i]=list[i].substring(1);
2261 if(alist.size()==1){
2262 out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>"+
2263 "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2264 }
2265 else if(alist.size()>1){
2266 out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>"+
2267 "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2268 }
2269 else{
2270 out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>No Source Available\r\n");
2271 }
2272 }
2273 else{
2274
2275 if(alist.size()==1){
2276 out.write("<td>"+list[i].substring(0,200)+"...<td>" +
2277 "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2278 }
2279 else if(alist.size()>1){
2280 out.write("<td>"+list[i].substring(0,200)+"...<td>"+
2281 "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2282 }
2283 else{
2284 out.write("<td>"+list[i].substring(0,200)+"...<td>No Source Available\r\n");
2285 }
2286 }
2287 }
2288 }
2289 else{
2290 if(list[i].startsWith("http://")){
2291 //out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2292 //out.write("<td><a href=\""+list[i]+"\">1</a>");
2293 //if(title.equals("dc.Identifier")){
2294 if(title.equals(IDENTIFIER)){
2295 if(list[i].length()>=100){
2296 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2297 }
2298 else{
2299 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2300 }
2301 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2302 }
2303 else{
2304 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
2305 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2306
2307 if(list[i].length()>=100){
2308 if(alist.size()==1){
2309 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2310 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2311 }
2312 else if(alist.size()>1){
2313 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2314 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2315 }
2316 else{
2317 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
2318 out.write("<td>No Source Available\r\n");
2319 }
2320 }
2321 else{
2322 if(alist.size()==1){
2323 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2324 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2325 }
2326 else if(alist.size()>1){
2327 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2328 out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2329 }
2330 else{
2331 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2332 out.write("<td>No Source Available\r\n");
2333 }
2334 }
2335
2336 }
2337
2338 }
2339 else{
2340
2341 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2342
2343 if(list[i].startsWith(" ")){
2344 list[i]=list[i].substring(1);
2345 //out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
2346 if(alist.size()==1){
2347 out.write("<td>"+spaceLeft+space+spaceRight+list[i]+
2348 "<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2349 }
2350 else if(alist.size()>1){
2351 out.write("<td>"+spaceLeft+space+spaceRight+list[i]+
2352 "<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2353 }
2354 else{
2355 out.write("<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
2356 }
2357 }
2358 else{
2359 if(alist.size()==1){
2360 out.write("<td>"+list[i]+"<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
2361 }
2362 else if(alist.size()>1){
2363 out.write("<td>"+list[i]+"<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
2364 }
2365 else{
2366 out.write("<td>"+list[i]+"<td>No Source Available\r\n");
2367 }
2368 }
2369 }
2370 }
2371 counter++;
2372 out.write("<td onclick=\"GD(this)\">View");
2373 }
2374 }
2375 out.write("</table>\r\n");
2376 }
2377 else{
2378 out.write("<p>Sorry! The list is empty</p>");
2379 }
2380 out.write("<tr>\r\n");
2381
2382
2383 out.write("<p><a href=\" Overall.html \">Summary</a>");
2384 out.write("&raquo;");
2385 ////////////////////////////////////////////////////////////////////////////////////
2386 if(metadataSetName.equalsIgnoreCase("dublin")){
2387 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2388 }
2389 else if (metadataSetName.equalsIgnoreCase("extracted")){
2390 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2391 }
2392 else{
2393 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2394 }
2395 out.write("&raquo;");
2396 out.write("<a href=\""+title+".html\">"+title+"</a></p>");
2397 out.write("</body></html>\r\n");
2398 out.close();
2399 fstream.close();
2400 }catch(Exception e){
2401 //System.err.println("Error: " + e.getMessage());
2402 e.printStackTrace(outx);
2403 }
2404
2405
2406 //printWriter.write("<!-- generating all possible page-->");
2407 //printWriter.flush();
2408 if(status){
2409 return suggestionMap;
2410 }
2411 else{
2412 return new HashMap();
2413 }
2414 }
2415
2416
2417 private void setupMetadataLink(String fileName){
2418
2419 try{
2420 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
2421 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
2422 Document doc = docBuilder.newDocument();
2423 doc = docBuilder.parse (new File("/research/cc108/greenstone3/web/mat/script/"+fileName+".xml"));
2424 Element rootNode = doc.getDocumentElement();
2425
2426 NodeList listOfName = rootNode.getElementsByTagName("metadataElement");
2427 url = new HashMap();
2428 for(int i = 0; i<listOfName.getLength(); i++){
2429 Node NameNode = listOfName.item(i);
2430 Element docElement = (Element)NameNode;
2431 NodeList valueList = docElement.getElementsByTagName("URL");
2432 Node urlParentNode = valueList.item(0);
2433 String urlText = urlParentNode.getChildNodes().item(0).getNodeValue();
2434
2435 valueList = docElement.getElementsByTagName("name");
2436 Node urlNameParentNode = valueList.item(0);
2437 String urlNameText = urlNameParentNode.getChildNodes().item(0).getNodeValue();
2438
2439 url.put(urlNameText, urlText);
2440 //System.out.println(urlText+" "+urlNameText);
2441
2442 }
2443
2444
2445 }catch(Exception e){
2446 //e.printStackTrace(printWriter);
2447 //System.out.print(e.toString());
2448 e.printStackTrace(printWriter);
2449 }
2450 }
2451
2452 /*
2453 private void generateIdentifierPage (String title, String sort, String metadataSetName,PrintWriter outx){
2454 //String str = sdf.format(cl.getTime());
2455 //String collectionFolder = mds.getCollectionName();
2456 String fileName = title+"_"+sort;
2457 String collectionFolder = mds.getCollectionName();
2458 String IDENTIFIER = "dc.Identifier";
2459 SearchLink sl = new SearchLink();
2460 //DataMaker dmx = new DataMaker(this.mds);
2461 //outx.write("start");
2462 //outx.flush();
2463
2464 try{
2465 printWriter.write("<!-- generating all possible page-->");
2466 printWriter.flush();
2467 //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
2468 //BufferedWriter out = new BufferedWriter(fstream);
2469
2470 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
2471 BufferedWriter out = new BufferedWriter(fstream);
2472
2473 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
2474 out.write ("<html>\r\n");
2475 out.write("<head>\r\n<title>Metadata Element Sort List</title>\r\n");
2476 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
2477 //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
2478 out.write("<style type=\"text/css\">\r\n");
2479 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
2480 out.write(".tam{height:20; text-align:center}\r\n");
2481 out.write("th{height:20; text-align:center;}\r\n");
2482 out.write("body{font-family: Arial;}\r\n");
2483 out.write("</style>\r\n");
2484 out.write("</head><body>\r\n");
2485
2486 out.write("<td><div style=\"float:left;\"><a href=\" Overall.html \">Summary</a>");
2487 out.write("&raquo;");
2488 ////////////////////////////////////////////////////////////////////////////////////
2489 if(metadataSetName.equalsIgnoreCase("dublin")){
2490 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2491 }
2492 else if (metadataSetName.equalsIgnoreCase("extracted")){
2493 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2494 }
2495 else{
2496 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2497 }
2498 out.write("&raquo;");
2499 out.write("<a href=\""+title+".html\">"+title+"</a></div>");
2500
2501
2502 // out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
2503 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
2504
2505
2506 String[] list = dm.getSortList(title, sort);
2507 //String Link = "Link";
2508 //int MaxLinks = 2;
2509
2510
2511 if(list.length>=1){
2512
2513
2514 if(sort.equals("ASCII")){
2515
2516 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
2517 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
2518 out.write ("<th class=\"tam\">ASCII Sort\r\n");
2519 out.write ("<th class=\"tam\">Element Values\r\n");
2520 out.write ("<th class=\"tam\">Source Documents\r\n");
2521 out.write ("<a name='topFive'>\r\n");
2522
2523 int counter = 0;
2524
2525 for(int i = 0; i<list.length; i++){
2526 if(list.length<=5 && i==0){
2527 out.write ("<a name='lastFive'>\r\n");
2528 }
2529 else if((list.length>5) && (list.length-5==i)){
2530 out.write ("<a name='lastFive'>\r\n");
2531 }
2532 out.write("<tr>\r\n");
2533
2534 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder);
2535 //out.write("<td>"+"Length"+alist.size());
2536
2537 if(list[i].length()>=201){
2538 if(list[i].startsWith("http://")){
2539 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
2540 out.write("<td><a href=\""+list[i]+"\">Source</a>");
2541 }
2542 else{
2543
2544 if(list[i].startsWith(" ")){
2545 list[i] = list[i].substring(1);
2546
2547 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...");
2548 //out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"... \r\n");
2549 out.write("<td>No Source Available");
2550
2551 }
2552 else{
2553 out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... \r\n");
2554 out.write("<td>No Source Available");
2555 }
2556 }
2557
2558 }
2559 else{
2560
2561 if(list[i].startsWith("http://")){
2562 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
2563 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2564 }
2565
2566 else{
2567
2568
2569 if(list[i].startsWith(" ")){
2570 list[i] = list[i].substring(1);
2571
2572 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
2573 out.write("<td>No Source Available");
2574 //out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
2575 }
2576 else{
2577
2578 out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
2579 out.write("<td>No Source Available");
2580 //out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
2581 }
2582 }
2583 }
2584 counter++;
2585 }
2586 }
2587 else{
2588
2589
2590 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
2591 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
2592 out.write ("<th class=\"tam\">&nbsp;\r\n");
2593 out.write ("<th class=\"tam\">Frequency\r\n");
2594 out.write ("<th class=\"tam\">Element Values\r\n");
2595 out.write ("<th class=\"tam\">Source Documents\r\n");
2596 out.write ("<a name='topFive'>\r\n");
2597
2598 HashMap xMap = dm.getDistinctValueMap(title);
2599 int counter = 0;
2600 for(int i = 0; i<list.length; i++){
2601 if(list.length<=5 && i==0){
2602 out.write ("<a name='lastFive'>\r\n");
2603 }
2604 else if((list.length>5) && (list.length-5==i)){
2605 out.write ("<a name='lastFive'>\r\n");
2606 }
2607 out.write("<tr>\r\n");
2608 out.write("<td>"+(counter+1)+"<th> "+((Integer)xMap.get(list[i])).toString()+"\r\n");
2609
2610 if(list[i].length()>=201){
2611 if(list[i].startsWith("http://")){
2612 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
2613 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2614 }
2615 else{
2616 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
2617
2618 if(list[i].startsWith(" ")){
2619 list[i]=list[i].substring(1);
2620
2621 out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...\r\n");
2622 out.write("<td>No Source Available");
2623 }
2624 else{
2625
2626 out.write("<td>"+list[i].substring(0,200)+"...\r\n");
2627 out.write("<td>No Source Available");
2628 }
2629 }
2630 }
2631 else{
2632 if(list[i].startsWith("http://")){
2633 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
2634 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
2635 }
2636 else{
2637
2638 ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder);
2639
2640 if(list[i].startsWith(" ")){
2641 list[i]=list[i].substring(1);
2642 //out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
2643
2644 out.write("<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
2645 out.write("<td>No Source Available");
2646 }
2647 else{
2648
2649 out.write("<td>"+list[i]+"\r\n");
2650 out.write("<td>No Source Available");
2651 }
2652 }
2653 }
2654 counter++;
2655 }
2656 }
2657 out.write("</table>\r\n");
2658 }
2659 else{
2660 out.write("<p>Sorry! The list is empty</p>");
2661 }
2662 out.write("<tr>\r\n");
2663
2664
2665 out.write("<p><a href=\" Overall.html \">Summary</a>");
2666 out.write("&raquo;");
2667 ////////////////////////////////////////////////////////////////////////////////////
2668 if(metadataSetName.equalsIgnoreCase("dublin")){
2669 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2670 }
2671 else if (metadataSetName.equalsIgnoreCase("extracted")){
2672 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2673 }
2674 else{
2675 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2676 }
2677 out.write("&raquo;");
2678 out.write("<a href=\""+title+".html\">"+title+"</a></p>");
2679 out.write("</body></html>\r\n");
2680 out.close();
2681 fstream.close();
2682 }catch(Exception e){
2683 //System.err.println("Error: " + e.getMessage());
2684 e.printStackTrace(outx);
2685 }
2686
2687 printWriter.write("<!-- generating all possible page-->");
2688 printWriter.flush();
2689 }
2690
2691
2692
2693
2694 private void createIncompletedList(String fileName, String metadataSetName){
2695 HashMap hp = dm.getIdentifierLink("dc.Identifier");
2696 String[] ids = dm.getDocumentIDList(fileName);
2697 System.out.println("Length: "+ids.length+" "+fileName+ " "+hp.size());
2698 for(int i = 0; i<ids.length; i++){
2699 hp.remove(ids[i]);
2700 }
2701 String collectionFolder = mds.getCollectionName();
2702 System.out.println(hp.size());
2703 try{
2704 FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+"_IncompletedList.html");
2705 BufferedWriter out = new BufferedWriter(fstream);
2706
2707 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
2708 out.write ("<html>\r\n");
2709 out.write("<head>\r\n<title>Incompleted Document List</title>\r\n");
2710 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
2711 out.write("<style type=\"text/css\">\r\n");
2712 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
2713 out.write(".tam{height:20; text-align:center}\r\n");
2714 out.write("th{height:20; text-align:center;}\r\n");
2715 out.write("body{font-family: Arial;}\r\n");
2716 out.write("</style>\r\n");
2717 out.write("</head><body>\r\n");
2718
2719 out.write("<p><a href=\" Overall.html \">Summary</a>");
2720 out.write("&raquo;");
2721 if(metadataSetName.equalsIgnoreCase("dublin")){
2722 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2723 }
2724 else if (metadataSetName.equalsIgnoreCase("extracted")){
2725 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2726 }
2727 else{
2728 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2729 }
2730 out.write("&raquo;");
2731 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
2732
2733 out.write("<h3 align=center>"+fileName+"</h3>");
2734 int counter = 0;
2735 Set s = hp.keySet();
2736 Iterator i = s.iterator();
2737 out.write("<table border=1 align=center><tr><th>Document ID<th>Source Link\r\n");
2738 while(i.hasNext()){
2739 counter++;
2740 String keys = (String)i.next();
2741 InternalLink il = (InternalLink) hp.get(keys);
2742 ArrayList alist = il.retrieveList();
2743 String url = (String)alist.get(0);
2744 out.write("<tr><td>"+counter+"<td><a href=\""+url+"\">"+url+"</a>\r\n");
2745 }
2746 out.write("</table></body></html>\r\n");
2747
2748
2749 out.write("<p><a href=\" Overall.html \">Summary</a>");
2750 out.write("&raquo;");
2751 if(metadataSetName.equalsIgnoreCase("dublin")){
2752 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2753 }
2754 else if (metadataSetName.equalsIgnoreCase("extracted")){
2755 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2756 }
2757 else{
2758 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2759 }
2760 out.write("&raquo;");
2761 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
2762
2763 out.close();
2764 fstream.close();
2765 }catch(IOException ex){ex.printStackTrace();}
2766
2767
2768 }
2769 */
2770
2771 private void createIncompletedList(String fileName, String metadataSetName, String collectionFolder,PrintWriter outx){
2772 //HashMap hp = dm.getIdentifierLink("dc.Identifier");
2773 HashMap hp = dm.getIdentifierLink(linkIdentifier);
2774 String[] ids = dm.getDocumentIDList(fileName);
2775 //System.out.println("Length: "+ids.length+" "+fileName+ " "+hp.size());
2776 for(int i = 0; i<ids.length; i++){
2777 hp.remove(ids[i]);
2778 }
2779 //String collectionFolder = mds.getCollectionName();
2780 //System.out.println(hp.size());
2781 try{
2782 FileWriter fstream = new FileWriter(destination+"/"+fileName+"_IncompletedList.html");
2783 BufferedWriter out = new BufferedWriter(fstream);
2784
2785 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
2786 out.write ("<html>\r\n");
2787 out.write("<head>\r\n<title>Incompleted Document List</title>\r\n");
2788 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
2789 out.write("<style type=\"text/css\">\r\n");
2790 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
2791 out.write(".tam{height:20; text-align:center}\r\n");
2792 out.write("th{height:20; text-align:center;}\r\n");
2793 out.write("body{font-family: Arial;}\r\n");
2794 out.write("</style>\r\n");
2795 out.write("</head><body>\r\n");
2796
2797 out.write("<p><a href=\" Overall.html \">Summary</a>");
2798 out.write("&raquo;");
2799 if(metadataSetName.equalsIgnoreCase("dublin")){
2800 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2801 }
2802 else if (metadataSetName.equalsIgnoreCase("extracted")){
2803 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2804 }
2805 else{
2806 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2807 }
2808 out.write("&raquo;");
2809 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
2810
2811 out.write("<h3 align=center>"+fileName+" does not appear in the following documents</h3>");
2812 int counter = 0;
2813 Set s = hp.keySet();
2814 Iterator i = s.iterator();
2815 out.write("<table border=1 align=center><tr><th>Document ID<th>Source Link\r\n");
2816 while(i.hasNext()){
2817 //printWriter.write("<!-- generating all possible page-->");
2818 counter++;
2819 String keys = (String)i.next();
2820 InternalLink il = (InternalLink) hp.get(keys);
2821 ArrayList alist = il.retrieveList();
2822 String url = (String)alist.get(0);
2823 out.write("<tr><td>"+counter+"<td><a href=\""+url+"\">"+url+"</a>\r\n");
2824 }
2825 out.write("</table></body></html>\r\n");
2826
2827
2828 out.write("<p><a href=\" Overall.html \">Summary</a>");
2829 out.write("&raquo;");
2830 if(metadataSetName.equalsIgnoreCase("dublin")){
2831 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
2832 }
2833 else if (metadataSetName.equalsIgnoreCase("extracted")){
2834 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
2835 }
2836 else{
2837 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
2838 }
2839 out.write("&raquo;");
2840 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
2841
2842 out.close();
2843 fstream.close();
2844 }catch(IOException ex){ex.printStackTrace();}
2845
2846
2847 }
2848
2849 public boolean compareElement(String fileName,String collectionFolder,HashMap suggestionMap, String metadataSetName){
2850
2851 //EditDistance ed = new EditDistance();
2852 //SearchLink sl = new SearchLink();
2853 boolean status = false;
2854 //System.out.println("Starting test "+fileName);
2855 long time = System.currentTimeMillis();
2856 //List list = Arrays.asList(args);
2857 Set kset = suggestionMap.keySet();
2858 ArrayList arrayList = new ArrayList();
2859 Iterator is = kset.iterator();
2860 while(is.hasNext()){
2861 arrayList.add((String)is.next());
2862 }
2863 HashMap distanceMap = new HashMap();
2864
2865 int totalLength = 0;
2866
2867 int arrayListLength = arrayList.size();
2868 int counter = 0;
2869 //System.out.println("Length: "+arrayListLength);
2870 //printWriter.write("<!-- generating all possible page-->");
2871 //printWriter.flush();
2872 printWriter.write("<!-- generating all possible page-->");
2873 printWriter.flush();
2874 double distance ;
2875 try{
2876 for(int i = 0; i<arrayListLength; i++){
2877 String keyword = (String)arrayList.get(i);
2878 //printWriter.write("<!-- generating all possible page-->");
2879 //printWriter.flush();
2880 //ArrayList alistkw1 = sl.CreateIndentifierLinkPage(fileName, keyword,"dc.Identifier", collectionFolder,valueMap,linkMap);
2881 int spaceCounterFront1 = 0;
2882 int spaceCounterEnd1 = 0;
2883 String keywordClone = keyword;
2884 String _keywordClone = keyword;
2885 String bkKeyWord = keyword;
2886 //System.out.println("before parsing kw1");
2887 keywordClone = removeUnusedCharacter(keywordClone);
2888 //System.out.println("after parsing kw1");
2889 //System.out.println("before removing space from kw1");
2890 while(true){
2891 //printWriter.write("<!-- generating all possible page-->");
2892 //printWriter.flush();
2893 if(_keywordClone.length()>1){
2894 if(_keywordClone.charAt(0)==' '){
2895 _keywordClone = _keywordClone.substring(1);
2896 spaceCounterFront1++;
2897 }
2898 else{
2899 if(_keywordClone.charAt(_keywordClone.length()-1)==' '){
2900 _keywordClone = _keywordClone.substring(0,_keywordClone.length()-1);
2901 spaceCounterEnd1++;
2902 }
2903 else{
2904 break;
2905 }
2906 }
2907 }
2908 else{
2909 break;
2910 }
2911 }
2912 //System.out.println("after removing space from kw1");
2913 /*
2914 for(int a = 0; a<spaceCounterFront; a++){
2915 keywordClone = spaceLeft+space+spaceRight+keywordClone;
2916 }
2917 for(int a = 0; a<spaceCounterFront; a++){
2918 keywordClone = keywordClone+spaceLeft+space+spaceRight;
2919 }
2920 */
2921 //System.out.println("after5");
2922 //printWriter.write("<!-- generating all possible page-->");
2923 //printWriter.flush();
2924 int keywordLength = keywordClone.length();
2925 totalLength = totalLength + keywordLength;
2926 for(int j = i+1; j<arrayListLength; j++){
2927 String keyword2 = (String)arrayList.get(j);
2928 counter ++;
2929 //printWriter.write("<!-- generating all possible page-->");
2930 //printWriter.flush();
2931 //ArrayList alistkw2 = sl.CreateIndentifierLinkPage(fileName, keyword2,"dc.Identifier", collectionFolder,valueMap,linkMap);
2932 double pre_cost = 0;
2933 String keywordClone2 = keyword2;
2934 String _keywordClone2 = keyword2;
2935 String bkKeyWord2 = keyword2;
2936 //System.out.println("before parsing kw2");
2937 costModel cm = new costModel();
2938 cm = removeUnusedCharacter(keywordClone2,pre_cost);
2939 //System.out.println("after parsing kw2");
2940 keywordClone2 = cm.getString();
2941 pre_cost = cm.getCost();
2942
2943 int spaceCounterFront2 = 0;
2944 int spaceCounterEnd2 = 0;
2945
2946 //System.out.println("before removing space from kw2");
2947 while(true){
2948 //printWriter.write("<!-- generating all possible page-->");
2949 //printWriter.flush();
2950 if(_keywordClone2.length()>1){
2951 if(_keywordClone2.charAt(0)==' '){
2952 _keywordClone2 = _keywordClone2.substring(1);
2953 spaceCounterFront2++;
2954 }
2955 else{
2956 if(_keywordClone2.charAt(_keywordClone2.length()-1)==' '){
2957 _keywordClone2 = _keywordClone2.substring(0,_keywordClone2.length()-1);
2958 spaceCounterEnd2++;
2959 }
2960 else{
2961 break;
2962 }
2963 }}
2964 else{
2965 break;
2966 }
2967 }
2968 /*
2969 while(true){
2970 if(_keywordClone2.contains(" ")){
2971 _keywordClone2.replaceFirst(" "," ");
2972 }
2973 else{
2974 break;
2975 }
2976 }*/
2977 //System.out.println("after removing space from kw2");
2978
2979 //System.out.println("after4");
2980 if(counter == 50000){
2981 printWriter.write("<!-- generating all possible page-->");
2982 printWriter.flush();
2983 counter = 0;
2984 }
2985 int keyword2Length = keywordClone2.length();
2986 //printWriter.write("<!-- generating all possible page-->");
2987 //printWriter.flush();
2988 if(keywordLength>(keyword2Length+2) || (keywordLength+2)<keyword2Length ){}
2989 else{
2990 //System.out.println("start edit distance: "+keywordClone + " " + keywordClone2);
2991 //distance = ed.getLevenshteinDistance(keyword, keyword2);
2992 //printWriter.write("<!-- generating all possible page-->");
2993 //printWriter.flush();
2994 distance = calculateEditDistance(keywordClone.toLowerCase().toCharArray(),keywordClone2.toLowerCase().toCharArray());
2995 //printWriter.write("<!-- generating all possible page-->");
2996 //printWriter.flush();
2997 distance = distance + pre_cost;
2998 //System.out.println("finish calculating edit distance");
2999 if(distance<=2){
3000 if(distanceMap.containsKey(_keywordClone)){
3001 InternalLink il = (InternalLink)distanceMap.get(_keywordClone);
3002
3003 String keywordHolder = _keywordClone2;
3004
3005 while(true){
3006 if(keywordHolder.contains(" ")){
3007 keywordHolder = keywordHolder.replaceFirst(" ",spaceLeft+space+spaceRight+" ");
3008 }
3009 else{
3010 break;
3011 }
3012 }
3013
3014 for(int a = 0; a<spaceCounterFront2; a++){
3015 keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
3016 }
3017 for(int a = 0; a<spaceCounterEnd2; a++){
3018 keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
3019 }
3020
3021 InternalLink il2 = new InternalLink();
3022 il2.setValue(keywordHolder);
3023 if(suggestionMap.containsKey(bkKeyWord2)){
3024 il2.increaseElement((String)suggestionMap.get(bkKeyWord2));
3025 //System.out.println("input this url(3):"+(String)alistkw2.get(0));
3026 }
3027 else{
3028 il2.increaseElement("&nbsp;");
3029 }
3030
3031 il.increaseNode(il2);
3032 //il.increaseElement(keywordHolder);
3033 distanceMap.put(_keywordClone, il);
3034
3035 //il.increaseElement(keywordClone2);
3036 //distanceMap.put(keyword, il);
3037 }
3038 else{
3039 InternalLink il = new InternalLink();
3040 String keywordHolder = _keywordClone;
3041
3042 while(true){
3043 if(keywordHolder.contains(" ")){
3044 keywordHolder = keywordHolder.replaceFirst(" ",spaceLeft+space+spaceRight+" ");
3045 }
3046 else{
3047 break;
3048 }
3049 }
3050
3051 for(int a = 0; a<spaceCounterFront1; a++){
3052 keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
3053 }
3054 for(int a = 0; a<spaceCounterEnd1; a++){
3055 keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
3056 }
3057
3058 InternalLink il2 = new InternalLink();
3059 il2.setValue(keywordHolder);
3060 if(suggestionMap.containsKey(bkKeyWord)){
3061 il2.increaseElement((String)suggestionMap.get(bkKeyWord));
3062 //System.out.println("input this url(1):"+(String)alistkw1.get(0));
3063 }
3064 else{
3065 il2.increaseElement("&nbsp;");
3066 }
3067
3068 il.increaseNode(il2);
3069 //il.increaseElement(keywordHolder);
3070
3071 keywordHolder = _keywordClone2;
3072
3073 while(true){
3074 if(keywordHolder.contains(" ")){
3075 keywordHolder = keywordHolder.replaceFirst(" ",spaceLeft+space+spaceRight+" ");
3076 }
3077 else{
3078 break;
3079 }
3080 }
3081 for(int a = 0; a<spaceCounterFront2; a++){
3082 keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
3083 }
3084 for(int a = 0; a<spaceCounterEnd2; a++){
3085 keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
3086 }
3087
3088 InternalLink il3 = new InternalLink();
3089 il3.setValue(keywordHolder);
3090 if(suggestionMap.containsKey(bkKeyWord2)){
3091 il3.increaseElement((String)suggestionMap.get(bkKeyWord2));
3092 //System.out.println("input this url(2):"+(String)alistkw2.get(0));
3093 }
3094 else{
3095 il3.increaseElement("&nbsp;");
3096 }
3097 //printWriter.write("<!-- generating all possible page-->");
3098 //printWriter.flush();
3099 il.increaseNode(il3);
3100 //il.increaseElement(keywordHolder);
3101 distanceMap.put(_keywordClone, il);
3102 }
3103 }
3104 }
3105 //alistkw2.clear();
3106 }
3107 //alistkw1.clear();
3108 //System.gc();
3109 }
3110 //System.out.println("after3");
3111 time = System.currentTimeMillis() - time;
3112
3113 printWriter.write("<!-- generating all possible page-->");
3114 printWriter.flush();
3115 //System.out.println("The test took " + time + " milliseconds");
3116 //System.out.println("TotalLength: "+totalLength+"Avg. Length:"+totalLength/arrayListLength);
3117 //arrayList.clear();
3118 //System.gc();
3119 //if(fileName.endsWith("dc.Title")){
3120 //System.out.println(fileName +"Map Size"+ distanceMap.size(
3121 //System.out.println("after2");
3122 if(distanceMap.size()!=0){
3123 //System.out.println("Eric "+distanceMap.size()+ " "+fileName+" "+ metadataSetName );
3124 generateHTML(distanceMap,fileName,metadataSetName);
3125 status = true;
3126 }
3127 }catch(Exception ex){ex.printStackTrace();}
3128 return status;
3129 //System.out.println("after1");
3130 }
3131
3132
3133 private void generateHTML(HashMap distanceMap, String fileName,String metadataSetName){
3134 printWriter.write("<!-- generating all possible page-->");
3135 printWriter.flush();
3136
3137 String collectionFolder = mds.getCollectionName();
3138
3139 try{
3140 FileWriter fstream = new FileWriter(destination+"/"+fileName+"_Suggestion.html");
3141 BufferedWriter out = new BufferedWriter(fstream);
3142 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
3143 out.write ("<html>\r\n");
3144 out.write("<head>\r\n<title>Potential Duplicate List</title>\r\n");
3145 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
3146 out.write("<style type=\"text/css\">\r\n");
3147 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
3148 out.write(".tam{height:20; text-align:center}\r\n");
3149 out.write("th{height:20; text-align:left;}\r\n");
3150 out.write("body{font-family: Arial;}\r\n");
3151 out.write("</style>\r\n");
3152 out.write("</head><body>\r\n");
3153 out.write("<p><a href=\" Overall.html \">Summary</a>");
3154 out.write("&raquo;");
3155 if(metadataSetName.equalsIgnoreCase("dublin")){
3156 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3157 }
3158 else if (metadataSetName.equalsIgnoreCase("extracted")){
3159 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3160 }
3161 else{
3162 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3163 }
3164 out.write("&raquo;");
3165 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
3166 out.write("<h3 align=center>Potential Duplicate List</h3>");
3167 out.write("<table border=1 align=center>\r\n");
3168 //out.write("<tr><td>&nbsp;<td>&nbsp;\r\n");
3169 Set s = distanceMap.keySet();
3170 Iterator i = s.iterator();
3171 while(i.hasNext()){
3172 //printWriter.write("<!-- generating all possible page-->");
3173 //printWriter.flush();
3174 String keyword = (String)i.next();
3175 InternalLink il = (InternalLink)distanceMap.get(keyword);
3176 //ArrayList alist = il.retrieveList();
3177 ArrayList alist = il.retrieveNodeList();
3178 //out.write("<tr><td>&nbsp;<td>&nbsp;\r\n");
3179 //System.out.println("here");
3180
3181 //out.write("<tr><th>"+keyword+"\r\n");
3182 out.write("<tr><th>Original Text<th>Source Link\r\n");
3183 for(int a = 0; a<alist.size(); a++){
3184 InternalLink il2 = new InternalLink();
3185 il2 = (InternalLink)alist.get(a);
3186 String url = (String)il2.retrieveList().get(0);
3187 out.write("<tr><td>"+il2.getValue()+"<td><a href=\""+url+"\">"+url+"</a>");
3188 //out.write("<tr><td>"+(String)alist.get(a));
3189 }
3190 out.write("</tr>");
3191 //System.out.println("\n\n");
3192 }
3193 out.write("</table>\r\n");
3194
3195 out.write("<p><a href=\" Overall.html \">Summary</a>");
3196 out.write("&raquo;");
3197 if(metadataSetName.equalsIgnoreCase("dublin")){
3198 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3199 }
3200 else if (metadataSetName.equalsIgnoreCase("extracted")){
3201 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3202 }
3203 else{
3204 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3205 }
3206 out.write("&raquo;");
3207 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
3208 out.write("</body></html>\r\n");
3209 out.close();
3210 fstream.close();
3211 }catch(IOException ex){ex.printStackTrace();}
3212
3213 //distanceMap.clear();
3214 //System.gc();
3215 }
3216
3217 public int calculateEditDistance(char[] args1, char[] args2){
3218
3219 int n = args1.length;
3220 int m = args2.length;
3221 if (n == 0) {
3222 return m;
3223 }
3224 else if (m == 0) {
3225 return n;
3226 }
3227
3228 int[] p = new int[n + 1];
3229 int[] d = new int[n + 1];
3230 int[] _d;
3231
3232
3233 int i;
3234 int j;
3235
3236 int cost; // cost
3237
3238 for (i = 0; i <= n; i++) {
3239 p[i] = i;
3240 }
3241 for (j = 1; j <= m; j++) {
3242
3243 d[0] = j;
3244 for (i = 1; i <= n; i++) {
3245 cost = (args1[i-1] == args2[j-1]) ? 0 : 1;
3246 d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1),
3247 p[i - 1] + cost);
3248 }
3249
3250 // copy current distance counts to 'previous row' distance counts
3251 _d = p;
3252 p = d;
3253 d = _d;
3254 }
3255 // our last action in the above loop was to switch d and p, so p now
3256 // actually has the most recent cost counts
3257 return p[n];
3258 }
3259
3260 private String removeUnusedCharacter(String target){
3261 //printWriter.write("<!-- generating all possible page-->");
3262 //printWriter.flush();
3263
3264 // remove \n
3265 while(true){
3266 if(target.contains("\\n")){
3267 target = target.replaceFirst("\\\\n","");
3268 }
3269 else{
3270 break;
3271 }
3272 }
3273
3274 //remove spaces at the end of string
3275 if(target.length()>1){
3276 while(true){
3277 //printWriter.write("<!-- generating all possible page-->");
3278 //printWriter.flush();
3279 if(target.length()>1){
3280 if(target.charAt(target.length()-1)==' '){
3281 target = target.substring(0,target.length()-1);
3282 }
3283 else{
3284 break;
3285 }
3286 }
3287 else{
3288 break;
3289 }
3290 }
3291 }
3292 //remove leading spaces
3293 if(target.length()>1){
3294 while(true){
3295 //printWriter.write("<!-- generating all possible page-->");
3296 //printWriter.flush();
3297 if(target.length()>1){
3298 if(target.charAt(0)==' '){
3299 target = target.substring(1,target.length());
3300 }
3301 else{
3302 break;
3303 }}
3304 else{
3305 break;
3306 }
3307 }
3308 }
3309 //remove multiple spaces between words
3310 while(true){
3311 //printWriter.write("<!-- generating all possible page-->");
3312 //printWriter.flush();
3313 if(target.contains(" ")){
3314 target = target.replaceFirst(" "," ");
3315 }
3316 else{
3317 break;
3318 }
3319 }
3320 //printWriter.write("<!-- generating all possible page-->");
3321 //printWriter.flush();
3322 return target;
3323 }
3324
3325
3326 private costModel removeUnusedCharacter(String target, double cost){
3327 //printWriter.write("<!-- generating all possible page-->");
3328 //printWriter.flush();
3329
3330 costModel cm = new costModel();
3331
3332 // remove \n plus cost
3333 while(true){
3334 //printWriter.write("<!-- generating all possible page-->");
3335 //printWriter.flush();
3336 if(target.contains("\\n")){
3337 target = target.replaceFirst("\\\\n","");
3338 cost = cost + 0.2;
3339 }
3340 else{
3341 break;
3342 }
3343 }
3344
3345 //remove spaces at the end of string
3346 if(target.length()>1){
3347 while(true){
3348 if(target.length()>1){
3349 if(target.charAt(target.length()-1)==' '){
3350 target = target.substring(0,target.length()-1);
3351 cost = cost + 0.2;
3352 }
3353 else{
3354 break;
3355 }}
3356 else{
3357 break;
3358 }
3359 }
3360 }
3361 //remove leading spaces
3362 if(target.length()>1){
3363 while(true){
3364 //printWriter.write("<!-- generating all possible page-->");
3365 //printWriter.flush();
3366 if(target.length()>1){
3367 if(target.charAt(0)==' '){
3368 target = target.substring(1,target.length());
3369 cost = cost + 0.2;
3370 }
3371 else{
3372 break;
3373 }}
3374 else{
3375 break;
3376 }
3377 }
3378 }
3379 //remove multiple spaces between words
3380 while(true){
3381 //printWriter.write("<!-- generating all possible page-->");
3382 //printWriter.flush();
3383 if(target.contains(" ")){
3384 target = target.replaceFirst(" "," ");
3385 cost = cost + 0.2;
3386 }
3387 else{
3388 break;
3389 }
3390 }
3391
3392 cm.setCost(cost);
3393 cm.setString(target);
3394 //printWriter.write("<!-- generating all possible page-->");
3395 //printWriter.flush();
3396 return cm;
3397 }
3398
3399 /////////////////////////////////////////////////////////////////////////////////// Extra
3400
3401 private HashMap generateMetadataElementSortListNoIdentifier(String title, String sort, String metadataSetName,PrintWriter outx){
3402
3403 String fileName = title+"_"+sort;
3404 String collectionFolder = mds.getCollectionName();
3405 System.out.println("level 3");
3406 SearchLink sl = new SearchLink(mds.StatsDirectory);
3407 System.out.println("level 4");
3408 HashMap suggestionMap = new HashMap();
3409
3410 HashMap internalIDMap = dm.getInternalIdentifier(title);
3411 boolean status = false;
3412
3413 try{
3414 printWriter.write("<!-- generating all possible page-->");
3415 printWriter.flush();
3416
3417 FileWriter fstream = new FileWriter(destination+"/"+fileName+".html");
3418 BufferedWriter out = new BufferedWriter(fstream);
3419
3420 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
3421 out.write ("<html>\r\n");
3422 out.write("<head>\r\n<title>Metadata Element Sort List</title>\r\n");
3423 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
3424 out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
3425 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");
3426 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");
3427 out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");
3428
3429 out.write("<style type=\"text/css\">\r\n");
3430 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
3431 out.write(".tam{height:20; text-align:center}\r\n");
3432 out.write("th{height:20; text-align:center;}\r\n");
3433 out.write("body{font-family: Arial;}\r\n");
3434 out.write("</style>\r\n");
3435 out.write("</head><body id=\""+collectionFolder+"\">\r\n");
3436
3437 out.write("<td><div style=\"float:left;\"><a href=\" Overall.html \">Summary</a>");
3438 out.write("&raquo;");
3439 ////////////////////////////////////////////////////////////////////////////////////
3440 if(metadataSetName.equalsIgnoreCase("dublin")){
3441 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3442 }
3443 else if (metadataSetName.equalsIgnoreCase("extracted")){
3444 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3445 }
3446 else{
3447 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3448 }
3449 out.write("&raquo;");
3450 out.write("<a href=\""+title+".html\">"+title+"</a></div>");
3451
3452
3453 // out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
3454 out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
3455
3456
3457 String[] list = dm.getSortList(title, sort);
3458 //String Link = "Link";
3459 //int MaxLinks = 2;
3460
3461
3462 if(list.length>=1){
3463
3464
3465 if(sort.equals("ASCII")){
3466
3467 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
3468 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
3469 out.write ("<th class=\"tam\">ASCII Sort\r\n");
3470 out.write ("<th class=\"tam\">Element Values\r\n");
3471 out.write ("<th class=\"tam\">Source Documents\r\n");
3472 out.write ("<th class=\"tam\">Internal Link\r\n");
3473
3474 out.write ("<a name='topFive'>\r\n");
3475
3476 int counter = 0;
3477
3478 for(int i = 0; i<list.length; i++){
3479 //suggestionMap.put(list[i], "No Source Available");
3480 if(list.length<=5 && i==0){
3481 out.write ("<a name='lastFive'>\r\n");
3482 }
3483 else if((list.length>5) && (list.length-5==i)){
3484 out.write ("<a name='lastFive'>\r\n");
3485 }
3486
3487
3488 InternalLink il= (InternalLink)internalIDMap.get(list[i]);
3489 ArrayList alist2 = il.retrieveList();
3490 String id = (String)alist2.get(0);
3491 id = id.substring(4);
3492 out.write("<tr id=\""+id+"\" >\r\n");
3493
3494
3495 //out.write("<tr>\r\n");
3496
3497 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder);
3498 //out.write("<td>"+"Length"+alist.size());
3499
3500 if(list[i].length()>=201){
3501 if(list[i].startsWith("http://")){
3502
3503 if(list[i].length()>=100){
3504 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
3505 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
3506 }
3507 else{
3508 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
3509 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
3510 }
3511
3512 }
3513 else{
3514
3515 if(list[i].startsWith(" ")){
3516 String elements = list[i];
3517 list[i] = list[i].substring(1);
3518 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>No Source Available \r\n");
3519 }
3520 else{
3521 out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... <td>No Source Available\r\n");
3522 }
3523 }
3524
3525 }
3526 else{
3527
3528
3529 if(list[i].startsWith("http://")){
3530
3531 if(list[i].length()>=100){
3532 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
3533 }
3534 else{
3535 out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
3536 }
3537 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
3538
3539 }
3540
3541 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
3542
3543 else{
3544
3545 if(list[i].startsWith(" ")){
3546 String elements = list[i];
3547 list[i] = list[i].substring(1);
3548
3549 out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
3550 suggestionMap.put(elements,"No Source Available");
3551
3552 }
3553 else{
3554 out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td>No Source Available\r\n");
3555 }
3556 }
3557 }
3558 counter++;
3559 out.write("<td onclick=\"GD(this)\">View");
3560 }
3561 //if(suggestionMap.size()>1 && !title.equals("dc.Identifier")){
3562
3563 //return suggestionMap;
3564 }
3565 else{
3566
3567
3568 out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
3569 out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
3570 out.write ("<th class=\"tam\">&nbsp;\r\n");
3571 out.write ("<th class=\"tam\">Frequency\r\n");
3572 out.write ("<th class=\"tam\">Element Values\r\n");
3573 out.write ("<th class=\"tam\">Source Documents\r\n");
3574 out.write ("<th class=\"tam\">Internal Link\r\n");
3575 out.write ("<a name='topFive'>\r\n");
3576
3577 HashMap xMap = dm.getDistinctValueMap(title);
3578 int counter = 0;
3579 for(int i = 0; i<list.length; i++){
3580 if(list.length<=5 && i==0){
3581 out.write ("<a name='lastFive'>\r\n");
3582 }
3583 else if((list.length>5) && (list.length-5==i)){
3584 out.write ("<a name='lastFive'>\r\n");
3585 }
3586 //out.write("<tr>\r\n");
3587 InternalLink il= (InternalLink)internalIDMap.get(list[i]);
3588 ArrayList alist2 = il.retrieveList();
3589 String id = (String)alist2.get(0);
3590 id = id.substring(4);
3591 out.write("<tr id=\""+id+"\" >\r\n");
3592
3593 out.write("<td>"+(counter+1)+"<th> "+((Integer)xMap.get(list[i])).toString()+"\r\n");
3594
3595 if(list[i].length()>=201){
3596
3597 if(list[i].startsWith("http://")){
3598 if(list[i].length()>=100){
3599 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
3600 }
3601 else{
3602 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
3603 }
3604
3605 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
3606 }
3607
3608
3609
3610
3611 else{
3612 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
3613
3614 if(list[i].startsWith(" ")){
3615 list[i]=list[i].substring(1);
3616
3617 out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>No Source Available\r\n");
3618
3619 }
3620 else{
3621
3622 out.write("<td>"+list[i].substring(0,200)+"...<td>No Source Available\r\n");
3623
3624 }
3625 }
3626 }
3627 else{
3628 if(list[i].startsWith("http://")){
3629 if(list[i].length()>=100){
3630 out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
3631 }
3632 else{
3633 out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
3634 }
3635 out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
3636
3637 }
3638 else{
3639
3640 //ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
3641
3642 if(list[i].startsWith(" ")){
3643 list[i]=list[i].substring(1);
3644 //out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
3645
3646 out.write("<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
3647
3648 }
3649 else{
3650
3651 out.write("<td>"+list[i]+"<td>No Source Available\r\n");
3652
3653 }
3654 }
3655 }
3656 counter++;
3657 out.write("<td onclick=\"GD(this)\">View");
3658 }
3659 }
3660 out.write("</table>\r\n");
3661 }
3662 else{
3663 out.write("<p>Sorry! The list is empty</p>");
3664 }
3665 out.write("<tr>\r\n");
3666
3667
3668 out.write("<p><a href=\" Overall.html \">Summary</a>");
3669 out.write("&raquo;");
3670 ////////////////////////////////////////////////////////////////////////////////////
3671 if(metadataSetName.equalsIgnoreCase("dublin")){
3672 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3673 }
3674 else if (metadataSetName.equalsIgnoreCase("extracted")){
3675 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3676 }
3677 else{
3678 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3679 }
3680 out.write("&raquo;");
3681 out.write("<a href=\""+title+".html\">"+title+"</a></p>");
3682 out.write("</body></html>\r\n");
3683 out.close();
3684 fstream.close();
3685 }catch(Exception e){
3686 //System.err.println("Error: " + e.getMessage());
3687 e.printStackTrace(outx);
3688 }
3689
3690 return new HashMap();
3691 //printWriter.write("<!-- generating all possible page-->");
3692 //printWriter.flush();
3693
3694 }
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727 private void createIncompletedListNoIdentifier(String fileName, String metadataSetName, String collectionFolder,PrintWriter outx){
3728 //HashMap hp = dm.getIdentifierLink("dc.Identifier");
3729 HashMap hp = dm.getIdentifierLinkNoIdentifier();
3730 String[] ids = dm.getDocumentIDList(fileName);
3731 System.out.println("Length: "+ids.length+" "+fileName+ " "+hp.size());
3732
3733 Set st = hp.keySet();
3734 Iterator it = st.iterator();
3735 while(it.hasNext()){
3736 System.out.println(it.next());
3737 }
3738 for(int i = 0; i<ids.length; i++){
3739 System.out.println("IDS:" +ids[i]);
3740 hp.remove(ids[i]);
3741 }
3742 System.out.println("Length: "+ids.length+" "+fileName+ " "+hp.size());
3743 //String collectionFolder = mds.getCollectionName();
3744 //System.out.println(hp.size());
3745 try{
3746 FileWriter fstream = new FileWriter(destination+"/"+fileName+"_IncompletedList.html");
3747 BufferedWriter out = new BufferedWriter(fstream);
3748
3749 out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
3750 out.write ("<html>\r\n");
3751 out.write("<head>\r\n<title>Incompleted Document List</title>\r\n");
3752 out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
3753 out.write("<style type=\"text/css\">\r\n");
3754 out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
3755 out.write(".tam{height:20; text-align:center}\r\n");
3756 out.write("th{height:20; text-align:center;}\r\n");
3757 out.write("body{font-family: Arial;}\r\n");
3758 out.write("</style>\r\n");
3759 out.write("</head><body>\r\n");
3760
3761 out.write("<p><a href=\" Overall.html \">Summary</a>");
3762 out.write("&raquo;");
3763 if(metadataSetName.equalsIgnoreCase("dublin")){
3764 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3765 }
3766 else if (metadataSetName.equalsIgnoreCase("extracted")){
3767 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3768 }
3769 else{
3770 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3771 }
3772 out.write("&raquo;");
3773 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
3774
3775 out.write("<h3 align=center>"+fileName+" does not appear in the following documents</h3>");
3776 int counter = 0;
3777 System.out.println("link.....");
3778 Set s = hp.keySet();
3779 Iterator i = s.iterator();
3780 System.out.println("link2.....");
3781 out.write("<table border=1 align=center><tr><th>Document ID<th>Source Link\r\n");
3782 while(i.hasNext()){
3783 //printWriter.write("<!-- generating all possible page-->");
3784 System.out.println("link.....3");
3785 counter++;
3786 String keys = (String)i.next();
3787 System.out.println("link.....4"+keys);
3788 InternalLink il = (InternalLink) hp.get(keys);
3789
3790 ArrayList alist = il.retrieveList();
3791 System.out.println("link.....5"+alist.size());
3792 String url = (String)alist.get(0);
3793 out.write("<tr><td>"+counter+"<td><a href=\""+url+"\">"+url+"</a>\r\n");
3794 }
3795 out.write("</table></body></html>\r\n");
3796
3797
3798 out.write("<p><a href=\" Overall.html \">Summary</a>");
3799 out.write("&raquo;");
3800 if(metadataSetName.equalsIgnoreCase("dublin")){
3801 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>");
3802 }
3803 else if (metadataSetName.equalsIgnoreCase("extracted")){
3804 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>");
3805 }
3806 else{
3807 out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>");
3808 }
3809 out.write("&raquo;");
3810 out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
3811
3812 out.close();
3813 fstream.close();
3814 }catch(IOException ex){ex.printStackTrace();}
3815
3816
3817 }
3818 ///////////////////////////////////////////////////////////////////////////////////////
3819}
3820
Note: See TracBrowser for help on using the repository browser.