1   /**
2    * Copyright (c) 2000-2008 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  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.messageboards.model.MBMessageFlag;
31  import com.liferay.portlet.messageboards.model.MBMessageFlagSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="MBMessageFlagModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>MBMessageFlag</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlag
58   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlagModel
59   * @see com.liferay.portlet.messageboards.service.model.impl.MBMessageFlagImpl
60   *
61   */
62  public class MBMessageFlagModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "MBMessageFlag";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "messageFlagId", new Integer(Types.BIGINT) },
66              
67  
68              { "userId", new Integer(Types.BIGINT) },
69              
70  
71              { "messageId", new Integer(Types.BIGINT) },
72              
73  
74              { "flag", new Integer(Types.INTEGER) }
75          };
76      public static final String TABLE_SQL_CREATE = "create table MBMessageFlag (messageFlagId LONG not null primary key,userId LONG,messageId LONG,flag INTEGER)";
77      public static final String TABLE_SQL_DROP = "drop table MBMessageFlag";
78      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessageFlag"),
80              true);
81  
82      public static MBMessageFlag toModel(MBMessageFlagSoap soapModel) {
83          MBMessageFlag model = new MBMessageFlagImpl();
84  
85          model.setMessageFlagId(soapModel.getMessageFlagId());
86          model.setUserId(soapModel.getUserId());
87          model.setMessageId(soapModel.getMessageId());
88          model.setFlag(soapModel.getFlag());
89  
90          return model;
91      }
92  
93      public static List<MBMessageFlag> toModels(MBMessageFlagSoap[] soapModels) {
94          List<MBMessageFlag> models = new ArrayList<MBMessageFlag>(soapModels.length);
95  
96          for (MBMessageFlagSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessageFlag"));
105 
106     public MBMessageFlagModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _messageFlagId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setMessageFlagId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_messageFlagId);
119     }
120 
121     public long getMessageFlagId() {
122         return _messageFlagId;
123     }
124 
125     public void setMessageFlagId(long messageFlagId) {
126         if (messageFlagId != _messageFlagId) {
127             _messageFlagId = messageFlagId;
128         }
129     }
130 
131     public long getUserId() {
132         return _userId;
133     }
134 
135     public void setUserId(long userId) {
136         if (userId != _userId) {
137             _userId = userId;
138         }
139     }
140 
141     public long getMessageId() {
142         return _messageId;
143     }
144 
145     public void setMessageId(long messageId) {
146         if (messageId != _messageId) {
147             _messageId = messageId;
148         }
149     }
150 
151     public int getFlag() {
152         return _flag;
153     }
154 
155     public void setFlag(int flag) {
156         if (flag != _flag) {
157             _flag = flag;
158         }
159     }
160 
161     public MBMessageFlag toEscapedModel() {
162         if (isEscapedModel()) {
163             return (MBMessageFlag)this;
164         }
165         else {
166             MBMessageFlag model = new MBMessageFlagImpl();
167 
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 }