RepositoryConnection con = repository.getConnection();
try {
con.begin();
ValueFactory vf = repository.getValueFactory();
URI subject = vf.createURI(resourceUri);
// add the type based on the facebook category
if(data.get("category") != null) {
con.add(subject, RDF.TYPE, getType(data.get("category").toString()));
}
con.add(subject,DCTERMS.identifier,vf.createLiteral(data.get("id").toString()));
// schema:name is the facebook name (can have multiple languages)
con.add(subject, SCHEMA.name, vf.createLiteral(data.get("name").toString(), language));
con.add(subject, DCTERMS.title, vf.createLiteral(data.get("name").toString(), language));
// dct:description in case a description or about is present (all content in English)
if(data.get("description") != null) {
con.add(subject,SCHEMA.description, vf.createLiteral(data.get("description").toString(), "en"));
con.add(subject,DCTERMS.description, vf.createLiteral(data.get("description").toString(), "en"));
}
if(data.get("about") != null) {
con.add(subject,SCHEMA.description, vf.createLiteral(data.get("about").toString(), "en"));
con.add(subject,DCTERMS.description, vf.createLiteral(data.get("about").toString(), "en"));
}
// if there is genre information, add it using schema:genre and dct:subject
if(data.get("genre") != null) {
con.add(subject,SCHEMA.genre, vf.createLiteral(data.get("genre").toString()));
con.add(subject,DCTERMS.subject, vf.createLiteral(data.get("genre").toString()));
}
if(data.get("directed_by") != null) {
con.add(subject,SCHEMA.director, vf.createLiteral(data.get("directed_by").toString()));
con.add(subject,DCTERMS.creator, vf.createLiteral(data.get("directed_by").toString()));
}
if(data.get("studio") != null) {
con.add(subject,SCHEMA.publisher, vf.createLiteral(data.get("studio").toString()));
con.add(subject,DCTERMS.publisher, vf.createLiteral(data.get("studio").toString()));
}
if(data.get("plot_outline") != null) {
con.add(subject,SCHEMA.description, vf.createLiteral(data.get("plot_outline").toString()));
con.add(subject,DCTERMS.description, vf.createLiteral(data.get("plot_outline").toString()));
}
if(data.get("phone") != null) {
con.add(subject,SCHEMA.telephone, vf.createLiteral(data.get("phone").toString()));
con.add(subject,FOAF.phone, vf.createLiteral(data.get("phone").toString()));
}
if(data.get("username") != null) {
con.add(subject,FOAF.nick, vf.createLiteral(data.get("username").toString()));
}
if(data.get("cover") != null && data.get("cover") instanceof Map && ((Map)data.get("cover")).get("source") != null) {
con.add(subject,FOAF.thumbnail, vf.createURI(((Map) data.get("cover")).get("source").toString()));
}
// website
if(data.get("website") != null && UriUtil.validate(data.get("website").toString())) {
con.add(subject, FOAF.homepage, vf.createURI(data.get("website").toString()));
}
if(data.get("link") != null) {
con.add(subject, FOAF.homepage, vf.createURI(data.get("link").toString()));
}
con.commit();
} catch(RepositoryException ex) {
con.rollback();