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.expando.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.expando.model.ExpandoTable;
040    import com.liferay.portlet.expando.service.ExpandoColumnLocalService;
041    import com.liferay.portlet.expando.service.ExpandoColumnService;
042    import com.liferay.portlet.expando.service.ExpandoRowLocalService;
043    import com.liferay.portlet.expando.service.ExpandoTableLocalService;
044    import com.liferay.portlet.expando.service.ExpandoValueLocalService;
045    import com.liferay.portlet.expando.service.ExpandoValueService;
046    import com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence;
047    import com.liferay.portlet.expando.service.persistence.ExpandoRowPersistence;
048    import com.liferay.portlet.expando.service.persistence.ExpandoTablePersistence;
049    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
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 expando table 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.expando.service.impl.ExpandoTableLocalServiceImpl}.
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see com.liferay.portlet.expando.service.impl.ExpandoTableLocalServiceImpl
066     * @see com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil
067     * @generated
068     */
069    public abstract class ExpandoTableLocalServiceBaseImpl
070            extends BaseLocalServiceImpl implements ExpandoTableLocalService,
071                    IdentifiableBean {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil} to access the expando table local service.
076             */
077    
078            /**
079             * Adds the expando table to the database. Also notifies the appropriate model listeners.
080             *
081             * @param expandoTable the expando table
082             * @return the expando table that was added
083             * @throws SystemException if a system exception occurred
084             */
085            @Indexable(type = IndexableType.REINDEX)
086            public ExpandoTable addExpandoTable(ExpandoTable expandoTable)
087                    throws SystemException {
088                    expandoTable.setNew(true);
089    
090                    return expandoTablePersistence.update(expandoTable);
091            }
092    
093            /**
094             * Creates a new expando table with the primary key. Does not add the expando table to the database.
095             *
096             * @param tableId the primary key for the new expando table
097             * @return the new expando table
098             */
099            public ExpandoTable createExpandoTable(long tableId) {
100                    return expandoTablePersistence.create(tableId);
101            }
102    
103            /**
104             * Deletes the expando table with the primary key from the database. Also notifies the appropriate model listeners.
105             *
106             * @param tableId the primary key of the expando table
107             * @return the expando table that was removed
108             * @throws PortalException if a expando table with the primary key could not be found
109             * @throws SystemException if a system exception occurred
110             */
111            @Indexable(type = IndexableType.DELETE)
112            public ExpandoTable deleteExpandoTable(long tableId)
113                    throws PortalException, SystemException {
114                    return expandoTablePersistence.remove(tableId);
115            }
116    
117            /**
118             * Deletes the expando table from the database. Also notifies the appropriate model listeners.
119             *
120             * @param expandoTable the expando table
121             * @return the expando table that was removed
122             * @throws SystemException if a system exception occurred
123             */
124            @Indexable(type = IndexableType.DELETE)
125            public ExpandoTable deleteExpandoTable(ExpandoTable expandoTable)
126                    throws SystemException {
127                    return expandoTablePersistence.remove(expandoTable);
128            }
129    
130            public DynamicQuery dynamicQuery() {
131                    Class<?> clazz = getClass();
132    
133                    return DynamicQueryFactoryUtil.forClass(ExpandoTable.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 expandoTablePersistence.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.expando.model.impl.ExpandoTableModelImpl}. 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 expandoTablePersistence.findWithDynamicQuery(dynamicQuery,
167                            start, 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.expando.model.impl.ExpandoTableModelImpl}. 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 expandoTablePersistence.findWithDynamicQuery(dynamicQuery,
188                            start, 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 expandoTablePersistence.countWithDynamicQuery(dynamicQuery);
201            }
202    
203            public ExpandoTable fetchExpandoTable(long tableId)
204                    throws SystemException {
205                    return expandoTablePersistence.fetchByPrimaryKey(tableId);
206            }
207    
208            /**
209             * Returns the expando table with the primary key.
210             *
211             * @param tableId the primary key of the expando table
212             * @return the expando table
213             * @throws PortalException if a expando table with the primary key could not be found
214             * @throws SystemException if a system exception occurred
215             */
216            public ExpandoTable getExpandoTable(long tableId)
217                    throws PortalException, SystemException {
218                    return expandoTablePersistence.findByPrimaryKey(tableId);
219            }
220    
221            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
222                    throws PortalException, SystemException {
223                    return expandoTablePersistence.findByPrimaryKey(primaryKeyObj);
224            }
225    
226            /**
227             * Returns a range of all the expando tables.
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.expando.model.impl.ExpandoTableModelImpl}. 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 expando tables
234             * @param end the upper bound of the range of expando tables (not inclusive)
235             * @return the range of expando tables
236             * @throws SystemException if a system exception occurred
237             */
238            public List<ExpandoTable> getExpandoTables(int start, int end)
239                    throws SystemException {
240                    return expandoTablePersistence.findAll(start, end);
241            }
242    
243            /**
244             * Returns the number of expando tables.
245             *
246             * @return the number of expando tables
247             * @throws SystemException if a system exception occurred
248             */
249            public int getExpandoTablesCount() throws SystemException {
250                    return expandoTablePersistence.countAll();
251            }
252    
253            /**
254             * Updates the expando table in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
255             *
256             * @param expandoTable the expando table
257             * @return the expando table that was updated
258             * @throws SystemException if a system exception occurred
259             */
260            @Indexable(type = IndexableType.REINDEX)
261            public ExpandoTable updateExpandoTable(ExpandoTable expandoTable)
262                    throws SystemException {
263                    return expandoTablePersistence.update(expandoTable);
264            }
265    
266            /**
267             * Returns the expando column local service.
268             *
269             * @return the expando column local service
270             */
271            public ExpandoColumnLocalService getExpandoColumnLocalService() {
272                    return expandoColumnLocalService;
273            }
274    
275            /**
276             * Sets the expando column local service.
277             *
278             * @param expandoColumnLocalService the expando column local service
279             */
280            public void setExpandoColumnLocalService(
281                    ExpandoColumnLocalService expandoColumnLocalService) {
282                    this.expandoColumnLocalService = expandoColumnLocalService;
283            }
284    
285            /**
286             * Returns the expando column remote service.
287             *
288             * @return the expando column remote service
289             */
290            public ExpandoColumnService getExpandoColumnService() {
291                    return expandoColumnService;
292            }
293    
294            /**
295             * Sets the expando column remote service.
296             *
297             * @param expandoColumnService the expando column remote service
298             */
299            public void setExpandoColumnService(
300                    ExpandoColumnService expandoColumnService) {
301                    this.expandoColumnService = expandoColumnService;
302            }
303    
304            /**
305             * Returns the expando column persistence.
306             *
307             * @return the expando column persistence
308             */
309            public ExpandoColumnPersistence getExpandoColumnPersistence() {
310                    return expandoColumnPersistence;
311            }
312    
313            /**
314             * Sets the expando column persistence.
315             *
316             * @param expandoColumnPersistence the expando column persistence
317             */
318            public void setExpandoColumnPersistence(
319                    ExpandoColumnPersistence expandoColumnPersistence) {
320                    this.expandoColumnPersistence = expandoColumnPersistence;
321            }
322    
323            /**
324             * Returns the expando row local service.
325             *
326             * @return the expando row local service
327             */
328            public ExpandoRowLocalService getExpandoRowLocalService() {
329                    return expandoRowLocalService;
330            }
331    
332            /**
333             * Sets the expando row local service.
334             *
335             * @param expandoRowLocalService the expando row local service
336             */
337            public void setExpandoRowLocalService(
338                    ExpandoRowLocalService expandoRowLocalService) {
339                    this.expandoRowLocalService = expandoRowLocalService;
340            }
341    
342            /**
343             * Returns the expando row persistence.
344             *
345             * @return the expando row persistence
346             */
347            public ExpandoRowPersistence getExpandoRowPersistence() {
348                    return expandoRowPersistence;
349            }
350    
351            /**
352             * Sets the expando row persistence.
353             *
354             * @param expandoRowPersistence the expando row persistence
355             */
356            public void setExpandoRowPersistence(
357                    ExpandoRowPersistence expandoRowPersistence) {
358                    this.expandoRowPersistence = expandoRowPersistence;
359            }
360    
361            /**
362             * Returns the expando table local service.
363             *
364             * @return the expando table local service
365             */
366            public ExpandoTableLocalService getExpandoTableLocalService() {
367                    return expandoTableLocalService;
368            }
369    
370            /**
371             * Sets the expando table local service.
372             *
373             * @param expandoTableLocalService the expando table local service
374             */
375            public void setExpandoTableLocalService(
376                    ExpandoTableLocalService expandoTableLocalService) {
377                    this.expandoTableLocalService = expandoTableLocalService;
378            }
379    
380            /**
381             * Returns the expando table persistence.
382             *
383             * @return the expando table persistence
384             */
385            public ExpandoTablePersistence getExpandoTablePersistence() {
386                    return expandoTablePersistence;
387            }
388    
389            /**
390             * Sets the expando table persistence.
391             *
392             * @param expandoTablePersistence the expando table persistence
393             */
394            public void setExpandoTablePersistence(
395                    ExpandoTablePersistence expandoTablePersistence) {
396                    this.expandoTablePersistence = expandoTablePersistence;
397            }
398    
399            /**
400             * Returns the expando value local service.
401             *
402             * @return the expando value local service
403             */
404            public ExpandoValueLocalService getExpandoValueLocalService() {
405                    return expandoValueLocalService;
406            }
407    
408            /**
409             * Sets the expando value local service.
410             *
411             * @param expandoValueLocalService the expando value local service
412             */
413            public void setExpandoValueLocalService(
414                    ExpandoValueLocalService expandoValueLocalService) {
415                    this.expandoValueLocalService = expandoValueLocalService;
416            }
417    
418            /**
419             * Returns the expando value remote service.
420             *
421             * @return the expando value remote service
422             */
423            public ExpandoValueService getExpandoValueService() {
424                    return expandoValueService;
425            }
426    
427            /**
428             * Sets the expando value remote service.
429             *
430             * @param expandoValueService the expando value remote service
431             */
432            public void setExpandoValueService(ExpandoValueService expandoValueService) {
433                    this.expandoValueService = expandoValueService;
434            }
435    
436            /**
437             * Returns the expando value persistence.
438             *
439             * @return the expando value persistence
440             */
441            public ExpandoValuePersistence getExpandoValuePersistence() {
442                    return expandoValuePersistence;
443            }
444    
445            /**
446             * Sets the expando value persistence.
447             *
448             * @param expandoValuePersistence the expando value persistence
449             */
450            public void setExpandoValuePersistence(
451                    ExpandoValuePersistence expandoValuePersistence) {
452                    this.expandoValuePersistence = expandoValuePersistence;
453            }
454    
455            /**
456             * Returns the counter local service.
457             *
458             * @return the counter local service
459             */
460            public CounterLocalService getCounterLocalService() {
461                    return counterLocalService;
462            }
463    
464            /**
465             * Sets the counter local service.
466             *
467             * @param counterLocalService the counter local service
468             */
469            public void setCounterLocalService(CounterLocalService counterLocalService) {
470                    this.counterLocalService = counterLocalService;
471            }
472    
473            /**
474             * Returns the resource local service.
475             *
476             * @return the resource local service
477             */
478            public ResourceLocalService getResourceLocalService() {
479                    return resourceLocalService;
480            }
481    
482            /**
483             * Sets the resource local service.
484             *
485             * @param resourceLocalService the resource local service
486             */
487            public void setResourceLocalService(
488                    ResourceLocalService resourceLocalService) {
489                    this.resourceLocalService = resourceLocalService;
490            }
491    
492            /**
493             * Returns the user local service.
494             *
495             * @return the user local service
496             */
497            public UserLocalService getUserLocalService() {
498                    return userLocalService;
499            }
500    
501            /**
502             * Sets the user local service.
503             *
504             * @param userLocalService the user local service
505             */
506            public void setUserLocalService(UserLocalService userLocalService) {
507                    this.userLocalService = userLocalService;
508            }
509    
510            /**
511             * Returns the user remote service.
512             *
513             * @return the user remote service
514             */
515            public UserService getUserService() {
516                    return userService;
517            }
518    
519            /**
520             * Sets the user remote service.
521             *
522             * @param userService the user remote service
523             */
524            public void setUserService(UserService userService) {
525                    this.userService = userService;
526            }
527    
528            /**
529             * Returns the user persistence.
530             *
531             * @return the user persistence
532             */
533            public UserPersistence getUserPersistence() {
534                    return userPersistence;
535            }
536    
537            /**
538             * Sets the user persistence.
539             *
540             * @param userPersistence the user persistence
541             */
542            public void setUserPersistence(UserPersistence userPersistence) {
543                    this.userPersistence = userPersistence;
544            }
545    
546            /**
547             * Returns the user finder.
548             *
549             * @return the user finder
550             */
551            public UserFinder getUserFinder() {
552                    return userFinder;
553            }
554    
555            /**
556             * Sets the user finder.
557             *
558             * @param userFinder the user finder
559             */
560            public void setUserFinder(UserFinder userFinder) {
561                    this.userFinder = userFinder;
562            }
563    
564            public void afterPropertiesSet() {
565                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.expando.model.ExpandoTable",
566                            expandoTableLocalService);
567            }
568    
569            public void destroy() {
570                    persistedModelLocalServiceRegistry.unregister(
571                            "com.liferay.portlet.expando.model.ExpandoTable");
572            }
573    
574            /**
575             * Returns the Spring bean ID for this bean.
576             *
577             * @return the Spring bean ID for this bean
578             */
579            public String getBeanIdentifier() {
580                    return _beanIdentifier;
581            }
582    
583            /**
584             * Sets the Spring bean ID for this bean.
585             *
586             * @param beanIdentifier the Spring bean ID for this bean
587             */
588            public void setBeanIdentifier(String beanIdentifier) {
589                    _beanIdentifier = beanIdentifier;
590            }
591    
592            protected Class<?> getModelClass() {
593                    return ExpandoTable.class;
594            }
595    
596            protected String getModelClassName() {
597                    return ExpandoTable.class.getName();
598            }
599    
600            /**
601             * Performs an SQL query.
602             *
603             * @param sql the sql query
604             */
605            protected void runSQL(String sql) throws SystemException {
606                    try {
607                            DataSource dataSource = expandoTablePersistence.getDataSource();
608    
609                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
610                                            sql, new int[0]);
611    
612                            sqlUpdate.update();
613                    }
614                    catch (Exception e) {
615                            throw new SystemException(e);
616                    }
617            }
618    
619            @BeanReference(type = ExpandoColumnLocalService.class)
620            protected ExpandoColumnLocalService expandoColumnLocalService;
621            @BeanReference(type = ExpandoColumnService.class)
622            protected ExpandoColumnService expandoColumnService;
623            @BeanReference(type = ExpandoColumnPersistence.class)
624            protected ExpandoColumnPersistence expandoColumnPersistence;
625            @BeanReference(type = ExpandoRowLocalService.class)
626            protected ExpandoRowLocalService expandoRowLocalService;
627            @BeanReference(type = ExpandoRowPersistence.class)
628            protected ExpandoRowPersistence expandoRowPersistence;
629            @BeanReference(type = ExpandoTableLocalService.class)
630            protected ExpandoTableLocalService expandoTableLocalService;
631            @BeanReference(type = ExpandoTablePersistence.class)
632            protected ExpandoTablePersistence expandoTablePersistence;
633            @BeanReference(type = ExpandoValueLocalService.class)
634            protected ExpandoValueLocalService expandoValueLocalService;
635            @BeanReference(type = ExpandoValueService.class)
636            protected ExpandoValueService expandoValueService;
637            @BeanReference(type = ExpandoValuePersistence.class)
638            protected ExpandoValuePersistence expandoValuePersistence;
639            @BeanReference(type = CounterLocalService.class)
640            protected CounterLocalService counterLocalService;
641            @BeanReference(type = ResourceLocalService.class)
642            protected ResourceLocalService resourceLocalService;
643            @BeanReference(type = UserLocalService.class)
644            protected UserLocalService userLocalService;
645            @BeanReference(type = UserService.class)
646            protected UserService userService;
647            @BeanReference(type = UserPersistence.class)
648            protected UserPersistence userPersistence;
649            @BeanReference(type = UserFinder.class)
650            protected UserFinder userFinder;
651            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
652            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
653            private String _beanIdentifier;
654    }