Contact.java

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 Contact implements Serializable {
00032   //add serial version to avoid serialization error if the version change
00033   // without class change. 
00034   static final long serialVersionUID = 5521257935120563452L;
00035  
00036   //define the category for all function label in LabelManager
00037   public static final String CONTACT_FUNCTION_LABEL_CATEGORY = "2";
00038   private String id;
00039   private String firstname, lastname;
00040   private int function;
00041   private Array reportList;
00042 
00043   public Contact(String id) {
00044     super();
00045     this.id = id;
00046     reportList = new Array();
00047  }
00048   
00049   public Array getAllReports() {
00050     return reportList;
00051   }
00052   
00053   public void addReport(Report report)   {
00054     if (report == null) return;
00055     for (int i=0; i<reportList.size(); i++)    {
00056       Report r = (Report)reportList.get(i);
00057       if (r.getId().equals(report.getId()))  {
00058         reportList.replace(i, report);
00059         return;
00060       }
00061     }    
00062     reportList.add(report);
00063   }
00064   
00065   public void removeReport(String reportid)   {
00066     if (reportid == null) return;
00067     for (int i=0; i<reportList.size(); i++)    {
00068       Report r = (Report)reportList.get(i);
00069       if (r.getId().equals(reportid))  {
00070         reportList.remove(i);
00071       }
00072     }    
00073   }
00074   
00075   public Report getReportById(String reportid){
00076     if (reportid == null) return null;
00077     Report report = null;    
00078     for (int i=0; i<reportList.size(); i++)    {
00079       Report r = (Report)reportList.get(i);
00080       if (r.getId().equals(reportid))  {
00081         report = r;
00082       }
00083     }    
00084     return report;
00085   }
00086 
00087   public String getFirstname() {
00088     return firstname;
00089   }
00090 
00091   public void setFirstname(String firstname) {
00092     this.firstname = firstname;
00093   }
00094 
00095   public int getFunction() {
00096     return function;
00097   }
00098 
00099   public void setFunction(int function) {
00100     this.function = function;
00101   }
00102 
00103   public String getLastname() {
00104     return lastname;
00105   }
00106 
00107   public void setLastname(String lastname) {
00108     this.lastname = lastname;
00109   }
00110 
00111   public String getId() {
00112     return id;
00113   }
00114   
00115   public boolean equals(Object obj)   {
00116       if (this.id.equals(((Contact)obj).id))    {
00117           return true;
00118       }
00119       return false;
00120   }
00121   
00122   public int hashCode()   {
00123       return this.id.hashCode();
00124   }
00125 
00126 }

Generated on Mon Dec 4 11:03:25 2006 for OpenMobileIS by  doxygen 1.5.1-p1