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