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.ClusterGroup; 036 import com.liferay.portal.model.PersistedModel; 037 import com.liferay.portal.service.BaseLocalServiceImpl; 038 import com.liferay.portal.service.ClusterGroupLocalService; 039 import com.liferay.portal.service.PersistedModelLocalServiceRegistry; 040 import com.liferay.portal.service.persistence.ClusterGroupPersistence; 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 cluster group 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.ClusterGroupLocalServiceImpl}. 054 * </p> 055 * 056 * @author Brian Wing Shun Chan 057 * @see com.liferay.portal.service.impl.ClusterGroupLocalServiceImpl 058 * @see com.liferay.portal.service.ClusterGroupLocalServiceUtil 059 * @generated 060 */ 061 @ProviderType 062 public abstract class ClusterGroupLocalServiceBaseImpl 063 extends BaseLocalServiceImpl implements ClusterGroupLocalService, 064 IdentifiableOSGiService { 065 /* 066 * NOTE FOR DEVELOPERS: 067 * 068 * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.ClusterGroupLocalServiceUtil} to access the cluster group local service. 069 */ 070 071 /** 072 * Adds the cluster group to the database. Also notifies the appropriate model listeners. 073 * 074 * @param clusterGroup the cluster group 075 * @return the cluster group that was added 076 */ 077 @Indexable(type = IndexableType.REINDEX) 078 @Override 079 public ClusterGroup addClusterGroup(ClusterGroup clusterGroup) { 080 clusterGroup.setNew(true); 081 082 return clusterGroupPersistence.update(clusterGroup); 083 } 084 085 /** 086 * Creates a new cluster group with the primary key. Does not add the cluster group to the database. 087 * 088 * @param clusterGroupId the primary key for the new cluster group 089 * @return the new cluster group 090 */ 091 @Override 092 public ClusterGroup createClusterGroup(long clusterGroupId) { 093 return clusterGroupPersistence.create(clusterGroupId); 094 } 095 096 /** 097 * Deletes the cluster group with the primary key from the database. Also notifies the appropriate model listeners. 098 * 099 * @param clusterGroupId the primary key of the cluster group 100 * @return the cluster group that was removed 101 * @throws PortalException if a cluster group with the primary key could not be found 102 */ 103 @Indexable(type = IndexableType.DELETE) 104 @Override 105 public ClusterGroup deleteClusterGroup(long clusterGroupId) 106 throws PortalException { 107 return clusterGroupPersistence.remove(clusterGroupId); 108 } 109 110 /** 111 * Deletes the cluster group from the database. Also notifies the appropriate model listeners. 112 * 113 * @param clusterGroup the cluster group 114 * @return the cluster group that was removed 115 */ 116 @Indexable(type = IndexableType.DELETE) 117 @Override 118 public ClusterGroup deleteClusterGroup(ClusterGroup clusterGroup) { 119 return clusterGroupPersistence.remove(clusterGroup); 120 } 121 122 @Override 123 public DynamicQuery dynamicQuery() { 124 Class<?> clazz = getClass(); 125 126 return DynamicQueryFactoryUtil.forClass(ClusterGroup.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 clusterGroupPersistence.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.ClusterGroupModelImpl}. 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 clusterGroupPersistence.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.ClusterGroupModelImpl}. 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 clusterGroupPersistence.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 clusterGroupPersistence.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 clusterGroupPersistence.countWithDynamicQuery(dynamicQuery, 202 projection); 203 } 204 205 @Override 206 public ClusterGroup fetchClusterGroup(long clusterGroupId) { 207 return clusterGroupPersistence.fetchByPrimaryKey(clusterGroupId); 208 } 209 210 /** 211 * Returns the cluster group with the primary key. 212 * 213 * @param clusterGroupId the primary key of the cluster group 214 * @return the cluster group 215 * @throws PortalException if a cluster group with the primary key could not be found 216 */ 217 @Override 218 public ClusterGroup getClusterGroup(long clusterGroupId) 219 throws PortalException { 220 return clusterGroupPersistence.findByPrimaryKey(clusterGroupId); 221 } 222 223 @Override 224 public ActionableDynamicQuery getActionableDynamicQuery() { 225 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery(); 226 227 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ClusterGroupLocalServiceUtil.getService()); 228 actionableDynamicQuery.setClass(ClusterGroup.class); 229 actionableDynamicQuery.setClassLoader(getClassLoader()); 230 231 actionableDynamicQuery.setPrimaryKeyPropertyName("clusterGroupId"); 232 233 return actionableDynamicQuery; 234 } 235 236 protected void initActionableDynamicQuery( 237 ActionableDynamicQuery actionableDynamicQuery) { 238 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.ClusterGroupLocalServiceUtil.getService()); 239 actionableDynamicQuery.setClass(ClusterGroup.class); 240 actionableDynamicQuery.setClassLoader(getClassLoader()); 241 242 actionableDynamicQuery.setPrimaryKeyPropertyName("clusterGroupId"); 243 } 244 245 /** 246 * @throws PortalException 247 */ 248 @Override 249 public PersistedModel deletePersistedModel(PersistedModel persistedModel) 250 throws PortalException { 251 return clusterGroupLocalService.deleteClusterGroup((ClusterGroup)persistedModel); 252 } 253 254 @Override 255 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 256 throws PortalException { 257 return clusterGroupPersistence.findByPrimaryKey(primaryKeyObj); 258 } 259 260 /** 261 * Returns a range of all the cluster groups. 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.ClusterGroupModelImpl}. 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 cluster groups 268 * @param end the upper bound of the range of cluster groups (not inclusive) 269 * @return the range of cluster groups 270 */ 271 @Override 272 public List<ClusterGroup> getClusterGroups(int start, int end) { 273 return clusterGroupPersistence.findAll(start, end); 274 } 275 276 /** 277 * Returns the number of cluster groups. 278 * 279 * @return the number of cluster groups 280 */ 281 @Override 282 public int getClusterGroupsCount() { 283 return clusterGroupPersistence.countAll(); 284 } 285 286 /** 287 * Updates the cluster group in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 288 * 289 * @param clusterGroup the cluster group 290 * @return the cluster group that was updated 291 */ 292 @Indexable(type = IndexableType.REINDEX) 293 @Override 294 public ClusterGroup updateClusterGroup(ClusterGroup clusterGroup) { 295 return clusterGroupPersistence.update(clusterGroup); 296 } 297 298 /** 299 * Returns the cluster group local service. 300 * 301 * @return the cluster group local service 302 */ 303 public ClusterGroupLocalService getClusterGroupLocalService() { 304 return clusterGroupLocalService; 305 } 306 307 /** 308 * Sets the cluster group local service. 309 * 310 * @param clusterGroupLocalService the cluster group local service 311 */ 312 public void setClusterGroupLocalService( 313 ClusterGroupLocalService clusterGroupLocalService) { 314 this.clusterGroupLocalService = clusterGroupLocalService; 315 } 316 317 /** 318 * Returns the cluster group persistence. 319 * 320 * @return the cluster group persistence 321 */ 322 public ClusterGroupPersistence getClusterGroupPersistence() { 323 return clusterGroupPersistence; 324 } 325 326 /** 327 * Sets the cluster group persistence. 328 * 329 * @param clusterGroupPersistence the cluster group persistence 330 */ 331 public void setClusterGroupPersistence( 332 ClusterGroupPersistence clusterGroupPersistence) { 333 this.clusterGroupPersistence = clusterGroupPersistence; 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.ClusterGroup", 357 clusterGroupLocalService); 358 } 359 360 public void destroy() { 361 persistedModelLocalServiceRegistry.unregister( 362 "com.liferay.portal.model.ClusterGroup"); 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 ClusterGroupLocalService.class.getName(); 373 } 374 375 protected Class<?> getModelClass() { 376 return ClusterGroup.class; 377 } 378 379 protected String getModelClassName() { 380 return ClusterGroup.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 = clusterGroupPersistence.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.ClusterGroupLocalService.class) 408 protected ClusterGroupLocalService clusterGroupLocalService; 409 @BeanReference(type = ClusterGroupPersistence.class) 410 protected ClusterGroupPersistence clusterGroupPersistence; 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 }