001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.search.Indexable;
033    import com.liferay.portal.kernel.search.IndexableType;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.model.PasswordTracker;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PasswordTrackerLocalService;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.persistence.PasswordPolicyFinder;
041    import com.liferay.portal.service.persistence.PasswordPolicyPersistence;
042    import com.liferay.portal.service.persistence.PasswordTrackerPersistence;
043    import com.liferay.portal.service.persistence.UserFinder;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.util.PortalUtil;
046    
047    import java.io.Serializable;
048    
049    import java.util.List;
050    
051    import javax.sql.DataSource;
052    
053    /**
054     * Provides the base implementation for the password tracker local service.
055     *
056     * <p>
057     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portal.service.impl.PasswordTrackerLocalServiceImpl}.
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see com.liferay.portal.service.impl.PasswordTrackerLocalServiceImpl
062     * @see com.liferay.portal.service.PasswordTrackerLocalServiceUtil
063     * @generated
064     */
065    @ProviderType
066    public abstract class PasswordTrackerLocalServiceBaseImpl
067            extends BaseLocalServiceImpl implements PasswordTrackerLocalService,
068                    IdentifiableBean {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.PasswordTrackerLocalServiceUtil} to access the password tracker local service.
073             */
074    
075            /**
076             * Adds the password tracker to the database. Also notifies the appropriate model listeners.
077             *
078             * @param passwordTracker the password tracker
079             * @return the password tracker that was added
080             */
081            @Indexable(type = IndexableType.REINDEX)
082            @Override
083            public PasswordTracker addPasswordTracker(PasswordTracker passwordTracker) {
084                    passwordTracker.setNew(true);
085    
086                    return passwordTrackerPersistence.update(passwordTracker);
087            }
088    
089            /**
090             * Creates a new password tracker with the primary key. Does not add the password tracker to the database.
091             *
092             * @param passwordTrackerId the primary key for the new password tracker
093             * @return the new password tracker
094             */
095            @Override
096            public PasswordTracker createPasswordTracker(long passwordTrackerId) {
097                    return passwordTrackerPersistence.create(passwordTrackerId);
098            }
099    
100            /**
101             * Deletes the password tracker with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param passwordTrackerId the primary key of the password tracker
104             * @return the password tracker that was removed
105             * @throws PortalException if a password tracker with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public PasswordTracker deletePasswordTracker(long passwordTrackerId)
110                    throws PortalException {
111                    return passwordTrackerPersistence.remove(passwordTrackerId);
112            }
113    
114            /**
115             * Deletes the password tracker from the database. Also notifies the appropriate model listeners.
116             *
117             * @param passwordTracker the password tracker
118             * @return the password tracker that was removed
119             */
120            @Indexable(type = IndexableType.DELETE)
121            @Override
122            public PasswordTracker deletePasswordTracker(
123                    PasswordTracker passwordTracker) {
124                    return passwordTrackerPersistence.remove(passwordTracker);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(PasswordTracker.class,
132                            clazz.getClassLoader());
133            }
134    
135            /**
136             * Performs a dynamic query on the database and returns the matching rows.
137             *
138             * @param dynamicQuery the dynamic query
139             * @return the matching rows
140             */
141            @Override
142            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
143                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery);
144            }
145    
146            /**
147             * Performs a dynamic query on the database and returns a range of the matching rows.
148             *
149             * <p>
150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.PasswordTrackerModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
151             * </p>
152             *
153             * @param dynamicQuery the dynamic query
154             * @param start the lower bound of the range of model instances
155             * @param end the upper bound of the range of model instances (not inclusive)
156             * @return the range of matching rows
157             */
158            @Override
159            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
160                    int end) {
161                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery,
162                            start, end);
163            }
164    
165            /**
166             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
167             *
168             * <p>
169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.PasswordTrackerModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
170             * </p>
171             *
172             * @param dynamicQuery the dynamic query
173             * @param start the lower bound of the range of model instances
174             * @param end the upper bound of the range of model instances (not inclusive)
175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
176             * @return the ordered range of matching rows
177             */
178            @Override
179            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
180                    int end, OrderByComparator<T> orderByComparator) {
181                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery,
182                            start, end, orderByComparator);
183            }
184    
185            /**
186             * Returns the number of rows matching the dynamic query.
187             *
188             * @param dynamicQuery the dynamic query
189             * @return the number of rows matching the dynamic query
190             */
191            @Override
192            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
193                    return passwordTrackerPersistence.countWithDynamicQuery(dynamicQuery);
194            }
195    
196            /**
197             * Returns the number of rows matching the dynamic query.
198             *
199             * @param dynamicQuery the dynamic query
200             * @param projection the projection to apply to the query
201             * @return the number of rows matching the dynamic query
202             */
203            @Override
204            public long dynamicQueryCount(DynamicQuery dynamicQuery,
205                    Projection projection) {
206                    return passwordTrackerPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public PasswordTracker fetchPasswordTracker(long passwordTrackerId) {
212                    return passwordTrackerPersistence.fetchByPrimaryKey(passwordTrackerId);
213            }
214    
215            /**
216             * Returns the password tracker with the primary key.
217             *
218             * @param passwordTrackerId the primary key of the password tracker
219             * @return the password tracker
220             * @throws PortalException if a password tracker with the primary key could not be found
221             */
222            @Override
223            public PasswordTracker getPasswordTracker(long passwordTrackerId)
224                    throws PortalException {
225                    return passwordTrackerPersistence.findByPrimaryKey(passwordTrackerId);
226            }
227    
228            @Override
229            public ActionableDynamicQuery getActionableDynamicQuery() {
230                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
231    
232                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PasswordTrackerLocalServiceUtil.getService());
233                    actionableDynamicQuery.setClass(PasswordTracker.class);
234                    actionableDynamicQuery.setClassLoader(getClassLoader());
235    
236                    actionableDynamicQuery.setPrimaryKeyPropertyName("passwordTrackerId");
237    
238                    return actionableDynamicQuery;
239            }
240    
241            protected void initActionableDynamicQuery(
242                    ActionableDynamicQuery actionableDynamicQuery) {
243                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PasswordTrackerLocalServiceUtil.getService());
244                    actionableDynamicQuery.setClass(PasswordTracker.class);
245                    actionableDynamicQuery.setClassLoader(getClassLoader());
246    
247                    actionableDynamicQuery.setPrimaryKeyPropertyName("passwordTrackerId");
248            }
249    
250            /**
251             * @throws PortalException
252             */
253            @Override
254            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
255                    throws PortalException {
256                    return passwordTrackerLocalService.deletePasswordTracker((PasswordTracker)persistedModel);
257            }
258    
259            @Override
260            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
261                    throws PortalException {
262                    return passwordTrackerPersistence.findByPrimaryKey(primaryKeyObj);
263            }
264    
265            /**
266             * Returns a range of all the password trackers.
267             *
268             * <p>
269             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.PasswordTrackerModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
270             * </p>
271             *
272             * @param start the lower bound of the range of password trackers
273             * @param end the upper bound of the range of password trackers (not inclusive)
274             * @return the range of password trackers
275             */
276            @Override
277            public List<PasswordTracker> getPasswordTrackers(int start, int end) {
278                    return passwordTrackerPersistence.findAll(start, end);
279            }
280    
281            /**
282             * Returns the number of password trackers.
283             *
284             * @return the number of password trackers
285             */
286            @Override
287            public int getPasswordTrackersCount() {
288                    return passwordTrackerPersistence.countAll();
289            }
290    
291            /**
292             * Updates the password tracker in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
293             *
294             * @param passwordTracker the password tracker
295             * @return the password tracker that was updated
296             */
297            @Indexable(type = IndexableType.REINDEX)
298            @Override
299            public PasswordTracker updatePasswordTracker(
300                    PasswordTracker passwordTracker) {
301                    return passwordTrackerPersistence.update(passwordTracker);
302            }
303    
304            /**
305             * Returns the password tracker local service.
306             *
307             * @return the password tracker local service
308             */
309            public PasswordTrackerLocalService getPasswordTrackerLocalService() {
310                    return passwordTrackerLocalService;
311            }
312    
313            /**
314             * Sets the password tracker local service.
315             *
316             * @param passwordTrackerLocalService the password tracker local service
317             */
318            public void setPasswordTrackerLocalService(
319                    PasswordTrackerLocalService passwordTrackerLocalService) {
320                    this.passwordTrackerLocalService = passwordTrackerLocalService;
321            }
322    
323            /**
324             * Returns the password tracker persistence.
325             *
326             * @return the password tracker persistence
327             */
328            public PasswordTrackerPersistence getPasswordTrackerPersistence() {
329                    return passwordTrackerPersistence;
330            }
331    
332            /**
333             * Sets the password tracker persistence.
334             *
335             * @param passwordTrackerPersistence the password tracker persistence
336             */
337            public void setPasswordTrackerPersistence(
338                    PasswordTrackerPersistence passwordTrackerPersistence) {
339                    this.passwordTrackerPersistence = passwordTrackerPersistence;
340            }
341    
342            /**
343             * Returns the counter local service.
344             *
345             * @return the counter local service
346             */
347            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
348                    return counterLocalService;
349            }
350    
351            /**
352             * Sets the counter local service.
353             *
354             * @param counterLocalService the counter local service
355             */
356            public void setCounterLocalService(
357                    com.liferay.counter.service.CounterLocalService counterLocalService) {
358                    this.counterLocalService = counterLocalService;
359            }
360    
361            /**
362             * Returns the password policy local service.
363             *
364             * @return the password policy local service
365             */
366            public com.liferay.portal.service.PasswordPolicyLocalService getPasswordPolicyLocalService() {
367                    return passwordPolicyLocalService;
368            }
369    
370            /**
371             * Sets the password policy local service.
372             *
373             * @param passwordPolicyLocalService the password policy local service
374             */
375            public void setPasswordPolicyLocalService(
376                    com.liferay.portal.service.PasswordPolicyLocalService passwordPolicyLocalService) {
377                    this.passwordPolicyLocalService = passwordPolicyLocalService;
378            }
379    
380            /**
381             * Returns the password policy remote service.
382             *
383             * @return the password policy remote service
384             */
385            public com.liferay.portal.service.PasswordPolicyService getPasswordPolicyService() {
386                    return passwordPolicyService;
387            }
388    
389            /**
390             * Sets the password policy remote service.
391             *
392             * @param passwordPolicyService the password policy remote service
393             */
394            public void setPasswordPolicyService(
395                    com.liferay.portal.service.PasswordPolicyService passwordPolicyService) {
396                    this.passwordPolicyService = passwordPolicyService;
397            }
398    
399            /**
400             * Returns the password policy persistence.
401             *
402             * @return the password policy persistence
403             */
404            public PasswordPolicyPersistence getPasswordPolicyPersistence() {
405                    return passwordPolicyPersistence;
406            }
407    
408            /**
409             * Sets the password policy persistence.
410             *
411             * @param passwordPolicyPersistence the password policy persistence
412             */
413            public void setPasswordPolicyPersistence(
414                    PasswordPolicyPersistence passwordPolicyPersistence) {
415                    this.passwordPolicyPersistence = passwordPolicyPersistence;
416            }
417    
418            /**
419             * Returns the password policy finder.
420             *
421             * @return the password policy finder
422             */
423            public PasswordPolicyFinder getPasswordPolicyFinder() {
424                    return passwordPolicyFinder;
425            }
426    
427            /**
428             * Sets the password policy finder.
429             *
430             * @param passwordPolicyFinder the password policy finder
431             */
432            public void setPasswordPolicyFinder(
433                    PasswordPolicyFinder passwordPolicyFinder) {
434                    this.passwordPolicyFinder = passwordPolicyFinder;
435            }
436    
437            /**
438             * Returns the user local service.
439             *
440             * @return the user local service
441             */
442            public com.liferay.portal.service.UserLocalService getUserLocalService() {
443                    return userLocalService;
444            }
445    
446            /**
447             * Sets the user local service.
448             *
449             * @param userLocalService the user local service
450             */
451            public void setUserLocalService(
452                    com.liferay.portal.service.UserLocalService userLocalService) {
453                    this.userLocalService = userLocalService;
454            }
455    
456            /**
457             * Returns the user remote service.
458             *
459             * @return the user remote service
460             */
461            public com.liferay.portal.service.UserService getUserService() {
462                    return userService;
463            }
464    
465            /**
466             * Sets the user remote service.
467             *
468             * @param userService the user remote service
469             */
470            public void setUserService(
471                    com.liferay.portal.service.UserService userService) {
472                    this.userService = userService;
473            }
474    
475            /**
476             * Returns the user persistence.
477             *
478             * @return the user persistence
479             */
480            public UserPersistence getUserPersistence() {
481                    return userPersistence;
482            }
483    
484            /**
485             * Sets the user persistence.
486             *
487             * @param userPersistence the user persistence
488             */
489            public void setUserPersistence(UserPersistence userPersistence) {
490                    this.userPersistence = userPersistence;
491            }
492    
493            /**
494             * Returns the user finder.
495             *
496             * @return the user finder
497             */
498            public UserFinder getUserFinder() {
499                    return userFinder;
500            }
501    
502            /**
503             * Sets the user finder.
504             *
505             * @param userFinder the user finder
506             */
507            public void setUserFinder(UserFinder userFinder) {
508                    this.userFinder = userFinder;
509            }
510    
511            public void afterPropertiesSet() {
512                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.PasswordTracker",
513                            passwordTrackerLocalService);
514            }
515    
516            public void destroy() {
517                    persistedModelLocalServiceRegistry.unregister(
518                            "com.liferay.portal.model.PasswordTracker");
519            }
520    
521            /**
522             * Returns the Spring bean ID for this bean.
523             *
524             * @return the Spring bean ID for this bean
525             */
526            @Override
527            public String getBeanIdentifier() {
528                    return _beanIdentifier;
529            }
530    
531            /**
532             * Sets the Spring bean ID for this bean.
533             *
534             * @param beanIdentifier the Spring bean ID for this bean
535             */
536            @Override
537            public void setBeanIdentifier(String beanIdentifier) {
538                    _beanIdentifier = beanIdentifier;
539            }
540    
541            protected Class<?> getModelClass() {
542                    return PasswordTracker.class;
543            }
544    
545            protected String getModelClassName() {
546                    return PasswordTracker.class.getName();
547            }
548    
549            /**
550             * Performs a SQL query.
551             *
552             * @param sql the sql query
553             */
554            protected void runSQL(String sql) {
555                    try {
556                            DataSource dataSource = passwordTrackerPersistence.getDataSource();
557    
558                            DB db = DBFactoryUtil.getDB();
559    
560                            sql = db.buildSQL(sql);
561                            sql = PortalUtil.transformSQL(sql);
562    
563                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
564                                            sql, new int[0]);
565    
566                            sqlUpdate.update();
567                    }
568                    catch (Exception e) {
569                            throw new SystemException(e);
570                    }
571            }
572    
573            @BeanReference(type = PasswordTrackerLocalService.class)
574            protected PasswordTrackerLocalService passwordTrackerLocalService;
575            @BeanReference(type = PasswordTrackerPersistence.class)
576            protected PasswordTrackerPersistence passwordTrackerPersistence;
577            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
578            protected com.liferay.counter.service.CounterLocalService counterLocalService;
579            @BeanReference(type = com.liferay.portal.service.PasswordPolicyLocalService.class)
580            protected com.liferay.portal.service.PasswordPolicyLocalService passwordPolicyLocalService;
581            @BeanReference(type = com.liferay.portal.service.PasswordPolicyService.class)
582            protected com.liferay.portal.service.PasswordPolicyService passwordPolicyService;
583            @BeanReference(type = PasswordPolicyPersistence.class)
584            protected PasswordPolicyPersistence passwordPolicyPersistence;
585            @BeanReference(type = PasswordPolicyFinder.class)
586            protected PasswordPolicyFinder passwordPolicyFinder;
587            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
588            protected com.liferay.portal.service.UserLocalService userLocalService;
589            @BeanReference(type = com.liferay.portal.service.UserService.class)
590            protected com.liferay.portal.service.UserService userService;
591            @BeanReference(type = UserPersistence.class)
592            protected UserPersistence userPersistence;
593            @BeanReference(type = UserFinder.class)
594            protected UserFinder userFinder;
595            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
596            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
597            private String _beanIdentifier;
598    }