1 19 20 package org.efs.openreports.objects; 21 22 import java.io.Serializable ; 23 24 public class ReportUserAlert implements Comparable , Serializable 25 { 26 private static final long serialVersionUID = 6833718935442336961L; 27 28 private ReportUser user; 29 private ReportAlert alert; 30 private Report report; 31 private int limit; 32 private String operator; 33 34 private int count; 35 36 public String getCondition() 37 { 38 return getOperator() + " " + limit; 39 } 40 41 public ReportAlert getAlert() 42 { 43 return alert; 44 } 45 46 public void setAlert(ReportAlert alert) 47 { 48 this.alert = alert; 49 } 50 51 public int getLimit() 52 { 53 return limit; 54 } 55 56 public void setLimit(int limit) 57 { 58 this.limit = limit; 59 } 60 61 public String getOperator() 62 { 63 if (operator == null || operator.trim().length() < 1) return ReportAlert.OPERATOR_EQUAL; 64 return operator; 65 } 66 67 public void setOperator(String operator) 68 { 69 this.operator = operator; 70 } 71 72 public ReportUser getUser() 73 { 74 return user; 75 } 76 77 public void setUser(ReportUser user) 78 { 79 this.user = user; 80 } 81 82 public int compareTo(Object object) 83 { 84 ReportUserAlert map = (ReportUserAlert) object; 85 return alert.getName().compareTo(map.getAlert().getName()); 86 } 87 88 public int getCount() 89 { 90 return count; 91 } 92 93 public void setCount(int count) 94 { 95 this.count = count; 96 } 97 98 public boolean isTriggered() 99 { 100 if ("=".equals(operator)) 101 { 102 if (limit == count) return true; 103 } 104 else if (">".equals(operator)) 105 { 106 if (count > limit) return true; 107 } 108 else if ("<".equals(operator)) 109 { 110 if (count < limit) return true; 111 } 112 113 return false; 114 } 115 116 public Report getReport() 117 { 118 return report; 119 } 120 121 public void setReport(Report report) 122 { 123 this.report = report; 124 } 125 } | Popular Tags |