1 |
#!/usr/bin/env perl |
2 |
# the simplest implementation of a node gatherer |
3 |
|
4 |
use strict; |
5 |
use warnings; |
6 |
|
7 |
use HyperEstraier; |
8 |
|
9 |
# open the database |
10 |
my $node = HyperEstraier::Node->new("http://localhost:1978/node/test1"); |
11 |
$node->set_auth('admin', 'admin'); |
12 |
|
13 |
print "Connected to node ", $node->name, " (", $node->label, ")\n"; |
14 |
print "docnum: ", $node->doc_num, " word_num: ", $node->word_num, " size: ",$node->size,"\n"; |
15 |
|
16 |
# create a document object |
17 |
my $doc = HyperEstraier::Document->new; |
18 |
|
19 |
# add attributes to the document object |
20 |
$doc->add_attr('@uri', "http://estraier.gov/example001.txt"); |
21 |
$doc->add_attr('@title', "Over the Rainbow"); |
22 |
|
23 |
# add the body text to the document object |
24 |
$doc->add_text("Somewhere over the rainbow. Way up high."); |
25 |
$doc->add_text("There's a land that I heard of once in a lullaby."); |
26 |
|
27 |
print $doc->dump_draft; |
28 |
|
29 |
|
30 |
# register the document object to the database |
31 |
my $id; |
32 |
unless ($id = $node->put_doc($doc)) { |
33 |
printf "ERROR: %d\n", $node->status; |
34 |
} else { |
35 |
print "id: $id\n"; |
36 |
} |