subject);
int effectiveTill = requestParameters.getTill() - 1;
for (int i = 0; i <= effectiveTill; i++) {
try {
// Relation relation = itemsList.getRelation(i);
Relation relation = itemIterator.nextRelation();
if ((!requestParameters.getUnOrdered())
&& (relation.getCurrentStrength() < requestParameters
.getMinimalRelevance())) {
break;
}
Resource targetResource = relation.getTarget();
if (!isRelationToBeShown(relation, targetResource, hideRead,
subject, ehRequest, requestParameters)) {
effectiveTill++;
continue;
}
if (relation.isPath()) {
effectiveTill++;
}
if (log.isDebugEnabled()) {
log.debug("returning " + i + "nd relation with strenght"
+ relation.getCurrentStrength() + "(" + relation
+ ")");
log.debug("target: "+targetResource);
}
boolean isItem = targetResource.hasProperty(RDF.type, RSS.item);
if (i < (requestParameters.getFrom() - 1)) {
continue;
}
/*
* relation = itemsList.getRelation(i); log.info( "returning " +
* i + "nd relation with strenght"
*/
// resultModel.write(System.out);
Model relationModel = JenaUtil.getExpandedResource(relation
.getResource(), 3, true);
Statement feedStmt = relation.getTarget().getProperty(
AGGREGATOR.feed);
if (feedStmt != null) {
relationModel.add(feedStmt);
}
// relationModel.write(System.out);
/*
* Resource relationInResourceModel = (Resource) relation
*/
Resource relationInResourceModel = JenaUtil
.getRoots(relationModel)[0];
relationInResourceModel.removeAll(KNOBOT.nextRelation);
// we may still have nextRelation stmts in relationModel
resultModel.add(JenaUtil.getExpandedResource(
relationInResourceModel, 3, true));
boolean isAgent = targetResource.hasProperty(RDF.type,
FOAF.Agent);
Model targetModel = JenaUtil.getExpandedResource(
targetResource, 3, true);
Resource target = targetResource;
targetResource = (Resource) targetResource.inModel(targetModel);
targetResource.removeAll(KNOBOT.firstRelation);
resultModel
.add(JenaUtil.getExpandedResource(targetResource, 3));
if (isItem) {
Resource item = (Resource) target.inModel(resultModel);
addMissingSummaries(item);
addCommentCount(item);
// itemSeq.add(item);
}
/*
* Util.getExpandedResource(relation.getTarget(),
*/
ResIterator aggregatorIter = model.listSubjectsWithProperty(
AGGREGATOR.aggregated, relation.getTarget());
if (aggregatorIter.hasNext()) {
resultModel.add(JenaUtil.getExpandedResource(aggregatorIter
.nextResource(), 2, true));
}
if (isAgent) {
if (target.hasProperty(RDF.type, ROLE.Participation)) {
resultModel.add(JenaUtil.getExpandedResource(target
.getProperty(ROLE.group).getResource(), 2));
resultModel.add(JenaUtil
.getExpandedResource(target.getProperty(
ROLE.participant).getResource(), 2));
}
}
// fdr the atom transformation
if (!target.hasProperty(DC.date)) {
target.addProperty(DC.date, Util.formatDate(new Date()));
}
} catch (NoSuchElementException ex) {
log.debug("No such element at position " + i, ex);
break;
}
}
boolean hasMore = itemIterator.hasNext();
if (hasMore && !requestParameters.getUnOrdered()) {
Relation relation = itemIterator.nextRelation();
hasMore = !(relation.getCurrentStrength() < requestParameters
.getMinimalRelevance());
}
RelationNodeUtil.addInverseRelations(resource, resultModel,
requestParameters.getMinimalRelevance());
resource = (Resource) resource.inModel(resultModel);