00001
00025 package org.openmobileis.examples.mycrm.data;
00026
00027 import java.io.Serializable;
00028
00029 import org.openmobileis.common.util.collection.Array;
00030
00031 public final class Account implements Serializable{
00032
00033
00034 static final long serialVersionUID = 5521257935120563452L;
00035
00036
00037 public static final String ACCOUNT_ACTIVITY_LABEL_CATEGORY = "1";
00038 private String id;
00039 private String name, address, city;
00040 private String activity;
00041 private Array contactList;
00042
00043 public Account(String id) {
00044 super();
00045 this.id = id;
00046 contactList = new Array();
00047 }
00048
00049 public Array getAllContacts() {
00050 return contactList;
00051 }
00052
00053 public void addContact(Contact contact) {
00054 if (contact == null) return;
00055 for (int i=0; i<contactList.size(); i++) {
00056 Contact c = (Contact)contactList.get(i);
00057 if (c.getId().equals(contact.getId())) {
00058 contactList.replace(i, contact);
00059 return;
00060 }
00061 }
00062 contactList.add(contact);
00063 }
00064
00065 public Contact getContactById(String contactid){
00066 if (contactid == null) return null;
00067 Contact contact = null;
00068 for (int i=0; i<contactList.size(); i++) {
00069 Contact c = (Contact)contactList.get(i);
00070 if (c.getId().equals(contactid)) {
00071 contact = c;
00072 }
00073 }
00074 return contact;
00075 }
00076
00077 public void removeContact(String contactid) {
00078 if (contactid == null) return;
00079 for (int i=0; i<contactList.size(); i++) {
00080 Contact c = (Contact)contactList.get(i);
00081 if (c.getId().equals(contactid)) {
00082 contactList.remove(i);
00083 }
00084 }
00085 }
00086
00087 public String getActivity() {
00088 return activity;
00089 }
00090
00091 public void setActivity(String activity) {
00092 this.activity = activity;
00093 }
00094
00095 public String getAddress() {
00096 return address;
00097 }
00098
00099 public void setAddress(String address) {
00100 this.address = address;
00101 }
00102
00103 public String getCity() {
00104 return city;
00105 }
00106
00107 public void setCity(String city) {
00108 this.city = city;
00109 }
00110
00111 public String getName() {
00112 return name;
00113 }
00114
00115 public void setName(String name) {
00116 this.name = name;
00117 }
00118
00119 public String getId() {
00120 return id;
00121 }
00122
00123 public boolean equals(Object obj) {
00124 if (this.id.equals(((Account)obj).id)) {
00125 return true;
00126 }
00127 return false;
00128 }
00129
00130 public int hashCode() {
00131 return this.id.hashCode();
00132 }
00133
00134 }