View Javadoc

1   package uk.ac.ebi.intenz.domain.history;
2   
3   import uk.ac.ebi.intenz.domain.constants.EventConstant;
4   import uk.ac.ebi.intenz.domain.enzyme.EnzymeEntry;
5   
6   import java.util.ArrayList;
7   import java.util.List;
8   
9   /**
10   * This node represents an enzyme within the history graph of an enzyme.
11   *
12   * @author Michael Darsow
13   * @version $Revision: 1.2 $ $Date: 2008/01/28 12:33:04 $
14   */
15  public class HistoryNode {
16    private EnzymeEntry enzymeEntry;
17  
18    private List<HistoryEvent> edges;
19  
20    private String historyLine;
21  
22    private boolean isRoot;
23  
24    /**
25     * Nothing special.
26     */
27    public HistoryNode() {
28      this.enzymeEntry = null;
29      this.edges = new ArrayList<HistoryEvent>();
30      this.historyLine = "";
31      this.isRoot = true;
32    }
33  
34    /**
35     * Checks all events of this node for <code>DELETION</code> events and returns the source node of this event.
36     *
37     * @return the source node of the deletion.
38     */
39    public HistoryNode checkForDeletion() {
40      if (edges.size() > 0) {
41        HistoryEvent event = edges.get(0);
42        if (event.getEventClass().equals(EventConstant.DELETION)) return event.getBeforeNode();
43      }
44      return this;
45    }
46  
47    public String toString() {
48      StringBuffer historyNodeString = new StringBuffer();
49      historyNodeString.append("ENZYME ID: ");
50      historyNodeString.append(enzymeEntry.getId());
51      historyNodeString.append("\nEDGES SIZE: ");
52      historyNodeString.append(edges.size());
53      historyNodeString.append("\nHISTORY LINE: ");
54      historyNodeString.append(historyLine);
55      historyNodeString.append(isRoot ? "\nIS ROOT NODE" : "\nIS NOT ROOT NODE");
56      return historyNodeString.toString();
57    }
58  
59  
60    // --------------------  GETTER/SETTER -----------------------
61  
62    public EnzymeEntry getEnzymeEntry() {
63      return enzymeEntry;
64    }
65  
66    public void setEnzymeEntry(EnzymeEntry enzymeEntry) {
67      this.enzymeEntry = enzymeEntry;
68    }
69  
70    public List<HistoryEvent> getEdges() {
71      return edges;
72    }
73  
74    public void setEdges(List<HistoryEvent> edges) {
75      this.edges = edges;
76    }
77  
78    public String getHistoryLine() {
79      return historyLine;
80    }
81  
82    public void setHistoryLine(String historyLine) {
83      this.historyLine = historyLine;
84    }
85  
86    public boolean isRoot() {
87      return isRoot;
88    }
89  
90    public void setRoot(boolean root) {
91      isRoot = root;
92    }
93  }