% Test 001 Jena 2.0 Toolkit
% prova_jena.bat or prova_jena.sh must be used to run this code.
% Jena packages should be in ./lib/jena.

% The example demonstrates how
%   - a model can be created;
%   - it can be output to System.out accessed from a static field;
%   - to use properties defined as static fields
%        in the built-in vocabulary class VCARD;
%   - element(Item,Iterator) can be used to enumerate over elements 
%        by using an Iterator as opposed to a List as the second argument;
:- eval(test029()).

test029() :-
	println(["==========test029=========="]),
	PersonURI = "http://somewhere/JohnSmith",
	FullName = "John Smith",
	GivenName = "John",
	FamilyName = "Smith",
	Model = com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(),
	JohnSmith = Model.createResource(PersonURI),
	JohnSmith.addProperty(com.hp.hpl.jena.vocabulary.VCARD.FN,FullName),
	Child1 = Model.createResource(),
	Child1.addProperty(com.hp.hpl.jena.vocabulary.VCARD.Given,GivenName),
	Child1.addProperty(com.hp.hpl.jena.vocabulary.VCARD.Family,FamilyName),
	JohnSmith.addProperty(com.hp.hpl.jena.vocabulary.VCARD.N,Child1),
	Model.write(System.out),
	Iter = Model.listStatements(),
	element(Stmt,Iter),
%	println(["Stmt=",Stmt]),
	Subject = Stmt.getSubject(),
	Predicate = Stmt.getPredicate(),
	Object = Stmt.getObject(),
	println(["Subject=",Subject]),
	println(["Predicate=",Predicate]),
	println(["Object=",Object]).