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