#!/bin/perl
#
# Squish/Algae test script
# usage: ./sqtest.pl --data=../samples/data2.rdf 
#
BEGIN {unshift @INC,('../../..','../..','..');}

use RDF::RDFWeb::SquishAlgae;
use strict;


my $data = "../samples/dcmiarch1.rdf"; 
print "Sample data: $data\n";
my $q = new RDF::RDFWeb::SquishAlgae;

# Dublin Core Architecture:
# see http://rdfweb.org/people/danbri/2001/06/dcarch-test/rdfq-tests.html
#

# Our query...	
my $q1= "
SELECT ?x, ?title, ?a, ?moddate, ?createddate, ?name, ?creatormail
FROM http://rdfweb.org/people/danbri/2001/06/dcarch-test/dc3.rdf
WHERE
(dc::title ?x ?title)
(dcq::abstract ?x ?a)
(dcq::modified ?x ?m)
(dcq::created ?x ?cd)
(rdf::value ?m ?moddate)
(rdf::value ?cd ?createddate)
(dc::creator ?x ?cr)
(vcard::FN ?cr ?name)
(vcard::EMAIL ?cr ?creatormail)
USING dcq for http://dublincore.org/2000/03/13/dcq#
rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#
vcard for http://www.w3.org/2001/vcard-rdf/3.0#
dc for http://purl.org/dc/elements/1.1/
";

my $q1a = $q->squish2algae( $q1);
#print "Algae: \n\n $q1a \n\n\n";
print "\n\nDCMI Architecture test results:\n";
my @results = $q->doalgae( $data, $q1a ); # 'FROM' clause ignored, hence $data



print "\n\n";
foreach my $hit (@results) {
  printf (      "Resource URI: %s \tTitle: %s \tAbstract: %s 
		Last-modified date: %s \tCreated_Date: %s 	
		Creator name: %s\tCreator email: %s \n\n",
	 	$$hit{0}, $$hit{1}, $$hit{2},
	 	$$hit{3}, $$hit{4}, 
		$$hit{5}, $$hit{6}, $$hit{7});
}


# print $q->formatResultSet( @results ); 

