1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.messageboards.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.model.impl.BaseModelImpl;
25  
26  import com.liferay.portlet.messageboards.model.MBMessageFlag;
27  import com.liferay.portlet.messageboards.model.MBMessageFlagSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  
38  /**
39   * <a href="MBMessageFlagModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>MBMessageFlag</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.messageboards.model.MBMessageFlag
54   * @see com.liferay.portlet.messageboards.model.MBMessageFlagModel
55   * @see com.liferay.portlet.messageboards.model.impl.MBMessageFlagImpl
56   *
57   */
58  public class MBMessageFlagModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "MBMessageFlag";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "messageFlagId", new Integer(Types.BIGINT) },
62              
63  
64              { "userId", new Integer(Types.BIGINT) },
65              
66  
67              { "messageId", new Integer(Types.BIGINT) },
68              
69  
70              { "flag", new Integer(Types.INTEGER) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table MBMessageFlag (messageFlagId LONG not null primary key,userId LONG,messageId LONG,flag INTEGER)";
73      public static final String TABLE_SQL_DROP = "drop table MBMessageFlag";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessageFlag"),
79              true);
80  
81      public static MBMessageFlag toModel(MBMessageFlagSoap soapModel) {
82          MBMessageFlag model = new MBMessageFlagImpl();
83  
84          model.setMessageFlagId(soapModel.getMessageFlagId());
85          model.setUserId(soapModel.getUserId());
86          model.setMessageId(soapModel.getMessageId());
87          model.setFlag(soapModel.getFlag());
88  
89          return model;
90      }
91  
92      public static List<MBMessageFlag> toModels(MBMessageFlagSoap[] soapModels) {
93          List<MBMessageFlag> models = new ArrayList<MBMessageFlag>(soapModels.length);
94  
95          for (MBMessageFlagSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessageFlag"));
104 
105     public MBMessageFlagModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _messageFlagId;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setMessageFlagId(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_messageFlagId);
118     }
119 
120     public long getMessageFlagId() {
121         return _messageFlagId;
122     }
123 
124     public void setMessageFlagId(long messageFlagId) {
125         if (messageFlagId != _messageFlagId) {
126             _messageFlagId = messageFlagId;
127         }
128     }
129 
130     public long getUserId() {
131         return _userId;
132     }
133 
134     public void setUserId(long userId) {
135         if (userId != _userId) {
136             _userId = userId;
137         }
138     }
139 
140     public long getMessageId() {
141         return _messageId;
142     }
143 
144     public void setMessageId(long messageId) {
145         if (messageId != _messageId) {
146             _messageId = messageId;
147         }
148     }
149 
150     public int getFlag() {
151         return _flag;
152     }
153 
154     public void setFlag(int flag) {
155         if (flag != _flag) {
156             _flag = flag;
157         }
158     }
159 
160     public MBMessageFlag toEscapedModel() {
161         if (isEscapedModel()) {
162             return (MBMessageFlag)this;
163         }
164         else {
165             MBMessageFlag model = new MBMessageFlagImpl();
166 
167             model.setNew(isNew());
168             model.setEscapedModel(true);
169 
170             model.setMessageFlagId(getMessageFlagId());
171             model.setUserId(getUserId());
172             model.setMessageId(getMessageId());
173             model.setFlag(getFlag());
174 
175             model = (MBMessageFlag)Proxy.newProxyInstance(MBMessageFlag.class.getClassLoader(),
176                     new Class[] { MBMessageFlag.class },
177                     new ReadOnlyBeanHandler(model));
178 
179             return model;
180         }
181     }
182 
183     public Object clone() {
184         MBMessageFlagImpl clone = new MBMessageFlagImpl();
185 
186         clone.setMessageFlagId(getMessageFlagId());
187         clone.setUserId(getUserId());
188         clone.setMessageId(getMessageId());
189         clone.setFlag(getFlag());
190 
191         return clone;
192     }
193 
194     public int compareTo(Object obj) {
195         if (obj == null) {
196             return -1;
197         }
198 
199         MBMessageFlagImpl mbMessageFlag = (MBMessageFlagImpl)obj;
200 
201         long pk = mbMessageFlag.getPrimaryKey();
202 
203         if (getPrimaryKey() < pk) {
204             return -1;
205         }
206         else if (getPrimaryKey() > pk) {
207             return 1;
208         }
209         else {
210             return 0;
211         }
212     }
213 
214     public boolean equals(Object obj) {
215         if (obj == null) {
216             return false;
217         }
218 
219         MBMessageFlagImpl mbMessageFlag = null;
220 
221         try {
222             mbMessageFlag = (MBMessageFlagImpl)obj;
223         }
224         catch (ClassCastException cce) {
225             return false;
226         }
227 
228         long pk = mbMessageFlag.getPrimaryKey();
229 
230         if (getPrimaryKey() == pk) {
231             return true;
232         }
233         else {
234             return false;
235         }
236     }
237 
238     public int hashCode() {
239         return (int)getPrimaryKey();
240     }
241 
242     private long _messageFlagId;
243     private long _userId;
244     private long _messageId;
245     private int _flag;
246 }