}
return repEva;
}
public ReputationValue getReputationValue(Model model, Resource resource) throws Exception {
ReputationValue repVal = (ReputationValue) getResourceFromCache(
resource, ReputationValue.class);
if(repVal == null) {
repVal = new ReputationValue();
repVal.setResource(resource);
addResourceInstanceToCache(resource,repVal);
} else {
return repVal;
}
// Specific Attributes and Properties of ReputationValue 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.REPUTATIONVALUE,
"collectionIdentifier property of resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
repVal.setCollectionIdentifier(statement.getObject(
).asLiteral().getString());
}
}
// timeStamp //
Property homePage = ResourceFactory.createProperty(
riNamespace + "timeStamp");
stmtI1 = model.listStatements(resource,
homePage, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate timeStamp property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
"timeStamp property of resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
DateFormat dt = DateFormat.getDateTimeInstance();
repVal.setTimeStamp(dt.parse(statement.getObject(
).asLiteral().getString()));
}
}
// expirationTime //
Property expirationTime = ResourceFactory.createProperty(
riNamespace + "expirationTime");
stmtI1 = model.listStatements(resource,
expirationTime, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate expirationTime property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
"expirationTime property of resource:"+
resource.getURI()+" is not a literal")) {
return null;
}
} else {
DateFormat dt = DateFormat.getDateTimeInstance();
repVal.setExpirationTime(dt.parse(statement.getObject(
).asLiteral().getString()));
}
}
// obtainedBy //
Property obtainedBy = ResourceFactory.createProperty(
riNamespace + "obtainedBy");
stmtI1 = model.listStatements(resource,
obtainedBy, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate obtainedBy property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
"obtainedBy property of resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
ReputationAlgorithmImplementation repAlg = (ReputationAlgorithmImplementation)
getResourceFromCache(statement.getObject().asResource(),
ReputationAlgorithmImplementation.class);
if(repAlg == null) {
repAlg = getReputationAlgorithm(model,
statement.getObject().asResource(),null);
}
repVal.setObtainedBy(repAlg);
}
}
// 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.REPUTATIONVALUE,
"owner property of 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);
}
repVal.setOwner(entity);
}
}
// hasEvaluation //
Property hasEvaluation = ResourceFactory.createProperty(
riNamespace + "hasEvaluation");
stmtI1 = model.listStatements(resource,
hasEvaluation, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate hasEvaluation property //
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
"hasEvaluation property of resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
ReputationEvaluation repEva = (ReputationEvaluation) getResourceFromCache(
statement.getObject().asResource(), ReputationEvaluation.class);
if(repEva == null) {
repEva = getReputationEvaluation(model,
statement.getObject().asResource());
}
repVal.addHasEvaluations(repEva);
}
}
return repVal;
}