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