}
}
public CategoryMatching getCategoryMatching(Model model,
Resource resource) throws Exception {
CategoryMatching catMat = (CategoryMatching)
getResourceFromCache(resource, CategoryMatching.class);
if(catMat != null) {
return catMat;
}
catMat = (CategoryMatching) getTrustBetweenCommunities(
model, resource, CategoryMatching.class);;
// originatingCategory //
Property originatingCategory = ResourceFactory.
createProperty(riNamespace + "originatingCategory");
StmtIterator stmtI1 = model.listStatements(resource,
originatingCategory, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate originatingCategory property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.CATEGORYMATCHING,
"originatingCategory property of CategoryMatching resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Category category = (Category) getResourceFromCache(
statement.getObject().asResource(), Category.class);
if(category == null) {
category = getCategory(model, statement.getObject().asResource());
}
catMat.setOriginatingCategory(category);
}
}
Property receivingCategory = ResourceFactory.
createProperty(riNamespace + "receivingCategory");
/* receivingCategory */
stmtI1 = model.listStatements(resource,
receivingCategory, (RDFNode)null);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
/* validate receivingCategory property */
if(!statement.getObject().isResource()) {
if(!ModelException.throwException(ModelException.CATEGORYMATCHING,
"receivingCategory property of CategoryMatching resource:"+
resource.getURI()+" is not a resource")) {
return null;
}
} else {
Category category = (Category) getResourceFromCache(
statement.getObject().asResource(), Category.class);
if(category == null) {
category = getCategory(model, statement.getObject().asResource());
}
catMat.setReceivingCategory(category);
}
}
return catMat;
}