Model model, Resource resource) throws Exception {
Property identifier = ResourceFactory.
createProperty(riNamespace + "identifier");
/* identifier */
String identifierInstance = null;
StmtIterator stmtI1 = model.listStatements(resource,
identifier, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate identifier property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
"identifier property of MetricTransformer resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
identifierInstance = statement.getObject().asLiteral().getString();
}
}
Property sourceMetric = ResourceFactory.
createProperty(riNamespace + "sourceMetric");
/* sourceMetric */
Metric sourceInstance = null;
stmtI1 = model.listStatements(resource, sourceMetric, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate sourceMetric property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
"sourceMetric property of MetricTransformer resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
sourceInstance = (Metric) getResourceFromCache(
statement.getObject().asResource(),Metric.class);
if(sourceInstance == null) {
sourceInstance = getMetric(model, statement.getObject().asResource());
}
}
}
Property destinationMetric = ResourceFactory.
createProperty(riNamespace + "destinationMetric");
/* destinationMetric */
Metric destinationInstance = null;
stmtI1 = model.listStatements(resource,
destinationMetric, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate destinationMetric property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
"destinationMetric property of MetricTransformer resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
destinationInstance = (Metric) getResourceFromCache(
statement.getObject().asResource(),Metric.class);
if(destinationInstance == null) {
destinationInstance = getMetric(model, statement.getObject().asResource());
}
}
}
//TODO: correlationBetweenMetrics
/*Property correlationBetweenMetrics = ResourceFactory.
createProperty(riNamespace + "correlationBetweenMetrics");
Double correlationInstance = null;
stmtI1 = model.listStatements(resource,
correlationBetweenMetrics, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate correlationBetweenMetrics property //
if(!statement.getObject().isLiteral()) {
throw new Exception("correlationBetweenMetrics property of resource:"+
resource.getURI()+" is not a literal");
} else {
correlationInstance =
Double.parseDouble(statement.getObject().toString());
}
}*/
List<Double> correlationsInstance = new ArrayList<Double>();
Property correlationBetweenDimensions = ResourceFactory.
createProperty(riNamespace + "correlationBetweenDimensions");
stmtI1 = model.listStatements(resource,
correlationBetweenDimensions, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate correlationBetweenMetrics property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
"correlationBetweenDimensions property of MetricTransformer resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
DimensionCorrelation correlationInstance = getDimensionCorrelation(
model,statement.getObject().asResource());
//TODO: validate dimensions are the same of source and destination metrics
correlationsInstance.add(correlationInstance.getCorrelationValue());
}
}
Property correlationBetweenScales = ResourceFactory.
createProperty(riNamespace + "correlationBetweenScales");
stmtI1 = model.listStatements(resource,
correlationBetweenScales, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate correlationBetweenMetrics property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
"correlationBetweenScales property of MetricTransformer resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
ScaleCorrelation correlationInstance = getScaleCorrelation(
model,statement.getObject().asResource());
//TODO: validate scales are the same of source and destination metrics
correlationsInstance.add(correlationInstance.getCorrelationValue());
}
}
Property description = ResourceFactory.
createProperty(dcNamespace + "description");
// description //
String descriptionInstance = null;
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.METRICTRANSFORMER,
"dc:description property of MetricTransformer resource:"+
resource.getURI()+" is not a literal")) {