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.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.db.DB;
022    import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
028    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
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.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.model.Ticket;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.service.TicketLocalService;
040    import com.liferay.portal.service.persistence.ClassNamePersistence;
041    import com.liferay.portal.service.persistence.TicketPersistence;
042    import com.liferay.portal.util.PortalUtil;
043    
044    import java.io.Serializable;
045    
046    import java.util.List;
047    
048    import javax.sql.DataSource;
049    
050    /**
051     * Provides the base implementation for the ticket local service.
052     *
053     * <p>
054     * 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}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see com.liferay.portal.service.impl.TicketLocalServiceImpl
059     * @see com.liferay.portal.service.TicketLocalServiceUtil
060     * @generated
061     */
062    @ProviderType
063    public abstract class TicketLocalServiceBaseImpl extends BaseLocalServiceImpl
064            implements TicketLocalService, IdentifiableBean {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.TicketLocalServiceUtil} to access the ticket local service.
069             */
070    
071            /**
072             * Adds the ticket to the database. Also notifies the appropriate model listeners.
073             *
074             * @param ticket the ticket
075             * @return the ticket that was added
076             */
077            @Indexable(type = IndexableType.REINDEX)
078            @Override
079            public Ticket addTicket(Ticket ticket) {
080                    ticket.setNew(true);
081    
082                    return ticketPersistence.update(ticket);
083            }
084    
085            /**
086             * Creates a new ticket with the primary key. Does not add the ticket to the database.
087             *
088             * @param ticketId the primary key for the new ticket
089             * @return the new ticket
090             */
091            @Override
092            public Ticket createTicket(long ticketId) {
093                    return ticketPersistence.create(ticketId);
094            }
095    
096            /**
097             * Deletes the ticket with the primary key from the database. Also notifies the appropriate model listeners.
098             *
099             * @param ticketId the primary key of the ticket
100             * @return the ticket that was removed
101             * @throws PortalException if a ticket with the primary key could not be found
102             */
103            @Indexable(type = IndexableType.DELETE)
104            @Override
105            public Ticket deleteTicket(long ticketId) throws PortalException {
106                    return ticketPersistence.remove(ticketId);
107            }
108    
109            /**
110             * Deletes the ticket from the database. Also notifies the appropriate model listeners.
111             *
112             * @param ticket the ticket
113             * @return the ticket that was removed
114             */
115            @Indexable(type = IndexableType.DELETE)
116            @Override
117            public Ticket deleteTicket(Ticket ticket) {
118                    return ticketPersistence.remove(ticket);
119            }
120    
121            @Override
122            public DynamicQuery dynamicQuery() {
123                    Class<?> clazz = getClass();
124    
125                    return DynamicQueryFactoryUtil.forClass(Ticket.class,
126                            clazz.getClassLoader());
127            }
128    
129            /**
130             * Performs a dynamic query on the database and returns the matching rows.
131             *
132             * @param dynamicQuery the dynamic query
133             * @return the matching rows
134             */
135            @Override
136            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
137                    return ticketPersistence.findWithDynamicQuery(dynamicQuery);
138            }
139    
140            /**
141             * Performs a dynamic query on the database and returns a range of the matching rows.
142             *
143             * <p>
144             * 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.
145             * </p>
146             *
147             * @param dynamicQuery the dynamic query
148             * @param start the lower bound of the range of model instances
149             * @param end the upper bound of the range of model instances (not inclusive)
150             * @return the range of matching rows
151             */
152            @Override
153            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
154                    int end) {
155                    return ticketPersistence.findWithDynamicQuery(dynamicQuery, start, end);
156            }
157    
158            /**
159             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
160             *
161             * <p>
162             * 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.
163             * </p>
164             *
165             * @param dynamicQuery the dynamic query
166             * @param start the lower bound of the range of model instances
167             * @param end the upper bound of the range of model instances (not inclusive)
168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
169             * @return the ordered range of matching rows
170             */
171            @Override
172            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
173                    int end, OrderByComparator<T> orderByComparator) {
174                    return ticketPersistence.findWithDynamicQuery(dynamicQuery, start, end,
175                            orderByComparator);
176            }
177    
178            /**
179             * Returns the number of rows matching the dynamic query.
180             *
181             * @param dynamicQuery the dynamic query
182             * @return the number of rows matching the dynamic query
183             */
184            @Override
185            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
186                    return ticketPersistence.countWithDynamicQuery(dynamicQuery);
187            }
188    
189            /**
190             * Returns the number of rows matching the dynamic query.
191             *
192             * @param dynamicQuery the dynamic query
193             * @param projection the projection to apply to the query
194             * @return the number of rows matching the dynamic query
195             */
196            @Override
197            public long dynamicQueryCount(DynamicQuery dynamicQuery,
198                    Projection projection) {
199                    return ticketPersistence.countWithDynamicQuery(dynamicQuery, projection);
200            }
201    
202            @Override
203            public Ticket fetchTicket(long ticketId) {
204                    return ticketPersistence.fetchByPrimaryKey(ticketId);
205            }
206    
207            /**
208             * Returns the ticket with the primary key.
209             *
210             * @param ticketId the primary key of the ticket
211             * @return the ticket
212             * @throws PortalException if a ticket with the primary key could not be found
213             */
214            @Override
215            public Ticket getTicket(long ticketId) throws PortalException {
216                    return ticketPersistence.findByPrimaryKey(ticketId);
217            }
218    
219            @Override
220            public ActionableDynamicQuery getActionableDynamicQuery() {
221                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
222    
223                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.TicketLocalServiceUtil.getService());
224                    actionableDynamicQuery.setClass(Ticket.class);
225                    actionableDynamicQuery.setClassLoader(getClassLoader());
226    
227                    actionableDynamicQuery.setPrimaryKeyPropertyName("ticketId");
228    
229                    return actionableDynamicQuery;
230            }
231    
232            protected void initActionableDynamicQuery(
233                    ActionableDynamicQuery actionableDynamicQuery) {
234                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.TicketLocalServiceUtil.getService());
235                    actionableDynamicQuery.setClass(Ticket.class);
236                    actionableDynamicQuery.setClassLoader(getClassLoader());
237    
238                    actionableDynamicQuery.setPrimaryKeyPropertyName("ticketId");
239            }
240    
241            /**
242             * @throws PortalException
243             */
244            @Override
245            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
246                    throws PortalException {
247                    return ticketLocalService.deleteTicket((Ticket)persistedModel);
248            }
249    
250            @Override
251            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
252                    throws PortalException {
253                    return ticketPersistence.findByPrimaryKey(primaryKeyObj);
254            }
255    
256            /**
257             * Returns a range of all the tickets.
258             *
259             * <p>
260             * 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.
261             * </p>
262             *
263             * @param start the lower bound of the range of tickets
264             * @param end the upper bound of the range of tickets (not inclusive)
265             * @return the range of tickets
266             */
267            @Override
268            public List<Ticket> getTickets(int start, int end) {
269                    return ticketPersistence.findAll(start, end);
270            }
271    
272            /**
273             * Returns the number of tickets.
274             *
275             * @return the number of tickets
276             */
277            @Override
278            public int getTicketsCount() {
279                    return ticketPersistence.countAll();
280            }
281    
282            /**
283             * Updates the ticket in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
284             *
285             * @param ticket the ticket
286             * @return the ticket that was updated
287             */
288            @Indexable(type = IndexableType.REINDEX)
289            @Override
290            public Ticket updateTicket(Ticket ticket) {
291                    return ticketPersistence.update(ticket);
292            }
293    
294            /**
295             * Returns the ticket local service.
296             *
297             * @return the ticket local service
298             */
299            public com.liferay.portal.service.TicketLocalService getTicketLocalService() {
300                    return ticketLocalService;
301            }
302    
303            /**
304             * Sets the ticket local service.
305             *
306             * @param ticketLocalService the ticket local service
307             */
308            public void setTicketLocalService(
309                    com.liferay.portal.service.TicketLocalService ticketLocalService) {
310                    this.ticketLocalService = ticketLocalService;
311            }
312    
313            /**
314             * Returns the ticket persistence.
315             *
316             * @return the ticket persistence
317             */
318            public TicketPersistence getTicketPersistence() {
319                    return ticketPersistence;
320            }
321    
322            /**
323             * Sets the ticket persistence.
324             *
325             * @param ticketPersistence the ticket persistence
326             */
327            public void setTicketPersistence(TicketPersistence ticketPersistence) {
328                    this.ticketPersistence = ticketPersistence;
329            }
330    
331            /**
332             * Returns the counter local service.
333             *
334             * @return the counter local service
335             */
336            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
337                    return counterLocalService;
338            }
339    
340            /**
341             * Sets the counter local service.
342             *
343             * @param counterLocalService the counter local service
344             */
345            public void setCounterLocalService(
346                    com.liferay.counter.service.CounterLocalService counterLocalService) {
347                    this.counterLocalService = counterLocalService;
348            }
349    
350            /**
351             * Returns the class name local service.
352             *
353             * @return the class name local service
354             */
355            public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
356                    return classNameLocalService;
357            }
358    
359            /**
360             * Sets the class name local service.
361             *
362             * @param classNameLocalService the class name local service
363             */
364            public void setClassNameLocalService(
365                    com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
366                    this.classNameLocalService = classNameLocalService;
367            }
368    
369            /**
370             * Returns the class name remote service.
371             *
372             * @return the class name remote service
373             */
374            public com.liferay.portal.service.ClassNameService getClassNameService() {
375                    return classNameService;
376            }
377    
378            /**
379             * Sets the class name remote service.
380             *
381             * @param classNameService the class name remote service
382             */
383            public void setClassNameService(
384                    com.liferay.portal.service.ClassNameService classNameService) {
385                    this.classNameService = classNameService;
386            }
387    
388            /**
389             * Returns the class name persistence.
390             *
391             * @return the class name persistence
392             */
393            public ClassNamePersistence getClassNamePersistence() {
394                    return classNamePersistence;
395            }
396    
397            /**
398             * Sets the class name persistence.
399             *
400             * @param classNamePersistence the class name persistence
401             */
402            public void setClassNamePersistence(
403                    ClassNamePersistence classNamePersistence) {
404                    this.classNamePersistence = classNamePersistence;
405            }
406    
407            public void afterPropertiesSet() {
408                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.Ticket",
409                            ticketLocalService);
410            }
411    
412            public void destroy() {
413                    persistedModelLocalServiceRegistry.unregister(
414                            "com.liferay.portal.model.Ticket");
415            }
416    
417            /**
418             * Returns the Spring bean ID for this bean.
419             *
420             * @return the Spring bean ID for this bean
421             */
422            @Override
423            public String getBeanIdentifier() {
424                    return _beanIdentifier;
425            }
426    
427            /**
428             * Sets the Spring bean ID for this bean.
429             *
430             * @param beanIdentifier the Spring bean ID for this bean
431             */
432            @Override
433            public void setBeanIdentifier(String beanIdentifier) {
434                    _beanIdentifier = beanIdentifier;
435            }
436    
437            protected Class<?> getModelClass() {
438                    return Ticket.class;
439            }
440    
441            protected String getModelClassName() {
442                    return Ticket.class.getName();
443            }
444    
445            /**
446             * Performs a SQL query.
447             *
448             * @param sql the sql query
449             */
450            protected void runSQL(String sql) {
451                    try {
452                            DataSource dataSource = ticketPersistence.getDataSource();
453    
454                            DB db = DBFactoryUtil.getDB();
455    
456                            sql = db.buildSQL(sql);
457                            sql = PortalUtil.transformSQL(sql);
458    
459                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
460                                            sql, new int[0]);
461    
462                            sqlUpdate.update();
463                    }
464                    catch (Exception e) {
465                            throw new SystemException(e);
466                    }
467            }
468    
469            @BeanReference(type = com.liferay.portal.service.TicketLocalService.class)
470            protected com.liferay.portal.service.TicketLocalService ticketLocalService;
471            @BeanReference(type = TicketPersistence.class)
472            protected TicketPersistence ticketPersistence;
473            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
474            protected com.liferay.counter.service.CounterLocalService counterLocalService;
475            @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
476            protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
477            @BeanReference(type = com.liferay.portal.service.ClassNameService.class)
478            protected com.liferay.portal.service.ClassNameService classNameService;
479            @BeanReference(type = ClassNamePersistence.class)
480            protected ClassNamePersistence classNamePersistence;
481            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
482            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
483            private String _beanIdentifier;
484    }