001    /**
002     * Copyright (c) 2000-2013 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.portlet.trash.service.base;
016    
017    import com.liferay.portal.kernel.bean.BeanReference;
018    import com.liferay.portal.kernel.bean.IdentifiableBean;
019    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
020    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
021    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
022    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
023    import com.liferay.portal.kernel.dao.orm.Projection;
024    import com.liferay.portal.kernel.exception.PortalException;
025    import com.liferay.portal.kernel.exception.SystemException;
026    import com.liferay.portal.kernel.search.Indexable;
027    import com.liferay.portal.kernel.search.IndexableType;
028    import com.liferay.portal.kernel.util.OrderByComparator;
029    import com.liferay.portal.model.PersistedModel;
030    import com.liferay.portal.service.BaseLocalServiceImpl;
031    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
032    import com.liferay.portal.service.persistence.GroupFinder;
033    import com.liferay.portal.service.persistence.GroupPersistence;
034    import com.liferay.portal.service.persistence.UserFinder;
035    import com.liferay.portal.service.persistence.UserPersistence;
036    
037    import com.liferay.portlet.trash.model.TrashEntry;
038    import com.liferay.portlet.trash.service.TrashEntryLocalService;
039    import com.liferay.portlet.trash.service.persistence.TrashEntryPersistence;
040    import com.liferay.portlet.trash.service.persistence.TrashVersionPersistence;
041    
042    import java.io.Serializable;
043    
044    import java.util.List;
045    
046    import javax.sql.DataSource;
047    
048    /**
049     * Provides the base implementation for the trash entry local service.
050     *
051     * <p>
052     * 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.portlet.trash.service.impl.TrashEntryLocalServiceImpl}.
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see com.liferay.portlet.trash.service.impl.TrashEntryLocalServiceImpl
057     * @see com.liferay.portlet.trash.service.TrashEntryLocalServiceUtil
058     * @generated
059     */
060    public abstract class TrashEntryLocalServiceBaseImpl
061            extends BaseLocalServiceImpl implements TrashEntryLocalService,
062                    IdentifiableBean {
063            /*
064             * NOTE FOR DEVELOPERS:
065             *
066             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.trash.service.TrashEntryLocalServiceUtil} to access the trash entry local service.
067             */
068    
069            /**
070             * Adds the trash entry to the database. Also notifies the appropriate model listeners.
071             *
072             * @param trashEntry the trash entry
073             * @return the trash entry that was added
074             * @throws SystemException if a system exception occurred
075             */
076            @Indexable(type = IndexableType.REINDEX)
077            @Override
078            public TrashEntry addTrashEntry(TrashEntry trashEntry)
079                    throws SystemException {
080                    trashEntry.setNew(true);
081    
082                    return trashEntryPersistence.update(trashEntry);
083            }
084    
085            /**
086             * Creates a new trash entry with the primary key. Does not add the trash entry to the database.
087             *
088             * @param entryId the primary key for the new trash entry
089             * @return the new trash entry
090             */
091            @Override
092            public TrashEntry createTrashEntry(long entryId) {
093                    return trashEntryPersistence.create(entryId);
094            }
095    
096            /**
097             * Deletes the trash entry with the primary key from the database. Also notifies the appropriate model listeners.
098             *
099             * @param entryId the primary key of the trash entry
100             * @return the trash entry that was removed
101             * @throws PortalException if a trash entry with the primary key could not be found
102             * @throws SystemException if a system exception occurred
103             */
104            @Indexable(type = IndexableType.DELETE)
105            @Override
106            public TrashEntry deleteTrashEntry(long entryId)
107                    throws PortalException, SystemException {
108                    return trashEntryPersistence.remove(entryId);
109            }
110    
111            /**
112             * Deletes the trash entry from the database. Also notifies the appropriate model listeners.
113             *
114             * @param trashEntry the trash entry
115             * @return the trash entry that was removed
116             * @throws SystemException if a system exception occurred
117             */
118            @Indexable(type = IndexableType.DELETE)
119            @Override
120            public TrashEntry deleteTrashEntry(TrashEntry trashEntry)
121                    throws SystemException {
122                    return trashEntryPersistence.remove(trashEntry);
123            }
124    
125            @Override
126            public DynamicQuery dynamicQuery() {
127                    Class<?> clazz = getClass();
128    
129                    return DynamicQueryFactoryUtil.forClass(TrashEntry.class,
130                            clazz.getClassLoader());
131            }
132    
133            /**
134             * Performs a dynamic query on the database and returns the matching rows.
135             *
136             * @param dynamicQuery the dynamic query
137             * @return the matching rows
138             * @throws SystemException if a system exception occurred
139             */
140            @Override
141            @SuppressWarnings("rawtypes")
142            public List dynamicQuery(DynamicQuery dynamicQuery)
143                    throws SystemException {
144                    return trashEntryPersistence.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.portlet.trash.model.impl.TrashEntryModelImpl}. 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             * @throws SystemException if a system exception occurred
159             */
160            @Override
161            @SuppressWarnings("rawtypes")
162            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
163                    throws SystemException {
164                    return trashEntryPersistence.findWithDynamicQuery(dynamicQuery, start,
165                            end);
166            }
167    
168            /**
169             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
170             *
171             * <p>
172             * 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.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
173             * </p>
174             *
175             * @param dynamicQuery the dynamic query
176             * @param start the lower bound of the range of model instances
177             * @param end the upper bound of the range of model instances (not inclusive)
178             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
179             * @return the ordered range of matching rows
180             * @throws SystemException if a system exception occurred
181             */
182            @Override
183            @SuppressWarnings("rawtypes")
184            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
185                    OrderByComparator orderByComparator) throws SystemException {
186                    return trashEntryPersistence.findWithDynamicQuery(dynamicQuery, start,
187                            end, orderByComparator);
188            }
189    
190            /**
191             * Returns the number of rows that match the dynamic query.
192             *
193             * @param dynamicQuery the dynamic query
194             * @return the number of rows that match the dynamic query
195             * @throws SystemException if a system exception occurred
196             */
197            @Override
198            public long dynamicQueryCount(DynamicQuery dynamicQuery)
199                    throws SystemException {
200                    return trashEntryPersistence.countWithDynamicQuery(dynamicQuery);
201            }
202    
203            /**
204             * Returns the number of rows that match the dynamic query.
205             *
206             * @param dynamicQuery the dynamic query
207             * @param projection the projection to apply to the query
208             * @return the number of rows that match the dynamic query
209             * @throws SystemException if a system exception occurred
210             */
211            @Override
212            public long dynamicQueryCount(DynamicQuery dynamicQuery,
213                    Projection projection) throws SystemException {
214                    return trashEntryPersistence.countWithDynamicQuery(dynamicQuery,
215                            projection);
216            }
217    
218            @Override
219            public TrashEntry fetchTrashEntry(long entryId) throws SystemException {
220                    return trashEntryPersistence.fetchByPrimaryKey(entryId);
221            }
222    
223            /**
224             * Returns the trash entry with the primary key.
225             *
226             * @param entryId the primary key of the trash entry
227             * @return the trash entry
228             * @throws PortalException if a trash entry with the primary key could not be found
229             * @throws SystemException if a system exception occurred
230             */
231            @Override
232            public TrashEntry getTrashEntry(long entryId)
233                    throws PortalException, SystemException {
234                    return trashEntryPersistence.findByPrimaryKey(entryId);
235            }
236    
237            @Override
238            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
239                    throws PortalException, SystemException {
240                    return trashEntryPersistence.findByPrimaryKey(primaryKeyObj);
241            }
242    
243            /**
244             * Returns a range of all the trash entries.
245             *
246             * <p>
247             * 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.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
248             * </p>
249             *
250             * @param start the lower bound of the range of trash entries
251             * @param end the upper bound of the range of trash entries (not inclusive)
252             * @return the range of trash entries
253             * @throws SystemException if a system exception occurred
254             */
255            @Override
256            public List<TrashEntry> getTrashEntries(int start, int end)
257                    throws SystemException {
258                    return trashEntryPersistence.findAll(start, end);
259            }
260    
261            /**
262             * Returns the number of trash entries.
263             *
264             * @return the number of trash entries
265             * @throws SystemException if a system exception occurred
266             */
267            @Override
268            public int getTrashEntriesCount() throws SystemException {
269                    return trashEntryPersistence.countAll();
270            }
271    
272            /**
273             * Updates the trash entry in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
274             *
275             * @param trashEntry the trash entry
276             * @return the trash entry that was updated
277             * @throws SystemException if a system exception occurred
278             */
279            @Indexable(type = IndexableType.REINDEX)
280            @Override
281            public TrashEntry updateTrashEntry(TrashEntry trashEntry)
282                    throws SystemException {
283                    return trashEntryPersistence.update(trashEntry);
284            }
285    
286            /**
287             * Returns the trash entry local service.
288             *
289             * @return the trash entry local service
290             */
291            public com.liferay.portlet.trash.service.TrashEntryLocalService getTrashEntryLocalService() {
292                    return trashEntryLocalService;
293            }
294    
295            /**
296             * Sets the trash entry local service.
297             *
298             * @param trashEntryLocalService the trash entry local service
299             */
300            public void setTrashEntryLocalService(
301                    com.liferay.portlet.trash.service.TrashEntryLocalService trashEntryLocalService) {
302                    this.trashEntryLocalService = trashEntryLocalService;
303            }
304    
305            /**
306             * Returns the trash entry remote service.
307             *
308             * @return the trash entry remote service
309             */
310            public com.liferay.portlet.trash.service.TrashEntryService getTrashEntryService() {
311                    return trashEntryService;
312            }
313    
314            /**
315             * Sets the trash entry remote service.
316             *
317             * @param trashEntryService the trash entry remote service
318             */
319            public void setTrashEntryService(
320                    com.liferay.portlet.trash.service.TrashEntryService trashEntryService) {
321                    this.trashEntryService = trashEntryService;
322            }
323    
324            /**
325             * Returns the trash entry persistence.
326             *
327             * @return the trash entry persistence
328             */
329            public TrashEntryPersistence getTrashEntryPersistence() {
330                    return trashEntryPersistence;
331            }
332    
333            /**
334             * Sets the trash entry persistence.
335             *
336             * @param trashEntryPersistence the trash entry persistence
337             */
338            public void setTrashEntryPersistence(
339                    TrashEntryPersistence trashEntryPersistence) {
340                    this.trashEntryPersistence = trashEntryPersistence;
341            }
342    
343            /**
344             * Returns the trash version persistence.
345             *
346             * @return the trash version persistence
347             */
348            public TrashVersionPersistence getTrashVersionPersistence() {
349                    return trashVersionPersistence;
350            }
351    
352            /**
353             * Sets the trash version persistence.
354             *
355             * @param trashVersionPersistence the trash version persistence
356             */
357            public void setTrashVersionPersistence(
358                    TrashVersionPersistence trashVersionPersistence) {
359                    this.trashVersionPersistence = trashVersionPersistence;
360            }
361    
362            /**
363             * Returns the counter local service.
364             *
365             * @return the counter local service
366             */
367            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
368                    return counterLocalService;
369            }
370    
371            /**
372             * Sets the counter local service.
373             *
374             * @param counterLocalService the counter local service
375             */
376            public void setCounterLocalService(
377                    com.liferay.counter.service.CounterLocalService counterLocalService) {
378                    this.counterLocalService = counterLocalService;
379            }
380    
381            /**
382             * Returns the group local service.
383             *
384             * @return the group local service
385             */
386            public com.liferay.portal.service.GroupLocalService getGroupLocalService() {
387                    return groupLocalService;
388            }
389    
390            /**
391             * Sets the group local service.
392             *
393             * @param groupLocalService the group local service
394             */
395            public void setGroupLocalService(
396                    com.liferay.portal.service.GroupLocalService groupLocalService) {
397                    this.groupLocalService = groupLocalService;
398            }
399    
400            /**
401             * Returns the group remote service.
402             *
403             * @return the group remote service
404             */
405            public com.liferay.portal.service.GroupService getGroupService() {
406                    return groupService;
407            }
408    
409            /**
410             * Sets the group remote service.
411             *
412             * @param groupService the group remote service
413             */
414            public void setGroupService(
415                    com.liferay.portal.service.GroupService groupService) {
416                    this.groupService = groupService;
417            }
418    
419            /**
420             * Returns the group persistence.
421             *
422             * @return the group persistence
423             */
424            public GroupPersistence getGroupPersistence() {
425                    return groupPersistence;
426            }
427    
428            /**
429             * Sets the group persistence.
430             *
431             * @param groupPersistence the group persistence
432             */
433            public void setGroupPersistence(GroupPersistence groupPersistence) {
434                    this.groupPersistence = groupPersistence;
435            }
436    
437            /**
438             * Returns the group finder.
439             *
440             * @return the group finder
441             */
442            public GroupFinder getGroupFinder() {
443                    return groupFinder;
444            }
445    
446            /**
447             * Sets the group finder.
448             *
449             * @param groupFinder the group finder
450             */
451            public void setGroupFinder(GroupFinder groupFinder) {
452                    this.groupFinder = groupFinder;
453            }
454    
455            /**
456             * Returns the resource local service.
457             *
458             * @return the resource local service
459             */
460            public com.liferay.portal.service.ResourceLocalService getResourceLocalService() {
461                    return resourceLocalService;
462            }
463    
464            /**
465             * Sets the resource local service.
466             *
467             * @param resourceLocalService the resource local service
468             */
469            public void setResourceLocalService(
470                    com.liferay.portal.service.ResourceLocalService resourceLocalService) {
471                    this.resourceLocalService = resourceLocalService;
472            }
473    
474            /**
475             * Returns the user local service.
476             *
477             * @return the user local service
478             */
479            public com.liferay.portal.service.UserLocalService getUserLocalService() {
480                    return userLocalService;
481            }
482    
483            /**
484             * Sets the user local service.
485             *
486             * @param userLocalService the user local service
487             */
488            public void setUserLocalService(
489                    com.liferay.portal.service.UserLocalService userLocalService) {
490                    this.userLocalService = userLocalService;
491            }
492    
493            /**
494             * Returns the user remote service.
495             *
496             * @return the user remote service
497             */
498            public com.liferay.portal.service.UserService getUserService() {
499                    return userService;
500            }
501    
502            /**
503             * Sets the user remote service.
504             *
505             * @param userService the user remote service
506             */
507            public void setUserService(
508                    com.liferay.portal.service.UserService userService) {
509                    this.userService = userService;
510            }
511    
512            /**
513             * Returns the user persistence.
514             *
515             * @return the user persistence
516             */
517            public UserPersistence getUserPersistence() {
518                    return userPersistence;
519            }
520    
521            /**
522             * Sets the user persistence.
523             *
524             * @param userPersistence the user persistence
525             */
526            public void setUserPersistence(UserPersistence userPersistence) {
527                    this.userPersistence = userPersistence;
528            }
529    
530            /**
531             * Returns the user finder.
532             *
533             * @return the user finder
534             */
535            public UserFinder getUserFinder() {
536                    return userFinder;
537            }
538    
539            /**
540             * Sets the user finder.
541             *
542             * @param userFinder the user finder
543             */
544            public void setUserFinder(UserFinder userFinder) {
545                    this.userFinder = userFinder;
546            }
547    
548            public void afterPropertiesSet() {
549                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.trash.model.TrashEntry",
550                            trashEntryLocalService);
551            }
552    
553            public void destroy() {
554                    persistedModelLocalServiceRegistry.unregister(
555                            "com.liferay.portlet.trash.model.TrashEntry");
556            }
557    
558            /**
559             * Returns the Spring bean ID for this bean.
560             *
561             * @return the Spring bean ID for this bean
562             */
563            @Override
564            public String getBeanIdentifier() {
565                    return _beanIdentifier;
566            }
567    
568            /**
569             * Sets the Spring bean ID for this bean.
570             *
571             * @param beanIdentifier the Spring bean ID for this bean
572             */
573            @Override
574            public void setBeanIdentifier(String beanIdentifier) {
575                    _beanIdentifier = beanIdentifier;
576            }
577    
578            protected Class<?> getModelClass() {
579                    return TrashEntry.class;
580            }
581    
582            protected String getModelClassName() {
583                    return TrashEntry.class.getName();
584            }
585    
586            /**
587             * Performs an SQL query.
588             *
589             * @param sql the sql query
590             */
591            protected void runSQL(String sql) throws SystemException {
592                    try {
593                            DataSource dataSource = trashEntryPersistence.getDataSource();
594    
595                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
596                                            sql, new int[0]);
597    
598                            sqlUpdate.update();
599                    }
600                    catch (Exception e) {
601                            throw new SystemException(e);
602                    }
603            }
604    
605            @BeanReference(type = com.liferay.portlet.trash.service.TrashEntryLocalService.class)
606            protected com.liferay.portlet.trash.service.TrashEntryLocalService trashEntryLocalService;
607            @BeanReference(type = com.liferay.portlet.trash.service.TrashEntryService.class)
608            protected com.liferay.portlet.trash.service.TrashEntryService trashEntryService;
609            @BeanReference(type = TrashEntryPersistence.class)
610            protected TrashEntryPersistence trashEntryPersistence;
611            @BeanReference(type = TrashVersionPersistence.class)
612            protected TrashVersionPersistence trashVersionPersistence;
613            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
614            protected com.liferay.counter.service.CounterLocalService counterLocalService;
615            @BeanReference(type = com.liferay.portal.service.GroupLocalService.class)
616            protected com.liferay.portal.service.GroupLocalService groupLocalService;
617            @BeanReference(type = com.liferay.portal.service.GroupService.class)
618            protected com.liferay.portal.service.GroupService groupService;
619            @BeanReference(type = GroupPersistence.class)
620            protected GroupPersistence groupPersistence;
621            @BeanReference(type = GroupFinder.class)
622            protected GroupFinder groupFinder;
623            @BeanReference(type = com.liferay.portal.service.ResourceLocalService.class)
624            protected com.liferay.portal.service.ResourceLocalService resourceLocalService;
625            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
626            protected com.liferay.portal.service.UserLocalService userLocalService;
627            @BeanReference(type = com.liferay.portal.service.UserService.class)
628            protected com.liferay.portal.service.UserService userService;
629            @BeanReference(type = UserPersistence.class)
630            protected UserPersistence userPersistence;
631            @BeanReference(type = UserFinder.class)
632            protected UserFinder userFinder;
633            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
634            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
635            private String _beanIdentifier;
636    }