}
public ReputationAlgorithmImplementation getReputationAlgorithm(Model model,
Resource resource, List<Class<? extends ReputationBehaviour>> types
) throws Exception {
ReputationAlgorithmImplementation repAlg = (
ReputationAlgorithmImplementation) getResourceFromCache(
resource, ReputationAlgorithmImplementation.class);
if(repAlg != null) {
return repAlg;
}
repAlg = new ReputationAlgorithmImplementation();
repAlg.setResource(resource);
addResourceInstanceToCache(resource, repAlg);
if(types == null) {
StmtIterator stmtI1 = model.listStatements(resource, RDF.type, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement typeStatement = stmtI1.nextStatement();
for(Resource resourceType : reputationAlgorithmSubclasses.keySet()) {
if(typeStatement.getObject().asResource().getURI().equals(
resourceType.getURI())) {
addBehaviourToReputationAlgorithm(model, resource,
reputationAlgorithmSubclasses.get(resourceType),repAlg);
}
}
}
for(Property property : reputationSubclassesProperties.keySet()) {
stmtI1 = model.listStatements((Resource) null, property, resource);
if(stmtI1.hasNext()) {
addBehaviourToReputationAlgorithm(model, resource,
reputationSubclassesProperties.get(property),repAlg);
}
}
for(Property property : reputationSubclassSubjectProperties.keySet()) {
stmtI1 = model.listStatements(resource, property, (RDFNode) null);
if(stmtI1.hasNext()) {
addBehaviourToReputationAlgorithm(model, resource,
reputationSubclassSubjectProperties.get(property),repAlg);
}
}
} else {
for(Class<? extends ReputationBehaviour> type : types) {
ReputationBehaviour behaviour = (
ReputationBehaviour) getResourceFromCache(resource, type);
if(behaviour == null) {
behaviour = type.newInstance();
addResourceInstanceToCache(resource, behaviour);
}
repAlg.addBehaviour(behaviour, repAlg);
//behaviour.setRoot(repAlg);
}
}
// Specific Attributes and Properties of ReputationalAlgorithm Class //