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  
29  import com.liferay.portlet.messageboards.model.MBMessageFlag;
30  import com.liferay.portlet.messageboards.model.MBMessageFlagSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="MBMessageFlagModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>MBMessageFlag</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlag
57   * @see com.liferay.portlet.messageboards.service.model.MBMessageFlagModel
58   * @see com.liferay.portlet.messageboards.service.model.impl.MBMessageFlagImpl
59   *
60   */
61  public class MBMessageFlagModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "MBMessageFlag";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "messageFlagId", new Integer(Types.BIGINT) },
65              
66  
67              { "userId", new Integer(Types.BIGINT) },
68              
69  
70              { "messageId", new Integer(Types.BIGINT) },
71              
72  
73              { "flag", new Integer(Types.INTEGER) }
74          };
75      public static final String TABLE_SQL_CREATE = "create table MBMessageFlag (messageFlagId LONG not null primary key,userId LONG,messageId LONG,flag INTEGER)";
76      public static final String TABLE_SQL_DROP = "drop table MBMessageFlag";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessageFlag"),
82              true);
83  
84      public static MBMessageFlag toModel(MBMessageFlagSoap soapModel) {
85          MBMessageFlag model = new MBMessageFlagImpl();
86  
87          model.setMessageFlagId(soapModel.getMessageFlagId());
88          model.setUserId(soapModel.getUserId());
89          model.setMessageId(soapModel.getMessageId());
90          model.setFlag(soapModel.getFlag());
91  
92          return model;
93      }
94  
95      public static List<MBMessageFlag> toModels(MBMessageFlagSoap[] soapModels) {
96          List<MBMessageFlag> models = new ArrayList<MBMessageFlag>(soapModels.length);
97  
98          for (MBMessageFlagSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessageFlag"));
107 
108     public MBMessageFlagModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _messageFlagId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setMessageFlagId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_messageFlagId);
121     }
122 
123     public long getMessageFlagId() {
124         return _messageFlagId;
125     }
126 
127     public void setMessageFlagId(long messageFlagId) {
128         if (messageFlagId != _messageFlagId) {
129             _messageFlagId = messageFlagId;
130         }
131     }
132 
133     public long getUserId() {
134         return _userId;
135     }
136 
137     public void setUserId(long userId) {
138         if (userId != _userId) {
139             _userId = userId;
140         }
141     }
142 
143     public long getMessageId() {
144         return _messageId;
145     }
146 
147     public void setMessageId(long messageId) {
148         if (messageId != _messageId) {
149             _messageId = messageId;
150         }
151     }
152 
153     public int getFlag() {
154         return _flag;
155     }
156 
157     public void setFlag(int flag) {
158         if (flag != _flag) {
159             _flag = flag;
160         }
161     }
162 
163     public MBMessageFlag toEscapedModel() {
164         if (isEscapedModel()) {
165             return (MBMessageFlag)this;
166         }
167         else {
168             MBMessageFlag model = new MBMessageFlagImpl();
169 
170             model.setEscapedModel(true);
171 
172             model.setMessageFlagId(getMessageFlagId());
173             model.setUserId(getUserId());
174             model.setMessageId(getMessageId());
175             model.setFlag(getFlag());
176 
177             model = (MBMessageFlag)Proxy.newProxyInstance(MBMessageFlag.class.getClassLoader(),
178                     new Class[] { MBMessageFlag.class },
179                     new ReadOnlyBeanHandler(model));
180 
181             return model;
182         }
183     }
184 
185     public Object clone() {
186         MBMessageFlagImpl clone = new MBMessageFlagImpl();
187 
188         clone.setMessageFlagId(getMessageFlagId());
189         clone.setUserId(getUserId());
190         clone.setMessageId(getMessageId());
191         clone.setFlag(getFlag());
192 
193         return clone;
194     }
195 
196     public int compareTo(Object obj) {
197         if (obj == null) {
198             return -1;
199         }
200 
201         MBMessageFlagImpl mbMessageFlag = (MBMessageFlagImpl)obj;
202 
203         long pk = mbMessageFlag.getPrimaryKey();
204 
205         if (getPrimaryKey() < pk) {
206             return -1;
207         }
208         else if (getPrimaryKey() > pk) {
209             return 1;
210         }
211         else {
212             return 0;
213         }
214     }
215 
216     public boolean equals(Object obj) {
217         if (obj == null) {
218             return false;
219         }
220 
221         MBMessageFlagImpl mbMessageFlag = null;
222 
223         try {
224             mbMessageFlag = (MBMessageFlagImpl)obj;
225         }
226         catch (ClassCastException cce) {
227             return false;
228         }
229 
230         long pk = mbMessageFlag.getPrimaryKey();
231 
232         if (getPrimaryKey() == pk) {
233             return true;
234         }
235         else {
236             return false;
237         }
238     }
239 
240     public int hashCode() {
241         return (int)getPrimaryKey();
242     }
243 
244     private long _messageFlagId;
245     private long _userId;
246     private long _messageId;
247     private int _flag;
248 }