Genealogy Domain Abstraction Layer
Last Tuesday as I was writing the Agent Writing Guide it really came home to me how difficult it was to write a plug-in for Genesis. I mean, I know it wasn’t cake, but just take a gander at this code snippet for adding a person to the data store:
// Create the graph in which to store the data
IResourceNode graph;
try {
graph = view.getResource("urn:source1#default");
graph.addObject(view.getResource(GP.SOURCE), site, graph);
} catch (Exception e) {
// Handle exception
}
// Create the person
try {
IResourceNode person = view.getResource("urn:person1");
person.addObject(view.getResource(RDF.TYPE), view.getResource(GC.INDIVIDUAL), graph);
// Set the name
person.addObject(view.getResource(GC.NAME), view.getLiteral("Geertruida Dirks /Adama/"), graph);
// Set the gender
person.addObject(view.getResource(GC.GENDER), view.getLiteral("F"), graph);
} catch (Exception e) {
// Handle exception
}
For an RDF buff this is of course fine, but knowledge of RDF shouldn’t be a prerequisite at all.
Something had to be done, so today I wrote a genealogy abstraction layer. The above code can now be accomplished with:
// Create the source of this data
Source source = new Source("urn:source1", null);
// Create the person
Individual person = new Individual("urn:person1", source);
// Set the name
person.addName("Geertruida Dirks /Adama/", source);
// Set the gender
person.addGender(Individual.FEMALE, source);
That’s better.
Filed in 

