void setAttibutesAndProperties(Model model, Resource resource,
ReputationAlgorithmImplementation repAlg) throws Exception {
Property accesibility = ResourceFactory.
createProperty(riNamespace + "accesibility");
// accesibility //
StmtIterator stmtI1 = model.listStatements(resource,
accesibility, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate accesibility property //
if(!statement.getObject().isResource()) {
throw new Exception("uriFormat property of resource:"+
resource.getURI()+" is not a resource");
} else {
AccessType type = getAccessType(statement.getObject().asResource());
if(type == null) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"accessType(resource:"+statement.getObject().asResource()+
") from ReputationAlgorithm(resource"+resource+") is not known")) {
repAlg = null;
return;
}
} else {
repAlg.addAccesibility(type);
}
}
}
Property name = ResourceFactory.
createProperty(riNamespace + "name");
// name //
stmtI1 = model.listStatements(resource,
name, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate name property */
if(!statement.getObject().isLiteral()) {
if(ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"name property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a literal")) {
repAlg = null;
return;
}
} else {
repAlg.setName(statement.getObject().asLiteral().getString());
}
}
Property resultCollectionType = ResourceFactory.
createProperty(riNamespace + "resultCollectionType");
/* resultCollectionType */
stmtI1 = model.listStatements(resource,
resultCollectionType, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate resultCollectionType property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"resultCollectionType property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
CollectionType collectionType = (CollectionType) getResourceFromCache(
statement.getObject().asResource(),CollectionType.class);
if(collectionType == null) {
collectionType = getCollectionType(statement.getObject().asResource());
}
if(collectionType == null) {
ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"collectionType(resource:"+statement.getObject().asResource()+
" from ReputationAlgorithm(resource"+resource+") is not known");
} else {
repAlg.setResultCollectionType(collectionType);
}
}
}
Property description = ResourceFactory.
createProperty(dcNamespace + "description");
/* description */
stmtI1 = model.listStatements(resource,
description, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* description name property */
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"dc:description property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a literal")) {
repAlg = null;
return;
}
} else {
repAlg.setDescription(statement.getObject().asLiteral().getString());
}
}
Property entityType = ResourceFactory.
createProperty(riNamespace + "entityType");
/* entityType */
stmtI1 = model.listStatements(resource,
entityType, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate entityType property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"entityType property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
EntityType entityTypeIns = (EntityType) getResourceFromCache(
statement.getObject().asResource(),EntityType.class);
if(entityTypeIns == null) {
entityTypeIns = getEntityType(model,
statement.getObject().asResource());
}
repAlg.addEntityType(entityTypeIns);
}
}
Property usesMetric = ResourceFactory.
createProperty(riNamespace + "usesMetric");
/* usesMetric */
stmtI1 = model.listStatements(resource,
usesMetric, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate usesMetric property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"usesMetric property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
Metric metric = (Metric) getResourceFromCache(
statement.getObject().asResource(),Metric.class);
if(metric == null) {
metric = getMetric(model,statement.getObject().asResource());
}
repAlg.addUsesMetrics(metric);
}
}
Property reputationSource = ResourceFactory.
createProperty(riNamespace + "reputationSource");
/* reputationSource */
stmtI1 = model.listStatements(resource,
reputationSource, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate reputationSource property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"reputationSource property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
ReputationValue reputationValue = (ReputationValue) getResourceFromCache(
statement.getObject().asResource(),ReputationValue.class);
if(reputationValue == null) {
reputationValue = getReputationValue(model,
statement.getObject().asResource());
}
repAlg.addReputationSources(reputationValue);
}
}
Property reputationResult = ResourceFactory.
createProperty(riNamespace + "reputationResult");
/* reputationResult */
stmtI1 = model.listStatements(resource,
reputationResult, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate reputationResult property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"reputationResult property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
ReputationValue reputationValue = (ReputationValue) getResourceFromCache(
statement.getObject().asResource(),ReputationValue.class);
if(reputationValue == null) {
reputationValue = getReputationValue(model,
statement.getObject().asResource());
}
repAlg.addReputationResults(reputationValue);
}
}
/* definedByReputationModel */
Property definedByReputationModel = ResourceFactory.createProperty(
riNamespace + "definedByReputationModel");
stmtI1 = model.listStatements(resource,
definedByReputationModel, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate definedByReputationModel property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"definedByReputationModel property of ReputationAlgorithm resource:"+
resource.getURI()+" is not a resource")) {
repAlg = null;
return;
}
} else {
repAlg.setDefinedByReputationModel(getReputationAlgorithm(
model,statement.getObject().asResource(),null));
}
}
// stepIdentifier //
Property stepIdentificator = ResourceFactory.createProperty(
riNamespace + "stepIdentifier");
stmtI1 = model.listStatements(resource,
stepIdentificator, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
// validate stepIdentifier property //
if(!statement.getObject().isLiteral()) {
if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
"stepIdentifier property of resource:"+
resource.getURI()+" is not a literal")) {