1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 import java.math.*; 19 import java.io.Serializable ; 20 import org.compiere.util.*; 21 22 23 32 public class MInterestArea extends X_R_InterestArea 33 { 34 39 public MInterestArea (Properties ctx, int R_InterestArea_ID) 40 { 41 super (ctx, R_InterestArea_ID); 42 if (R_InterestArea_ID == 0) 43 { 44 } 47 } 49 54 public MInterestArea (Properties ctx, ResultSet rs) 55 { 56 super (ctx, rs); 57 } 59 60 61 62 66 public String toString () 67 { 68 StringBuffer sb = new StringBuffer ("MInterestArea[") 69 .append (getID()).append(" - ").append(getName()) 70 .append ("]"); 71 return sb.toString (); 72 } 73 74 75 76 private int m_AD_User_ID = -1; 77 private int m_old_AD_User_ID = -1; 78 private Timestamp m_OptOutDate = null; 79 private Timestamp m_SubscribeDate = null; 80 private boolean m_Subscribed = false; 81 82 88 public void setSubscription (int AD_User_ID, Timestamp SubscribeDate, Timestamp OptOutDate) 89 { 90 m_old_AD_User_ID = AD_User_ID; 91 m_AD_User_ID = AD_User_ID; 92 setSubscribeDate(SubscribeDate); 93 setOptOutDate(OptOutDate); 94 isSelfService(); 95 } 97 public void setAD_User_ID (int AD_User_ID) 98 { 99 m_AD_User_ID = AD_User_ID; 100 } 101 102 public int getAD_User_ID () 103 { 104 return m_AD_User_ID; 105 } 106 107 public void setSubscribeDate (Timestamp SubscribeDate) 108 { 109 m_SubscribeDate = SubscribeDate; 110 } 111 112 public Timestamp getSubscribeDate () 113 { 114 return m_SubscribeDate; 115 } 116 117 public void setOptOutDate (Timestamp OptOutDate) 118 { 119 m_OptOutDate = OptOutDate; 120 } 121 122 public Timestamp getOptOutDate () 123 { 124 return m_OptOutDate; 125 } 126 127 public boolean isSubscribed() 128 { 129 if (m_AD_User_ID <= 0) 130 return false; 131 return (m_OptOutDate == null); 133 } 135 139 public boolean saveSubscription () 140 { 141 log.debug ("saveSubscription"); 142 if (m_AD_User_ID <= 0) 144 return false; 145 146 int no = 0; 147 148 if (m_AD_User_ID != m_old_AD_User_ID) 150 { 151 String sql = "INSERT INTO R_ContactInterest (" 152 + "R_InterestArea_ID,AD_User_ID," 153 + " AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy," 154 + " SubscribeDate,OptOutDate) VALUES ("; 155 sql += getR_InterestArea_ID() + "," + m_AD_User_ID + ","; 157 sql += getAD_Client_ID() + "," + getAD_Org_ID() + ",'Y',SysDate,0,SysDate,0,"; 159 if (m_SubscribeDate == null) 161 sql += "NULL,"; 162 else 163 sql += DB.TO_DATE(m_SubscribeDate, false) + ","; 164 if (m_OptOutDate == null) 165 sql += "NULL"; 166 else 167 sql += DB.TO_DATE(m_OptOutDate, false); 168 sql += ")"; 169 no = DB.executeUpdate(sql); 171 if (no == 0) m_old_AD_User_ID = m_AD_User_ID; 173 } 174 175 if (m_AD_User_ID == m_old_AD_User_ID) 177 { 178 String sql = "UPDATE R_ContactInterest" 179 + " SET SubscribeDate="; 180 if (m_SubscribeDate == null) 181 sql += "NULL,"; 182 else 183 sql += DB.TO_DATE(m_SubscribeDate, false) + ","; 184 sql += " OptOutDate="; 185 if (m_OptOutDate == null) 186 sql += "NULL,"; 187 else 188 sql += DB.TO_DATE(m_OptOutDate, false) + ","; 189 sql +=" Updated=SysDate, IsActive='Y' " 190 + "WHERE AD_User_ID=" + m_AD_User_ID 191 + " AND R_InterestArea_ID=" + getR_InterestArea_ID(); 192 no = DB.executeUpdate(sql); 194 } 195 return no == 1; 196 } 198 }
| Popular Tags
|