}
}
public ScaleCorrelation getScaleCorrelation(
Model model, Resource resource) throws Exception {
ScaleCorrelation scaCor = (ScaleCorrelation)
getResourceFromCache(resource, ScaleCorrelation.class);
if(scaCor != null) {
return scaCor;
}
scaCor = new ScaleCorrelation();
scaCor.setResource(resource);
addResourceInstanceToCache(resource, scaCor);
Property sourceScale = ResourceFactory.
createProperty(riNamespace + "sourceScale");
// sourceScale //
StmtIterator stmtI1 = model.listStatements(resource,
sourceScale, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate sourceScale property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.SCALECORRELATION,
"sourceScale property of ScaleCorrelation resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
scaCor.setSourceScale(getScale(
model, statement.getObject().asResource(),null));
}
}
Property targetScale = ResourceFactory.
createProperty(riNamespace + "targetScale");
// targetScale //
stmtI1 = model.listStatements(resource,
targetScale, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate targetScale property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.SCALECORRELATION,
"targetScale property of ScaleCorrelation resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
scaCor.setTargetScale(getScale(
model, statement.getObject().asResource(),null));
}
}
Property correlationValue = ResourceFactory.
createProperty(riNamespace + "correlationValue");
// correlationValue //
stmtI1 = model.listStatements(resource,
correlationValue, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate correlationValue property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.SCALECORRELATION,
"correlationValue property of ScaleCorrelation resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
scaCor.setCorrelationValue(
statement.getObject().asLiteral().getDouble());
}
}
return scaCor;
}