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