/**
 * 
 */
package gov.nih.nci.calab.dto.common;

import gov.nih.nci.calab.domain.Protocol;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zengje
 * 
 */
public class ProtocolBean implements Comparable {
	private String id;

	private String name;

	private String type;

	public ProtocolBean(Protocol protocol) {
		id = protocol.getId().toString();
		name = protocol.getName();
		type = protocol.getType();
	}

	private List<ProtocolFileBean> fileBeanList = new ArrayList<ProtocolFileBean>();

	/**
	 * 
	 */
	public ProtocolBean() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<ProtocolFileBean> getFileBeanList() {
		return fileBeanList;
	}

	public void setFileBeanList(List<ProtocolFileBean> fileBeanList) {
		this.fileBeanList = fileBeanList;
	}

	public int compareTo(Object obj) {
		if (obj instanceof ProtocolBean) {
			ProtocolBean inPb = (ProtocolBean) obj;
			int comparison = this.getName().compareTo(inPb.getName());
			return comparison;
		}
		return -1;
	}

	public boolean equals(Object obj) {
		boolean eq = false;
		if (obj instanceof ProtocolBean) {
			ProtocolBean c = (ProtocolBean) obj;
			String thisId = this.getId();
			// String name = this.getName();
			if (thisId != null && thisId.equals(c.getId())) { // &&
				// name != null && name.equals(c.getName())) {
				eq = true;
			}
		}
		return eq;
	}
}

@@ -1276,16 +1276,102 @@
 ame());%0A
+%09%09%09if (comparison == 0) %7B%0A%09%09%09%09comparison = this.getId().compareTo(inPb.getId());%0A%09%09%09%7D%0A
 %09%09%09retur
@@ -1442,16 +1442,18 @@
  obj) %7B%0A
+//
 %09%09boolea
@@ -1466,16 +1466,18 @@
  false;%0A
+//
 %09%09if (ob
@@ -1497,32 +1497,34 @@
 ProtocolBean) %7B%0A
+//
 %09%09%09ProtocolBean 
@@ -1547,16 +1547,18 @@
 n) obj;%0A
+//
 %09%09%09Strin
@@ -1582,16 +1582,18 @@
 etId();%0A
+//
 %09%09%09// St
@@ -1620,16 +1620,18 @@
 Name();%0A
+//
 %09%09%09if (t
@@ -1681,16 +1681,18 @@
 %7B // &&%0A
+//
 %09%09%09%09// n
@@ -1730,24 +1730,26 @@
 tName())) %7B%0A
+//
 %09%09%09%09eq = tru
@@ -1755,17 +1755,23 @@
 ue;%0A
+//
 %09%09%09%7D%0A
+//
 %09%09%7D%0A
+//
 %09%09re
@@ -1779,13 +1779,93 @@
 urn eq;%0A
+%09%09if (this.compareTo(obj)== 0)%7B%0A%09%09%09return true;%0A%09%09%7D else %7B%0A%09%09%09return false;%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

Correct the logic in compareTo(), and update the equal() to use compareTo()