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.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.PasswordPolicy;
29  import com.liferay.portal.model.PasswordPolicySoap;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="PasswordPolicyModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>PasswordPolicy</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.model.PasswordPolicy
60   * @see com.liferay.portal.model.PasswordPolicyModel
61   * @see com.liferay.portal.model.impl.PasswordPolicyImpl
62   *
63   */
64  public class PasswordPolicyModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "PasswordPolicy";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "passwordPolicyId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "defaultPolicy", new Integer(Types.BOOLEAN) },
86              
87  
88              { "name", new Integer(Types.VARCHAR) },
89              
90  
91              { "description", new Integer(Types.VARCHAR) },
92              
93  
94              { "changeable", new Integer(Types.BOOLEAN) },
95              
96  
97              { "changeRequired", new Integer(Types.BOOLEAN) },
98              
99  
100             { "minAge", new Integer(Types.BIGINT) },
101             
102 
103             { "checkSyntax", new Integer(Types.BOOLEAN) },
104             
105 
106             { "allowDictionaryWords", new Integer(Types.BOOLEAN) },
107             
108 
109             { "minLength", new Integer(Types.INTEGER) },
110             
111 
112             { "history", new Integer(Types.BOOLEAN) },
113             
114 
115             { "historyCount", new Integer(Types.INTEGER) },
116             
117 
118             { "expireable", new Integer(Types.BOOLEAN) },
119             
120 
121             { "maxAge", new Integer(Types.BIGINT) },
122             
123 
124             { "warningTime", new Integer(Types.BIGINT) },
125             
126 
127             { "graceLimit", new Integer(Types.INTEGER) },
128             
129 
130             { "lockout", new Integer(Types.BOOLEAN) },
131             
132 
133             { "maxFailure", new Integer(Types.INTEGER) },
134             
135 
136             { "lockoutDuration", new Integer(Types.BIGINT) },
137             
138 
139             { "requireUnlock", new Integer(Types.BOOLEAN) },
140             
141 
142             { "resetFailureCount", new Integer(Types.BIGINT) }
143         };
144     public static final String TABLE_SQL_CREATE = "create table PasswordPolicy (passwordPolicyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,defaultPolicy BOOLEAN,name VARCHAR(75) null,description STRING null,changeable BOOLEAN,changeRequired BOOLEAN,minAge LONG,checkSyntax BOOLEAN,allowDictionaryWords BOOLEAN,minLength INTEGER,history BOOLEAN,historyCount INTEGER,expireable BOOLEAN,maxAge LONG,warningTime LONG,graceLimit INTEGER,lockout BOOLEAN,maxFailure INTEGER,lockoutDuration LONG,requireUnlock BOOLEAN,resetFailureCount LONG)";
145     public static final String TABLE_SQL_DROP = "drop table PasswordPolicy";
146     public static final String DATA_SOURCE = "liferayDataSource";
147     public static final String SESSION_FACTORY = "liferaySessionFactory";
148     public static final String TX_MANAGER = "liferayTransactionManager";
149     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
150                 "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordPolicy"),
151             true);
152 
153     public static PasswordPolicy toModel(PasswordPolicySoap soapModel) {
154         PasswordPolicy model = new PasswordPolicyImpl();
155 
156         model.setPasswordPolicyId(soapModel.getPasswordPolicyId());
157         model.setCompanyId(soapModel.getCompanyId());
158         model.setUserId(soapModel.getUserId());
159         model.setUserName(soapModel.getUserName());
160         model.setCreateDate(soapModel.getCreateDate());
161         model.setModifiedDate(soapModel.getModifiedDate());
162         model.setDefaultPolicy(soapModel.getDefaultPolicy());
163         model.setName(soapModel.getName());
164         model.setDescription(soapModel.getDescription());
165         model.setChangeable(soapModel.getChangeable());
166         model.setChangeRequired(soapModel.getChangeRequired());
167         model.setMinAge(soapModel.getMinAge());
168         model.setCheckSyntax(soapModel.getCheckSyntax());
169         model.setAllowDictionaryWords(soapModel.getAllowDictionaryWords());
170         model.setMinLength(soapModel.getMinLength());
171         model.setHistory(soapModel.getHistory());
172         model.setHistoryCount(soapModel.getHistoryCount());
173         model.setExpireable(soapModel.getExpireable());
174         model.setMaxAge(soapModel.getMaxAge());
175         model.setWarningTime(soapModel.getWarningTime());
176         model.setGraceLimit(soapModel.getGraceLimit());
177         model.setLockout(soapModel.getLockout());
178         model.setMaxFailure(soapModel.getMaxFailure());
179         model.setLockoutDuration(soapModel.getLockoutDuration());
180         model.setRequireUnlock(soapModel.getRequireUnlock());
181         model.setResetFailureCount(soapModel.getResetFailureCount());
182 
183         return model;
184     }
185 
186     public static List<PasswordPolicy> toModels(PasswordPolicySoap[] soapModels) {
187         List<PasswordPolicy> models = new ArrayList<PasswordPolicy>(soapModels.length);
188 
189         for (PasswordPolicySoap soapModel : soapModels) {
190             models.add(toModel(soapModel));
191         }
192 
193         return models;
194     }
195 
196     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
197                 "lock.expiration.time.com.liferay.portal.model.PasswordPolicy"));
198 
199     public PasswordPolicyModelImpl() {
200     }
201 
202     public long getPrimaryKey() {
203         return _passwordPolicyId;
204     }
205 
206     public void setPrimaryKey(long pk) {
207         setPasswordPolicyId(pk);
208     }
209 
210     public Serializable getPrimaryKeyObj() {
211         return new Long(_passwordPolicyId);
212     }
213 
214     public long getPasswordPolicyId() {
215         return _passwordPolicyId;
216     }
217 
218     public void setPasswordPolicyId(long passwordPolicyId) {
219         if (passwordPolicyId != _passwordPolicyId) {
220             _passwordPolicyId = passwordPolicyId;
221         }
222     }
223 
224     public long getCompanyId() {
225         return _companyId;
226     }
227 
228     public void setCompanyId(long companyId) {
229         if (companyId != _companyId) {
230             _companyId = companyId;
231         }
232     }
233 
234     public long getUserId() {
235         return _userId;
236     }
237 
238     public void setUserId(long userId) {
239         if (userId != _userId) {
240             _userId = userId;
241         }
242     }
243 
244     public String getUserName() {
245         return GetterUtil.getString(_userName);
246     }
247 
248     public void setUserName(String userName) {
249         if (((userName == null) && (_userName != null)) ||
250                 ((userName != null) && (_userName == null)) ||
251                 ((userName != null) && (_userName != null) &&
252                 !userName.equals(_userName))) {
253             _userName = userName;
254         }
255     }
256 
257     public Date getCreateDate() {
258         return _createDate;
259     }
260 
261     public void setCreateDate(Date createDate) {
262         if (((createDate == null) && (_createDate != null)) ||
263                 ((createDate != null) && (_createDate == null)) ||
264                 ((createDate != null) && (_createDate != null) &&
265                 !createDate.equals(_createDate))) {
266             _createDate = createDate;
267         }
268     }
269 
270     public Date getModifiedDate() {
271         return _modifiedDate;
272     }
273 
274     public void setModifiedDate(Date modifiedDate) {
275         if (((modifiedDate == null) && (_modifiedDate != null)) ||
276                 ((modifiedDate != null) && (_modifiedDate == null)) ||
277                 ((modifiedDate != null) && (_modifiedDate != null) &&
278                 !modifiedDate.equals(_modifiedDate))) {
279             _modifiedDate = modifiedDate;
280         }
281     }
282 
283     public boolean getDefaultPolicy() {
284         return _defaultPolicy;
285     }
286 
287     public boolean isDefaultPolicy() {
288         return _defaultPolicy;
289     }
290 
291     public void setDefaultPolicy(boolean defaultPolicy) {
292         if (defaultPolicy != _defaultPolicy) {
293             _defaultPolicy = defaultPolicy;
294         }
295     }
296 
297     public String getName() {
298         return GetterUtil.getString(_name);
299     }
300 
301     public void setName(String name) {
302         if (((name == null) && (_name != null)) ||
303                 ((name != null) && (_name == null)) ||
304                 ((name != null) && (_name != null) && !name.equals(_name))) {
305             _name = name;
306         }
307     }
308 
309     public String getDescription() {
310         return GetterUtil.getString(_description);
311     }
312 
313     public void setDescription(String description) {
314         if (((description == null) && (_description != null)) ||
315                 ((description != null) && (_description == null)) ||
316                 ((description != null) && (_description != null) &&
317                 !description.equals(_description))) {
318             _description = description;
319         }
320     }
321 
322     public boolean getChangeable() {
323         return _changeable;
324     }
325 
326     public boolean isChangeable() {
327         return _changeable;
328     }
329 
330     public void setChangeable(boolean changeable) {
331         if (changeable != _changeable) {
332             _changeable = changeable;
333         }
334     }
335 
336     public boolean getChangeRequired() {
337         return _changeRequired;
338     }
339 
340     public boolean isChangeRequired() {
341         return _changeRequired;
342     }
343 
344     public void setChangeRequired(boolean changeRequired) {
345         if (changeRequired != _changeRequired) {
346             _changeRequired = changeRequired;
347         }
348     }
349 
350     public long getMinAge() {
351         return _minAge;
352     }
353 
354     public void setMinAge(long minAge) {
355         if (minAge != _minAge) {
356             _minAge = minAge;
357         }
358     }
359 
360     public boolean getCheckSyntax() {
361         return _checkSyntax;
362     }
363 
364     public boolean isCheckSyntax() {
365         return _checkSyntax;
366     }
367 
368     public void setCheckSyntax(boolean checkSyntax) {
369         if (checkSyntax != _checkSyntax) {
370             _checkSyntax = checkSyntax;
371         }
372     }
373 
374     public boolean getAllowDictionaryWords() {
375         return _allowDictionaryWords;
376     }
377 
378     public boolean isAllowDictionaryWords() {
379         return _allowDictionaryWords;
380     }
381 
382     public void setAllowDictionaryWords(boolean allowDictionaryWords) {
383         if (allowDictionaryWords != _allowDictionaryWords) {
384             _allowDictionaryWords = allowDictionaryWords;
385         }
386     }
387 
388     public int getMinLength() {
389         return _minLength;
390     }
391 
392     public void setMinLength(int minLength) {
393         if (minLength != _minLength) {
394             _minLength = minLength;
395         }
396     }
397 
398     public boolean getHistory() {
399         return _history;
400     }
401 
402     public boolean isHistory() {
403         return _history;
404     }
405 
406     public void setHistory(boolean history) {
407         if (history != _history) {
408             _history = history;
409         }
410     }
411 
412     public int getHistoryCount() {
413         return _historyCount;
414     }
415 
416     public void setHistoryCount(int historyCount) {
417         if (historyCount != _historyCount) {
418             _historyCount = historyCount;
419         }
420     }
421 
422     public boolean getExpireable() {
423         return _expireable;
424     }
425 
426     public boolean isExpireable() {
427         return _expireable;
428     }
429 
430     public void setExpireable(boolean expireable) {
431         if (expireable != _expireable) {
432             _expireable = expireable;
433         }
434     }
435 
436     public long getMaxAge() {
437         return _maxAge;
438     }
439 
440     public void setMaxAge(long maxAge) {
441         if (maxAge != _maxAge) {
442             _maxAge = maxAge;
443         }
444     }
445 
446     public long getWarningTime() {
447         return _warningTime;
448     }
449 
450     public void setWarningTime(long warningTime) {
451         if (warningTime != _warningTime) {
452             _warningTime = warningTime;
453         }
454     }
455 
456     public int getGraceLimit() {
457         return _graceLimit;
458     }
459 
460     public void setGraceLimit(int graceLimit) {
461         if (graceLimit != _graceLimit) {
462             _graceLimit = graceLimit;
463         }
464     }
465 
466     public boolean getLockout() {
467         return _lockout;
468     }
469 
470     public boolean isLockout() {
471         return _lockout;
472     }
473 
474     public void setLockout(boolean lockout) {
475         if (lockout != _lockout) {
476             _lockout = lockout;
477         }
478     }
479 
480     public int getMaxFailure() {
481         return _maxFailure;
482     }
483 
484     public void setMaxFailure(int maxFailure) {
485         if (maxFailure != _maxFailure) {
486             _maxFailure = maxFailure;
487         }
488     }
489 
490     public long getLockoutDuration() {
491         return _lockoutDuration;
492     }
493 
494     public void setLockoutDuration(long lockoutDuration) {
495         if (lockoutDuration != _lockoutDuration) {
496             _lockoutDuration = lockoutDuration;
497         }
498     }
499 
500     public boolean getRequireUnlock() {
501         return _requireUnlock;
502     }
503 
504     public boolean isRequireUnlock() {
505         return _requireUnlock;
506     }
507 
508     public void setRequireUnlock(boolean requireUnlock) {
509         if (requireUnlock != _requireUnlock) {
510             _requireUnlock = requireUnlock;
511         }
512     }
513 
514     public long getResetFailureCount() {
515         return _resetFailureCount;
516     }
517 
518     public void setResetFailureCount(long resetFailureCount) {
519         if (resetFailureCount != _resetFailureCount) {
520             _resetFailureCount = resetFailureCount;
521         }
522     }
523 
524     public PasswordPolicy toEscapedModel() {
525         if (isEscapedModel()) {
526             return (PasswordPolicy)this;
527         }
528         else {
529             PasswordPolicy model = new PasswordPolicyImpl();
530 
531             model.setNew(isNew());
532             model.setEscapedModel(true);
533 
534             model.setPasswordPolicyId(getPasswordPolicyId());
535             model.setCompanyId(getCompanyId());
536             model.setUserId(getUserId());
537             model.setUserName(HtmlUtil.escape(getUserName()));
538             model.setCreateDate(getCreateDate());
539             model.setModifiedDate(getModifiedDate());
540             model.setDefaultPolicy(getDefaultPolicy());
541             model.setName(HtmlUtil.escape(getName()));
542             model.setDescription(HtmlUtil.escape(getDescription()));
543             model.setChangeable(getChangeable());
544             model.setChangeRequired(getChangeRequired());
545             model.setMinAge(getMinAge());
546             model.setCheckSyntax(getCheckSyntax());
547             model.setAllowDictionaryWords(getAllowDictionaryWords());
548             model.setMinLength(getMinLength());
549             model.setHistory(getHistory());
550             model.setHistoryCount(getHistoryCount());
551             model.setExpireable(getExpireable());
552             model.setMaxAge(getMaxAge());
553             model.setWarningTime(getWarningTime());
554             model.setGraceLimit(getGraceLimit());
555             model.setLockout(getLockout());
556             model.setMaxFailure(getMaxFailure());
557             model.setLockoutDuration(getLockoutDuration());
558             model.setRequireUnlock(getRequireUnlock());
559             model.setResetFailureCount(getResetFailureCount());
560 
561             model = (PasswordPolicy)Proxy.newProxyInstance(PasswordPolicy.class.getClassLoader(),
562                     new Class[] { PasswordPolicy.class },
563                     new ReadOnlyBeanHandler(model));
564 
565             return model;
566         }
567     }
568 
569     public ExpandoBridge getExpandoBridge() {
570         if (_expandoBridge == null) {
571             _expandoBridge = new ExpandoBridgeImpl(PasswordPolicy.class.getName(),
572                     getPrimaryKey());
573         }
574 
575         return _expandoBridge;
576     }
577 
578     public Object clone() {
579         PasswordPolicyImpl clone = new PasswordPolicyImpl();
580 
581         clone.setPasswordPolicyId(getPasswordPolicyId());
582         clone.setCompanyId(getCompanyId());
583         clone.setUserId(getUserId());
584         clone.setUserName(getUserName());
585         clone.setCreateDate(getCreateDate());
586         clone.setModifiedDate(getModifiedDate());
587         clone.setDefaultPolicy(getDefaultPolicy());
588         clone.setName(getName());
589         clone.setDescription(getDescription());
590         clone.setChangeable(getChangeable());
591         clone.setChangeRequired(getChangeRequired());
592         clone.setMinAge(getMinAge());
593         clone.setCheckSyntax(getCheckSyntax());
594         clone.setAllowDictionaryWords(getAllowDictionaryWords());
595         clone.setMinLength(getMinLength());
596         clone.setHistory(getHistory());
597         clone.setHistoryCount(getHistoryCount());
598         clone.setExpireable(getExpireable());
599         clone.setMaxAge(getMaxAge());
600         clone.setWarningTime(getWarningTime());
601         clone.setGraceLimit(getGraceLimit());
602         clone.setLockout(getLockout());
603         clone.setMaxFailure(getMaxFailure());
604         clone.setLockoutDuration(getLockoutDuration());
605         clone.setRequireUnlock(getRequireUnlock());
606         clone.setResetFailureCount(getResetFailureCount());
607 
608         return clone;
609     }
610 
611     public int compareTo(Object obj) {
612         if (obj == null) {
613             return -1;
614         }
615 
616         PasswordPolicyImpl passwordPolicy = (PasswordPolicyImpl)obj;
617 
618         long pk = passwordPolicy.getPrimaryKey();
619 
620         if (getPrimaryKey() < pk) {
621             return -1;
622         }
623         else if (getPrimaryKey() > pk) {
624             return 1;
625         }
626         else {
627             return 0;
628         }
629     }
630 
631     public boolean equals(Object obj) {
632         if (obj == null) {
633             return false;
634         }
635 
636         PasswordPolicyImpl passwordPolicy = null;
637 
638         try {
639             passwordPolicy = (PasswordPolicyImpl)obj;
640         }
641         catch (ClassCastException cce) {
642             return false;
643         }
644 
645         long pk = passwordPolicy.getPrimaryKey();
646 
647         if (getPrimaryKey() == pk) {
648             return true;
649         }
650         else {
651             return false;
652         }
653     }
654 
655     public int hashCode() {
656         return (int)getPrimaryKey();
657     }
658 
659     private long _passwordPolicyId;
660     private long _companyId;
661     private long _userId;
662     private String _userName;
663     private Date _createDate;
664     private Date _modifiedDate;
665     private boolean _defaultPolicy;
666     private String _name;
667     private String _description;
668     private boolean _changeable;
669     private boolean _changeRequired;
670     private long _minAge;
671     private boolean _checkSyntax;
672     private boolean _allowDictionaryWords;
673     private int _minLength;
674     private boolean _history;
675     private int _historyCount;
676     private boolean _expireable;
677     private long _maxAge;
678     private long _warningTime;
679     private int _graceLimit;
680     private boolean _lockout;
681     private int _maxFailure;
682     private long _lockoutDuration;
683     private boolean _requireUnlock;
684     private long _resetFailureCount;
685     private transient ExpandoBridge _expandoBridge;
686 }