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