001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.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.model.Ticket;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.TicketLocalService;
041    import com.liferay.portal.service.persistence.ClassNamePersistence;
042    import com.liferay.portal.service.persistence.TicketPersistence;
043    import com.liferay.portal.util.PortalUtil;
044    
045    import java.io.Serializable;
046    
047    import java.util.List;
048    
049    import javax.sql.DataSource;
050    
051    /**
052     * Provides the base implementation for the ticket local service.
053     *
054     * <p>
055     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portal.service.impl.TicketLocalServiceImpl}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see com.liferay.portal.service.impl.TicketLocalServiceImpl
060     * @see com.liferay.portal.service.TicketLocalServiceUtil
061     * @generated
062     */
063    @ProviderType
064    public abstract class TicketLocalServiceBaseImpl extends BaseLocalServiceImpl
065            implements TicketLocalService, IdentifiableOSGiService {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.TicketLocalServiceUtil} to access the ticket local service.
070             */
071    
072            /**
073             * Adds the ticket to the database. Also notifies the appropriate model listeners.
074             *
075             * @param ticket the ticket
076             * @return the ticket that was added
077             */
078            @Indexable(type = IndexableType.REINDEX)
079            @Override
080            public Ticket addTicket(Ticket ticket) {
081                    ticket.setNew(true);
082    
083                    return ticketPersistence.update(ticket);
084            }
085    
086            /**
087             * Creates a new ticket with the primary key. Does not add the ticket to the database.
088             *
089             * @param ticketId the primary key for the new ticket
090             * @return the new ticket
091             */
092            @Override
093            public Ticket createTicket(long ticketId) {
094                    return ticketPersistence.create(ticketId);
095            }
096    
097            /**
098             * Deletes the ticket with the primary key from the database. Also notifies the appropriate model listeners.
099             *
100             * @param ticketId the primary key of the ticket
101             * @return the ticket that was removed
102             * @throws PortalException if a ticket with the primary key could not be found
103             */
104            @Indexable(type = IndexableType.DELETE)
105            @Override
106            public Ticket deleteTicket(long ticketId) throws PortalException {
107                    return ticketPersistence.remove(ticketId);
108            }
109    
110            /**
111             * Deletes the ticket from the database. Also notifies the appropriate model listeners.
112             *
113             * @param ticket the ticket
114             * @return the ticket that was removed
115             */
116            @Indexable(type = IndexableType.DELETE)
117            @Override
118            public Ticket deleteTicket(Ticket ticket) {
119                    return ticketPersistence.remove(ticket);
120            }
121    
122            @Override
123            public DynamicQuery dynamicQuery() {
124                    Class<?> clazz = getClass();
125    
126                    return DynamicQueryFactoryUtil.forClass(Ticket.class,
127                            clazz.getClassLoader());
128            }
129    
130            /**
131             * Performs a dynamic query on the database and returns the matching rows.
132             *
133             * @param dynamicQuery the dynamic query
134             * @return the matching rows
135             */
136            @Override
137            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
138                    return ticketPersistence.findWithDynamicQuery(dynamicQuery);
139            }
140    
141            /**
142             * Performs a dynamic query on the database and returns a range of the matching rows.
143             *
144             * <p>
145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.TicketModelImpl}. 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.
146             * </p>
147             *
148             * @param dynamicQuery the dynamic query
149             * @param start the lower bound of the range of model instances
150             * @param end the upper bound of the range of model instances (not inclusive)
151             * @return the range of matching rows
152             */
153            @Override
154            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
155                    int end) {
156                    return ticketPersistence.findWithDynamicQuery(dynamicQuery, start, end);
157            }
158    
159            /**
160             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
161             *
162             * <p>
163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.TicketModelImpl}. 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.
164             * </p>
165             *
166             * @param dynamicQuery the dynamic query
167             * @param start the lower bound of the range of model instances
168             * @param end the upper bound of the range of model instances (not inclusive)
169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
170             * @return the ordered range of matching rows
171             */
172            @Override
173            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
174                    int end, OrderByComparator<T> orderByComparator) {
175                    return ticketPersistence.findWithDynamicQuery(dynamicQuery, start, end,
176                            orderByComparator);
177            }
178    
179            /**
180             * Returns the number of rows matching the dynamic query.
181             *
182             * @param dynamicQuery the dynamic query
183             * @return the number of rows matching the dynamic query
184             */
185            @Override
186            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
187                    return ticketPersistence.countWithDynamicQuery(dynamicQuery);
188            }
189    
190            /**
191             * Returns the number of rows matching the dynamic query.
192             *
193             * @param dynamicQuery the dynamic query
194             * @param projection the projection to apply to the query
195             * @return the number of rows matching the dynamic query
196             */
197            @Override
198            public long dynamicQueryCount(DynamicQuery dynamicQuery,
199                    Projection projection) {
200                    return ticketPersistence.countWithDynamicQuery(dynamicQuery, projection);
201            }
202    
203            @Override
204            public Ticket fetchTicket(long ticketId) {
205                    return ticketPersistence.fetchByPrimaryKey(ticketId);
206            }
207    
208            /**
209             * Returns the ticket with the primary key.
210             *
211             * @param ticketId the primary key of the ticket
212             * @return the ticket
213             * @throws PortalException if a ticket with the primary key could not be found
214             */
215            @Override
216            public Ticket getTicket(long ticketId) throws PortalException {
217                    return ticketPersistence.findByPrimaryKey(ticketId);
218            }
219    
220            @Override
221            public ActionableDynamicQuery getActionableDynamicQuery() {
222                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
223    
224                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.TicketLocalServiceUtil.getService());
225                    actionableDynamicQuery.setClassLoader(getClassLoader());
226                    actionableDynamicQuery.setModelClass(Ticket.class);
227    
228                    actionableDynamicQuery.setPrimaryKeyPropertyName("ticketId");
229    
230                    return actionableDynamicQuery;
231            }
232    
233            @Override
234            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
235                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
236    
237                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.TicketLocalServiceUtil.getService());
238                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
239                    indexableActionableDynamicQuery.setModelClass(Ticket.class);
240    
241                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("ticketId");
242    
243                    return indexableActionableDynamicQuery;
244            }
245    
246            protected void initActionableDynamicQuery(
247                    ActionableDynamicQuery actionableDynamicQuery) {
248                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.TicketLocalServiceUtil.getService());
249                    actionableDynamicQuery.setClassLoader(getClassLoader());
250                    actionableDynamicQuery.setModelClass(Ticket.class);
251    
252                    actionableDynamicQuery.setPrimaryKeyPropertyName("ticketId");
253            }
254    
255            /**
256             * @throws PortalException
257             */
258            @Override
259            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
260                    throws PortalException {
261                    return ticketLocalService.deleteTicket((Ticket)persistedModel);
262            }
263    
264            @Override
265            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
266                    throws PortalException {
267                    return ticketPersistence.findByPrimaryKey(primaryKeyObj);
268            }
269    
270            /**
271             * Returns a range of all the tickets.
272             *
273             * <p>
274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.TicketModelImpl}. 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.
275             * </p>
276             *
277             * @param start the lower bound of the range of tickets
278             * @param end the upper bound of the range of tickets (not inclusive)
279             * @return the range of tickets
280             */
281            @Override
282            public List<Ticket> getTickets(int start, int end) {
283                    return ticketPersistence.findAll(start, end);
284            }
285    
286            /**
287             * Returns the number of tickets.
288             *
289             * @return the number of tickets
290             */
291            @Override
292            public int getTicketsCount() {
293                    return ticketPersistence.countAll();
294            }
295    
296            /**
297             * Updates the ticket in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
298             *
299             * @param ticket the ticket
300             * @return the ticket that was updated
301             */
302            @Indexable(type = IndexableType.REINDEX)
303            @Override
304            public Ticket updateTicket(Ticket ticket) {
305                    return ticketPersistence.update(ticket);
306            }
307    
308            /**
309             * Returns the ticket local service.
310             *
311             * @return the ticket local service
312             */
313            public TicketLocalService getTicketLocalService() {
314                    return ticketLocalService;
315            }
316    
317            /**
318             * Sets the ticket local service.
319             *
320             * @param ticketLocalService the ticket local service
321             */
322            public void setTicketLocalService(TicketLocalService ticketLocalService) {
323                    this.ticketLocalService = ticketLocalService;
324            }
325    
326            /**
327             * Returns the ticket persistence.
328             *
329             * @return the ticket persistence
330             */
331            public TicketPersistence getTicketPersistence() {
332                    return ticketPersistence;
333            }
334    
335            /**
336             * Sets the ticket persistence.
337             *
338             * @param ticketPersistence the ticket persistence
339             */
340            public void setTicketPersistence(TicketPersistence ticketPersistence) {
341                    this.ticketPersistence = ticketPersistence;
342            }
343    
344            /**
345             * Returns the counter local service.
346             *
347             * @return the counter local service
348             */
349            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
350                    return counterLocalService;
351            }
352    
353            /**
354             * Sets the counter local service.
355             *
356             * @param counterLocalService the counter local service
357             */
358            public void setCounterLocalService(
359                    com.liferay.counter.service.CounterLocalService counterLocalService) {
360                    this.counterLocalService = counterLocalService;
361            }
362    
363            /**
364             * Returns the class name local service.
365             *
366             * @return the class name local service
367             */
368            public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
369                    return classNameLocalService;
370            }
371    
372            /**
373             * Sets the class name local service.
374             *
375             * @param classNameLocalService the class name local service
376             */
377            public void setClassNameLocalService(
378                    com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
379                    this.classNameLocalService = classNameLocalService;
380            }
381    
382            /**
383             * Returns the class name persistence.
384             *
385             * @return the class name persistence
386             */
387            public ClassNamePersistence getClassNamePersistence() {
388                    return classNamePersistence;
389            }
390    
391            /**
392             * Sets the class name persistence.
393             *
394             * @param classNamePersistence the class name persistence
395             */
396            public void setClassNamePersistence(
397                    ClassNamePersistence classNamePersistence) {
398                    this.classNamePersistence = classNamePersistence;
399            }
400    
401            public void afterPropertiesSet() {
402                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Ticket",
403                            ticketLocalService);
404            }
405    
406            public void destroy() {
407                    persistedModelLocalServiceRegistry.unregister(
408                            "com.liferay.portal.model.Ticket");
409            }
410    
411            /**
412             * Returns the OSGi service identifier.
413             *
414             * @return the OSGi service identifier
415             */
416            @Override
417            public String getOSGiServiceIdentifier() {
418                    return TicketLocalService.class.getName();
419            }
420    
421            protected Class<?> getModelClass() {
422                    return Ticket.class;
423            }
424    
425            protected String getModelClassName() {
426                    return Ticket.class.getName();
427            }
428    
429            /**
430             * Performs a SQL query.
431             *
432             * @param sql the sql query
433             */
434            protected void runSQL(String sql) {
435                    try {
436                            DataSource dataSource = ticketPersistence.getDataSource();
437    
438                            DB db = DBManagerUtil.getDB();
439    
440                            sql = db.buildSQL(sql);
441                            sql = PortalUtil.transformSQL(sql);
442    
443                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
444                                            sql, new int[0]);
445    
446                            sqlUpdate.update();
447                    }
448                    catch (Exception e) {
449                            throw new SystemException(e);
450                    }
451            }
452    
453            @BeanReference(type = com.liferay.portal.service.TicketLocalService.class)
454            protected TicketLocalService ticketLocalService;
455            @BeanReference(type = TicketPersistence.class)
456            protected TicketPersistence ticketPersistence;
457            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
458            protected com.liferay.counter.service.CounterLocalService counterLocalService;
459            @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
460            protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
461            @BeanReference(type = ClassNamePersistence.class)
462            protected ClassNamePersistence classNamePersistence;
463            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
464            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
465    }