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.UserIdMapper;
038    import com.liferay.portal.service.BaseLocalServiceImpl;
039    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
040    import com.liferay.portal.service.UserIdMapperLocalService;
041    import com.liferay.portal.service.persistence.UserIdMapperPersistence;
042    import com.liferay.portal.util.PortalUtil;
043    
044    import java.io.Serializable;
045    
046    import java.util.List;
047    
048    import javax.sql.DataSource;
049    
050    /**
051     * Provides the base implementation for the user ID mapper local service.
052     *
053     * <p>
054     * 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.UserIdMapperLocalServiceImpl}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see com.liferay.portal.service.impl.UserIdMapperLocalServiceImpl
059     * @see com.liferay.portal.service.UserIdMapperLocalServiceUtil
060     * @generated
061     */
062    @ProviderType
063    public abstract class UserIdMapperLocalServiceBaseImpl
064            extends BaseLocalServiceImpl implements UserIdMapperLocalService,
065                    IdentifiableOSGiService {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.UserIdMapperLocalServiceUtil} to access the user ID mapper local service.
070             */
071    
072            /**
073             * Adds the user ID mapper to the database. Also notifies the appropriate model listeners.
074             *
075             * @param userIdMapper the user ID mapper
076             * @return the user ID mapper that was added
077             */
078            @Indexable(type = IndexableType.REINDEX)
079            @Override
080            public UserIdMapper addUserIdMapper(UserIdMapper userIdMapper) {
081                    userIdMapper.setNew(true);
082    
083                    return userIdMapperPersistence.update(userIdMapper);
084            }
085    
086            /**
087             * Creates a new user ID mapper with the primary key. Does not add the user ID mapper to the database.
088             *
089             * @param userIdMapperId the primary key for the new user ID mapper
090             * @return the new user ID mapper
091             */
092            @Override
093            public UserIdMapper createUserIdMapper(long userIdMapperId) {
094                    return userIdMapperPersistence.create(userIdMapperId);
095            }
096    
097            /**
098             * Deletes the user ID mapper with the primary key from the database. Also notifies the appropriate model listeners.
099             *
100             * @param userIdMapperId the primary key of the user ID mapper
101             * @return the user ID mapper that was removed
102             * @throws PortalException if a user ID mapper with the primary key could not be found
103             */
104            @Indexable(type = IndexableType.DELETE)
105            @Override
106            public UserIdMapper deleteUserIdMapper(long userIdMapperId)
107                    throws PortalException {
108                    return userIdMapperPersistence.remove(userIdMapperId);
109            }
110    
111            /**
112             * Deletes the user ID mapper from the database. Also notifies the appropriate model listeners.
113             *
114             * @param userIdMapper the user ID mapper
115             * @return the user ID mapper that was removed
116             */
117            @Indexable(type = IndexableType.DELETE)
118            @Override
119            public UserIdMapper deleteUserIdMapper(UserIdMapper userIdMapper) {
120                    return userIdMapperPersistence.remove(userIdMapper);
121            }
122    
123            @Override
124            public DynamicQuery dynamicQuery() {
125                    Class<?> clazz = getClass();
126    
127                    return DynamicQueryFactoryUtil.forClass(UserIdMapper.class,
128                            clazz.getClassLoader());
129            }
130    
131            /**
132             * Performs a dynamic query on the database and returns the matching rows.
133             *
134             * @param dynamicQuery the dynamic query
135             * @return the matching rows
136             */
137            @Override
138            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
139                    return userIdMapperPersistence.findWithDynamicQuery(dynamicQuery);
140            }
141    
142            /**
143             * Performs a dynamic query on the database and returns a range of the matching rows.
144             *
145             * <p>
146             * 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.UserIdMapperModelImpl}. 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.
147             * </p>
148             *
149             * @param dynamicQuery the dynamic query
150             * @param start the lower bound of the range of model instances
151             * @param end the upper bound of the range of model instances (not inclusive)
152             * @return the range of matching rows
153             */
154            @Override
155            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
156                    int end) {
157                    return userIdMapperPersistence.findWithDynamicQuery(dynamicQuery,
158                            start, end);
159            }
160    
161            /**
162             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
163             *
164             * <p>
165             * 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.UserIdMapperModelImpl}. 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.
166             * </p>
167             *
168             * @param dynamicQuery the dynamic query
169             * @param start the lower bound of the range of model instances
170             * @param end the upper bound of the range of model instances (not inclusive)
171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
172             * @return the ordered range of matching rows
173             */
174            @Override
175            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
176                    int end, OrderByComparator<T> orderByComparator) {
177                    return userIdMapperPersistence.findWithDynamicQuery(dynamicQuery,
178                            start, end, orderByComparator);
179            }
180    
181            /**
182             * Returns the number of rows matching the dynamic query.
183             *
184             * @param dynamicQuery the dynamic query
185             * @return the number of rows matching the dynamic query
186             */
187            @Override
188            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
189                    return userIdMapperPersistence.countWithDynamicQuery(dynamicQuery);
190            }
191    
192            /**
193             * Returns the number of rows matching the dynamic query.
194             *
195             * @param dynamicQuery the dynamic query
196             * @param projection the projection to apply to the query
197             * @return the number of rows matching the dynamic query
198             */
199            @Override
200            public long dynamicQueryCount(DynamicQuery dynamicQuery,
201                    Projection projection) {
202                    return userIdMapperPersistence.countWithDynamicQuery(dynamicQuery,
203                            projection);
204            }
205    
206            @Override
207            public UserIdMapper fetchUserIdMapper(long userIdMapperId) {
208                    return userIdMapperPersistence.fetchByPrimaryKey(userIdMapperId);
209            }
210    
211            /**
212             * Returns the user ID mapper with the primary key.
213             *
214             * @param userIdMapperId the primary key of the user ID mapper
215             * @return the user ID mapper
216             * @throws PortalException if a user ID mapper with the primary key could not be found
217             */
218            @Override
219            public UserIdMapper getUserIdMapper(long userIdMapperId)
220                    throws PortalException {
221                    return userIdMapperPersistence.findByPrimaryKey(userIdMapperId);
222            }
223    
224            @Override
225            public ActionableDynamicQuery getActionableDynamicQuery() {
226                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
227    
228                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserIdMapperLocalServiceUtil.getService());
229                    actionableDynamicQuery.setClassLoader(getClassLoader());
230                    actionableDynamicQuery.setModelClass(UserIdMapper.class);
231    
232                    actionableDynamicQuery.setPrimaryKeyPropertyName("userIdMapperId");
233    
234                    return actionableDynamicQuery;
235            }
236    
237            @Override
238            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
239                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
240    
241                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserIdMapperLocalServiceUtil.getService());
242                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
243                    indexableActionableDynamicQuery.setModelClass(UserIdMapper.class);
244    
245                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
246                            "userIdMapperId");
247    
248                    return indexableActionableDynamicQuery;
249            }
250    
251            protected void initActionableDynamicQuery(
252                    ActionableDynamicQuery actionableDynamicQuery) {
253                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.UserIdMapperLocalServiceUtil.getService());
254                    actionableDynamicQuery.setClassLoader(getClassLoader());
255                    actionableDynamicQuery.setModelClass(UserIdMapper.class);
256    
257                    actionableDynamicQuery.setPrimaryKeyPropertyName("userIdMapperId");
258            }
259    
260            /**
261             * @throws PortalException
262             */
263            @Override
264            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
265                    throws PortalException {
266                    return userIdMapperLocalService.deleteUserIdMapper((UserIdMapper)persistedModel);
267            }
268    
269            @Override
270            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
271                    throws PortalException {
272                    return userIdMapperPersistence.findByPrimaryKey(primaryKeyObj);
273            }
274    
275            /**
276             * Returns a range of all the user ID mappers.
277             *
278             * <p>
279             * 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.UserIdMapperModelImpl}. 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.
280             * </p>
281             *
282             * @param start the lower bound of the range of user ID mappers
283             * @param end the upper bound of the range of user ID mappers (not inclusive)
284             * @return the range of user ID mappers
285             */
286            @Override
287            public List<UserIdMapper> getUserIdMappers(int start, int end) {
288                    return userIdMapperPersistence.findAll(start, end);
289            }
290    
291            /**
292             * Returns the number of user ID mappers.
293             *
294             * @return the number of user ID mappers
295             */
296            @Override
297            public int getUserIdMappersCount() {
298                    return userIdMapperPersistence.countAll();
299            }
300    
301            /**
302             * Updates the user ID mapper in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
303             *
304             * @param userIdMapper the user ID mapper
305             * @return the user ID mapper that was updated
306             */
307            @Indexable(type = IndexableType.REINDEX)
308            @Override
309            public UserIdMapper updateUserIdMapper(UserIdMapper userIdMapper) {
310                    return userIdMapperPersistence.update(userIdMapper);
311            }
312    
313            /**
314             * Returns the user ID mapper local service.
315             *
316             * @return the user ID mapper local service
317             */
318            public UserIdMapperLocalService getUserIdMapperLocalService() {
319                    return userIdMapperLocalService;
320            }
321    
322            /**
323             * Sets the user ID mapper local service.
324             *
325             * @param userIdMapperLocalService the user ID mapper local service
326             */
327            public void setUserIdMapperLocalService(
328                    UserIdMapperLocalService userIdMapperLocalService) {
329                    this.userIdMapperLocalService = userIdMapperLocalService;
330            }
331    
332            /**
333             * Returns the user ID mapper persistence.
334             *
335             * @return the user ID mapper persistence
336             */
337            public UserIdMapperPersistence getUserIdMapperPersistence() {
338                    return userIdMapperPersistence;
339            }
340    
341            /**
342             * Sets the user ID mapper persistence.
343             *
344             * @param userIdMapperPersistence the user ID mapper persistence
345             */
346            public void setUserIdMapperPersistence(
347                    UserIdMapperPersistence userIdMapperPersistence) {
348                    this.userIdMapperPersistence = userIdMapperPersistence;
349            }
350    
351            /**
352             * Returns the counter local service.
353             *
354             * @return the counter local service
355             */
356            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
357                    return counterLocalService;
358            }
359    
360            /**
361             * Sets the counter local service.
362             *
363             * @param counterLocalService the counter local service
364             */
365            public void setCounterLocalService(
366                    com.liferay.counter.service.CounterLocalService counterLocalService) {
367                    this.counterLocalService = counterLocalService;
368            }
369    
370            public void afterPropertiesSet() {
371                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.UserIdMapper",
372                            userIdMapperLocalService);
373            }
374    
375            public void destroy() {
376                    persistedModelLocalServiceRegistry.unregister(
377                            "com.liferay.portal.model.UserIdMapper");
378            }
379    
380            /**
381             * Returns the OSGi service identifier.
382             *
383             * @return the OSGi service identifier
384             */
385            @Override
386            public String getOSGiServiceIdentifier() {
387                    return UserIdMapperLocalService.class.getName();
388            }
389    
390            protected Class<?> getModelClass() {
391                    return UserIdMapper.class;
392            }
393    
394            protected String getModelClassName() {
395                    return UserIdMapper.class.getName();
396            }
397    
398            /**
399             * Performs a SQL query.
400             *
401             * @param sql the sql query
402             */
403            protected void runSQL(String sql) {
404                    try {
405                            DataSource dataSource = userIdMapperPersistence.getDataSource();
406    
407                            DB db = DBManagerUtil.getDB();
408    
409                            sql = db.buildSQL(sql);
410                            sql = PortalUtil.transformSQL(sql);
411    
412                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
413                                            sql, new int[0]);
414    
415                            sqlUpdate.update();
416                    }
417                    catch (Exception e) {
418                            throw new SystemException(e);
419                    }
420            }
421    
422            @BeanReference(type = com.liferay.portal.service.UserIdMapperLocalService.class)
423            protected UserIdMapperLocalService userIdMapperLocalService;
424            @BeanReference(type = UserIdMapperPersistence.class)
425            protected UserIdMapperPersistence userIdMapperPersistence;
426            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
427            protected com.liferay.counter.service.CounterLocalService counterLocalService;
428            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
429            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
430    }