" in the database");
}
}
public Dimension getDimension(Model model, Resource resource) throws Exception {
Dimension dimension = (Dimension) getResourceFromCache(resource, Dimension.class);
if(dimension != null) {
return dimension;
}
Property name = ResourceFactory.createProperty(riNamespace + "name");
// name //
StmtIterator stmtI1 = model.listStatements(resource, name, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate name property */
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.DIMENSION,
"name property of Dimension resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
}
dimension = new Dimension(statement.getObject().asLiteral().getString());
dimension.setResource(resource);
addResourceInstanceToCache(resource, dimension);
}
Property description = ResourceFactory.createProperty(dcNamespace + "description");
// description //
stmtI1 = model.listStatements(resource, description, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate description property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.DIMENSION,
"description property of Dimension resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
}
if(dimension != null) {
dimension.setDescription(statement.getObject().asLiteral().getString());
}
}
return dimension;
}