001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.polls.service.base;
016    
017    import com.liferay.counter.service.CounterLocalService;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.bean.IdentifiableBean;
021    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
023    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
024    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
025    import com.liferay.portal.kernel.exception.PortalException;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.search.Indexable;
028    import com.liferay.portal.kernel.search.IndexableType;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.model.PersistedModel;
031    import com.liferay.portal.service.BaseLocalServiceImpl;
032    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
033    import com.liferay.portal.service.ResourceLocalService;
034    import com.liferay.portal.service.UserLocalService;
035    import com.liferay.portal.service.UserService;
036    import com.liferay.portal.service.persistence.UserFinder;
037    import com.liferay.portal.service.persistence.UserPersistence;
038    
039    import com.liferay.portlet.polls.model.PollsChoice;
040    import com.liferay.portlet.polls.service.PollsChoiceLocalService;
041    import com.liferay.portlet.polls.service.PollsChoiceService;
042    import com.liferay.portlet.polls.service.PollsQuestionLocalService;
043    import com.liferay.portlet.polls.service.PollsQuestionService;
044    import com.liferay.portlet.polls.service.PollsVoteLocalService;
045    import com.liferay.portlet.polls.service.PollsVoteService;
046    import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
047    import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
048    import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
049    import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
050    
051    import java.io.Serializable;
052    
053    import java.util.List;
054    
055    import javax.sql.DataSource;
056    
057    /**
058     * The base implementation of the polls choice local service.
059     *
060     * <p>
061     * 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.polls.service.impl.PollsChoiceLocalServiceImpl}.
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see com.liferay.portlet.polls.service.impl.PollsChoiceLocalServiceImpl
066     * @see com.liferay.portlet.polls.service.PollsChoiceLocalServiceUtil
067     * @generated
068     */
069    public abstract class PollsChoiceLocalServiceBaseImpl
070            extends BaseLocalServiceImpl implements PollsChoiceLocalService,
071                    IdentifiableBean {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.polls.service.PollsChoiceLocalServiceUtil} to access the polls choice local service.
076             */
077    
078            /**
079             * Adds the polls choice to the database. Also notifies the appropriate model listeners.
080             *
081             * @param pollsChoice the polls choice
082             * @return the polls choice that was added
083             * @throws SystemException if a system exception occurred
084             */
085            @Indexable(type = IndexableType.REINDEX)
086            public PollsChoice addPollsChoice(PollsChoice pollsChoice)
087                    throws SystemException {
088                    pollsChoice.setNew(true);
089    
090                    return pollsChoicePersistence.update(pollsChoice);
091            }
092    
093            /**
094             * Creates a new polls choice with the primary key. Does not add the polls choice to the database.
095             *
096             * @param choiceId the primary key for the new polls choice
097             * @return the new polls choice
098             */
099            public PollsChoice createPollsChoice(long choiceId) {
100                    return pollsChoicePersistence.create(choiceId);
101            }
102    
103            /**
104             * Deletes the polls choice with the primary key from the database. Also notifies the appropriate model listeners.
105             *
106             * @param choiceId the primary key of the polls choice
107             * @return the polls choice that was removed
108             * @throws PortalException if a polls choice with the primary key could not be found
109             * @throws SystemException if a system exception occurred
110             */
111            @Indexable(type = IndexableType.DELETE)
112            public PollsChoice deletePollsChoice(long choiceId)
113                    throws PortalException, SystemException {
114                    return pollsChoicePersistence.remove(choiceId);
115            }
116    
117            /**
118             * Deletes the polls choice from the database. Also notifies the appropriate model listeners.
119             *
120             * @param pollsChoice the polls choice
121             * @return the polls choice that was removed
122             * @throws SystemException if a system exception occurred
123             */
124            @Indexable(type = IndexableType.DELETE)
125            public PollsChoice deletePollsChoice(PollsChoice pollsChoice)
126                    throws SystemException {
127                    return pollsChoicePersistence.remove(pollsChoice);
128            }
129    
130            public DynamicQuery dynamicQuery() {
131                    Class<?> clazz = getClass();
132    
133                    return DynamicQueryFactoryUtil.forClass(PollsChoice.class,
134                            clazz.getClassLoader());
135            }
136    
137            /**
138             * Performs a dynamic query on the database and returns the matching rows.
139             *
140             * @param dynamicQuery the dynamic query
141             * @return the matching rows
142             * @throws SystemException if a system exception occurred
143             */
144            @SuppressWarnings("rawtypes")
145            public List dynamicQuery(DynamicQuery dynamicQuery)
146                    throws SystemException {
147                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery);
148            }
149    
150            /**
151             * Performs a dynamic query on the database and returns a range of the matching rows.
152             *
153             * <p>
154             * 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.polls.model.impl.PollsChoiceModelImpl}. 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.
155             * </p>
156             *
157             * @param dynamicQuery the dynamic query
158             * @param start the lower bound of the range of model instances
159             * @param end the upper bound of the range of model instances (not inclusive)
160             * @return the range of matching rows
161             * @throws SystemException if a system exception occurred
162             */
163            @SuppressWarnings("rawtypes")
164            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
165                    throws SystemException {
166                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
167                            end);
168            }
169    
170            /**
171             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
172             *
173             * <p>
174             * 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.polls.model.impl.PollsChoiceModelImpl}. 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.
175             * </p>
176             *
177             * @param dynamicQuery the dynamic query
178             * @param start the lower bound of the range of model instances
179             * @param end the upper bound of the range of model instances (not inclusive)
180             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
181             * @return the ordered range of matching rows
182             * @throws SystemException if a system exception occurred
183             */
184            @SuppressWarnings("rawtypes")
185            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
186                    OrderByComparator orderByComparator) throws SystemException {
187                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
188                            end, orderByComparator);
189            }
190    
191            /**
192             * Returns the number of rows that match the dynamic query.
193             *
194             * @param dynamicQuery the dynamic query
195             * @return the number of rows that match the dynamic query
196             * @throws SystemException if a system exception occurred
197             */
198            public long dynamicQueryCount(DynamicQuery dynamicQuery)
199                    throws SystemException {
200                    return pollsChoicePersistence.countWithDynamicQuery(dynamicQuery);
201            }
202    
203            public PollsChoice fetchPollsChoice(long choiceId)
204                    throws SystemException {
205                    return pollsChoicePersistence.fetchByPrimaryKey(choiceId);
206            }
207    
208            /**
209             * Returns the polls choice with the primary key.
210             *
211             * @param choiceId the primary key of the polls choice
212             * @return the polls choice
213             * @throws PortalException if a polls choice with the primary key could not be found
214             * @throws SystemException if a system exception occurred
215             */
216            public PollsChoice getPollsChoice(long choiceId)
217                    throws PortalException, SystemException {
218                    return pollsChoicePersistence.findByPrimaryKey(choiceId);
219            }
220    
221            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
222                    throws PortalException, SystemException {
223                    return pollsChoicePersistence.findByPrimaryKey(primaryKeyObj);
224            }
225    
226            /**
227             * Returns a range of all the polls choices.
228             *
229             * <p>
230             * 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.polls.model.impl.PollsChoiceModelImpl}. 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.
231             * </p>
232             *
233             * @param start the lower bound of the range of polls choices
234             * @param end the upper bound of the range of polls choices (not inclusive)
235             * @return the range of polls choices
236             * @throws SystemException if a system exception occurred
237             */
238            public List<PollsChoice> getPollsChoices(int start, int end)
239                    throws SystemException {
240                    return pollsChoicePersistence.findAll(start, end);
241            }
242    
243            /**
244             * Returns the number of polls choices.
245             *
246             * @return the number of polls choices
247             * @throws SystemException if a system exception occurred
248             */
249            public int getPollsChoicesCount() throws SystemException {
250                    return pollsChoicePersistence.countAll();
251            }
252    
253            /**
254             * Updates the polls choice in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
255             *
256             * @param pollsChoice the polls choice
257             * @return the polls choice that was updated
258             * @throws SystemException if a system exception occurred
259             */
260            @Indexable(type = IndexableType.REINDEX)
261            public PollsChoice updatePollsChoice(PollsChoice pollsChoice)
262                    throws SystemException {
263                    return pollsChoicePersistence.update(pollsChoice);
264            }
265    
266            /**
267             * Returns the polls choice local service.
268             *
269             * @return the polls choice local service
270             */
271            public PollsChoiceLocalService getPollsChoiceLocalService() {
272                    return pollsChoiceLocalService;
273            }
274    
275            /**
276             * Sets the polls choice local service.
277             *
278             * @param pollsChoiceLocalService the polls choice local service
279             */
280            public void setPollsChoiceLocalService(
281                    PollsChoiceLocalService pollsChoiceLocalService) {
282                    this.pollsChoiceLocalService = pollsChoiceLocalService;
283            }
284    
285            /**
286             * Returns the polls choice remote service.
287             *
288             * @return the polls choice remote service
289             */
290            public PollsChoiceService getPollsChoiceService() {
291                    return pollsChoiceService;
292            }
293    
294            /**
295             * Sets the polls choice remote service.
296             *
297             * @param pollsChoiceService the polls choice remote service
298             */
299            public void setPollsChoiceService(PollsChoiceService pollsChoiceService) {
300                    this.pollsChoiceService = pollsChoiceService;
301            }
302    
303            /**
304             * Returns the polls choice persistence.
305             *
306             * @return the polls choice persistence
307             */
308            public PollsChoicePersistence getPollsChoicePersistence() {
309                    return pollsChoicePersistence;
310            }
311    
312            /**
313             * Sets the polls choice persistence.
314             *
315             * @param pollsChoicePersistence the polls choice persistence
316             */
317            public void setPollsChoicePersistence(
318                    PollsChoicePersistence pollsChoicePersistence) {
319                    this.pollsChoicePersistence = pollsChoicePersistence;
320            }
321    
322            /**
323             * Returns the polls choice finder.
324             *
325             * @return the polls choice finder
326             */
327            public PollsChoiceFinder getPollsChoiceFinder() {
328                    return pollsChoiceFinder;
329            }
330    
331            /**
332             * Sets the polls choice finder.
333             *
334             * @param pollsChoiceFinder the polls choice finder
335             */
336            public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
337                    this.pollsChoiceFinder = pollsChoiceFinder;
338            }
339    
340            /**
341             * Returns the polls question local service.
342             *
343             * @return the polls question local service
344             */
345            public PollsQuestionLocalService getPollsQuestionLocalService() {
346                    return pollsQuestionLocalService;
347            }
348    
349            /**
350             * Sets the polls question local service.
351             *
352             * @param pollsQuestionLocalService the polls question local service
353             */
354            public void setPollsQuestionLocalService(
355                    PollsQuestionLocalService pollsQuestionLocalService) {
356                    this.pollsQuestionLocalService = pollsQuestionLocalService;
357            }
358    
359            /**
360             * Returns the polls question remote service.
361             *
362             * @return the polls question remote service
363             */
364            public PollsQuestionService getPollsQuestionService() {
365                    return pollsQuestionService;
366            }
367    
368            /**
369             * Sets the polls question remote service.
370             *
371             * @param pollsQuestionService the polls question remote service
372             */
373            public void setPollsQuestionService(
374                    PollsQuestionService pollsQuestionService) {
375                    this.pollsQuestionService = pollsQuestionService;
376            }
377    
378            /**
379             * Returns the polls question persistence.
380             *
381             * @return the polls question persistence
382             */
383            public PollsQuestionPersistence getPollsQuestionPersistence() {
384                    return pollsQuestionPersistence;
385            }
386    
387            /**
388             * Sets the polls question persistence.
389             *
390             * @param pollsQuestionPersistence the polls question persistence
391             */
392            public void setPollsQuestionPersistence(
393                    PollsQuestionPersistence pollsQuestionPersistence) {
394                    this.pollsQuestionPersistence = pollsQuestionPersistence;
395            }
396    
397            /**
398             * Returns the polls vote local service.
399             *
400             * @return the polls vote local service
401             */
402            public PollsVoteLocalService getPollsVoteLocalService() {
403                    return pollsVoteLocalService;
404            }
405    
406            /**
407             * Sets the polls vote local service.
408             *
409             * @param pollsVoteLocalService the polls vote local service
410             */
411            public void setPollsVoteLocalService(
412                    PollsVoteLocalService pollsVoteLocalService) {
413                    this.pollsVoteLocalService = pollsVoteLocalService;
414            }
415    
416            /**
417             * Returns the polls vote remote service.
418             *
419             * @return the polls vote remote service
420             */
421            public PollsVoteService getPollsVoteService() {
422                    return pollsVoteService;
423            }
424    
425            /**
426             * Sets the polls vote remote service.
427             *
428             * @param pollsVoteService the polls vote remote service
429             */
430            public void setPollsVoteService(PollsVoteService pollsVoteService) {
431                    this.pollsVoteService = pollsVoteService;
432            }
433    
434            /**
435             * Returns the polls vote persistence.
436             *
437             * @return the polls vote persistence
438             */
439            public PollsVotePersistence getPollsVotePersistence() {
440                    return pollsVotePersistence;
441            }
442    
443            /**
444             * Sets the polls vote persistence.
445             *
446             * @param pollsVotePersistence the polls vote persistence
447             */
448            public void setPollsVotePersistence(
449                    PollsVotePersistence pollsVotePersistence) {
450                    this.pollsVotePersistence = pollsVotePersistence;
451            }
452    
453            /**
454             * Returns the counter local service.
455             *
456             * @return the counter local service
457             */
458            public CounterLocalService getCounterLocalService() {
459                    return counterLocalService;
460            }
461    
462            /**
463             * Sets the counter local service.
464             *
465             * @param counterLocalService the counter local service
466             */
467            public void setCounterLocalService(CounterLocalService counterLocalService) {
468                    this.counterLocalService = counterLocalService;
469            }
470    
471            /**
472             * Returns the resource local service.
473             *
474             * @return the resource local service
475             */
476            public ResourceLocalService getResourceLocalService() {
477                    return resourceLocalService;
478            }
479    
480            /**
481             * Sets the resource local service.
482             *
483             * @param resourceLocalService the resource local service
484             */
485            public void setResourceLocalService(
486                    ResourceLocalService resourceLocalService) {
487                    this.resourceLocalService = resourceLocalService;
488            }
489    
490            /**
491             * Returns the user local service.
492             *
493             * @return the user local service
494             */
495            public UserLocalService getUserLocalService() {
496                    return userLocalService;
497            }
498    
499            /**
500             * Sets the user local service.
501             *
502             * @param userLocalService the user local service
503             */
504            public void setUserLocalService(UserLocalService userLocalService) {
505                    this.userLocalService = userLocalService;
506            }
507    
508            /**
509             * Returns the user remote service.
510             *
511             * @return the user remote service
512             */
513            public UserService getUserService() {
514                    return userService;
515            }
516    
517            /**
518             * Sets the user remote service.
519             *
520             * @param userService the user remote service
521             */
522            public void setUserService(UserService userService) {
523                    this.userService = userService;
524            }
525    
526            /**
527             * Returns the user persistence.
528             *
529             * @return the user persistence
530             */
531            public UserPersistence getUserPersistence() {
532                    return userPersistence;
533            }
534    
535            /**
536             * Sets the user persistence.
537             *
538             * @param userPersistence the user persistence
539             */
540            public void setUserPersistence(UserPersistence userPersistence) {
541                    this.userPersistence = userPersistence;
542            }
543    
544            /**
545             * Returns the user finder.
546             *
547             * @return the user finder
548             */
549            public UserFinder getUserFinder() {
550                    return userFinder;
551            }
552    
553            /**
554             * Sets the user finder.
555             *
556             * @param userFinder the user finder
557             */
558            public void setUserFinder(UserFinder userFinder) {
559                    this.userFinder = userFinder;
560            }
561    
562            public void afterPropertiesSet() {
563                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsChoice",
564                            pollsChoiceLocalService);
565            }
566    
567            public void destroy() {
568                    persistedModelLocalServiceRegistry.unregister(
569                            "com.liferay.portlet.polls.model.PollsChoice");
570            }
571    
572            /**
573             * Returns the Spring bean ID for this bean.
574             *
575             * @return the Spring bean ID for this bean
576             */
577            public String getBeanIdentifier() {
578                    return _beanIdentifier;
579            }
580    
581            /**
582             * Sets the Spring bean ID for this bean.
583             *
584             * @param beanIdentifier the Spring bean ID for this bean
585             */
586            public void setBeanIdentifier(String beanIdentifier) {
587                    _beanIdentifier = beanIdentifier;
588            }
589    
590            protected Class<?> getModelClass() {
591                    return PollsChoice.class;
592            }
593    
594            protected String getModelClassName() {
595                    return PollsChoice.class.getName();
596            }
597    
598            /**
599             * Performs an SQL query.
600             *
601             * @param sql the sql query
602             */
603            protected void runSQL(String sql) throws SystemException {
604                    try {
605                            DataSource dataSource = pollsChoicePersistence.getDataSource();
606    
607                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
608                                            sql, new int[0]);
609    
610                            sqlUpdate.update();
611                    }
612                    catch (Exception e) {
613                            throw new SystemException(e);
614                    }
615            }
616    
617            @BeanReference(type = PollsChoiceLocalService.class)
618            protected PollsChoiceLocalService pollsChoiceLocalService;
619            @BeanReference(type = PollsChoiceService.class)
620            protected PollsChoiceService pollsChoiceService;
621            @BeanReference(type = PollsChoicePersistence.class)
622            protected PollsChoicePersistence pollsChoicePersistence;
623            @BeanReference(type = PollsChoiceFinder.class)
624            protected PollsChoiceFinder pollsChoiceFinder;
625            @BeanReference(type = PollsQuestionLocalService.class)
626            protected PollsQuestionLocalService pollsQuestionLocalService;
627            @BeanReference(type = PollsQuestionService.class)
628            protected PollsQuestionService pollsQuestionService;
629            @BeanReference(type = PollsQuestionPersistence.class)
630            protected PollsQuestionPersistence pollsQuestionPersistence;
631            @BeanReference(type = PollsVoteLocalService.class)
632            protected PollsVoteLocalService pollsVoteLocalService;
633            @BeanReference(type = PollsVoteService.class)
634            protected PollsVoteService pollsVoteService;
635            @BeanReference(type = PollsVotePersistence.class)
636            protected PollsVotePersistence pollsVotePersistence;
637            @BeanReference(type = CounterLocalService.class)
638            protected CounterLocalService counterLocalService;
639            @BeanReference(type = ResourceLocalService.class)
640            protected ResourceLocalService resourceLocalService;
641            @BeanReference(type = UserLocalService.class)
642            protected UserLocalService userLocalService;
643            @BeanReference(type = UserService.class)
644            protected UserService userService;
645            @BeanReference(type = UserPersistence.class)
646            protected UserPersistence userPersistence;
647            @BeanReference(type = UserFinder.class)
648            protected UserFinder userFinder;
649            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
650            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
651            private String _beanIdentifier;
652    }