Property identifier = ResourceFactory.createProperty(
riNamespace + "identifier");
StmtIterator stmtI1 = model.listStatements(resource,
identifier, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate identificator property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.METRIC,
"identificator property of Metric resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
metric.setIdentifier(statement.getObject().asLiteral().getString());
}
}
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.METRIC,
"description property of Metric resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
metric.setDescription(statement.getObject().asLiteral().getString());
}
}
Property hasScale = ResourceFactory.createProperty(
riNamespace + "hasScale");
// hasScale //
stmtI1 = model.listStatements(resource,
hasScale, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate hasScale property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRIC,
"hasScale property of Metric resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Scale scale = (Scale) getResourceFromCache(
statement.getObject().asResource(),Scale.class);
if(scale == null) {
scale = getScale(model,statement.getObject().asResource(),null);
}
metric.setScale(scale);
}
}
Property hasDimension = ResourceFactory.createProperty(
riNamespace + "hasDimension");
// hasDimension //
stmtI1 = model.listStatements(resource,
hasDimension, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate hasDimension property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRIC,
"hasDimension property of Metric resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Dimension dimension = (Dimension) getResourceFromCache(
statement.getObject().asResource(),Dimension.class);
if(dimension == null) {
dimension = getDimension(model,
statement.getObject().asResource());
}
metric.setDimension(dimension);
}
}
return metric;