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