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