-
Notifications
You must be signed in to change notification settings - Fork 4
/
rdf_mappers.sql
7045 lines (6441 loc) · 249 KB
/
rdf_mappers.sql
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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
--
-- $Id: rdf_mappers.sql,v 1.178 2009-05-20 14:59:20 source Exp $
--
-- RDF Mappings
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
-- install the handlers for supported metadata, keep in sync with xslt/html2rdf.xsl rules
delete from DB.DBA.SYS_RDF_MAPPERS where RM_PATTERN = '(text/html)|(application/atom.xml)|(text/xml)|(application/xml)|(application/rss.xml)' and RM_TYPE = 'MIME';
delete from DB.DBA.SYS_RDF_MAPPERS where RM_PATTERN = '(text/html)|(application/atom.xml)|(text/xml)|(application/xml)|(application/rss.xml)|(application/rdf.xml)' and RM_TYPE = 'MIME';
--delete from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_HTML_RESPONSE';
-- remove wrong patterns for svg, ics and odt files
delete from DB.DBA.SYS_RDF_MAPPERS where RM_PATTERN = '.+\.svg\$';
delete from DB.DBA.SYS_RDF_MAPPERS where RM_PATTERN = '.+\.od[ts]\$';
delete from DB.DBA.SYS_RDF_MAPPERS where RM_PATTERN = '.+\.ics\$';
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = '(http://digg.com/.*)|(http://services.digg.com/.*)'
where RM_PATTERN = '(http://digg.com/search.*)' and RM_TYPE = 'URL';
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = '(http://twitter.com/.*)|(http://search.twitter.com/.*)'
where RM_PATTERN = '(http://twitter.com/.*)' and RM_TYPE = 'URL';
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = '(http://.*amazon.[^/]+/gp/product/.*)|'||
'(http://.*amazon.[^/]+/o/ASIN/.*)|'||
'(http://.*amazon.[^/]+/[^/]+/dp/[^/]+/.*)|'||
'(http://.*amazon.[^/]+/exec/obidos/ASIN/.*)|' ||
'(http://.*amazon.[^/]+/exec/obidos/tg/detail/-/[^/]+/.*)'
where RM_HOOK = 'DB.DBA.RDF_LOAD_AMAZON_ARTICLE';
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = 'http[s]*://www.facebook.com/.*' where RM_HOOK = 'DB.DBA.RDF_LOAD_FQL';
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_ENABLED)
values ('.*', 'HTTP', 'DB.DBA.RDF_LOAD_HTTP_SESSION', null, 'HTTP in RDF', 0);
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('(text/html)|(text/xml)|(application/xml)|(application/rdf.xml)',
'MIME', 'DB.DBA.RDF_LOAD_HTML_RESPONSE', null, 'xHTML', vector ('add-html-meta', 'yes', 'get-feeds', 'no'));
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('(application/atom.xml)|(text/xml)|(application/xml)|(application/rss.xml)',
'MIME', 'DB.DBA.RDF_LOAD_FEED_RESPONSE', null, 'Feeds', null);
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://farm[0-9]*.static.flickr.com/.*',
'URL', 'DB.DBA.RDF_LOAD_FLICKR_IMG', null, 'Flickr Images');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://.*openstreetmap.org/.*',
'URL', 'DB.DBA.RDF_LOAD_OPENSTREETMAP', null, 'OpenStreetMap');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*amazon.[^/]+/gp/product/.*)|'||
'(http://.*amazon.[^/]+/o/ASIN/.*)|'||
'(http://.*amazon.[^/]+/[^/]+/dp/[^/]+(/.*)?)|'||
'(http://.*amazon.[^/]+/exec/obidos/ASIN/.*)|' ||
'(http://.*amazon.[^/]+/exec/obidos/tg/detail/-/[^/]+/.*)',
'URL', 'DB.DBA.RDF_LOAD_AMAZON_ARTICLE', null, 'Amazon articles');
-- upgrade old youtube pattern
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = '(http://.*youtube.com/.*)' where RM_PATTERN =
'(http://.*youtube.com/results\\?search_query=.*)|'||
'(http://ru.youtube.com/results\\?search_query=.*)|'||
'(http://.*youtube.com/results\\?)';
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*youtube.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_YOUTUBE', null, 'YouTube');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://picasaweb.google.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_PICASA', null, 'Picasa');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*last.fm/.*)|'||
'(http://.*lastfm.*/.*)',
'URL', 'DB.DBA.RDF_LOAD_LASTFM', null, 'LastFM');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*meetup.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_MEETUP', null, 'Meetup');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*discogs.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_DISCOGS', null, 'Discogs');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*disqus.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_DISQUS', null, 'Disqus');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://www.radiopop.co.uk/users/.*)',
'URL', 'DB.DBA.RDF_LOAD_RADIOPOP', null, 'Radio Pop');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://www.rhapsody.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_RHAPSODY', null, 'Rhapsody');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('(http://.*slideshare.net/.*)',
'URL', 'DB.DBA.RDF_LOAD_SLIDESHARE', null, 'Slideshare', vector ('SharedSecret', ''));
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://bugs.*)|'||
'(http://.*/show_bug.cgi\\?id.*)|'||
'(http://.*bugzilla.*)|'||
'(https://bugzilla.*)|'||
'(https://.*bugzilla.*)',
'URL', 'DB.DBA.RDF_LOAD_BUGZILLA', null, 'Bugzillas');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://digg.com/.*)|(http://services.digg.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_DIGG', null, 'Digg');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://isbndb.com/.*)|'||
'(https://isbndb.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_ISBN', null, 'ISBN');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://www.librarything.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_LIBRARYTHING', null, 'LibraryThing');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://www.theyworkforyou.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_TWFY', null, 'TWFY');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*getsatisfaction.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_GETSATISFATION', null, 'GetSatisfaction');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://twitter.com/.*)|' ||
'(http://search.twitter.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_TWITTER', null, 'Twitter');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://.*salesforce.com/.*)|'||
'(https://.*salesforce.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_SALESFORCE', null, 'SalesForce');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://friendfeed.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_FRIENDFEED', null, 'FriendFeed');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://socialgraph.apis.google.com/lookup\\?.*)|'||
'(http://socialgraph.apis.google.com/otherme\\?.*)',
'URL', 'DB.DBA.RDF_LOAD_SOCIALGRAPH', null, 'SocialGraph');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://openlibrary.org/b/.*)',
'URL', 'DB.DBA.RDF_LOAD_OPENLIBRARY', null, 'OpenLibrary');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('.+\\.svg\x24', 'URL', 'DB.DBA.RDF_LOAD_SVG', null, 'SVG');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(http://cgi.sandbox.ebay.com/.*&item=[A-Z0-9]*&.*)|(http://cgi.ebay.com/.*QQitemZ[A-Z0-9]*QQ.*)',
'URL', 'DB.DBA.RDF_LOAD_EBAY_ARTICLE', null, 'eBay articles');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('.+\\.od[ts]\x24', 'URL', 'DB.DBA.RDF_LOAD_OO_DOCUMENT', null, 'OO Documents');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://local.yahooapis.com/MapsService/V1/trafficData.*',
'URL', 'DB.DBA.RDF_LOAD_YAHOO_TRAFFIC_DATA', null, 'Yahoo Traffic Data');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('.+\\.ics\x24', 'URL', 'DB.DBA.RDF_LOAD_ICAL', null, 'iCalendar');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('http[s]*://www.facebook.com/.*',
'URL', 'DB.DBA.RDF_LOAD_FQL', null, 'FaceBook', vector ('secret', '', 'session', ''));
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('http://www.freebase.com/view/.*',
'URL', 'DB.DBA.RDF_LOAD_MQL', null, 'Freebase', vector ());
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_ENABLED)
values ('.*', 'MIME', 'DB.DBA.RDF_LOAD_DAV_META', null, 'WebDAV Metadata', 1);
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://.*.wikipedia.org.*',
'URL', 'DB.DBA.RDF_LOAD_WIKIPEDIA_ARTICLE', null, 'Wikipedia');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://finance.yahoo.com/q\\?s=.*',
'URL', 'DB.DBA.RDF_LOAD_YAHOO_STOCK_DATA', null, 'Yahoo Finance');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('http://musicbrainz.org/([^/]*)/([^/]*)',
'URL', 'DB.DBA.RDF_LOAD_MBZ', null, 'Musicbrainz');
update DB.DBA.SYS_RDF_MAPPERS set RM_PATTERN = 'http://musicbrainz.org/([^/]*)/([^/]*)'
where RM_HOOK = 'DB.DBA.RDF_LOAD_MBZ';
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('(http://api.crunchbase.com/v/1/.*)|(http://www.crunchbase.com/.*)',
'URL', 'DB.DBA.RDF_LOAD_CRUNCHBASE', null, 'CrunchBase', null);
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION, RM_OPTIONS)
values ('.+\\.pptx\x24', 'URL', 'DB.DBA.RDF_LOAD_PPTX_DOCUMENT', null, 'Powerpoint documents', null);
-- we do default http & html handler first of all
--update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 0 where RM_HOOK = 'DB.DBA.RDF_LOAD_HTTP_SESSION';
--update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 1 where RM_HOOK = 'DB.DBA.RDF_LOAD_HTML_RESPONSE';
--update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 2 where RM_HOOK = 'DB.DBA.RDF_LOAD_FEED_RESPONSE';
--update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 3 where RM_HOOK = 'DB.DBA.RDF_LOAD_CALAIS';
update DB.DBA.SYS_RDF_MAPPERS set RM_ENABLED = 1 where RM_ENABLED is null;
create procedure RM_MAPPERS_UPGRADE ()
{
declare pk any;
pk := DB.DBA.REPL_PK_COLS ('DB.DBA.SYS_RDF_MAPPERS');
if (length (pk) = 2 and pk[0][0] = 'RM_TYPE' and pk[1][0] = 'RM_PATTERN')
{
declare skip_up int;
skip_up := 0;
for select RM_HOOK from DB.DBA.SYS_RDF_MAPPERS group by 1 having count(*) > 1 do
{
if (skip_up = 0)
log_message ('The DB.DBA.SYS_RDF_MAPPERS cannot be upgraded');
log_message (sprintf ('The %s cartridge is defined multiple times, remove duplicate', RM_HOOK));
skip_up := skip_up + 1;
}
if (skip_up = 0)
{
exec ('alter table DB.DBA.SYS_RDF_MAPPERS modify primary key (RM_HOOK)');
log_message ('The DB.DBA.SYS_RDF_MAPPERS have been upgraded');
}
}
return;
}
;
RM_MAPPERS_UPGRADE ()
;
EXEC_STMT(
'create table DB.DBA.RDF_META_CARTRIDGES (
MC_ID integer identity,
MC_SEQ integer identity,
MC_HOOK varchar,
MC_TYPE varchar default \'URL\',
MC_PATTERN varchar not null,
MC_KEY varchar,
MC_OPTIONS any,
MC_DESC long varchar,
MC_ENABLED int not null default 1,
primary key (MC_HOOK)
)
alter index RDF_META_CARTRIDGES on DB.DBA.RDF_META_CARTRIDGES partition cluster replicated
', 0)
;
create procedure MIGRATE_CALAIS ()
{
insert into DB.DBA.RDF_META_CARTRIDGES (MC_HOOK, MC_TYPE, MC_PATTERN, MC_KEY, MC_OPTIONS, MC_DESC, MC_ENABLED)
select RM_HOOK, RM_TYPE, RM_PATTERN, RM_KEY, RM_OPTIONS, RM_DESCRIPTION, RM_ENABLED from DB.DBA.SYS_RDF_MAPPERS
where RM_HOOK = 'DB.DBA.RDF_LOAD_CALAIS';
delete from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_CALAIS';
}
;
MIGRATE_CALAIS ();
create procedure RM_MAPPERS_SET_ORDER ()
{
declare inx int;
declare top_arr, arr, http, html, feed, calais, num any;
if (exists (select RM_PID, count(*) from SYS_RDF_MAPPERS group by RM_PID having count(*) > 1))
{
num := (select count(*) from DB.DBA.SYS_RDF_MAPPERS);
inx := 1;
for select RM_HOOK as hook from DB.DBA.SYS_RDF_MAPPERS do
{
update DB.DBA.SYS_RDF_MAPPERS set RM_PID = inx where RM_HOOK = hook;
inx := inx + 1;
}
}
http := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_HTTP_SESSION');
html := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_HTML_RESPONSE');
feed := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_FEED_RESPONSE');
-- calais := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_CALAIS');
top_arr := vector (http, html, feed);
arr := (select DB.DBA.VECTOR_AGG (RM_PID) from DB.DBA.SYS_RDF_MAPPERS where 0 = position (RM_PID, top_arr) order by RM_ID);
inx := 1;
arr := vector_concat (top_arr, arr);
foreach (int pid in arr) do
{
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = inx where RM_PID = pid;
inx := inx + 1;
}
DB.DBA.SET_IDENTITY_COLUMN ('DB.DBA.SYS_RDF_MAPPERS', 'RM_PID', inx);
DB.DBA.SET_IDENTITY_COLUMN ('DB.DBA.SYS_RDF_MAPPERS', 'RM_ID', inx);
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 10000 + inx where RM_HOOK = 'DB.DBA.RDF_LOAD_DAV_META';
}
;
RM_MAPPERS_SET_ORDER ();
-- /* to insert cartridge after another */
create procedure RM_MAPPERS_SET_CONSEQ (in proc_1 varchar, in proc_2 varchar)
{
declare inx int;
declare top_arr, arr, http, html, feed, calais, pid_1, pid_2, do_update any;
pid_1 := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = proc_1);
pid_2 := (select RM_PID from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = proc_2);
top_arr := (select DB.DBA.VECTOR_AGG (RM_PID) from DB.DBA.SYS_RDF_MAPPERS
where RM_HOOK in ('DB.DBA.RDF_LOAD_HTTP_SESSION','DB.DBA.RDF_LOAD_HTML_RESPONSE','DB.DBA.RDF_LOAD_FEED_RESPONSE')
order by RM_ID);
arr := (select DB.DBA.VECTOR_AGG (RM_PID) from DB.DBA.SYS_RDF_MAPPERS where 0 = position (RM_PID, top_arr) and RM_HOOK <> proc_2 order by RM_ID);
inx := 0;
do_update := 0;
arr := vector_concat (top_arr, arr);
foreach (int pid in arr) do
{
if (pid = pid_1)
{
inx := inx + 1;
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = inx where RM_PID = pid_2;
do_update := 1;
}
else if (do_update)
{
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = inx where RM_PID = pid;
}
inx := inx + 1;
}
DB.DBA.SET_IDENTITY_COLUMN ('DB.DBA.SYS_RDF_MAPPERS', 'RM_PID', inx);
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 10000 + inx where RM_HOOK = 'DB.DBA.RDF_LOAD_DAV_META';
}
;
--
-- The GRDDL filters
-- This keeps all microformat filters
-- Every of these is called inside XHTML mapper
--
EXEC_STMT(
'create table DB.DBA.OAI_SERVERS (
OS_ID integer identity,
OS_SERVER varchar,
OS_URN_PATTERN varchar,
OS_ENABLED int default 0,
primary key (OS_ID, OS_SERVER)
)
alter index OAI_SERVERS on DB.DBA.OAI_SERVERS partition cluster replicated', 0)
;
EXEC_STMT(
'create table DB.DBA.SYS_GRDDL_MAPPING (
GM_NAME varchar,
GM_PROFILE varchar,
GM_XSLT varchar,
GM_FLAG integer default 0,
primary key (GM_NAME)
)
alter index SYS_GRDDL_MAPPING on DB.DBA.SYS_GRDDL_MAPPING partition cluster replicated
create index SYS_GRDDL_MAPPING_PROFILE on DB.DBA.SYS_GRDDL_MAPPING (GM_PROFILE) partition cluster replicated', 0)
;
create procedure RM_UPGRADE_TBL (in tbl varchar, in col varchar, in coltype varchar)
{
if (exists( select top 1 1 from DB.DBA.SYS_COLS where upper("TABLE") = upper(tbl) and upper("COLUMN") = upper(col)))
return;
exec (sprintf ('alter table %s add column %s %s', tbl, col, coltype));
}
;
RM_UPGRADE_TBL ('DB.DBA.SYS_GRDDL_MAPPING', 'GM_FLAG', 'integer default 0');
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('eRDF', 'http://purl.org/NET/erdf/profile', registry_get ('_rdf_mappers_path_') || 'xslt/erdf2rdfxml.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('RDFa', '', registry_get ('_rdf_mappers_path_') || 'xslt/rdfa2rdfxml.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('AB Meta', 'http://abmeta.org/#spec', registry_get ('_rdf_mappers_path_') || 'xslt/abmeta2rdfxml.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hCard', 'http://www.w3.org/2006/03/hcard', registry_get ('_rdf_mappers_path_') || 'xslt/hcard2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hAudio', 'http://purl.org/weborganics/mo-haudio', registry_get ('_rdf_mappers_path_') || 'xslt/haudio2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hCalendar', 'http://dannyayers.com/microformats/hcalendar-profile', registry_get ('_rdf_mappers_path_') || 'xslt/hcal2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('Slidy', 'http://www.w3.org/Talks/Tools/Slidy', registry_get ('_rdf_mappers_path_') || 'xslt/slidy2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hReview', 'http://dannyayers.com/micromodels/profiles/hreview', registry_get ('_rdf_mappers_path_') || 'xslt/hreview2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hListing', 'http://dannyayers.com/micromodels/profiles/hlisting', registry_get ('_rdf_mappers_path_') || 'xslt/hlisting2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('relLicense', '', registry_get ('_rdf_mappers_path_') || 'xslt/cc2rdf.xsl')
;
-- specific case, so we put the GM_FLAG
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT, GM_FLAG)
values ('XBRL', '', registry_get ('_rdf_mappers_path_') || 'xslt/xbrl2rdf.xsl', 1)
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('HR-XML', '', registry_get ('_rdf_mappers_path_') || 'xslt/hrxml2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('hResume', 'http://dannyayers.com/micromodels/profiles/hresume', registry_get ('_rdf_mappers_path_') || 'xslt/hresume2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('Dublin Core', '', registry_get ('_rdf_mappers_path_') || 'xslt/dc2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('geoURL', '', registry_get ('_rdf_mappers_path_') || 'xslt/geo2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('Google Base', '', registry_get ('_rdf_mappers_path_') || 'xslt/google2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('Ning Metadata', '', registry_get ('_rdf_mappers_path_') || 'xslt/ning2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('XFN Profile', 'http://gmpg.org/xfn/11', registry_get ('_rdf_mappers_path_') || 'xslt/xfn2rdf.xsl')
;
insert replacing DB.DBA.SYS_GRDDL_MAPPING (GM_NAME, GM_PROFILE, GM_XSLT)
values ('xFolk', '', registry_get ('_rdf_mappers_path_') || 'xslt/xfolk2rdf.xsl')
;
create procedure DB.DBA.RM_RDF_LOAD_RDFXML (in strg varchar, in base varchar, in graph varchar)
{
declare nss, ses any;
nss := xmlnss_get (xtree_doc (strg));
ses := string_output ();
http ('@prefix opl: <http://www.openlinksw.com/schema/attribution#> .\n', ses);
http ('@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n', ses);
http ('@prefix ore: <http://www.openarchives.org/ore/terms/> .\n', ses);
for (declare i, l int, i := 0, l := length (nss); i < l; i := i + 2)
{
http (sprintf ('<%s> a opl:DataSource .\n', nss[i+1]), ses);
http (sprintf ('<%s> opl:isDescribedUsing <%s> .\n', graph, nss[i+1]), ses);
http (sprintf ('<%s> opl:hasNamespacePrefix "%s" .\n', nss[i+1], nss[i]), ses);
}
DB.DBA.RDF_LOAD_RDFXML (strg, base, graph);
DB.DBA.TTLP (ses, base, graph);
}
;
create procedure DB.DBA.RM_UMBEL_GET (in strg varchar)
{
declare data, meta any;
declare ses, cont, xt, xd, arr any;
declare exit handler for sqlstate '*'
{
return xtree_doc ('<error/>');
};
commit work;
cont := http_client (url=>'http://umbel.zitgist.com/ws/scones/index.php',
http_method=>'POST',
body=>sprintf ('text=%U', strg),
http_headers=>'Accept: text/xml',
proxy=>connection_get ('sparql-get:proxy'),
timeout=>30);
xt := xtree_doc (cont);
return xt;
}
;
grant execute on DB.DBA.RM_UMBEL_GET to public;
create procedure DB.DBA.XSLT_REGEXP_MATCH (in pattern varchar, in val varchar)
{
return regexp_match (pattern, val);
}
;
create procedure DB.DBA.XSLT_SPLIT_AND_DECODE (in val varchar, in md int, in pattern varchar)
{
declare x, ses any;
declare exit handler for sqlstate '*'
{
return xtree_doc ('<results/>');
};
x := split_and_decode (val, md, '\0\0'||pattern);
ses := string_output ();
http ('<results>', ses);
foreach (any elm in x) do
{
if (length (elm))
http (sprintf ('<result><![CDATA[%s]]></result>', elm), ses);
}
http ('</results>', ses);
return xtree_doc (string_output_string (ses));
}
;
create procedure DB.DBA.XSLT_UNIX2ISO_DATE (in val int)
{
if (val is null)
return null;
return date_iso8601 (dt_set_tz (dateadd ('second', val, dt_set_tz (stringdate ('1970-01-01'), 0)), 0));
}
;
create procedure DB.DBA.XSLT_STRING2ISO_DATE2 (in val varchar)
{
declare ret, tmp any;
if (val is null)
return null;
ret := stringdate(val);
ret := date_iso8601 (ret);
if (ret is not null)
return ret;
return null;
}
;
create procedure DB.DBA.XSLT_STRING2ISO_DATE (in val varchar)
{
declare ret, tmp any;
if (val is null)
return null;
tmp := sprintf_inverse (val, '%s %s %s %s %s %s', 0);
if (length(tmp) > 5)
{
ret := http_string_date(sprintf('%s, %s %s %s %s %s', tmp[0], tmp[2], tmp[1], tmp[5], tmp[3], tmp[4]));
ret := dt_set_tz (ret, 0);
ret := date_iso8601 (ret);
if (ret is not null)
return ret;
}
return null;
}
;
create procedure DB.DBA.XSLT_SHA1_HEX (in val varchar)
{
return tree_sha1 (val, 1);
}
;
create procedure DB.DBA.XSLT_STR2DATE (in val varchar)
{
declare ret any;
ret := null;
if (val like '[A-Za-z]* [0-9]*')
{
declare dt, pos, tmp, v any;
v := trim (val, '+');
pos := strchr (v, ' ');
tmp := subseq (v, 0, pos);
dt := trim(tmp);
tmp := trim (subseq (v, pos));
dt := 'Wee, ' || tmp || ' ' || dt || sprintf (' %d 00:00:00 GMT', year (now ()));
ret := http_string_date (dt, null, null);
}
else
ret := http_string_date (val, null, null);
if (ret is not null)
{
ret := dt_set_tz (ret, 0);
ret := date_iso8601 (ret);
}
return coalesce (ret, val);
}
;
create procedure DB.DBA.RDF_SPONGE_PROXY_IRI (in uri varchar := '', in login varchar := '', in frag varchar := 'this')
{
declare cname any;
declare ret any;
declare default_host, url_sch varchar;
declare ua any;
if (is_http_ctx ())
default_host := http_request_header(http_request_header (), 'Host', null, null);
else
default_host := cfg_item_value (virtuoso_ini_path (), 'URIQA', 'DefaultHost');
if (default_host is not null)
cname := default_host;
else
{
cname := sys_stat ('st_host_name');
if (server_http_port () <> '80')
cname := cname ||':'|| server_http_port ();
}
if (length (frag) and frag[0] <> '#'[0])
frag := '#' || frag;
if (strchr (uri, '#') is not null)
frag := '';
ua := rfc1808_parse_uri (uri);
url_sch := ua[0];
ua [0] := '';
uri := vspx_uri_compose (ua);
uri := ltrim (uri, '/');
if (length (login))
ret := sprintf ('http://%s/about/rdf/%s/%U/%s%s', cname, url_sch, login, uri, frag);
else
ret := sprintf ('http://%s/about/rdf/%s/%s%s', cname, url_sch, uri, frag);
return ret;
}
;
create procedure DB.DBA.XSLT_ESCAPE (in body any) returns varchar
{
declare str_out any;
declare s, s2 varchar;
s2 := serialize_to_UTF8_xml (body);
str_out := string_output();
http_value(s2, null, str_out);
s := string_output_string(str_out);
return s;
}
;
create procedure MOAT_APPLY (in ap_uid any, in phrase varchar)
{
declare ap_set_ids any;
declare res_out, script_out, match_list any;
declare m_apc, m_aps, m_app, m_apa, m_apa_w, m_aph any;
declare apa_w_ctr, apa_w_count integer;
declare app_ctr, app_count integer;
declare prev_end, prev_apa_id, prev_idx integer;
declare done any;
ap_set_ids := (select vector (APS_ID) from DB.DBA.SYS_ANN_PHRASE_SET where
APS_OWNER_UID = ap_uid and APS_NAME = sprintf ('Hyperlinking-%d', ap_uid));
if (not length (ap_set_ids))
return null;
match_list := ap_build_match_list (ap_set_ids, phrase, 'x-any', 1, 0);
m_apc := aref_set_0 (match_list, 0);
m_aps := aref_set_0 (match_list, 1);
m_app := aref_set_0 (match_list, 2);
m_apa := aref_set_0 (match_list, 3);
m_apa_w := aref_set_0 (match_list, 4);
m_aph := aref_set_0 (match_list, 5);
apa_w_count := length (m_apa_w);
app_count := length (m_app);
if (0 = app_count)
return null;
for (apa_w_ctr := 0; apa_w_ctr < apa_w_count; apa_w_ctr := apa_w_ctr + 1)
{
declare apa_idx integer;
declare apa any;
apa_idx := m_apa_w [apa_w_ctr];
apa := aref_set_0 (m_apa, apa_idx);
if (6 = length (apa))
{
declare this_apa_id integer;
declare arr, dta any;
if (position (prev_apa_id, apa[5]))
this_apa_id := prev_apa_id;
else
this_apa_id := apa[5][0];
arr := m_app[this_apa_id];
dta := arr [3];
return dta;
}
}
return null;
}
;
create procedure DB.DBA.RDF_SPONGE_DBP_IRI (in base varchar, in word varchar)
{
declare res, xp, xt varchar;
declare uri varchar;
declare exit handler for sqlstate '*' {
return base || '#' || word;
};
uri := MOAT_APPLY (http_dav_uid (), word);
if (uri is not null)
{
return uri;
}
if (word[0] >= 'a'[0] and word[0] <= 'z'[0])
word[0] := word[0] - 32;
uri := sprintf ('ask from <http://dbpedia.org> where { <http://dbpedia.org/resource/%U> ?y ?z }', word);
res := http_client (url=>sprintf ('http://dbpedia.org/sparql?query=%U', uri), timeout=>30, proxy=>connection_get ('sparql-get:proxy'));
xt := xtree_doc (res);
xp := cast (xpath_eval('/sparql/boolean/text()', xt) as varchar);
if (xp = 'true')
return sprintf ('http://dbpedia.org/resource/%U', word);
return base || '#' || word;
}
;
grant execute on DB.DBA.XSLT_REGEXP_MATCH to public;
grant execute on DB.DBA.XSLT_SPLIT_AND_DECODE to public;
grant execute on DB.DBA.XSLT_UNIX2ISO_DATE to public;
grant execute on DB.DBA.XSLT_SHA1_HEX to public;
grant execute on DB.DBA.XSLT_STR2DATE to public;
grant execute on DB.DBA.XSLT_STRING2ISO_DATE to public;
grant execute on DB.DBA.XSLT_STRING2ISO_DATE2 to public;
grant execute on DB.DBA.RDF_SPONGE_PROXY_IRI to public;
grant execute on DB.DBA.RDF_SPONGE_DBP_IRI to public;
grant execute on DB.DBA.XSLT_ESCAPE to public;
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:regexp-match', 'DB.DBA.XSLT_REGEXP_MATCH');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:split-and-decode', 'DB.DBA.XSLT_SPLIT_AND_DECODE');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:unix2iso-date', 'DB.DBA.XSLT_UNIX2ISO_DATE');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:sha1_hex', 'DB.DBA.XSLT_SHA1_HEX');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:str2date', 'DB.DBA.XSLT_STR2DATE');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:escape', 'DB.DBA.XSLT_ESCAPE');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:string2date', 'DB.DBA.XSLT_STRING2ISO_DATE');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:string2date2', 'DB.DBA.XSLT_STRING2ISO_DATE2');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:proxyIRI', 'DB.DBA.RDF_SPONGE_PROXY_IRI');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:dbpIRI', 'DB.DBA.RDF_SPONGE_DBP_IRI');
xpf_extension ('http://www.openlinksw.com/virtuoso/xslt/:umbelGet', 'DB.DBA.RM_UMBEL_GET');
--create procedure RDF_LOAD_AMAZON_ARTICLE_INIT ()
--{
-- if (__proc_exists ('DB.DBA.AmazonSearchService',0) is not null)
-- return;
-- SOAP_WSDL_IMPORT ('http://soap.amazon.com/schemas3/AmazonWebServices.wsdl');
--}
--;
--RDF_LOAD_AMAZON_ARTICLE_INIT ();
create procedure RDF_MAPPER_XSLT (in xslt varchar, inout xt any, in params any := null)
{
set_user_id ('dba');
if (params is null)
return xslt (xslt, xt);
else
return xslt (xslt, xt, params);
};
create procedure RDF_APERTURE_INIT ()
{
if (__proc_exists ('java_vm_attach', 2) is null)
{
delete from DB.DBA.SYS_RDF_MAPPERS where RM_HOOK = 'DB.DBA.RDF_LOAD_BIN_DOCUMENT';
return;
}
set_qualifier ('APERTURE');
if (not udt_is_available ('APERTURE.DBA.MetaExtractor'))
{
declare exit handler for sqlstate '*'
{
set_qualifier ('DB');
return;
};
DB.DBA.import_jar (NULL, 'MetaExtractor', 1);
}
exec (
'create procedure DB.DBA.RDF_LOAD_BIN_DOCUMENT (in graph_iri varchar, in new_origin_uri varchar, in dest varchar,
inout _ret_body any, inout aq any, inout ps any, inout _key any, inout opts any)
{
declare xd, tmp, fn any;
-- if (graph_iri like \'%.odt\' or graph_iri like \'%.ods\')
-- return 0;
tmp := null;
declare exit handler for sqlstate \'*\'
{
if (length (tmp))
file_delete (tmp, 1);
return 0;
};
tmp := tmp_file_name (\'rdfm\', \'bin\');
fn := tmp;
string_to_file (tmp, _ret_body, -2);
xd := APERTURE.DBA."MetaExtractor"().getMetaFromFile (fn, 5);
xd := charset_recode(xd, \'_WIDE_\', \'UTF-8\');
file_delete (tmp, 1);
if (xd is null)
return 0;
xd := replace (xd, \'file:\'||tmp, new_origin_uri);
DB.DBA.RM_RDF_LOAD_RDFXML (xd, new_origin_uri, coalesce (dest, graph_iri));
return 1;
}');
insert soft DB.DBA.SYS_RDF_MAPPERS (RM_PATTERN, RM_TYPE, RM_HOOK, RM_KEY, RM_DESCRIPTION)
values ('(application/octet-stream)|(application/pdf)|(application/mspowerpoint)',
'MIME', 'DB.DBA.RDF_LOAD_BIN_DOCUMENT', null, 'Binary Files');
update DB.DBA.SYS_RDF_MAPPERS set RM_ID = 1000 where RM_HOOK = 'DB.DBA.RDF_LOAD_BIN_DOCUMENT';
set_qualifier ('DB');
}
;
RDF_APERTURE_INIT ()
;
create procedure DB.DBA.RDF_LOAD_HTTP_SESSION (
in graph_iri varchar,
in new_origin_uri varchar,
in dest varchar,
inout ret_body any,
inout aq any, inout ps any,
inout headers any,
inout opts any)
{
declare req, resp any;
declare ses, tmp any;
declare meth, host, url, proto_ver, stat, resp_ver any;
ses := string_output ();
req := headers[0];
resp := headers[1];
host := http_request_header (req, 'Host');
tmp := split_and_decode (req[0], 0, '\0\0 ');
meth := tmp[0];
meth := lower (meth);
meth[0] := meth[0] - 32;
url := tmp[1];
proto_ver := substring (tmp[2], 6, 8);
tmp := rtrim (resp[0], '\r\n');
tmp := split_and_decode (resp[0], 0, '\0\0 ');
stat := tmp[1];
resp_ver := substring (tmp[0], 6, 8);
http ('<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:http="http://www.w3.org/2006/http#">\n', ses);
http ('<http:Connection rdf:ID="conn">\n', ses);
http (' <http:connectionAuthority>'|| host ||'</http:connectionAuthority>\n', ses);
http (' <http:request rdf:parseType="Collection">\n', ses);
http (' <http:Request rdf:about="#req0"/>\n', ses);
http (' </http:request>\n', ses);
http ('</http:Connection>\n', ses);
http ('<http:'|| meth ||'Request rdf:ID="req0">\n', ses);
http (' <http:abs_path>'|| url ||'</http:abs_path>\n', ses);
http (' <http:version>'|| proto_ver ||'</http:version>\n', ses);
http (' <http:header rdf:parseType="Collection">\n', ses);
-- loop over req from 1 - len
tmp := '';
for (declare i int, i := 1; i < length (req); i := i + 1)
{
tmp := tmp || trim (req[i], '\r\n') || '\r\n' ;
}
tmp := mime_tree (tmp);
tmp := tmp[0];
for (declare i int, i := 0; i < length (tmp); i := i + 2)
{
http ('<http:MessageHeader>\n', ses);
http (' <http:fieldName rdf:resource="http://www.w3.org/2006/http-header#'||lower (tmp[i])||'"/>\n', ses);
http (' <http:fieldValue>\n', ses);
http (' <http:HeaderElement>\n', ses);
http (' <http:elementName>'||tmp[i+1]||'</http:elementName>\n', ses);
http (' </http:HeaderElement>\n', ses);
http (' </http:fieldValue>\n', ses);
http ('</http:MessageHeader>\n', ses);
}
http (' </http:header>\n', ses);
http (' <http:response rdf:resource="#resp0"/>\n', ses);
http ('</http:'|| meth ||'Request>\n', ses);
http ('<http:Response rdf:ID="resp0">\n', ses);
http ('<http:responseCode rdf:resource="http://www.w3.org/2006/http#'||stat||'"/>\n', ses);
http (' <http:version>'||resp_ver||'</http:version>\n', ses);
http (' <http:header rdf:parseType="Collection">\n', ses);
-- loop over resp from 1 - len
tmp := '';
for (declare i int, i := 1; i < length (resp); i := i + 1)
{
tmp := tmp || trim (resp[i], '\r\n') || '\r\n' ;
}
tmp := mime_tree (tmp);
tmp := tmp[0];
for (declare i int, i := 0; i < length (tmp); i := i + 2)
{
http ('<http:MessageHeader>\n', ses);
http (' <http:fieldName rdf:resource="http://www.w3.org/2006/http-header#'||lower (tmp[i])||'"/>\n', ses);
http (' <http:fieldValue>\n', ses);
http (' <http:HeaderElement>\n', ses);
http (' <http:elementName>'||tmp[i+1]||'</http:elementName>\n', ses);
http (' </http:HeaderElement>\n', ses);
http (' </http:fieldValue>\n', ses);
http ('</http:MessageHeader>\n', ses);
}
http (' </http:header>\n', ses);
http ('</http:Response>\n', ses);
http ('</rdf:RDF>\n', ses);
tmp := string_output_string (ses);
DB.DBA.RM_RDF_LOAD_RDFXML (tmp, new_origin_uri, coalesce (dest, graph_iri));
-- never stop the rest of handlers
return 0;
}
;
create procedure FB_SIG (in params any, in secret any)
{
declare arr, pars, str any;
arr := split_and_decode (params, 0, '\0\0&=');
pars := vector ();
for (declare i int, i := 0; i < length (arr); i := i + 2)
{
declare tmp any;
tmp := split_and_decode (arr[i+1]);
tmp := tmp[0];
pars := vector_concat (pars, vector (arr[i]||'='||tmp));
}
pars := __vector_sort (pars);
str := '';
foreach (any elm in pars) do
{
str := str || elm;
}
str := str || secret;
return md5 (str);
};
create procedure DB.DBA.MQL_TREE_TO_XML_REC (in tree any, in tag varchar, inout ses any)
{
if (not isarray (tree) or isstring (tree))
{
if (tree is not null and tree <> '')
{
http_value (tree, tag, ses);
}
}
else if (length (tree) > 1 and __tag (tree[0]) = 255)
{
http (sprintf ('<%U>', tag), ses);
for (declare i,l int, i := 2, l := length (tree); i < l; i := i + 2)
{
DB.DBA.MQL_TREE_TO_XML_REC (tree[i+1], tree[i], ses);
}
http (sprintf ('</%U>', tag), ses);
}
else if (length (tree) > 0)
{
for (declare i,l int, i := 0, l := length (tree); i < l; i := i + 1)
{
DB.DBA.MQL_TREE_TO_XML_REC (tree[i], tag, ses);
}
}
}
;