return entity;
}
public ReputationObject getReputationObject(Model model,
Resource resource) throws Exception {
ReputationObject repObj = (ReputationObject) getResourceFromCache(
resource, ReputationObject.class);
if(repObj == null) {
repObj = new ReputationObject();
repObj.setResource(resource);
addResourceInstanceToCache(resource,repObj);
} else {
return repObj;
}
// Specific Attributes and Properties of ReputationEvaluation Class //
// fromCommunity //
Property fromCommunity = ResourceFactory.createProperty(
riNamespace + "fromCommunity");
StmtIterator stmtI1 = model.listStatements(resource,
fromCommunity, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate fromCommunity property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONOBJECT,
"fromCommunity property of ReputationObject resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Community community = (Community) getResourceFromCache(
statement.getObject().asResource(), Community.class);
if(community == null) {
community = getCommunity(model,
statement.getObject().asResource());
}
repObj.setFromCommunity(community);
}
}
// hasValue //
Property hasValue = ResourceFactory.createProperty(
riNamespace + "hasValue");
stmtI1 = model.listStatements(resource,
hasValue, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate hasValue property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONOBJECT,
"hasValue property of ReputationObject resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
ReputationValue repVal = (ReputationValue) getResourceFromCache(
statement.getObject().asResource(), ReputationValue.class);
if(repVal == null) {
repVal = getReputationValue(model,
statement.getObject().asResource());
}
repObj.addHasValue(repVal);
}
}
// owner //
Property owner = ResourceFactory.createProperty(
riNamespace + "owner");
stmtI1 = model.listStatements(resource,
owner, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate owner property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONOBJECT,
"owner property of ReputationObject resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Entity entity = (Entity) getResourceFromCache(
statement.getObject().asResource(), Entity.class);
if(entity == null) {
entity = getEntity(model,statement.getObject().asResource(),null);
}
repObj.setOwner(entity);
}
}
return repObj;
}