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.DBFactoryUtil; 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.Projection; 029 import com.liferay.portal.kernel.exception.PortalException; 030 import com.liferay.portal.kernel.exception.SystemException; 031 import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService; 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.BrowserTracker; 036 import com.liferay.portal.model.PersistedModel; 037 import com.liferay.portal.service.BaseLocalServiceImpl; 038 import com.liferay.portal.service.BrowserTrackerLocalService; 039 import com.liferay.portal.service.PersistedModelLocalServiceRegistry; 040 import com.liferay.portal.service.persistence.BrowserTrackerPersistence; 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 browser tracker 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.BrowserTrackerLocalServiceImpl}. 054 * </p> 055 * 056 * @author Brian Wing Shun Chan 057 * @see com.liferay.portal.service.impl.BrowserTrackerLocalServiceImpl 058 * @see com.liferay.portal.service.BrowserTrackerLocalServiceUtil 059 * @generated 060 */ 061 @ProviderType 062 public abstract class BrowserTrackerLocalServiceBaseImpl 063 extends BaseLocalServiceImpl implements BrowserTrackerLocalService, 064 IdentifiableOSGiService { 065 /* 066 * NOTE FOR DEVELOPERS: 067 * 068 * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.BrowserTrackerLocalServiceUtil} to access the browser tracker local service. 069 */ 070 071 /** 072 * Adds the browser tracker to the database. Also notifies the appropriate model listeners. 073 * 074 * @param browserTracker the browser tracker 075 * @return the browser tracker that was added 076 */ 077 @Indexable(type = IndexableType.REINDEX) 078 @Override 079 public BrowserTracker addBrowserTracker(BrowserTracker browserTracker) { 080 browserTracker.setNew(true); 081 082 return browserTrackerPersistence.update(browserTracker); 083 } 084 085 /** 086 * Creates a new browser tracker with the primary key. Does not add the browser tracker to the database. 087 * 088 * @param browserTrackerId the primary key for the new browser tracker 089 * @return the new browser tracker 090 */ 091 @Override 092 public BrowserTracker createBrowserTracker(long browserTrackerId) { 093 return browserTrackerPersistence.create(browserTrackerId); 094 } 095 096 /** 097 * Deletes the browser tracker with the primary key from the database. Also notifies the appropriate model listeners. 098 * 099 * @param browserTrackerId the primary key of the browser tracker 100 * @return the browser tracker that was removed 101 * @throws PortalException if a browser tracker with the primary key could not be found 102 */ 103 @Indexable(type = IndexableType.DELETE) 104 @Override 105 public BrowserTracker deleteBrowserTracker(long browserTrackerId) 106 throws PortalException { 107 return browserTrackerPersistence.remove(browserTrackerId); 108 } 109 110 /** 111 * Deletes the browser tracker from the database. Also notifies the appropriate model listeners. 112 * 113 * @param browserTracker the browser tracker 114 * @return the browser tracker that was removed 115 */ 116 @Indexable(type = IndexableType.DELETE) 117 @Override 118 public BrowserTracker deleteBrowserTracker(BrowserTracker browserTracker) { 119 return browserTrackerPersistence.remove(browserTracker); 120 } 121 122 @Override 123 public DynamicQuery dynamicQuery() { 124 Class<?> clazz = getClass(); 125 126 return DynamicQueryFactoryUtil.forClass(BrowserTracker.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 browserTrackerPersistence.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.BrowserTrackerModelImpl}. 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 browserTrackerPersistence.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.BrowserTrackerModelImpl}. 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 browserTrackerPersistence.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 browserTrackerPersistence.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 browserTrackerPersistence.countWithDynamicQuery(dynamicQuery, 202 projection); 203 } 204 205 @Override 206 public BrowserTracker fetchBrowserTracker(long browserTrackerId) { 207 return browserTrackerPersistence.fetchByPrimaryKey(browserTrackerId); 208 } 209 210 /** 211 * Returns the browser tracker with the primary key. 212 * 213 * @param browserTrackerId the primary key of the browser tracker 214 * @return the browser tracker 215 * @throws PortalException if a browser tracker with the primary key could not be found 216 */ 217 @Override 218 public BrowserTracker getBrowserTracker(long browserTrackerId) 219 throws PortalException { 220 return browserTrackerPersistence.findByPrimaryKey(browserTrackerId); 221 } 222 223 @Override 224 public ActionableDynamicQuery getActionableDynamicQuery() { 225 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery(); 226 227 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BrowserTrackerLocalServiceUtil.getService()); 228 actionableDynamicQuery.setClass(BrowserTracker.class); 229 actionableDynamicQuery.setClassLoader(getClassLoader()); 230 231 actionableDynamicQuery.setPrimaryKeyPropertyName("browserTrackerId"); 232 233 return actionableDynamicQuery; 234 } 235 236 protected void initActionableDynamicQuery( 237 ActionableDynamicQuery actionableDynamicQuery) { 238 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.BrowserTrackerLocalServiceUtil.getService()); 239 actionableDynamicQuery.setClass(BrowserTracker.class); 240 actionableDynamicQuery.setClassLoader(getClassLoader()); 241 242 actionableDynamicQuery.setPrimaryKeyPropertyName("browserTrackerId"); 243 } 244 245 /** 246 * @throws PortalException 247 */ 248 @Override 249 public PersistedModel deletePersistedModel(PersistedModel persistedModel) 250 throws PortalException { 251 return browserTrackerLocalService.deleteBrowserTracker((BrowserTracker)persistedModel); 252 } 253 254 @Override 255 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 256 throws PortalException { 257 return browserTrackerPersistence.findByPrimaryKey(primaryKeyObj); 258 } 259 260 /** 261 * Returns a range of all the browser trackers. 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.BrowserTrackerModelImpl}. 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 browser trackers 268 * @param end the upper bound of the range of browser trackers (not inclusive) 269 * @return the range of browser trackers 270 */ 271 @Override 272 public List<BrowserTracker> getBrowserTrackers(int start, int end) { 273 return browserTrackerPersistence.findAll(start, end); 274 } 275 276 /** 277 * Returns the number of browser trackers. 278 * 279 * @return the number of browser trackers 280 */ 281 @Override 282 public int getBrowserTrackersCount() { 283 return browserTrackerPersistence.countAll(); 284 } 285 286 /** 287 * Updates the browser tracker in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 288 * 289 * @param browserTracker the browser tracker 290 * @return the browser tracker that was updated 291 */ 292 @Indexable(type = IndexableType.REINDEX) 293 @Override 294 public BrowserTracker updateBrowserTracker(BrowserTracker browserTracker) { 295 return browserTrackerPersistence.update(browserTracker); 296 } 297 298 /** 299 * Returns the browser tracker local service. 300 * 301 * @return the browser tracker local service 302 */ 303 public BrowserTrackerLocalService getBrowserTrackerLocalService() { 304 return browserTrackerLocalService; 305 } 306 307 /** 308 * Sets the browser tracker local service. 309 * 310 * @param browserTrackerLocalService the browser tracker local service 311 */ 312 public void setBrowserTrackerLocalService( 313 BrowserTrackerLocalService browserTrackerLocalService) { 314 this.browserTrackerLocalService = browserTrackerLocalService; 315 } 316 317 /** 318 * Returns the browser tracker persistence. 319 * 320 * @return the browser tracker persistence 321 */ 322 public BrowserTrackerPersistence getBrowserTrackerPersistence() { 323 return browserTrackerPersistence; 324 } 325 326 /** 327 * Sets the browser tracker persistence. 328 * 329 * @param browserTrackerPersistence the browser tracker persistence 330 */ 331 public void setBrowserTrackerPersistence( 332 BrowserTrackerPersistence browserTrackerPersistence) { 333 this.browserTrackerPersistence = browserTrackerPersistence; 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.BrowserTracker", 357 browserTrackerLocalService); 358 } 359 360 public void destroy() { 361 persistedModelLocalServiceRegistry.unregister( 362 "com.liferay.portal.model.BrowserTracker"); 363 } 364 365 /** 366 * Returns the OSGi service identifier. 367 * 368 * @return the OSGi service identifier 369 */ 370 @Override 371 public String getOSGiServiceIdentifier() { 372 return BrowserTrackerLocalService.class.getName(); 373 } 374 375 protected Class<?> getModelClass() { 376 return BrowserTracker.class; 377 } 378 379 protected String getModelClassName() { 380 return BrowserTracker.class.getName(); 381 } 382 383 /** 384 * Performs a SQL query. 385 * 386 * @param sql the sql query 387 */ 388 protected void runSQL(String sql) { 389 try { 390 DataSource dataSource = browserTrackerPersistence.getDataSource(); 391 392 DB db = DBFactoryUtil.getDB(); 393 394 sql = db.buildSQL(sql); 395 sql = PortalUtil.transformSQL(sql); 396 397 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, 398 sql, new int[0]); 399 400 sqlUpdate.update(); 401 } 402 catch (Exception e) { 403 throw new SystemException(e); 404 } 405 } 406 407 @BeanReference(type = com.liferay.portal.service.BrowserTrackerLocalService.class) 408 protected BrowserTrackerLocalService browserTrackerLocalService; 409 @BeanReference(type = BrowserTrackerPersistence.class) 410 protected BrowserTrackerPersistence browserTrackerPersistence; 411 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class) 412 protected com.liferay.counter.service.CounterLocalService counterLocalService; 413 @BeanReference(type = PersistedModelLocalServiceRegistry.class) 414 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry; 415 }