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.PersistedModel;
037    import com.liferay.portal.model.UserTracker;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.UserTrackerLocalService;
041    import com.liferay.portal.service.persistence.UserTrackerPathPersistence;
042    import com.liferay.portal.service.persistence.UserTrackerPersistence;
043    import com.liferay.portal.util.PortalUtil;
044    
045    import java.io.Serializable;
046    
047    import java.util.List;
048    
049    import javax.sql.DataSource;
050    
051    /**
052     * Provides the base implementation for the user tracker local service.
053     *
054     * <p>
055     * 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.UserTrackerLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.UserTrackerLocalServiceImpl
060     * @see com.liferay.portal.service.UserTrackerLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class UserTrackerLocalServiceBaseImpl
065            extends BaseLocalServiceImpl implements UserTrackerLocalService,
066                    IdentifiableOSGiService {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.UserTrackerLocalServiceUtil} to access the user tracker local service.
071             */
072    
073            /**
074             * Adds the user tracker to the database. Also notifies the appropriate model listeners.
075             *
076             * @param userTracker the user tracker
077             * @return the user tracker that was added
078             */
079            @Indexable(type = IndexableType.REINDEX)
080            @Override
081            public UserTracker addUserTracker(UserTracker userTracker) {
082                    userTracker.setNew(true);
083    
084                    return userTrackerPersistence.update(userTracker);
085            }
086    
087            /**
088             * Creates a new user tracker with the primary key. Does not add the user tracker to the database.
089             *
090             * @param userTrackerId the primary key for the new user tracker
091             * @return the new user tracker
092             */
093            @Override
094            public UserTracker createUserTracker(long userTrackerId) {
095                    return userTrackerPersistence.create(userTrackerId);
096            }
097    
098            /**
099             * Deletes the user tracker with the primary key from the database. Also notifies the appropriate model listeners.
100             *
101             * @param userTrackerId the primary key of the user tracker
102             * @return the user tracker that was removed
103             * @throws PortalException if a user tracker with the primary key could not be found
104             */
105            @Indexable(type = IndexableType.DELETE)
106            @Override
107            public UserTracker deleteUserTracker(long userTrackerId)
108                    throws PortalException {
109                    return userTrackerPersistence.remove(userTrackerId);
110            }
111    
112            /**
113             * Deletes the user tracker from the database. Also notifies the appropriate model listeners.
114             *
115             * @param userTracker the user tracker
116             * @return the user tracker that was removed
117             */
118            @Indexable(type = IndexableType.DELETE)
119            @Override
120            public UserTracker deleteUserTracker(UserTracker userTracker) {
121                    return userTrackerPersistence.remove(userTracker);
122            }
123    
124            @Override
125            public DynamicQuery dynamicQuery() {
126                    Class<?> clazz = getClass();
127    
128                    return DynamicQueryFactoryUtil.forClass(UserTracker.class,
129                            clazz.getClassLoader());
130            }
131    
132            /**
133             * Performs a dynamic query on the database and returns the matching rows.
134             *
135             * @param dynamicQuery the dynamic query
136             * @return the matching rows
137             */
138            @Override
139            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
140                    return userTrackerPersistence.findWithDynamicQuery(dynamicQuery);
141            }
142    
143            /**
144             * Performs a dynamic query on the database and returns a range of the matching rows.
145             *
146             * <p>
147             * 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.UserTrackerModelImpl}. 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.
148             * </p>
149             *
150             * @param dynamicQuery the dynamic query
151             * @param start the lower bound of the range of model instances
152             * @param end the upper bound of the range of model instances (not inclusive)
153             * @return the range of matching rows
154             */
155            @Override
156            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
157                    int end) {
158                    return userTrackerPersistence.findWithDynamicQuery(dynamicQuery, start,
159                            end);
160            }
161    
162            /**
163             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
164             *
165             * <p>
166             * 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.UserTrackerModelImpl}. 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.
167             * </p>
168             *
169             * @param dynamicQuery the dynamic query
170             * @param start the lower bound of the range of model instances
171             * @param end the upper bound of the range of model instances (not inclusive)
172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
173             * @return the ordered range of matching rows
174             */
175            @Override
176            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
177                    int end, OrderByComparator<T> orderByComparator) {
178                    return userTrackerPersistence.findWithDynamicQuery(dynamicQuery, start,
179                            end, orderByComparator);
180            }
181    
182            /**
183             * Returns the number of rows matching the dynamic query.
184             *
185             * @param dynamicQuery the dynamic query
186             * @return the number of rows matching the dynamic query
187             */
188            @Override
189            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
190                    return userTrackerPersistence.countWithDynamicQuery(dynamicQuery);
191            }
192    
193            /**
194             * Returns the number of rows matching the dynamic query.
195             *
196             * @param dynamicQuery the dynamic query
197             * @param projection the projection to apply to the query
198             * @return the number of rows matching the dynamic query
199             */
200            @Override
201            public long dynamicQueryCount(DynamicQuery dynamicQuery,
202                    Projection projection) {
203                    return userTrackerPersistence.countWithDynamicQuery(dynamicQuery,
204                            projection);
205            }
206    
207            @Override
208            public UserTracker fetchUserTracker(long userTrackerId) {
209                    return userTrackerPersistence.fetchByPrimaryKey(userTrackerId);
210            }
211    
212            /**
213             * Returns the user tracker with the primary key.
214             *
215             * @param userTrackerId the primary key of the user tracker
216             * @return the user tracker
217             * @throws PortalException if a user tracker with the primary key could not be found
218             */
219            @Override
220            public UserTracker getUserTracker(long userTrackerId)
221                    throws PortalException {
222                    return userTrackerPersistence.findByPrimaryKey(userTrackerId);
223            }
224    
225            @Override
226            public ActionableDynamicQuery getActionableDynamicQuery() {
227                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
228    
229                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserTrackerLocalServiceUtil.getService());
230                    actionableDynamicQuery.setClassLoader(getClassLoader());
231                    actionableDynamicQuery.setModelClass(UserTracker.class);
232    
233                    actionableDynamicQuery.setPrimaryKeyPropertyName("userTrackerId");
234    
235                    return actionableDynamicQuery;
236            }
237    
238            @Override
239            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
240                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
241    
242                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserTrackerLocalServiceUtil.getService());
243                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
244                    indexableActionableDynamicQuery.setModelClass(UserTracker.class);
245    
246                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
247                            "userTrackerId");
248    
249                    return indexableActionableDynamicQuery;
250            }
251    
252            protected void initActionableDynamicQuery(
253                    ActionableDynamicQuery actionableDynamicQuery) {
254                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserTrackerLocalServiceUtil.getService());
255                    actionableDynamicQuery.setClassLoader(getClassLoader());
256                    actionableDynamicQuery.setModelClass(UserTracker.class);
257    
258                    actionableDynamicQuery.setPrimaryKeyPropertyName("userTrackerId");
259            }
260    
261            /**
262             * @throws PortalException
263             */
264            @Override
265            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
266                    throws PortalException {
267                    return userTrackerLocalService.deleteUserTracker((UserTracker)persistedModel);
268            }
269    
270            @Override
271            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
272                    throws PortalException {
273                    return userTrackerPersistence.findByPrimaryKey(primaryKeyObj);
274            }
275    
276            /**
277             * Returns a range of all the user trackers.
278             *
279             * <p>
280             * 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.UserTrackerModelImpl}. 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.
281             * </p>
282             *
283             * @param start the lower bound of the range of user trackers
284             * @param end the upper bound of the range of user trackers (not inclusive)
285             * @return the range of user trackers
286             */
287            @Override
288            public List<UserTracker> getUserTrackers(int start, int end) {
289                    return userTrackerPersistence.findAll(start, end);
290            }
291    
292            /**
293             * Returns the number of user trackers.
294             *
295             * @return the number of user trackers
296             */
297            @Override
298            public int getUserTrackersCount() {
299                    return userTrackerPersistence.countAll();
300            }
301    
302            /**
303             * Updates the user tracker in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
304             *
305             * @param userTracker the user tracker
306             * @return the user tracker that was updated
307             */
308            @Indexable(type = IndexableType.REINDEX)
309            @Override
310            public UserTracker updateUserTracker(UserTracker userTracker) {
311                    return userTrackerPersistence.update(userTracker);
312            }
313    
314            /**
315             * Returns the user tracker local service.
316             *
317             * @return the user tracker local service
318             */
319            public UserTrackerLocalService getUserTrackerLocalService() {
320                    return userTrackerLocalService;
321            }
322    
323            /**
324             * Sets the user tracker local service.
325             *
326             * @param userTrackerLocalService the user tracker local service
327             */
328            public void setUserTrackerLocalService(
329                    UserTrackerLocalService userTrackerLocalService) {
330                    this.userTrackerLocalService = userTrackerLocalService;
331            }
332    
333            /**
334             * Returns the user tracker persistence.
335             *
336             * @return the user tracker persistence
337             */
338            public UserTrackerPersistence getUserTrackerPersistence() {
339                    return userTrackerPersistence;
340            }
341    
342            /**
343             * Sets the user tracker persistence.
344             *
345             * @param userTrackerPersistence the user tracker persistence
346             */
347            public void setUserTrackerPersistence(
348                    UserTrackerPersistence userTrackerPersistence) {
349                    this.userTrackerPersistence = userTrackerPersistence;
350            }
351    
352            /**
353             * Returns the counter local service.
354             *
355             * @return the counter local service
356             */
357            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
358                    return counterLocalService;
359            }
360    
361            /**
362             * Sets the counter local service.
363             *
364             * @param counterLocalService the counter local service
365             */
366            public void setCounterLocalService(
367                    com.liferay.counter.service.CounterLocalService counterLocalService) {
368                    this.counterLocalService = counterLocalService;
369            }
370    
371            /**
372             * Returns the user tracker path local service.
373             *
374             * @return the user tracker path local service
375             */
376            public com.liferay.portal.service.UserTrackerPathLocalService getUserTrackerPathLocalService() {
377                    return userTrackerPathLocalService;
378            }
379    
380            /**
381             * Sets the user tracker path local service.
382             *
383             * @param userTrackerPathLocalService the user tracker path local service
384             */
385            public void setUserTrackerPathLocalService(
386                    com.liferay.portal.service.UserTrackerPathLocalService userTrackerPathLocalService) {
387                    this.userTrackerPathLocalService = userTrackerPathLocalService;
388            }
389    
390            /**
391             * Returns the user tracker path persistence.
392             *
393             * @return the user tracker path persistence
394             */
395            public UserTrackerPathPersistence getUserTrackerPathPersistence() {
396                    return userTrackerPathPersistence;
397            }
398    
399            /**
400             * Sets the user tracker path persistence.
401             *
402             * @param userTrackerPathPersistence the user tracker path persistence
403             */
404            public void setUserTrackerPathPersistence(
405                    UserTrackerPathPersistence userTrackerPathPersistence) {
406                    this.userTrackerPathPersistence = userTrackerPathPersistence;
407            }
408    
409            public void afterPropertiesSet() {
410                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.UserTracker",
411                            userTrackerLocalService);
412            }
413    
414            public void destroy() {
415                    persistedModelLocalServiceRegistry.unregister(
416                            "com.liferay.portal.model.UserTracker");
417            }
418    
419            /**
420             * Returns the OSGi service identifier.
421             *
422             * @return the OSGi service identifier
423             */
424            @Override
425            public String getOSGiServiceIdentifier() {
426                    return UserTrackerLocalService.class.getName();
427            }
428    
429            protected Class<?> getModelClass() {
430                    return UserTracker.class;
431            }
432    
433            protected String getModelClassName() {
434                    return UserTracker.class.getName();
435            }
436    
437            /**
438             * Performs a SQL query.
439             *
440             * @param sql the sql query
441             */
442            protected void runSQL(String sql) {
443                    try {
444                            DataSource dataSource = userTrackerPersistence.getDataSource();
445    
446                            DB db = DBManagerUtil.getDB();
447    
448                            sql = db.buildSQL(sql);
449                            sql = PortalUtil.transformSQL(sql);
450    
451                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
452                                            sql, new int[0]);
453    
454                            sqlUpdate.update();
455                    }
456                    catch (Exception e) {
457                            throw new SystemException(e);
458                    }
459            }
460    
461            @BeanReference(type = com.liferay.portal.service.UserTrackerLocalService.class)
462            protected UserTrackerLocalService userTrackerLocalService;
463            @BeanReference(type = UserTrackerPersistence.class)
464            protected UserTrackerPersistence userTrackerPersistence;
465            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
466            protected com.liferay.counter.service.CounterLocalService counterLocalService;
467            @BeanReference(type = com.liferay.portal.service.UserTrackerPathLocalService.class)
468            protected com.liferay.portal.service.UserTrackerPathLocalService userTrackerPathLocalService;
469            @BeanReference(type = UserTrackerPathPersistence.class)
470            protected UserTrackerPathPersistence userTrackerPathPersistence;
471            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
472            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
473    }