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.dao.db.DB;
021    import com.liferay.portal.kernel.dao.db.DBManagerUtil;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
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.module.framework.service.IdentifiableOSGiService;
033    import com.liferay.portal.kernel.search.Indexable;
034    import com.liferay.portal.kernel.search.IndexableType;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.model.PasswordTracker;
037    import com.liferay.portal.model.PersistedModel;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PasswordTrackerLocalService;
040    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
041    import com.liferay.portal.service.persistence.PasswordPolicyFinder;
042    import com.liferay.portal.service.persistence.PasswordPolicyPersistence;
043    import com.liferay.portal.service.persistence.PasswordTrackerPersistence;
044    import com.liferay.portal.service.persistence.UserFinder;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.util.PortalUtil;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the password tracker local service.
056     *
057     * <p>
058     * 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}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portal.service.impl.PasswordTrackerLocalServiceImpl
063     * @see com.liferay.portal.service.PasswordTrackerLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class PasswordTrackerLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements PasswordTrackerLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.PasswordTrackerLocalServiceUtil} to access the password tracker local service.
074             */
075    
076            /**
077             * Adds the password tracker to the database. Also notifies the appropriate model listeners.
078             *
079             * @param passwordTracker the password tracker
080             * @return the password tracker that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public PasswordTracker addPasswordTracker(PasswordTracker passwordTracker) {
085                    passwordTracker.setNew(true);
086    
087                    return passwordTrackerPersistence.update(passwordTracker);
088            }
089    
090            /**
091             * Creates a new password tracker with the primary key. Does not add the password tracker to the database.
092             *
093             * @param passwordTrackerId the primary key for the new password tracker
094             * @return the new password tracker
095             */
096            @Override
097            public PasswordTracker createPasswordTracker(long passwordTrackerId) {
098                    return passwordTrackerPersistence.create(passwordTrackerId);
099            }
100    
101            /**
102             * Deletes the password tracker with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param passwordTrackerId the primary key of the password tracker
105             * @return the password tracker that was removed
106             * @throws PortalException if a password tracker with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public PasswordTracker deletePasswordTracker(long passwordTrackerId)
111                    throws PortalException {
112                    return passwordTrackerPersistence.remove(passwordTrackerId);
113            }
114    
115            /**
116             * Deletes the password tracker from the database. Also notifies the appropriate model listeners.
117             *
118             * @param passwordTracker the password tracker
119             * @return the password tracker that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public PasswordTracker deletePasswordTracker(
124                    PasswordTracker passwordTracker) {
125                    return passwordTrackerPersistence.remove(passwordTracker);
126            }
127    
128            @Override
129            public DynamicQuery dynamicQuery() {
130                    Class<?> clazz = getClass();
131    
132                    return DynamicQueryFactoryUtil.forClass(PasswordTracker.class,
133                            clazz.getClassLoader());
134            }
135    
136            /**
137             * Performs a dynamic query on the database and returns the matching rows.
138             *
139             * @param dynamicQuery the dynamic query
140             * @return the matching rows
141             */
142            @Override
143            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
144                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery);
145            }
146    
147            /**
148             * Performs a dynamic query on the database and returns a range of the matching rows.
149             *
150             * <p>
151             * 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.
152             * </p>
153             *
154             * @param dynamicQuery the dynamic query
155             * @param start the lower bound of the range of model instances
156             * @param end the upper bound of the range of model instances (not inclusive)
157             * @return the range of matching rows
158             */
159            @Override
160            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
161                    int end) {
162                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery,
163                            start, end);
164            }
165    
166            /**
167             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
168             *
169             * <p>
170             * 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.
171             * </p>
172             *
173             * @param dynamicQuery the dynamic query
174             * @param start the lower bound of the range of model instances
175             * @param end the upper bound of the range of model instances (not inclusive)
176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
177             * @return the ordered range of matching rows
178             */
179            @Override
180            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
181                    int end, OrderByComparator<T> orderByComparator) {
182                    return passwordTrackerPersistence.findWithDynamicQuery(dynamicQuery,
183                            start, end, orderByComparator);
184            }
185    
186            /**
187             * Returns the number of rows matching the dynamic query.
188             *
189             * @param dynamicQuery the dynamic query
190             * @return the number of rows matching the dynamic query
191             */
192            @Override
193            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
194                    return passwordTrackerPersistence.countWithDynamicQuery(dynamicQuery);
195            }
196    
197            /**
198             * Returns the number of rows matching the dynamic query.
199             *
200             * @param dynamicQuery the dynamic query
201             * @param projection the projection to apply to the query
202             * @return the number of rows matching the dynamic query
203             */
204            @Override
205            public long dynamicQueryCount(DynamicQuery dynamicQuery,
206                    Projection projection) {
207                    return passwordTrackerPersistence.countWithDynamicQuery(dynamicQuery,
208                            projection);
209            }
210    
211            @Override
212            public PasswordTracker fetchPasswordTracker(long passwordTrackerId) {
213                    return passwordTrackerPersistence.fetchByPrimaryKey(passwordTrackerId);
214            }
215    
216            /**
217             * Returns the password tracker with the primary key.
218             *
219             * @param passwordTrackerId the primary key of the password tracker
220             * @return the password tracker
221             * @throws PortalException if a password tracker with the primary key could not be found
222             */
223            @Override
224            public PasswordTracker getPasswordTracker(long passwordTrackerId)
225                    throws PortalException {
226                    return passwordTrackerPersistence.findByPrimaryKey(passwordTrackerId);
227            }
228    
229            @Override
230            public ActionableDynamicQuery getActionableDynamicQuery() {
231                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
232    
233                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PasswordTrackerLocalServiceUtil.getService());
234                    actionableDynamicQuery.setClassLoader(getClassLoader());
235                    actionableDynamicQuery.setModelClass(PasswordTracker.class);
236    
237                    actionableDynamicQuery.setPrimaryKeyPropertyName("passwordTrackerId");
238    
239                    return actionableDynamicQuery;
240            }
241    
242            @Override
243            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
244                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
245    
246                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PasswordTrackerLocalServiceUtil.getService());
247                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
248                    indexableActionableDynamicQuery.setModelClass(PasswordTracker.class);
249    
250                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
251                            "passwordTrackerId");
252    
253                    return indexableActionableDynamicQuery;
254            }
255    
256            protected void initActionableDynamicQuery(
257                    ActionableDynamicQuery actionableDynamicQuery) {
258                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.PasswordTrackerLocalServiceUtil.getService());
259                    actionableDynamicQuery.setClassLoader(getClassLoader());
260                    actionableDynamicQuery.setModelClass(PasswordTracker.class);
261    
262                    actionableDynamicQuery.setPrimaryKeyPropertyName("passwordTrackerId");
263            }
264    
265            /**
266             * @throws PortalException
267             */
268            @Override
269            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
270                    throws PortalException {
271                    return passwordTrackerLocalService.deletePasswordTracker((PasswordTracker)persistedModel);
272            }
273    
274            @Override
275            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
276                    throws PortalException {
277                    return passwordTrackerPersistence.findByPrimaryKey(primaryKeyObj);
278            }
279    
280            /**
281             * Returns a range of all the password trackers.
282             *
283             * <p>
284             * 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.
285             * </p>
286             *
287             * @param start the lower bound of the range of password trackers
288             * @param end the upper bound of the range of password trackers (not inclusive)
289             * @return the range of password trackers
290             */
291            @Override
292            public List<PasswordTracker> getPasswordTrackers(int start, int end) {
293                    return passwordTrackerPersistence.findAll(start, end);
294            }
295    
296            /**
297             * Returns the number of password trackers.
298             *
299             * @return the number of password trackers
300             */
301            @Override
302            public int getPasswordTrackersCount() {
303                    return passwordTrackerPersistence.countAll();
304            }
305    
306            /**
307             * Updates the password tracker in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
308             *
309             * @param passwordTracker the password tracker
310             * @return the password tracker that was updated
311             */
312            @Indexable(type = IndexableType.REINDEX)
313            @Override
314            public PasswordTracker updatePasswordTracker(
315                    PasswordTracker passwordTracker) {
316                    return passwordTrackerPersistence.update(passwordTracker);
317            }
318    
319            /**
320             * Returns the password tracker local service.
321             *
322             * @return the password tracker local service
323             */
324            public PasswordTrackerLocalService getPasswordTrackerLocalService() {
325                    return passwordTrackerLocalService;
326            }
327    
328            /**
329             * Sets the password tracker local service.
330             *
331             * @param passwordTrackerLocalService the password tracker local service
332             */
333            public void setPasswordTrackerLocalService(
334                    PasswordTrackerLocalService passwordTrackerLocalService) {
335                    this.passwordTrackerLocalService = passwordTrackerLocalService;
336            }
337    
338            /**
339             * Returns the password tracker persistence.
340             *
341             * @return the password tracker persistence
342             */
343            public PasswordTrackerPersistence getPasswordTrackerPersistence() {
344                    return passwordTrackerPersistence;
345            }
346    
347            /**
348             * Sets the password tracker persistence.
349             *
350             * @param passwordTrackerPersistence the password tracker persistence
351             */
352            public void setPasswordTrackerPersistence(
353                    PasswordTrackerPersistence passwordTrackerPersistence) {
354                    this.passwordTrackerPersistence = passwordTrackerPersistence;
355            }
356    
357            /**
358             * Returns the counter local service.
359             *
360             * @return the counter local service
361             */
362            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
363                    return counterLocalService;
364            }
365    
366            /**
367             * Sets the counter local service.
368             *
369             * @param counterLocalService the counter local service
370             */
371            public void setCounterLocalService(
372                    com.liferay.counter.service.CounterLocalService counterLocalService) {
373                    this.counterLocalService = counterLocalService;
374            }
375    
376            /**
377             * Returns the password policy local service.
378             *
379             * @return the password policy local service
380             */
381            public com.liferay.portal.service.PasswordPolicyLocalService getPasswordPolicyLocalService() {
382                    return passwordPolicyLocalService;
383            }
384    
385            /**
386             * Sets the password policy local service.
387             *
388             * @param passwordPolicyLocalService the password policy local service
389             */
390            public void setPasswordPolicyLocalService(
391                    com.liferay.portal.service.PasswordPolicyLocalService passwordPolicyLocalService) {
392                    this.passwordPolicyLocalService = passwordPolicyLocalService;
393            }
394    
395            /**
396             * Returns the password policy persistence.
397             *
398             * @return the password policy persistence
399             */
400            public PasswordPolicyPersistence getPasswordPolicyPersistence() {
401                    return passwordPolicyPersistence;
402            }
403    
404            /**
405             * Sets the password policy persistence.
406             *
407             * @param passwordPolicyPersistence the password policy persistence
408             */
409            public void setPasswordPolicyPersistence(
410                    PasswordPolicyPersistence passwordPolicyPersistence) {
411                    this.passwordPolicyPersistence = passwordPolicyPersistence;
412            }
413    
414            /**
415             * Returns the password policy finder.
416             *
417             * @return the password policy finder
418             */
419            public PasswordPolicyFinder getPasswordPolicyFinder() {
420                    return passwordPolicyFinder;
421            }
422    
423            /**
424             * Sets the password policy finder.
425             *
426             * @param passwordPolicyFinder the password policy finder
427             */
428            public void setPasswordPolicyFinder(
429                    PasswordPolicyFinder passwordPolicyFinder) {
430                    this.passwordPolicyFinder = passwordPolicyFinder;
431            }
432    
433            /**
434             * Returns the user local service.
435             *
436             * @return the user local service
437             */
438            public com.liferay.portal.service.UserLocalService getUserLocalService() {
439                    return userLocalService;
440            }
441    
442            /**
443             * Sets the user local service.
444             *
445             * @param userLocalService the user local service
446             */
447            public void setUserLocalService(
448                    com.liferay.portal.service.UserLocalService userLocalService) {
449                    this.userLocalService = userLocalService;
450            }
451    
452            /**
453             * Returns the user persistence.
454             *
455             * @return the user persistence
456             */
457            public UserPersistence getUserPersistence() {
458                    return userPersistence;
459            }
460    
461            /**
462             * Sets the user persistence.
463             *
464             * @param userPersistence the user persistence
465             */
466            public void setUserPersistence(UserPersistence userPersistence) {
467                    this.userPersistence = userPersistence;
468            }
469    
470            /**
471             * Returns the user finder.
472             *
473             * @return the user finder
474             */
475            public UserFinder getUserFinder() {
476                    return userFinder;
477            }
478    
479            /**
480             * Sets the user finder.
481             *
482             * @param userFinder the user finder
483             */
484            public void setUserFinder(UserFinder userFinder) {
485                    this.userFinder = userFinder;
486            }
487    
488            public void afterPropertiesSet() {
489                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.PasswordTracker",
490                            passwordTrackerLocalService);
491            }
492    
493            public void destroy() {
494                    persistedModelLocalServiceRegistry.unregister(
495                            "com.liferay.portal.model.PasswordTracker");
496            }
497    
498            /**
499             * Returns the OSGi service identifier.
500             *
501             * @return the OSGi service identifier
502             */
503            @Override
504            public String getOSGiServiceIdentifier() {
505                    return PasswordTrackerLocalService.class.getName();
506            }
507    
508            protected Class<?> getModelClass() {
509                    return PasswordTracker.class;
510            }
511    
512            protected String getModelClassName() {
513                    return PasswordTracker.class.getName();
514            }
515    
516            /**
517             * Performs a SQL query.
518             *
519             * @param sql the sql query
520             */
521            protected void runSQL(String sql) {
522                    try {
523                            DataSource dataSource = passwordTrackerPersistence.getDataSource();
524    
525                            DB db = DBManagerUtil.getDB();
526    
527                            sql = db.buildSQL(sql);
528                            sql = PortalUtil.transformSQL(sql);
529    
530                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
531                                            sql, new int[0]);
532    
533                            sqlUpdate.update();
534                    }
535                    catch (Exception e) {
536                            throw new SystemException(e);
537                    }
538            }
539    
540            @BeanReference(type = com.liferay.portal.service.PasswordTrackerLocalService.class)
541            protected PasswordTrackerLocalService passwordTrackerLocalService;
542            @BeanReference(type = PasswordTrackerPersistence.class)
543            protected PasswordTrackerPersistence passwordTrackerPersistence;
544            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
545            protected com.liferay.counter.service.CounterLocalService counterLocalService;
546            @BeanReference(type = com.liferay.portal.service.PasswordPolicyLocalService.class)
547            protected com.liferay.portal.service.PasswordPolicyLocalService passwordPolicyLocalService;
548            @BeanReference(type = PasswordPolicyPersistence.class)
549            protected PasswordPolicyPersistence passwordPolicyPersistence;
550            @BeanReference(type = PasswordPolicyFinder.class)
551            protected PasswordPolicyFinder passwordPolicyFinder;
552            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
553            protected com.liferay.portal.service.UserLocalService userLocalService;
554            @BeanReference(type = UserPersistence.class)
555            protected UserPersistence userPersistence;
556            @BeanReference(type = UserFinder.class)
557            protected UserFinder userFinder;
558            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
559            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
560    }