Examples of DisplayPaperResult


Examples of net.relatedwork.shared.dto.DisplayPaperResult

  @Override
  public DisplayPaperResult execute(DisplayPaper action, ExecutionContext context)
      throws ActionException {
   
    DisplayPaperResult result = new DisplayPaperResult();
    Index<Node> uriIndex = ContextHelper.getUriIndex(servletContext);
   
    String uri = action.getPaperUri();
    IOHelper.log("Rendering paper page with uri '"+ uri +"'");
   
    Node paperNode = null;
    try{
      paperNode = uriIndex.get(DBNodeProperties.URI, uri).getSingle();
    } catch (Exception e) {
      System.out.println("URI INDEX ERROR. uri " + uri + " has more than one associated node.");
    }
   
    if (paperNode == null ||  !NodeType.isPaperNode(paperNode) || !paperNode.hasProperty(DBNodeProperties.PAGE_RANK_VALUE) ){
      System.out.println("Cannot render Paper page for node: "+paperNode.toString() +", uri: " + uri);
      result.setTitle("Paper Not Found!");
      return result;
    }

    try {
      result.setTitle((String) paperNode.getProperty(DBNodeProperties.PAPER_TITLE));
      result.setAbstract((String) paperNode.getProperty(DBNodeProperties.PAPER_ABSTRACT));
     
      // Author list
      for (Relationship rel: paperNode.getRelationships(DBRelationshipTypes.WRITTEN_BY)){
        Node authorNode = rel.getEndNode();
        result.addAuthor(authorAccessHandler.authorFromNode(authorNode));
      }
     
      // Reference list
      for (Relationship rel: paperNode.getRelationships(DBRelationshipTypes.CITES, Direction.OUTGOING)){
        Node citationTargetNode = rel.getEndNode();
        result.addCitedPaper(Neo4jToDTOHelper.paperFromNode(citationTargetNode));
      };

      // Unmatched references
      //String[] array = (String[])paperNode.getProperty(DBNodeProperties.PAPER_UNMATCHED_CITATIONS);
      for (String citeString: (String[])paperNode.getProperty(DBNodeProperties.PAPER_UNMATCHED_CITATIONS)){
        if (!citeString.equals("")){
        result.addCitedPaper(new Paper(citeString));
        }
      }
     
      // Citation List
      for (Relationship rel: paperNode.getRelationships(DBRelationshipTypes.CITES, Direction.INCOMING)){
        Node citationSourceNode = rel.getStartNode();
        result.addCitedByPaper(Neo4jToDTOHelper.paperFromNode(citationSourceNode));
      };

      // CoCitations
      for (Relationship rel: paperNode.getRelationships(DBRelationshipTypes.CO_CITATION_SCORE, Direction.INCOMING)){
        Node coCitationSourceNode = rel.getStartNode();
        result.addCoCitedWithPaper(Neo4jToDTOHelper.paperFromNode(coCitationSourceNode));
      };

      for (Relationship rel: paperNode.getRelationships(DBRelationshipTypes.CO_CITATION_SCORE, Direction.OUTGOING)){
        Node coCitationTargetNode = rel.getEndNode();
        result.addCoCitedFromPaper(Neo4jToDTOHelper.paperFromNode(coCitationTargetNode));
      };

    } catch (NotFoundException e) {
      result.setTitle("Paper properties not found: " + e.getMessage());
    }

    IOHelper.log("Return paper object");
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.