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