@Override
public DisplayAuthorResult execute(DisplayAuthor action,
ExecutionContext context) throws ActionException {
DisplayAuthorResult result = new DisplayAuthorResult();
String uri = action.getUri();
IOHelper.log("Rendering author page with uri '"+ uri +"'");
Node n = authorAccessHandler.authorNodeFromUri(uri);
if (n == null) {
System.out.println("URI INDEX ERROR. uri " + uri + " has more than one associated node.");
return result;
}
Author author = authorAccessHandler.authorFromNode(n);
if (author == null) {
System.out.println("Cannot render Author page for node: "+n.toString() +", uri: " + uri);
return result;
}
result.setAuthor(author);
//TODO: get from data base
AuthorSidebar authorSidebar = new AuthorSidebar();
if (n.hasProperty("metadata:url")){
authorSidebar.setWebsite((String)n.getProperty("metadata:url"));
}
else {
authorSidebar.setWebsite(null);
}
authorSidebar.setTwitterHandle("renepickhardt");
authorSidebar.setAdvisor(null);
authorSidebar.setStudents(null);
result.setSidebar(authorSidebar);
for (Relationship rel:n.getRelationships(DBRelationshipTypes.CO_AUTHOR_COUNT)){
Node coAuthor = rel.getEndNode();
Integer score = (Integer)rel.getProperty(DBRelationshipProperties.CO_AUTHOR_COUNT);
result.addCoAuthor(authorAccessHandler.authorFromNode(coAuthor,score));
}
for (Relationship rel:n.getRelationships(DBRelationshipTypes.CITES_AUTHOR,Direction.OUTGOING)){
Node citedAuthor = rel.getEndNode();
Integer score = (Integer)rel.getProperty(DBRelationshipProperties.CITATION_COUNT);
result.addCitedAuthor(authorAccessHandler.authorFromNode(citedAuthor, score));
}
for (Relationship rel:n.getRelationships(DBRelationshipTypes.CITES_AUTHOR,Direction.INCOMING)){
Node citedAuthor = rel.getStartNode();
Integer score = (Integer)rel.getProperty(DBRelationshipProperties.CITATION_COUNT);
result.addCitedByAuthor(authorAccessHandler.authorFromNode(citedAuthor, score));
}
for (Relationship rel:n.getRelationships(DBRelationshipTypes.SIM_AUTHOR, Direction.OUTGOING)){
Node simAuthor = rel.getEndNode();
Integer score = (int)((Double)rel.getProperty(DBRelationshipProperties.SIM_AUTHOR_SCORE)*1000.);
result.addSimilarAuthor(authorAccessHandler.authorFromNode(simAuthor, score));
}
for (Relationship rel:n.getRelationships(DBRelationshipTypes.WRITTEN_BY)){
Node paper = rel.getStartNode(); // {paper-node} --[AUTHOROF]--> {author-node}
result.addWrittenPaper(Neo4jToDTOHelper.paperFromNode(paper));
}
result.setCommentList(commentsAccessHelper.getRelatedComments(uri));
return result;
}