001
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.ExportActionableDynamicQuery;
029 import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
030 import com.liferay.portal.kernel.dao.orm.Projection;
031 import com.liferay.portal.kernel.exception.PortalException;
032 import com.liferay.portal.kernel.exception.SystemException;
033 import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
034 import com.liferay.portal.kernel.search.Indexable;
035 import com.liferay.portal.kernel.search.IndexableType;
036 import com.liferay.portal.kernel.util.OrderByComparator;
037 import com.liferay.portal.model.PersistedModel;
038 import com.liferay.portal.model.RepositoryEntry;
039 import com.liferay.portal.service.BaseLocalServiceImpl;
040 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
041 import com.liferay.portal.service.RepositoryEntryLocalService;
042 import com.liferay.portal.service.persistence.RepositoryEntryPersistence;
043 import com.liferay.portal.service.persistence.UserFinder;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.util.PortalUtil;
046
047 import com.liferay.portlet.exportimport.lar.ExportImportHelperUtil;
048 import com.liferay.portlet.exportimport.lar.ManifestSummary;
049 import com.liferay.portlet.exportimport.lar.PortletDataContext;
050 import com.liferay.portlet.exportimport.lar.StagedModelDataHandlerUtil;
051 import com.liferay.portlet.exportimport.lar.StagedModelType;
052
053 import java.io.Serializable;
054
055 import java.util.List;
056
057 import javax.sql.DataSource;
058
059
071 @ProviderType
072 public abstract class RepositoryEntryLocalServiceBaseImpl
073 extends BaseLocalServiceImpl implements RepositoryEntryLocalService,
074 IdentifiableOSGiService {
075
080
081
087 @Indexable(type = IndexableType.REINDEX)
088 @Override
089 public RepositoryEntry addRepositoryEntry(RepositoryEntry repositoryEntry) {
090 repositoryEntry.setNew(true);
091
092 return repositoryEntryPersistence.update(repositoryEntry);
093 }
094
095
101 @Override
102 public RepositoryEntry createRepositoryEntry(long repositoryEntryId) {
103 return repositoryEntryPersistence.create(repositoryEntryId);
104 }
105
106
113 @Indexable(type = IndexableType.DELETE)
114 @Override
115 public RepositoryEntry deleteRepositoryEntry(long repositoryEntryId)
116 throws PortalException {
117 return repositoryEntryPersistence.remove(repositoryEntryId);
118 }
119
120
126 @Indexable(type = IndexableType.DELETE)
127 @Override
128 public RepositoryEntry deleteRepositoryEntry(
129 RepositoryEntry repositoryEntry) {
130 return repositoryEntryPersistence.remove(repositoryEntry);
131 }
132
133 @Override
134 public DynamicQuery dynamicQuery() {
135 Class<?> clazz = getClass();
136
137 return DynamicQueryFactoryUtil.forClass(RepositoryEntry.class,
138 clazz.getClassLoader());
139 }
140
141
147 @Override
148 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
149 return repositoryEntryPersistence.findWithDynamicQuery(dynamicQuery);
150 }
151
152
164 @Override
165 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
166 int end) {
167 return repositoryEntryPersistence.findWithDynamicQuery(dynamicQuery,
168 start, end);
169 }
170
171
184 @Override
185 public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
186 int end, OrderByComparator<T> orderByComparator) {
187 return repositoryEntryPersistence.findWithDynamicQuery(dynamicQuery,
188 start, end, orderByComparator);
189 }
190
191
197 @Override
198 public long dynamicQueryCount(DynamicQuery dynamicQuery) {
199 return repositoryEntryPersistence.countWithDynamicQuery(dynamicQuery);
200 }
201
202
209 @Override
210 public long dynamicQueryCount(DynamicQuery dynamicQuery,
211 Projection projection) {
212 return repositoryEntryPersistence.countWithDynamicQuery(dynamicQuery,
213 projection);
214 }
215
216 @Override
217 public RepositoryEntry fetchRepositoryEntry(long repositoryEntryId) {
218 return repositoryEntryPersistence.fetchByPrimaryKey(repositoryEntryId);
219 }
220
221
228 @Override
229 public RepositoryEntry fetchRepositoryEntryByUuidAndGroupId(String uuid,
230 long groupId) {
231 return repositoryEntryPersistence.fetchByUUID_G(uuid, groupId);
232 }
233
234
241 @Override
242 public RepositoryEntry getRepositoryEntry(long repositoryEntryId)
243 throws PortalException {
244 return repositoryEntryPersistence.findByPrimaryKey(repositoryEntryId);
245 }
246
247 @Override
248 public ActionableDynamicQuery getActionableDynamicQuery() {
249 ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
250
251 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RepositoryEntryLocalServiceUtil.getService());
252 actionableDynamicQuery.setClassLoader(getClassLoader());
253 actionableDynamicQuery.setModelClass(RepositoryEntry.class);
254
255 actionableDynamicQuery.setPrimaryKeyPropertyName("repositoryEntryId");
256
257 return actionableDynamicQuery;
258 }
259
260 @Override
261 public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
262 IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
263
264 indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RepositoryEntryLocalServiceUtil.getService());
265 indexableActionableDynamicQuery.setClassLoader(getClassLoader());
266 indexableActionableDynamicQuery.setModelClass(RepositoryEntry.class);
267
268 indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
269 "repositoryEntryId");
270
271 return indexableActionableDynamicQuery;
272 }
273
274 protected void initActionableDynamicQuery(
275 ActionableDynamicQuery actionableDynamicQuery) {
276 actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.RepositoryEntryLocalServiceUtil.getService());
277 actionableDynamicQuery.setClassLoader(getClassLoader());
278 actionableDynamicQuery.setModelClass(RepositoryEntry.class);
279
280 actionableDynamicQuery.setPrimaryKeyPropertyName("repositoryEntryId");
281 }
282
283 @Override
284 public ExportActionableDynamicQuery getExportActionableDynamicQuery(
285 final PortletDataContext portletDataContext) {
286 final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
287 @Override
288 public long performCount() throws PortalException {
289 ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
290
291 StagedModelType stagedModelType = getStagedModelType();
292
293 long modelAdditionCount = super.performCount();
294
295 manifestSummary.addModelAdditionCount(stagedModelType,
296 modelAdditionCount);
297
298 long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
299 stagedModelType);
300
301 manifestSummary.addModelDeletionCount(stagedModelType,
302 modelDeletionCount);
303
304 return modelAdditionCount;
305 }
306 };
307
308 initActionableDynamicQuery(exportActionableDynamicQuery);
309
310 exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
311 @Override
312 public void addCriteria(DynamicQuery dynamicQuery) {
313 portletDataContext.addDateRangeCriteria(dynamicQuery,
314 "modifiedDate");
315 }
316 });
317
318 exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
319
320 exportActionableDynamicQuery.setGroupId(portletDataContext.getScopeGroupId());
321
322 exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<RepositoryEntry>() {
323 @Override
324 public void performAction(RepositoryEntry repositoryEntry)
325 throws PortalException {
326 StagedModelDataHandlerUtil.exportStagedModel(portletDataContext,
327 repositoryEntry);
328 }
329 });
330 exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
331 PortalUtil.getClassNameId(RepositoryEntry.class.getName())));
332
333 return exportActionableDynamicQuery;
334 }
335
336
339 @Override
340 public PersistedModel deletePersistedModel(PersistedModel persistedModel)
341 throws PortalException {
342 return repositoryEntryLocalService.deleteRepositoryEntry((RepositoryEntry)persistedModel);
343 }
344
345 @Override
346 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
347 throws PortalException {
348 return repositoryEntryPersistence.findByPrimaryKey(primaryKeyObj);
349 }
350
351
358 @Override
359 public List<RepositoryEntry> getRepositoryEntriesByUuidAndCompanyId(
360 String uuid, long companyId) {
361 return repositoryEntryPersistence.findByUuid_C(uuid, companyId);
362 }
363
364
374 @Override
375 public List<RepositoryEntry> getRepositoryEntriesByUuidAndCompanyId(
376 String uuid, long companyId, int start, int end,
377 OrderByComparator<RepositoryEntry> orderByComparator) {
378 return repositoryEntryPersistence.findByUuid_C(uuid, companyId, start,
379 end, orderByComparator);
380 }
381
382
390 @Override
391 public RepositoryEntry getRepositoryEntryByUuidAndGroupId(String uuid,
392 long groupId) throws PortalException {
393 return repositoryEntryPersistence.findByUUID_G(uuid, groupId);
394 }
395
396
407 @Override
408 public List<RepositoryEntry> getRepositoryEntries(int start, int end) {
409 return repositoryEntryPersistence.findAll(start, end);
410 }
411
412
417 @Override
418 public int getRepositoryEntriesCount() {
419 return repositoryEntryPersistence.countAll();
420 }
421
422
428 @Indexable(type = IndexableType.REINDEX)
429 @Override
430 public RepositoryEntry updateRepositoryEntry(
431 RepositoryEntry repositoryEntry) {
432 return repositoryEntryPersistence.update(repositoryEntry);
433 }
434
435
440 public RepositoryEntryLocalService getRepositoryEntryLocalService() {
441 return repositoryEntryLocalService;
442 }
443
444
449 public void setRepositoryEntryLocalService(
450 RepositoryEntryLocalService repositoryEntryLocalService) {
451 this.repositoryEntryLocalService = repositoryEntryLocalService;
452 }
453
454
459 public RepositoryEntryPersistence getRepositoryEntryPersistence() {
460 return repositoryEntryPersistence;
461 }
462
463
468 public void setRepositoryEntryPersistence(
469 RepositoryEntryPersistence repositoryEntryPersistence) {
470 this.repositoryEntryPersistence = repositoryEntryPersistence;
471 }
472
473
478 public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
479 return counterLocalService;
480 }
481
482
487 public void setCounterLocalService(
488 com.liferay.counter.service.CounterLocalService counterLocalService) {
489 this.counterLocalService = counterLocalService;
490 }
491
492
497 public com.liferay.portal.service.UserLocalService getUserLocalService() {
498 return userLocalService;
499 }
500
501
506 public void setUserLocalService(
507 com.liferay.portal.service.UserLocalService userLocalService) {
508 this.userLocalService = userLocalService;
509 }
510
511
516 public UserPersistence getUserPersistence() {
517 return userPersistence;
518 }
519
520
525 public void setUserPersistence(UserPersistence userPersistence) {
526 this.userPersistence = userPersistence;
527 }
528
529
534 public UserFinder getUserFinder() {
535 return userFinder;
536 }
537
538
543 public void setUserFinder(UserFinder userFinder) {
544 this.userFinder = userFinder;
545 }
546
547 public void afterPropertiesSet() {
548 persistedModelLocalServiceRegistry.register("com.liferay.portal.model.RepositoryEntry",
549 repositoryEntryLocalService);
550 }
551
552 public void destroy() {
553 persistedModelLocalServiceRegistry.unregister(
554 "com.liferay.portal.model.RepositoryEntry");
555 }
556
557
562 @Override
563 public String getOSGiServiceIdentifier() {
564 return RepositoryEntryLocalService.class.getName();
565 }
566
567 protected Class<?> getModelClass() {
568 return RepositoryEntry.class;
569 }
570
571 protected String getModelClassName() {
572 return RepositoryEntry.class.getName();
573 }
574
575
580 protected void runSQL(String sql) {
581 try {
582 DataSource dataSource = repositoryEntryPersistence.getDataSource();
583
584 DB db = DBManagerUtil.getDB();
585
586 sql = db.buildSQL(sql);
587 sql = PortalUtil.transformSQL(sql);
588
589 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
590 sql, new int[0]);
591
592 sqlUpdate.update();
593 }
594 catch (Exception e) {
595 throw new SystemException(e);
596 }
597 }
598
599 @BeanReference(type = com.liferay.portal.service.RepositoryEntryLocalService.class)
600 protected RepositoryEntryLocalService repositoryEntryLocalService;
601 @BeanReference(type = RepositoryEntryPersistence.class)
602 protected RepositoryEntryPersistence repositoryEntryPersistence;
603 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
604 protected com.liferay.counter.service.CounterLocalService counterLocalService;
605 @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
606 protected com.liferay.portal.service.UserLocalService userLocalService;
607 @BeanReference(type = UserPersistence.class)
608 protected UserPersistence userPersistence;
609 @BeanReference(type = UserFinder.class)
610 protected UserFinder userFinder;
611 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
612 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
613 }