001 /** 002 * Copyright (c) 2000-2010 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.counter.service.base; 016 017 import com.liferay.counter.model.Counter; 018 import com.liferay.counter.service.CounterLocalService; 019 import com.liferay.counter.service.persistence.CounterFinder; 020 import com.liferay.counter.service.persistence.CounterPersistence; 021 022 import com.liferay.portal.kernel.annotation.BeanReference; 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.DynamicQuery; 026 import com.liferay.portal.kernel.exception.PortalException; 027 import com.liferay.portal.kernel.exception.SystemException; 028 import com.liferay.portal.kernel.util.OrderByComparator; 029 import com.liferay.portal.service.ResourceLocalService; 030 import com.liferay.portal.service.ResourceService; 031 import com.liferay.portal.service.UserLocalService; 032 import com.liferay.portal.service.UserService; 033 import com.liferay.portal.service.persistence.ResourceFinder; 034 import com.liferay.portal.service.persistence.ResourcePersistence; 035 import com.liferay.portal.service.persistence.UserFinder; 036 import com.liferay.portal.service.persistence.UserPersistence; 037 038 import java.util.List; 039 040 import javax.sql.DataSource; 041 042 /** 043 * The base implementation of the counter local service. 044 * 045 * <p> 046 * 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.counter.service.impl.CounterLocalServiceImpl}. 047 * </p> 048 * 049 * <p> 050 * Never modify or reference this class directly. Always use {@link com.liferay.counter.service.CounterLocalServiceUtil} to access the counter local service. 051 * </p> 052 * 053 * @author Brian Wing Shun Chan 054 * @see com.liferay.counter.service.impl.CounterLocalServiceImpl 055 * @see com.liferay.counter.service.CounterLocalServiceUtil 056 * @generated 057 */ 058 public abstract class CounterLocalServiceBaseImpl implements CounterLocalService { 059 /** 060 * Adds the counter to the database. Also notifies the appropriate model listeners. 061 * 062 * @param counter the counter to add 063 * @return the counter that was added 064 * @throws SystemException if a system exception occurred 065 */ 066 public Counter addCounter(Counter counter) throws SystemException { 067 counter.setNew(true); 068 069 return counterPersistence.update(counter, false); 070 } 071 072 /** 073 * Creates a new counter with the primary key. Does not add the counter to the database. 074 * 075 * @param name the primary key for the new counter 076 * @return the new counter 077 */ 078 public Counter createCounter(String name) { 079 return counterPersistence.create(name); 080 } 081 082 /** 083 * Deletes the counter with the primary key from the database. Also notifies the appropriate model listeners. 084 * 085 * @param name the primary key of the counter to delete 086 * @throws PortalException if a counter with the primary key could not be found 087 * @throws SystemException if a system exception occurred 088 */ 089 public void deleteCounter(String name) 090 throws PortalException, SystemException { 091 counterPersistence.remove(name); 092 } 093 094 /** 095 * Deletes the counter from the database. Also notifies the appropriate model listeners. 096 * 097 * @param counter the counter to delete 098 * @throws SystemException if a system exception occurred 099 */ 100 public void deleteCounter(Counter counter) throws SystemException { 101 counterPersistence.remove(counter); 102 } 103 104 /** 105 * Performs a dynamic query on the database and returns the matching rows. 106 * 107 * @param dynamicQuery the dynamic query to search with 108 * @return the matching rows 109 * @throws SystemException if a system exception occurred 110 */ 111 @SuppressWarnings("rawtypes") 112 public List dynamicQuery(DynamicQuery dynamicQuery) 113 throws SystemException { 114 return counterPersistence.findWithDynamicQuery(dynamicQuery); 115 } 116 117 /** 118 * Performs a dynamic query on the database and returns a range of the matching rows. 119 * 120 * <p> 121 * 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. 122 * </p> 123 * 124 * @param dynamicQuery the dynamic query to search with 125 * @param start the lower bound of the range of model instances to return 126 * @param end the upper bound of the range of model instances to return (not inclusive) 127 * @return the range of matching rows 128 * @throws SystemException if a system exception occurred 129 */ 130 @SuppressWarnings("rawtypes") 131 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end) 132 throws SystemException { 133 return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end); 134 } 135 136 /** 137 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 138 * 139 * <p> 140 * 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. 141 * </p> 142 * 143 * @param dynamicQuery the dynamic query to search with 144 * @param start the lower bound of the range of model instances to return 145 * @param end the upper bound of the range of model instances to return (not inclusive) 146 * @param orderByComparator the comparator to order the results by 147 * @return the ordered range of matching rows 148 * @throws SystemException if a system exception occurred 149 */ 150 @SuppressWarnings("rawtypes") 151 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end, 152 OrderByComparator orderByComparator) throws SystemException { 153 return counterPersistence.findWithDynamicQuery(dynamicQuery, start, 154 end, orderByComparator); 155 } 156 157 /** 158 * Counts the number of rows that match the dynamic query. 159 * 160 * @param dynamicQuery the dynamic query to search with 161 * @return the number of rows that match the dynamic query 162 * @throws SystemException if a system exception occurred 163 */ 164 public long dynamicQueryCount(DynamicQuery dynamicQuery) 165 throws SystemException { 166 return counterPersistence.countWithDynamicQuery(dynamicQuery); 167 } 168 169 /** 170 * Gets the counter with the primary key. 171 * 172 * @param name the primary key of the counter to get 173 * @return the counter 174 * @throws PortalException if a counter with the primary key could not be found 175 * @throws SystemException if a system exception occurred 176 */ 177 public Counter getCounter(String name) 178 throws PortalException, SystemException { 179 return counterPersistence.findByPrimaryKey(name); 180 } 181 182 /** 183 * Gets a range of all the counters. 184 * 185 * <p> 186 * 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. 187 * </p> 188 * 189 * @param start the lower bound of the range of counters to return 190 * @param end the upper bound of the range of counters to return (not inclusive) 191 * @return the range of counters 192 * @throws SystemException if a system exception occurred 193 */ 194 public List<Counter> getCounters(int start, int end) 195 throws SystemException { 196 return counterPersistence.findAll(start, end); 197 } 198 199 /** 200 * Gets the number of counters. 201 * 202 * @return the number of counters 203 * @throws SystemException if a system exception occurred 204 */ 205 public int getCountersCount() throws SystemException { 206 return counterPersistence.countAll(); 207 } 208 209 /** 210 * Updates the counter in the database. Also notifies the appropriate model listeners. 211 * 212 * @param counter the counter to update 213 * @return the counter that was updated 214 * @throws SystemException if a system exception occurred 215 */ 216 public Counter updateCounter(Counter counter) throws SystemException { 217 counter.setNew(false); 218 219 return counterPersistence.update(counter, true); 220 } 221 222 /** 223 * Updates the counter in the database. Also notifies the appropriate model listeners. 224 * 225 * @param counter the counter to update 226 * @param merge whether to merge the counter with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation. 227 * @return the counter that was updated 228 * @throws SystemException if a system exception occurred 229 */ 230 public Counter updateCounter(Counter counter, boolean merge) 231 throws SystemException { 232 counter.setNew(false); 233 234 return counterPersistence.update(counter, merge); 235 } 236 237 /** 238 * Gets the counter local service. 239 * 240 * @return the counter local service 241 */ 242 public CounterLocalService getCounterLocalService() { 243 return counterLocalService; 244 } 245 246 /** 247 * Sets the counter local service. 248 * 249 * @param counterLocalService the counter local service 250 */ 251 public void setCounterLocalService(CounterLocalService counterLocalService) { 252 this.counterLocalService = counterLocalService; 253 } 254 255 /** 256 * Gets the counter persistence. 257 * 258 * @return the counter persistence 259 */ 260 public CounterPersistence getCounterPersistence() { 261 return counterPersistence; 262 } 263 264 /** 265 * Sets the counter persistence. 266 * 267 * @param counterPersistence the counter persistence 268 */ 269 public void setCounterPersistence(CounterPersistence counterPersistence) { 270 this.counterPersistence = counterPersistence; 271 } 272 273 /** 274 * Gets the counter finder. 275 * 276 * @return the counter finder 277 */ 278 public CounterFinder getCounterFinder() { 279 return counterFinder; 280 } 281 282 /** 283 * Sets the counter finder. 284 * 285 * @param counterFinder the counter finder 286 */ 287 public void setCounterFinder(CounterFinder counterFinder) { 288 this.counterFinder = counterFinder; 289 } 290 291 /** 292 * Gets the resource local service. 293 * 294 * @return the resource local service 295 */ 296 public ResourceLocalService getResourceLocalService() { 297 return resourceLocalService; 298 } 299 300 /** 301 * Sets the resource local service. 302 * 303 * @param resourceLocalService the resource local service 304 */ 305 public void setResourceLocalService( 306 ResourceLocalService resourceLocalService) { 307 this.resourceLocalService = resourceLocalService; 308 } 309 310 /** 311 * Gets the resource remote service. 312 * 313 * @return the resource remote service 314 */ 315 public ResourceService getResourceService() { 316 return resourceService; 317 } 318 319 /** 320 * Sets the resource remote service. 321 * 322 * @param resourceService the resource remote service 323 */ 324 public void setResourceService(ResourceService resourceService) { 325 this.resourceService = resourceService; 326 } 327 328 /** 329 * Gets the resource persistence. 330 * 331 * @return the resource persistence 332 */ 333 public ResourcePersistence getResourcePersistence() { 334 return resourcePersistence; 335 } 336 337 /** 338 * Sets the resource persistence. 339 * 340 * @param resourcePersistence the resource persistence 341 */ 342 public void setResourcePersistence(ResourcePersistence resourcePersistence) { 343 this.resourcePersistence = resourcePersistence; 344 } 345 346 /** 347 * Gets the resource finder. 348 * 349 * @return the resource finder 350 */ 351 public ResourceFinder getResourceFinder() { 352 return resourceFinder; 353 } 354 355 /** 356 * Sets the resource finder. 357 * 358 * @param resourceFinder the resource finder 359 */ 360 public void setResourceFinder(ResourceFinder resourceFinder) { 361 this.resourceFinder = resourceFinder; 362 } 363 364 /** 365 * Gets the user local service. 366 * 367 * @return the user local service 368 */ 369 public UserLocalService getUserLocalService() { 370 return userLocalService; 371 } 372 373 /** 374 * Sets the user local service. 375 * 376 * @param userLocalService the user local service 377 */ 378 public void setUserLocalService(UserLocalService userLocalService) { 379 this.userLocalService = userLocalService; 380 } 381 382 /** 383 * Gets the user remote service. 384 * 385 * @return the user remote service 386 */ 387 public UserService getUserService() { 388 return userService; 389 } 390 391 /** 392 * Sets the user remote service. 393 * 394 * @param userService the user remote service 395 */ 396 public void setUserService(UserService userService) { 397 this.userService = userService; 398 } 399 400 /** 401 * Gets the user persistence. 402 * 403 * @return the user persistence 404 */ 405 public UserPersistence getUserPersistence() { 406 return userPersistence; 407 } 408 409 /** 410 * Sets the user persistence. 411 * 412 * @param userPersistence the user persistence 413 */ 414 public void setUserPersistence(UserPersistence userPersistence) { 415 this.userPersistence = userPersistence; 416 } 417 418 /** 419 * Gets the user finder. 420 * 421 * @return the user finder 422 */ 423 public UserFinder getUserFinder() { 424 return userFinder; 425 } 426 427 /** 428 * Sets the user finder. 429 * 430 * @param userFinder the user finder 431 */ 432 public void setUserFinder(UserFinder userFinder) { 433 this.userFinder = userFinder; 434 } 435 436 /** 437 * Performs an SQL query. 438 * 439 * @param sql the sql query to perform 440 */ 441 protected void runSQL(String sql) throws SystemException { 442 try { 443 DataSource dataSource = counterPersistence.getDataSource(); 444 445 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, 446 sql, new int[0]); 447 448 sqlUpdate.update(); 449 } 450 catch (Exception e) { 451 throw new SystemException(e); 452 } 453 } 454 455 @BeanReference(type = CounterLocalService.class) 456 protected CounterLocalService counterLocalService; 457 @BeanReference(type = CounterPersistence.class) 458 protected CounterPersistence counterPersistence; 459 @BeanReference(type = CounterFinder.class) 460 protected CounterFinder counterFinder; 461 @BeanReference(type = ResourceLocalService.class) 462 protected ResourceLocalService resourceLocalService; 463 @BeanReference(type = ResourceService.class) 464 protected ResourceService resourceService; 465 @BeanReference(type = ResourcePersistence.class) 466 protected ResourcePersistence resourcePersistence; 467 @BeanReference(type = ResourceFinder.class) 468 protected ResourceFinder resourceFinder; 469 @BeanReference(type = UserLocalService.class) 470 protected UserLocalService userLocalService; 471 @BeanReference(type = UserService.class) 472 protected UserService userService; 473 @BeanReference(type = UserPersistence.class) 474 protected UserPersistence userPersistence; 475 @BeanReference(type = UserFinder.class) 476 protected UserFinder userFinder; 477 }