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