-
Notifications
You must be signed in to change notification settings - Fork 8
/
admin.xhtml
755 lines (715 loc) · 36.8 KB
/
admin.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012 Ethan Gruber
xEAC: https://github.com/ewg118/xEAC
Apache License 2.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xeac="https://github.com/ewg118/xEAC"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:eac="urn:isbn:1-931666-33-4" xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:saxon="http://saxon.sf.net/"
xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:exist="http://exist.sourceforge.net/NS/exist">
<head>
<title>xEAC Administration</title>
<link rel="stylesheet" href="/fr/style/bootstrap/css/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="/fr/style/form-runner-bootstrap-override.css" type="text/css"/>
<link rel="stylesheet" href="/config/theme/examples.css" type="text/css" media="all"/>
<link rel="shortcut icon" href="/ops/images/orbeon-icon-16.ico"/>
<link rel="icon" href="/ops/images/orbeon-icon-16.png" type="image/png"/>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/grids-min.css"/>
<link rel="stylesheet" type="text/css" href="/apps/xeac/xforms/css/xforms.cs"/>
<xforms:model>
<!-- exist URL is stored in an XML file -->
<xforms:instance id="exist-url">
<xi:include href="exist-url.xml"/>
</xforms:instance>
<xforms:instance id="control-instance">
<controls xmlns="">
<id/>
<identifiers/>
<publicationStatus/>
<collection-name/>
<status/>
<error/>
<numFound/>
<page>1</page>
<query_input/>
<query_sent/>
<solr-core/>
</controls>
</xforms:instance>
<xforms:instance id="config">
<config xmlns=""/>
</xforms:instance>
<xforms:instance id="config-template">
<config version="0.1">
<flickr_api_key/>
<geonames_api_key/>
<title>xEAC</title>
<banner_text>xEAC: XForms for EAC-CPF</banner_text>
<solr_published>http://localhost:8080/solr/xeac-published/</solr_published>
<url>http://localhost:8080/orbeon/xeac/</url>
<oai-pmh active="false"/>
<lang>en</lang>
<instances>
<agencyName-list>
<item default="true">Default Agency</item>
</agencyName-list>
</instances>
<theme>
<facets>
<facet>entityType</facet>
<facet>occupation</facet>
<facet>placeEntry</facet>
<facet>function</facet>
<facet>mandate</facet>
<facet>generalContext</facet>
<facet>legalStatus</facet>
<facet>localDescription</facet>
</facets>
<jquery_ui_theme>smoothness</jquery_ui_theme>
<layouts>
<index>
<yui_class>yui-t5</yui_class>
</index>
<results>
<yui_class>yui-t2</yui_class>
<image_location>right</image_location>
</results>
</layouts>
</theme>
</config>
</xforms:instance>
<xforms:instance id="list">
<list xmlns=""/>
</xforms:instance>
<xforms:instance id="item-template">
<item xmlns="">
<name/>
<id/>
<published/>
</item>
</xforms:instance>
<xforms:instance id="doc">
<eac-cpf xmlns=""/>
</xforms:instance>
<xforms:instance id="kml">
<kml/>
</xforms:instance>
<!-- xquery -->
<xforms:instance id="eXist-xquery">
<exist:query xmlns="">
<exist:text/>
</exist:query>
</xforms:instance>
<xforms:instance id="xqueries">
<queries xmlns="">
<query id="collection-count"><report>{count(collection())}</report></query>
<query id="get-objects"> declare namespace eac="urn:isbn:1-931666-33-4"; <report> { for $record in subsequence(collection(), START, 20) return <record>
<maintenanceStatus> {$record/eac:eac-cpf/eac:control/eac:maintenanceStatus/text()}</maintenanceStatus> <id>{$record//eac:recordId/text() }</id> <title>{
$record//eac:nameEntry[@xml:lang='en'][string(eac:preferredForm)][1]/text() }</title> <published/> </record> } </report> </query>
<query id="create-collection">xmldb:create-collection('/db/xeac', 'records')</query>
<query id="publish-all"><report> { for $foo in collection()[descendant::*:publicationStatus='approved'] return <item> { $foo//*:recordId } </item> } </report></query>
<!--<query id="query-objects"> <report> { for $record in collection()[contains(descendant::*[local-name()='unittitle'], 'QUERY') or descendant::*[local-name()='eadid'] = 'QUERY' or
descendant::*[local-name()='identifier'] = 'QUERY' or descendant::*[local-name()='recordIdentifier'] = 'QUERY' or contains(descendant::*[local-name()='title'], 'QUERY')] let
$type := $record/*/local-name() return if ($type='ead') then <record> <type>{ $type }</type> <id>{ $record//*[local-name()='eadid']/text() }</id> <title>{
$record//*[local-name()='archdesc']/*[local-name()='did']/*[local-name()='unittitle']/text() }</title> <components>{ if (count($record//*[local-name()='c']) > 0) then
'true' else 'false' }</components> <published/> </record> else <record> <type>{ $type }</type> <id>{
$record//*[local-name()='mods']/*[local-name()='recordInfo']/*[local-name()='recordIdentifier']/text() }</id> <title>{
$record//*[local-name()='mods']/*[local-name()='titleInfo']/*[local-name()='title']/text() }</title> <published/> </record> } </report> </query>-->
</queries>
</xforms:instance>
<xforms:instance id="pagination-result">
<exist:result/>
</xforms:instance>
<xforms:instance id="xquery-result">
<exist:result/>
</xforms:instance>
<!-- solr response for id query -->
<xforms:instance id="published-response">
<response xmlns=""/>
</xforms:instance>
<xforms:instance id="list-published-response">
<response xmlns=""/>
</xforms:instance>
<!-- send to Solr -->
<xforms:instance id="addIndex">
<add xmlns=""/>
</xforms:instance>
<xforms:instance id="addDoc">
<add xmlns=""/>
</xforms:instance>
<!-- Instance for Solr commit-->
<xforms:instance id="sendCommit">
<commit/>
</xforms:instance>
<!-- delete from Solr -->
<xforms:instance id="deleteId">
<delete xmlns="">
<query/>
</delete>
</xforms:instance>
<xforms:instance id="deleteAll">
<delete xmlns="">
<query>id:*</query>
</delete>
</xforms:instance>
<xforms:instance id="optimizeIndex">
<optimize/>
</xforms:instance>
<!--<xforms:bind nodeset="instance('config-template')">
<xforms:bind nodeset="title" required="true()"/>
<xforms:bind nodeset="url" required="true()" type="xs:anyURI"/>
<xforms:bind nodeset="solr_published" required="true()" type="xs:anyURI"/>
<xforms:bind nodeset="solr_all" required="true()" type="xs:anyURI"/>
</xforms:bind>-->
<!-- submissions -->
<xforms:submission id="load-config" serialization="none" method="get" action="{instance('exist-url')}xeac/config.xml" replace="instance" instance="config" xxforms:username="admin"
xxforms:password="">
<xforms:action ev:event="xforms-submit-done">
<!-- get the number of docs in the eXist collection() -->
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="instance('xqueries')/query[@id='collection-count']"/>
<xforms:send submission="xquery-collection"/>
<xforms:setvalue ref="instance('control-instance')/numFound" value="number(instance('xquery-result'))"/>
<!-- set value in control instance -->
<xxforms:variable name="end" select="if(instance('control-instance')/numFound > 20) then 20 else instance('control-instance')/numFound"/>
<!-- get list of files for page 1, replacing START and END -->
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '1')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
<xforms:action ev:event="xforms-submit-error">
<xforms:send submission="save-config"/>
</xforms:action>
</xforms:submission>
<xforms:submission id="save-config" ref="instance('config-template')" action="{instance('exist-url')}xeac/config.xml" method="put" replace="none" xxforms:username="admin"
xxforms:password="">
<xforms:message ev:event="xforms-submit-error" level="modal">Error Saving Config.</xforms:message>
<xforms:action ev:event="xforms-submit-done">
<xforms:send submission="create-records-collection"/>
</xforms:action>
</xforms:submission>
<xforms:submission id="create-records-collection" ref="instance('create-collection')" method="post" action="{instance('exist-url')}" replace="none" xxforms:username="admin"
xxforms:password="">
<xforms:action ev:event="xforms-submit-done">
<xforms:send submission="load-config"/>
</xforms:action>
</xforms:submission>
<!--***************** XQUERY ******************-->
<!-- xquery for getting and processing query results into pages of items -->
<xforms:submission id="xquery-pagination" ref="instance('eXist-xquery')" action="{instance('exist-url')}xeac/records" method="post" replace="instance" instance="pagination-result"
xxforms:username="admin" xxforms:password="">
<xforms:setvalue ref="instance('control-instance')/error" ev:event="xforms-submit-error">Error querying eXist database.</xforms:setvalue>
<xforms:action ev:event="xforms-submit-done">
<!--iterate through docs, check for publication -->
<xforms:action xxforms:iterate="instance('pagination-result')//record">
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:setvalue ref="instance('control-instance')/id" value="context()/id"/>
<xforms:send submission="query-solr-for-publication"/>
</xforms:action>
</xforms:action>
</xforms:submission>
<xforms:submission id="xquery-collection" ref="instance('eXist-xquery')" action="{instance('exist-url')}xeac/records" method="post" replace="instance" instance="xquery-result"
xxforms:username="admin" xxforms:password="">
<xforms:setvalue ref="instance('control-instance')/error" ev:event="xforms-submit-error">Error querying eXist database.</xforms:setvalue>
</xforms:submission>
<!--<xforms:submission id="temp-query" ref="instance('temp-xquery')" action="{instance('exist-url')}xeac/records/" method="post" replace="instance" instance="temp-result"
xxforms:username="admin" xxforms:password="">
<xforms:setvalue ref="instance('control-instance')/error" ev:event="xforms-submit-error">Error querying eXist database.</xforms:setvalue>
</xforms:submission>-->
<!-- submission to query solr to see if the document is published -->
<xforms:submission id="query-solr-for-publication" serialization="none" method="get" action="{instance('control-instance')/solr-core}select/?q=id:{instance('control-instance')/id}"
replace="instance" instance="published-response">
<!-- if the document is found in solr, get the updated solr doc -->
<xforms:setvalue ev:event="xforms-submit-done" if="instance('published-response')/result[@name='response']/@numFound = '1'"
ref="instance('pagination-result')//record[id=instance('control-instance')/id]/published" value="'true'"/>
</xforms:submission>
<!-- load eac record temporarily -->
<xforms:submission id="load-doc" serialization="none" method="get" action="{instance('exist-url')}xeac/records/{instance('control-instance')/id}.xml" replace="instance" instance="doc"
xxforms:username="admin" xxforms:password="">
<xforms:message ev:event="xforms-submit-error" level="modal">Cannot load finding aid.</xforms:message>
</xforms:submission>
<!-- delete finding aid -->
<xforms:submission id="delete-doc" action="{instance('exist-url')}xeac/records/{instance('control-instance')/id}.xml" method="delete" replace="none" xxforms:username="admin"
xxforms:password="">
<xforms:setvalue ev:event="xforms-submit-done" ref="instance('control-instance')/status">Finding aid successfully deleted.</xforms:setvalue>
</xforms:submission>
<!-- save KML -->
<xforms:submission id="save-kml" ref="instance('kml')" action="{instance('exist-url')}xeac/kml/{instance('doc')/eac:control/eac:recordId}.kml" method="put" replace="none"
xxforms:username="admin" xxforms:password="">
<xforms:message ev:event="xforms-submit-error" level="modal">Error Saving KML.</xforms:message>
</xforms:submission>
<xforms:submission id="delete-kml" action="{instance('exist-url')}xeac/kml/{instance('control-instance')/id}.kml" method="delete" replace="none" xxforms:username="admin"
xxforms:password="">
<xforms:setvalue ev:event="xforms-submit-done" ref="instance('control-instance')/status">Finding aid successfully deleted.</xforms:setvalue>
</xforms:submission>
<!-- ************************* Solr ************************** -->
<!-- access service to read in pre-transformed solr doc -->
<xforms:submission id="eac-to-solr" method="get" replace="instance" instance="addIndex" serialization="none" resource="/xeac/id/{instance('control-instance')/id}.solr">
<xforms:message ev:event="xforms-submit-error" level="modal">Error transforming EAC record to Solr document.</xforms:message>
<xforms:action ev:event="xforms-submit-done">
<xforms:send submission="post-solr-doc"/>
</xforms:action>
</xforms:submission>
<!-- post instance to Solr -->
<xforms:submission id="post-solr-doc" action="{instance('control-instance')/solr-core}update" ref="instance('addIndex')" instance="addIndex" replace="instance" method="post">
<xforms:message ev:event="xforms-submit-error" level="modal">Data Failed to POST to Solr. Index may be offline or URL is incorrect.</xforms:message>
</xforms:submission>
<!-- delete from Solr -->
<xforms:submission id="delete-solr-doc" action="{instance('control-instance')/solr-core}update" ref="instance('deleteId')" instance="deleteId" replace="none" method="post">
<xforms:send ev:event="xforms-submit-done" submission="commit"/>
<xforms:message ev:event="xforms-submit-error" level="modal">Data Failed to POST to Solr.</xforms:message>
</xforms:submission>
<xforms:submission id="delete-all" action="{instance('control-instance')/solr-core}update" ref="instance('deleteAll')" instance="deleteAll" replace="none" method="post">
<xforms:send ev:event="xforms-submit-done" submission="commit"/>
<xforms:setvalue ev:event="xforms-submit-done" ref="instance('control-instance')/status">EAC records removed from search index.</xforms:setvalue>
</xforms:submission>
<!-- send commit -->
<xforms:submission id="commit" action="{instance('control-instance')/solr-core}update" ref="instance('sendCommit')" instance="sendCommit" replace="none" method="post">
<xforms:message ev:event="xforms-submit-error" level="modal">Solr commit failed.</xforms:message>
</xforms:submission>
<!-- send optimize -->
<xforms:submission id="optimize" action="{instance('control-instance')/solr-core}update" ref="instance('optimizeIndex')" instance="optimizeIndex" replace="none" method="post">
<xforms:setvalue ev:event="xforms-submit-done" ref="instance('control-instance')/status">Index optimized.</xforms:setvalue>
<xforms:message ev:event="xforms-submit-error" level="modal">Solr optimize failed.</xforms:message>
</xforms:submission>
<!-- load xeac config file on xforms construction -->
<xforms:action ev:event="xforms-model-construct-done">
<xforms:send submission="load-config"/>
</xforms:action>
</xforms:model>
</head>
<body>
<xxforms:variable name="display_path">../</xxforms:variable>
<div class="yui3-g">
<div class="yui3-u-1">
<div class="content">
<div id="form">
<xforms:group ref="instance('status')/text()">
<div class="success">
<xforms:output ref="instance('status')"/>
</div>
</xforms:group>
<h2>Object Management</h2>
<ul>
<li>
<a href="edit/">Create New EAC-CPF Record</a>
</li>
<li>
<a href="settings/">xEAC Settings</a>
</li>
</ul>
<h2>Publication</h2>
<ul>
<li>
<xforms:trigger appearance="minimal">
<xforms:label>Publish All Records</xforms:label>
<xforms:dispatch target="publish-all" name="fr-show" ev:event="DOMActivate"/>
</xforms:trigger>
</li>
<!--<li>
<xforms:trigger appearance="minimal">
<xforms:label>Reindex Published Records</xforms:label>
<xforms:dispatch target="republish-dialog" name="fr-show" ev:event="DOMActivate"/>
</xforms:trigger>
</li>-->
<li>
<xforms:trigger appearance="minimal">
<xforms:label>Unpublish All Records</xforms:label>
<xforms:dispatch target="unpublish-all" name="fr-show" ev:event="DOMActivate"/>
</xforms:trigger>
</li>
</ul>
<xforms:group ref="instance('control-instance')[number(numFound) > 0]">
<div>
<h3>Search</h3>
<xforms:input ref="query_input"/>
<xforms:trigger>
<xforms:label>Search</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/query_sent" value="instance('control-instance')/query_input"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='query-objects'], 'QUERY', instance('control-instance')/query_sent)"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
<xforms:group ref=".[string(query_sent)]">
<xforms:trigger>
<xforms:label>Clear</xforms:label>
<xforms:action ev:event="DOMActivate">
<!-- clear queries-->
<xforms:setvalue ref="instance('control-instance')/query_input"/>
<xforms:setvalue ref="instance('control-instance')/query_sent"/>
<!-- re-establish pagination query on page 1 -->
<xforms:setvalue ref="instance('control-instance')/page" value="1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '1')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
</div>
</xforms:group>
<xforms:group ref="instance('pagination-result')">
<xforms:group ref=".[count(//record) > 0]">
<h3>List of Records</h3>
<!-- pagination variables -->
<xforms:var name="numFound" select="number(instance('control-instance')/numFound)"/>
<xforms:var name="page" select="number(instance('control-instance')/page)"/>
<xforms:var name="start" select="(($page - 1) * 20) + 1"/>
<xforms:var name="end" select="if ($numFound < $page * 20) then $numFound else $page * 20"/>
<xforms:var name="next" select="($page * 20) + 1"/>
<xforms:var name="total" select="ceiling($numFound div 20)"/>
<!-- pagination -->
<xforms:group ref=".[string-length(instance('control-instance')/query_sent) = 0]">
<div class="paging_div">
<div style="float:left;"> Displaying records <b><xforms:output value="$start"/></b> to <b><xforms:output value="$end"/></b> of <b><xforms:output
value="$numFound"/>
</b> total results.</div>
<div style="float:right;">
<xforms:group ref=".[$page > 1]">
<xforms:trigger appearance="minimal">
<xforms:label>«Previous</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page - 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string($start - 20))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[$page = 1]">
<span class="pagingSep">«Previous</span>
</xforms:group>
<!-- always display links to the first two pages -->
<xforms:group ref=".[$page > 3]">
<xforms:trigger appearance="minimal">
<xforms:label>1</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '1')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[$page > 4]">
<xforms:trigger appearance="minimal">
<xforms:label>2</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="2"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '21')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<!-- display only if you are on page 6 or greater -->
<xforms:group ref=".[$page > 5]">
<span class="pagingSep">...</span>
</xforms:group>
<!-- always display links to the previous two pages -->
<xforms:group ref=".[$page > 2]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$page - 2"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page - 2"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string((($page - 3) * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[$page > 1]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$page - 1"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page - 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string((($page - 2) * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<!-- current page -->
<span class="pagingBtn">
<xforms:output value="$page"/>
</span>
<!-- next two pages -->
<xforms:group ref=".[$page + 1 <= $total]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$page + 1"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page + 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string(($page * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[$page + 2 <= $total]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$page + 2"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page + 2"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string((($page +1) * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<!-- separator -->
<xforms:group ref=".[$page <= $total - 4]">
<span class="pagingSep">...</span>
</xforms:group>
<!-- last two pages -->
<xforms:group ref=".[$page <= $total - 4]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$total - 1"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$total - 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string((($total - 2) * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[$page <= $total - 3]">
<xforms:trigger appearance="minimal">
<xforms:label>
<xforms:output value="$total"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$total"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string((($total - 1) * 20) + 1))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<!-- next page -->
<xforms:group ref=".[$total > $page]">
<xforms:trigger appearance="minimal">
<xforms:label>Next»</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/page" value="$page + 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string($next))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[not($total > $page)]">
<span class="pagingSep">Next»</span>
</xforms:group>
</div>
</div>
</xforms:group>
<br/>
<table style="width:100%">
<thead>
<tr>
<th>Title</th>
<th style="width:10%">View</th>
<th style="width:5%">Publish</th>
<th style="width:5%">Delete</th>
</tr>
</thead>
<tbody>
<xforms:repeat nodeset="instance('pagination-result')//record">
<xforms:var name="id" select="id"/>
<xforms:var name="class" select="if (position() mod 2 = 0) then 'even-row' else 'odd-row'"/>
<tr>
<td class="{$class}">
<h4>
<a href="edit/?recordId={$id}">
<xforms:output ref="title"/>
<xforms:output ref="concat('(', $id, ')')"/>
</a>
</h4>
<div>
<xforms:output ref="maintenanceStatus">
<xforms:label>Status</xforms:label>
</xforms:output>
</div>
</td>
<td class="{$class} center">
<a href="{instance('config')/url}id/{$id}.xml" target="_blank">xml</a> | <a href="{instance('config')/url}id/{$id}" target="_blank">html</a>
</td>
<td class="{$class} center">
<!-- only enable publication if the maintenanceStatus allows it -->
<xforms:group ref=".[maintenanceStatus='new' or maintenanceStatus='revised' or maintenanceStatus='derived']">
<xforms:group ref=".[published = 'true']">
<xforms:trigger appearance="minimal">
<xforms:label>unpublish</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/id" value="$id"/>
<xforms:dispatch target="unpublish" name="fr-show"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
<xforms:group ref=".[published != 'true']">
<xforms:trigger appearance="minimal">
<xforms:label>publish</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/id" value="$id"/>
<xforms:dispatch target="publish" name="fr-show"/>
</xforms:action>
</xforms:trigger>
</xforms:group>
</xforms:group>
</td>
<td class="{$class} center">
<xforms:trigger appearance="minimal">
<xforms:label>
<img src="/xeac/xforms/images/remove.gif"/>
</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/id" value="$id"/>
<xforms:dispatch target="delete" name="fr-show"/>
</xforms:action>
</xforms:trigger>
</td>
</tr>
</xforms:repeat>
</tbody>
</table>
</xforms:group>
<xforms:group ref=".[count(//record)=0]">
<h1>No records in collection.</h1>
</xforms:group>
</xforms:group>
</div>
<!-- dialogs -->
<fr:alert-dialog id="publish">
<fr:label>Publish</fr:label>
<fr:message>Do you want to publish this object to the search index?</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<!-- update publicationStatus -->
<xforms:setvalue ref="instance('control-instance')/publicationStatus">approved</xforms:setvalue>
<xforms:send submission="load-object"/>
<!-- publish to solr -->
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:send submission="eac-to-solr"/>
<xforms:send submission="submit-commit"/>
<!-- reload table -->
<xforms:var name="page" select="number(instance('control-instance')/page)"/>
<xforms:var name="start" select="(($page - 1) * 20) + 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string($start))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<fr:alert-dialog id="unpublish">
<fr:label>Unpublish</fr:label>
<fr:message>Do you want to remove this object from the search index?</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<!-- update publicationStatus -->
<xforms:setvalue ref="instance('control-instance')/publicationStatus">inProcess</xforms:setvalue>
<xforms:send submission="load-object"/>
<!-- delete from Solr -->
<xforms:setvalue ref="instance('deleteId')/query" value="concat('recordId:"', instance('control-instance')/id, '"')"/>
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:send submission="delete-solr-doc"/>
<!-- reload table -->
<xforms:var name="page" select="number(instance('control-instance')/page)"/>
<xforms:var name="start" select="(($page - 1) * 20) + 1"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string($start))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<fr:alert-dialog id="delete">
<fr:label>Delete</fr:label>
<fr:message>Are you sure you want to delete this object?</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<xforms:send submission="delete-doc"/>
<xforms:send submission="delete-kml"/>
<xforms:setvalue ref="instance('deleteId')/query" value="concat('recordId:"', instance('control-instance')/id, '"')"/>
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:send submission="delete-solr-doc"/>
<!-- get new numCount -->
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="instance('xqueries')/query[@id='collection-count']"/>
<xforms:send submission="xquery-collection"/>
<!-- reload table -->
<xforms:var name="page" select="number(instance('control-instance')/page)"/>
<xforms:var name="start" select="(($page - 1) * 20) + 1"/>
<xforms:var name="end" select="$page * 20"/>
<xforms:setvalue ref="instance('eXist-xquery')/exist:text"
value="replace(instance('xqueries')/query[@id='get-objects'], 'START', string($start))"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<!-- mass publication dialogs -->
<fr:alert-dialog id="publish-all">
<fr:label>Publish All</fr:label>
<fr:message>Do you want to publish all records? This may take several minutes.</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="instance('xqueries')/query[@id='publish-all']"/>
<xforms:send submission="xquery-collection"/>
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:action xxforms:iterate="instance('xquery-result')/report/item">
<xxforms:variable name="id" select="@id"/>
<xforms:setvalue ref="instance('control-instance')/id" value="$id"/>
<xforms:send submission="eac-to-solr"/>
</xforms:action>
<!-- commit index -->
<xforms:send submission="commit"/>
<!-- reload table -->
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '1')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<fr:alert-dialog id="unpublish-all">
<fr:label>Unpublish All</fr:label>
<fr:message>Do you want to unpublish all records?</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:setvalue ref="instance('deleteAll')/query" value="concat('collection-name:', instance('control-instance')/collection-name)"/>
<xforms:send submission="delete-all" ev:event="DOMActivate"/>
<!-- optimize index -->
<xforms:send submission="optimize"/>
<!-- reload table -->
<xforms:setvalue ref="instance('eXist-xquery')/exist:text" value="replace(instance('xqueries')/query[@id='get-objects'], 'START', '1')"/>
<xforms:send submission="xquery-pagination"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<fr:alert-dialog id="republish-dialog">
<fr:label>Republish</fr:label>
<fr:message>Do you want to reindex currently published records?</fr:message>
<fr:negative-choice/>
<fr:positive-choice>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('control-instance')/solr-core" value="instance('config')/solr_published"/>
<xforms:send submission="republish"/>
<xforms:send submission="optimize" ev:event="xforms-submit-done"/>
</xforms:action>
</fr:positive-choice>
</fr:alert-dialog>
<fr:xforms-inspector id="orbeon-xforms-inspector"/>
</div>
</div>
</div>
</body>
</html>