Coverage report: /home/samppa/personal/opiskelu/ohtuprojekti/pulsu/trunk/document-view3.lisp
Kind | Covered | All | % |
expression | 3 | 89 | 3.4 |
branch | 0 | 28 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
3
; group is non-nil if we are viewing a unified group
4
; nil if we are viewing document cases
5
(defhtml render-case-attributes (row group page back)
8
(:div :id "right_container"
10
:name "attributes" :action "/updatedb"
11
(:input :type "button" :id "newcase" :value "New Case" :onclick "toNew();")
16
(:em (:span :id "wrong_values"))
17
(:em (:span :id "modified_text"))
18
(:input :type "hidden" :value "" :name "doc_selected_cases")
19
(:input :type "hidden" :value "" :name "submitter")
20
(:input :type "hidden" :value (getf row :docno) :name "docno")
21
(:input :type "hidden" :value page :name "page")
22
(:input :type "hidden" :value back :name "back")
25
(:input :type "hidden" :value (getf row :group_number) :name "group_number")))
26
(:input :type "hidden" :value (getf row :doc_date) :name "published")
27
(:input :type "hidden"
28
:value (getf row :event_id) :name "event_id"))
31
(:input :type "button" :id "accept" :value "Accept case" :onclick "submit('accept');")
32
(:input :type "button" :id "reject" :value "Reject case" :onclick "submit('reject');")))))
34
(defpage (updatedb :uri "/updatedb")
35
(docno event_id doc_selected_cases
36
submitter group_number page back search)
37
(puls.controller::authenticate-user)
38
(let* ((params (format nil "&search=~A&back=~A" search back))
39
; selected becomes ((docno0 event_id0) (docno1 event_id1) ...)
41
(loop :for i :in (cl-ppcre:split ";" doc_selected_cases)
42
:collect (cl-ppcre:split ":" i)))
44
(append (list :docno docno :event_id event_id)
45
(loop :for a :in (puls.controller:get-attrs)
46
:for value = (get-parameter (attr-id a))
47
:when (> (length value) 0)
48
:nconcing (list (attr-field a) value)))))
50
(cond ((string= "reject" submitter)
51
(puls.controller:reject-event docno event_id)
52
(if (null group_number)
54
(format nil "/dv?n=~A~A" docno params))
56
(format nil "/dv?group_number=~A~A" group_number params))))
58
((string= "reject_all" submitter)
59
(loop :for (docno c) :in selected
60
:do (puls.controller:reject-event docno c))
61
(if (null group_number)
63
(format nil "/dv?n=~A~A" docno params))
65
(format nil "/dv?group_number=~A~A" group_number params))))
67
((string= "remove_selected" submitter)
68
(loop :for (docno c) :in selected
69
:do (puls.controller:reject-event docno c)))
71
((string= "verify" submitter)
72
(puls.controller:verify-unified-case group_number "Web"))
74
; this probably doesn't work....
75
((string= "verify_all" submitter)
76
(loop :for (group_number) :in selected
77
:do (puls.controller:verify-unified-case group_number "Web")))
83
(handler-case (puls.controller:clean-row
85
(puls.controller:get-document-text docno))
86
(invalid-attr-value (y)
91
(hunchentoot:url-encode
93
"Invalid value '~A' for attribute '~A'"
94
(invalid-attr-value-value y)
95
(attr-desc (invalid-attr-value-attr y)))))))))
97
(cond ((string= "acceptnew" submitter)
98
(puls.controller:add-event docno attributes)
100
(format nil "/dv?n=~A~A" docno params)))
102
((string= "accept" submitter)
103
(puls.controller:set-event
105
(append '(:verify "Web") attributes))
106
(puls.controller:reunify-event docno event_id))
108
((string= "accept_all" submitter)
109
(loop :for (docno c) :in selected
110
:do (puls.controller:set-event docno c attributes)
111
:do (puls.controller:reunify-event docno c))
112
(puls.controller:set-event docno event_id attributes)
113
(puls.controller:reunify-event docno event_id)))))
116
(hunchentoot:redirect
117
(format nil "/dv?n=~A&c=~A&group_number=~A&page=~A~A"
118
docno event_id group_number page params))))
120
(defhtml render-main-content (string row rows)
121
(let* ((string (highlight-document string row rows))
122
(split (cl-ppcre:split "\\n" string :limit 4)))
124
(:div :id "main_content"
125
(:h2 (str (nth 2 split)))
126
(:p (str (nth 3 split)))))))
129
(defpage (setselected :uri "/setselected") (selected_cases docno event_id group_number back page)
131
(hunchentoot:redirect (format nil "/dv?n=~A&c=~A&selected_cases=~A&group_number=~A&back=~A&page=~A"
132
docno event_id selected_cases group_number back page)))
136
(defpage (document-view :uri "/dv")
137
((n :parameter-type 'STRING)
138
(c :parameter-type 'INTEGER)
139
(group_number :parameter-type 'INTEGER)
140
(selected_cases :parameter-type 'STRING :init-form "")
141
(msg :parameter-type 'STRING))
142
(puls.controller::authenticate-user)
145
((not (or (null n) (null c)))
146
(puls.controller:get-event n c))
148
(first (get-document-events n)))
149
((not (null group_number))
150
(first (puls.controller:get-unified-case group_number)))
152
(puls.controller:get-event
153
"20051227_reliefWeb_622c2b995e5cc2fa20fd343a3fd4a149"
155
(docevents (puls.controller:get-document-events n)))
158
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
160
:xmlns "http://www.w3.org/1999/xhtml"
164
(:meta :http-equiv "Content-Type"
165
:content "text/html;charset=iso-8859-1")
166
(:title "Document view")
167
(:link :href "static/docustyle.css" :rel "stylesheet" :type "text/css")
168
(:link :href "static/headerstyle.css" :rel "stylesheet" :type "text/css")
169
(:script :language "javascript"
170
:type "text/javascript"
171
:src "static/docuscript.js")
172
(:script :language "javascript"
173
:type "text/javascript"
174
:src "static/switch_input.js")
175
(:script :language "javascript"
176
:type "text/javascript"
177
:src "static/prototype-1.6.0.3.js")
178
(:script :language "javascript"
179
:type "text/javascript"
180
:src "static/tests.js")
181
(:script :language "javascript"
182
:type "text/javascript"
183
:src "static/jsunit/app/jsUnitCore.js"))
186
:onload "markChecked()"
193
(link* "Back to list" (if (get-parameter "back") (get-parameter "back") "newest")
194
:page (get-parameter "page")
195
:search (get-parameter "search")
196
:snippet (get-parameter "snippet"))
199
(if (null group_number)
202
(if (null group_number)
204
(htm (:div :class "group_view_tab"
205
(link-here* "Unified"
206
:group_number (getf row :group_number)))
207
(:div :class "doc_view_tab"
209
(:h3 "Document cases"))
211
(htm (:div :class "doc_view_tab"
212
(link-here* "Document"
214
(:div :class "group_view_tab"
216
(:h3 "Unified cases")))
218
(link "All" "javascript:selectAll()") ","
219
(link "None" "javascript:selectNone()") ","
220
(link "Invert" "javascript:selectInvert()")
223
:action "setselected"
224
(:input :type "hidden" :name "selected_cases" :value selected_cases)
225
(:input :type "hidden" :name "docno"
226
:value (getf row :docno))
227
(:input :type "hidden" :name "event_id"
228
:value (getf row :event_id))
229
(:input :type "hidden" :name "group_number"
231
(:input :type "hidden" :name "back"
232
:value (get-parameter "back"))
233
(:input :type "hidden" :name "page"
234
:value (get-parameter "page"))
236
(if (null group_number)
238
(render-left-container
244
(render-left-container
248
(puls.controller:get-unified-case group_number))))))
250
(render-case-attributes row group_number (get-parameter "page") (get-parameter "back"))
251
(render-main-content (puls.controller:get-document-text
252
(getf row :docno)) row docevents))
256
(defhtml render-left-container (current-n current-c row)
257
(let ((id (unique-id "case")))
261
(:input :type "checkbox"
263
:value (format nil "~A:~A" (getf row :docno) (getf row :event_id))
264
:onclick "checkChecked(id)")
266
(if (and (string= current-n (getf row :docno))
267
(= current-c (getf row :event_id)))
269
(:strong :id (format nil "~A~A" "link" id) :class "current"
270
(str (first (puls.controller:get-trigger-spans row)))))
271
(htm (:span :id (format nil "~A~A" "link" id) :class "uncheckd"
272
(link-here* (first (puls.controller:get-trigger-spans row))
274
:c (getf row :event_id)
279
(deftest test-document-view ()
282
(test-attribute-plain)
283
(test-attribute-select)
284
(test-attribute-status_select)
285
(test-attribute-text)
286
(test-render-case-attributes)
287
(test-render-main-content)))
289
(deftest test-switch-input ()
290
(check (equal (with-output-to-string (*http-stream*)
291
(switch-input "test"))
294
<a onclick=\"switch_input('test');\">
295
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
299
(deftest test-attribute-plain()
300
(check (equal (with-output-to-string (*http-stream*)
301
(render-attr (first (get-attrs)) '(:doc_date "abc")))
303
<tr id=\"doc_date_tr\">
304
<td id=\"doc_date_text\">Published
312
(deftest test-attribute-select()
315
(with-output-to-string (*http-stream*)
316
(puls.ui::render-attr (second (puls.controller::get-attrs))
317
'(:docno "20051106_IHT_6d2d65033534bfb3bd242fd8847ff941" :event_id 1)))
319
<tr id=\"disease_name_tr\">
320
<td id=\"disease_name_text\">Disease
323
<a onclick=\"switch_input('disease_name');\">
324
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
328
<select name=\"disease_name\" id=\"disease_name_id\" onchange=\"checkAttributes()\">
329
<option value=\"China's fourth reported outbreak\">China's fourth reported outbreak
331
<option value=\"The outbreak\">The outbreak
333
<option value=\"a virus\">a virus
335
<option value=\"SARS\">SARS
337
<option value=\"a public health threat bird flu\">a public health threat bird flu
339
<option value=\"the disease\">the disease
341
<option value=\"the virus\">the virus
343
<option value=\"H5N1\">H5N1
345
<option value=\"an outbreak\">an outbreak
347
<option value=\"pneumonia\">pneumonia
349
<option value=\"the H5N1 bird flu virus\">the H5N1 bird flu virus
351
<option value=\"bird flu\">bird flu
357
(deftest test-attribute-status_select ()
358
(check (equal (with-output-to-string (*http-stream*)
359
(render-attr (nth 7 (get-attrs)) '(:case_status "dead")))
361
<tr id=\"case_status_tr\">
362
<td id=\"case_status_text\">Status
365
<a onclick=\"switch_input('case_status');\">
366
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
370
<select name=\"case_status\" id=\"case_status_id\" onchange=\"checkAttributes()\">
371
<option value=\"sick\">sick
373
<option value=\"dead\" selected=\"selected\">dead
379
(deftest test-attribute-text ()
380
(check (equal (with-output-to-string (*http-stream*)
381
(render-attr (nth 8 (get-attrs)) '(:descriptor "abc")))
383
<tr id=\"case_descriptor_tr\">
384
<td id=\"case_descriptor_text\">Descriptor
387
<a onclick=\"switch_input('case_descriptor');\">
388
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
392
<input type=\"text\" name=\"case_descriptor\" id=\"case_descriptor_id\" size=\"20\" />
396
(deftest test-render-case-attributes ()
397
(let* ((docno "20050101_bbc_b118e8867977ba4feae312bb5ea17ef4")
398
(row (puls.controller:get-event docno 1)))
400
(check (equal (with-output-to-string (*http-stream*)
403
<tr id=\"doc_date_tr\">
404
<td id=\"doc_date_text\">Published
410
<tr id=\"disease_name_tr\">
411
<td id=\"disease_name_text\">Disease
414
<a onclick=\"switch_input('disease_name');\">
415
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
419
<select name=\"disease_name\" id=\"disease_name_id\" onchange=\"checkAttributes()\">
420
<option value=\"weapons-grade anthrax\">weapons-grade anthrax
425
<tr id=\"country_tr\">
426
<td id=\"country_text\">Country
429
<a onclick=\"switch_input('country');\">
430
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
434
<select name=\"country\" id=\"country_id\" onchange=\"checkAttributes()\">
435
<option value=\"the US\">the US
437
<option value=\"Iraq\">Iraq
439
<option value=\"Washington\">Washington
441
<option value=\"US\">US
446
<tr id=\"location_tr\">
447
<td id=\"location_text\">Location
450
<a onclick=\"switch_input('location');\">
451
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
455
<select name=\"location\" id=\"location_id\" onchange=\"checkAttributes()\">
460
<td id=\"time_text\">Time
463
<a onclick=\"switch_input('time');\">
464
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
468
<select name=\"time\" id=\"time_id\" onchange=\"checkAttributes()\">
469
<option value=\"after the 1991\">after the 1991
471
<option value=\"May 2003\" selected=\"selected\">May 2003
476
<tr id=\"norm_stime_tr\">
477
<td id=\"norm_stime_text\">Begin
480
<a onclick=\"switch_input('norm_stime');\">
481
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
485
<select name=\"norm_stime\" id=\"norm_stime_id\" onchange=\"checkAttributes()\">
486
<option value=\"1991\">1991
488
<option value=\"2003.05\" selected=\"selected\">2003.05
493
<tr id=\"norm_etime_tr\">
494
<td id=\"norm_etime_text\">End
497
<a onclick=\"switch_input('norm_etime');\">
498
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
502
<select name=\"norm_etime\" id=\"norm_etime_id\" onchange=\"checkAttributes()\">
503
<option value=\"2005\">2005
505
<option value=\"2003.05\" selected=\"selected\">2003.05
510
<tr id=\"case_status_tr\">
511
<td id=\"case_status_text\">Status
514
<a onclick=\"switch_input('case_status');\">
515
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
519
<select name=\"case_status\" id=\"case_status_id\" onchange=\"checkAttributes()\">
520
<option value=\"sick\">sick
522
<option value=\"dead\" selected=\"selected\">dead
527
<tr id=\"case_descriptor_tr\">
528
<td id=\"case_descriptor_text\">Descriptor
531
<a onclick=\"switch_input('case_descriptor');\">
532
<img class=\"switch_image\" src=\"static/switch_button.jpg\" alt=\"switch input\" />
536
<input type=\"text\" name=\"case_descriptor\" id=\"case_descriptor_id\" size=\"20\" value=\"any detainee\" />
539
<tr id=\"confidence_tr\">
540
<td id=\"confidence_text\">Confidence
546
<tr id=\"source_tr\">
547
<td id=\"source_text\">Source
553
<tr id=\"verify_tr\">
554
<td id=\"verify_text\">Verify
561
(deftest test-render-main-content ()
562
(let* ((docno "20050101_bbc_b118e8867977ba4feae312bb5ea17ef4")
563
(row (puls.controller:get-event docno 1)))
565
(check (equal (with-output-to-string (*http-stream*)
566
(render-main-content (puls.controller:get-document-text docno)
567
row (puls.controller:get-document-events docno)))
569
<div id=\"main_content\">
570
<h2>Iraq's jailed Mrs Anthrax 'dying'
572
<p>The jailed Iraqi microbiologist dubbed Mrs Anthrax is seriously ill and should be freed, an Iraqi lawyer has said. Dr Huda Salih Mahdi Ammash is dying from cancer, according to Badih Aref - who represents imprisoned former Iraqi deputy Prime Minister Tariq Aziz. The lawyer said his client had asked him to help Dr Ammash, who was in \"terrible pain\". Dr Ammash is one of two high profile Iraqi women arrested by US troops in <span class='time'>May 2003</span> and held at a secret location. The US military refused to comment on Dr Ammash's health. \"Certainly, we have medical care available to take care of <span class='case_descriptor'>any detainee</span>,\" a US military spokesman told AP news agency. 'Relapse' Mr Aref said Tariq Aziz passed on the information about Dr Ammash during a meeting. \"When I met Mr Aziz, he told me 'her case is more than important than mine,' Mr Aref said. \"She is always in terrible pain because of cancer, her medical condition is worsening quickly and is she remains like that <strong>she will undoubtedly die</strong>,\" the lawyer said. Mr Aref said Dr Ammash had been treated for <span class='disease_name'>breast cancer</span> before her arrest and had now suffered a relapse. The scientist was one of the few women in Saddam Hussein's inner circle and the only one on the US list of 55 most wanted Iraqis. She was the only female member of the Iraq Command, the 18-member council that ran the Baath Party, as well as a party regional commander. However the US-educated microbiologist is best known for her alleged involvement with the weapons of mass destruction programme. Dubbed \"Mrs Anthrax\" by Washington, US intelligence services say she masterminded the reconstruction of Iraq's biological weapons facilities after the 1991 Gulf War. The other high profile Iraqi woman imprisoned by <span class='location'>the US</span> is microbiologist Dr Rihab Rashid Taha, who became known as Dr Germ for helping Iraq develop weapons-grade anthrax.