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