return repObj;
}
public ReputationEvaluation getReputationEvaluation(Model model,
Resource resource) throws Exception {
ReputationEvaluation repEva = (ReputationEvaluation) getResourceFromCache(
resource, ReputationEvaluation.class);
if(repEva == null) {
repEva = new ReputationEvaluation();
repEva.setResource(resource);
addResourceInstanceToCache(resource,repEva);
} else {
return repEva;
}
// Specific Attributes and Properties of ReputationEvaluation Class //
// collectionIdentifier //
Property identifier = ResourceFactory.createProperty(
riNamespace + "collectionIdentifier");
StmtIterator stmtI1 = model.listStatements(resource,
identifier, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate collectionIdentifier property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
"collectionIdentifier property of ReputationEvaluation resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
repEva.setCollectionIdentifier(statement.getObject(
).asLiteral().getString());
}
}
// target //
Property target = ResourceFactory.createProperty(
riNamespace + "target");
stmtI1 = model.listStatements(resource,
target, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate target property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
"target property of ReputationEvaluation resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Entity targetImp = (Entity) getResourceFromCache(
statement.getObject().asResource(), Entity.class);
if(targetImp == null) {
targetImp = getEntity(model,statement.getObject().asResource(),null);
}
repEva.setTarget(targetImp);
}
}
// hasMetric //
Property hasMetric = ResourceFactory.createProperty(
riNamespace + "hasMetric");
stmtI1 = model.listStatements(resource,
hasMetric, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate hasMetric property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
"hasMetric property of ReputationEvaluation resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Metric metric = (Metric) getResourceFromCache(
statement.getObject().asResource(), Metric.class);
if(metric == null) {
metric = getMetric(model,
statement.getObject().asResource());
}
repEva.setHasMetric(metric);
}
}
return repEva;
}