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.portlet.asset.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.PersistedModel;
036    import com.liferay.portal.service.BaseLocalServiceImpl;
037    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
038    import com.liferay.portal.service.persistence.UserFinder;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.util.PortalUtil;
041    
042    import com.liferay.portlet.asset.model.AssetLink;
043    import com.liferay.portlet.asset.service.AssetLinkLocalService;
044    import com.liferay.portlet.asset.service.persistence.AssetEntryFinder;
045    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
046    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the asset link local service.
056     *
057     * <p>
058     * 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.portlet.asset.service.impl.AssetLinkLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.asset.service.impl.AssetLinkLocalServiceImpl
063     * @see com.liferay.portlet.asset.service.AssetLinkLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class AssetLinkLocalServiceBaseImpl extends BaseLocalServiceImpl
068            implements AssetLinkLocalService, IdentifiableOSGiService {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.asset.service.AssetLinkLocalServiceUtil} to access the asset link local service.
073             */
074    
075            /**
076             * Adds the asset link to the database. Also notifies the appropriate model listeners.
077             *
078             * @param assetLink the asset link
079             * @return the asset link that was added
080             */
081            @Indexable(type = IndexableType.REINDEX)
082            @Override
083            public AssetLink addAssetLink(AssetLink assetLink) {
084                    assetLink.setNew(true);
085    
086                    return assetLinkPersistence.update(assetLink);
087            }
088    
089            /**
090             * Creates a new asset link with the primary key. Does not add the asset link to the database.
091             *
092             * @param linkId the primary key for the new asset link
093             * @return the new asset link
094             */
095            @Override
096            public AssetLink createAssetLink(long linkId) {
097                    return assetLinkPersistence.create(linkId);
098            }
099    
100            /**
101             * Deletes the asset link with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param linkId the primary key of the asset link
104             * @return the asset link that was removed
105             * @throws PortalException if a asset link with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public AssetLink deleteAssetLink(long linkId) throws PortalException {
110                    return assetLinkPersistence.remove(linkId);
111            }
112    
113            /**
114             * Deletes the asset link from the database. Also notifies the appropriate model listeners.
115             *
116             * @param assetLink the asset link
117             * @return the asset link that was removed
118             */
119            @Indexable(type = IndexableType.DELETE)
120            @Override
121            public AssetLink deleteAssetLink(AssetLink assetLink) {
122                    return assetLinkPersistence.remove(assetLink);
123            }
124    
125            @Override
126            public DynamicQuery dynamicQuery() {
127                    Class<?> clazz = getClass();
128    
129                    return DynamicQueryFactoryUtil.forClass(AssetLink.class,
130                            clazz.getClassLoader());
131            }
132    
133            /**
134             * Performs a dynamic query on the database and returns the matching rows.
135             *
136             * @param dynamicQuery the dynamic query
137             * @return the matching rows
138             */
139            @Override
140            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
141                    return assetLinkPersistence.findWithDynamicQuery(dynamicQuery);
142            }
143    
144            /**
145             * Performs a dynamic query on the database and returns a range of the matching rows.
146             *
147             * <p>
148             * 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.portlet.asset.model.impl.AssetLinkModelImpl}. 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.
149             * </p>
150             *
151             * @param dynamicQuery the dynamic query
152             * @param start the lower bound of the range of model instances
153             * @param end the upper bound of the range of model instances (not inclusive)
154             * @return the range of matching rows
155             */
156            @Override
157            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
158                    int end) {
159                    return assetLinkPersistence.findWithDynamicQuery(dynamicQuery, start,
160                            end);
161            }
162    
163            /**
164             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
165             *
166             * <p>
167             * 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.portlet.asset.model.impl.AssetLinkModelImpl}. 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.
168             * </p>
169             *
170             * @param dynamicQuery the dynamic query
171             * @param start the lower bound of the range of model instances
172             * @param end the upper bound of the range of model instances (not inclusive)
173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
174             * @return the ordered range of matching rows
175             */
176            @Override
177            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
178                    int end, OrderByComparator<T> orderByComparator) {
179                    return assetLinkPersistence.findWithDynamicQuery(dynamicQuery, start,
180                            end, orderByComparator);
181            }
182    
183            /**
184             * Returns the number of rows matching the dynamic query.
185             *
186             * @param dynamicQuery the dynamic query
187             * @return the number of rows matching the dynamic query
188             */
189            @Override
190            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
191                    return assetLinkPersistence.countWithDynamicQuery(dynamicQuery);
192            }
193    
194            /**
195             * Returns the number of rows matching the dynamic query.
196             *
197             * @param dynamicQuery the dynamic query
198             * @param projection the projection to apply to the query
199             * @return the number of rows matching the dynamic query
200             */
201            @Override
202            public long dynamicQueryCount(DynamicQuery dynamicQuery,
203                    Projection projection) {
204                    return assetLinkPersistence.countWithDynamicQuery(dynamicQuery,
205                            projection);
206            }
207    
208            @Override
209            public AssetLink fetchAssetLink(long linkId) {
210                    return assetLinkPersistence.fetchByPrimaryKey(linkId);
211            }
212    
213            /**
214             * Returns the asset link with the primary key.
215             *
216             * @param linkId the primary key of the asset link
217             * @return the asset link
218             * @throws PortalException if a asset link with the primary key could not be found
219             */
220            @Override
221            public AssetLink getAssetLink(long linkId) throws PortalException {
222                    return assetLinkPersistence.findByPrimaryKey(linkId);
223            }
224    
225            @Override
226            public ActionableDynamicQuery getActionableDynamicQuery() {
227                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
228    
229                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.asset.service.AssetLinkLocalServiceUtil.getService());
230                    actionableDynamicQuery.setClass(AssetLink.class);
231                    actionableDynamicQuery.setClassLoader(getClassLoader());
232    
233                    actionableDynamicQuery.setPrimaryKeyPropertyName("linkId");
234    
235                    return actionableDynamicQuery;
236            }
237    
238            protected void initActionableDynamicQuery(
239                    ActionableDynamicQuery actionableDynamicQuery) {
240                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.asset.service.AssetLinkLocalServiceUtil.getService());
241                    actionableDynamicQuery.setClass(AssetLink.class);
242                    actionableDynamicQuery.setClassLoader(getClassLoader());
243    
244                    actionableDynamicQuery.setPrimaryKeyPropertyName("linkId");
245            }
246    
247            /**
248             * @throws PortalException
249             */
250            @Override
251            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
252                    throws PortalException {
253                    return assetLinkLocalService.deleteAssetLink((AssetLink)persistedModel);
254            }
255    
256            @Override
257            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
258                    throws PortalException {
259                    return assetLinkPersistence.findByPrimaryKey(primaryKeyObj);
260            }
261    
262            /**
263             * Returns a range of all the asset links.
264             *
265             * <p>
266             * 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.portlet.asset.model.impl.AssetLinkModelImpl}. 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.
267             * </p>
268             *
269             * @param start the lower bound of the range of asset links
270             * @param end the upper bound of the range of asset links (not inclusive)
271             * @return the range of asset links
272             */
273            @Override
274            public List<AssetLink> getAssetLinks(int start, int end) {
275                    return assetLinkPersistence.findAll(start, end);
276            }
277    
278            /**
279             * Returns the number of asset links.
280             *
281             * @return the number of asset links
282             */
283            @Override
284            public int getAssetLinksCount() {
285                    return assetLinkPersistence.countAll();
286            }
287    
288            /**
289             * Updates the asset link in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
290             *
291             * @param assetLink the asset link
292             * @return the asset link that was updated
293             */
294            @Indexable(type = IndexableType.REINDEX)
295            @Override
296            public AssetLink updateAssetLink(AssetLink assetLink) {
297                    return assetLinkPersistence.update(assetLink);
298            }
299    
300            /**
301             * Returns the asset link local service.
302             *
303             * @return the asset link local service
304             */
305            public AssetLinkLocalService getAssetLinkLocalService() {
306                    return assetLinkLocalService;
307            }
308    
309            /**
310             * Sets the asset link local service.
311             *
312             * @param assetLinkLocalService the asset link local service
313             */
314            public void setAssetLinkLocalService(
315                    AssetLinkLocalService assetLinkLocalService) {
316                    this.assetLinkLocalService = assetLinkLocalService;
317            }
318    
319            /**
320             * Returns the asset link persistence.
321             *
322             * @return the asset link persistence
323             */
324            public AssetLinkPersistence getAssetLinkPersistence() {
325                    return assetLinkPersistence;
326            }
327    
328            /**
329             * Sets the asset link persistence.
330             *
331             * @param assetLinkPersistence the asset link persistence
332             */
333            public void setAssetLinkPersistence(
334                    AssetLinkPersistence assetLinkPersistence) {
335                    this.assetLinkPersistence = assetLinkPersistence;
336            }
337    
338            /**
339             * Returns the counter local service.
340             *
341             * @return the counter local service
342             */
343            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
344                    return counterLocalService;
345            }
346    
347            /**
348             * Sets the counter local service.
349             *
350             * @param counterLocalService the counter local service
351             */
352            public void setCounterLocalService(
353                    com.liferay.counter.service.CounterLocalService counterLocalService) {
354                    this.counterLocalService = counterLocalService;
355            }
356    
357            /**
358             * Returns the user local service.
359             *
360             * @return the user local service
361             */
362            public com.liferay.portal.service.UserLocalService getUserLocalService() {
363                    return userLocalService;
364            }
365    
366            /**
367             * Sets the user local service.
368             *
369             * @param userLocalService the user local service
370             */
371            public void setUserLocalService(
372                    com.liferay.portal.service.UserLocalService userLocalService) {
373                    this.userLocalService = userLocalService;
374            }
375    
376            /**
377             * Returns the user remote service.
378             *
379             * @return the user remote service
380             */
381            public com.liferay.portal.service.UserService getUserService() {
382                    return userService;
383            }
384    
385            /**
386             * Sets the user remote service.
387             *
388             * @param userService the user remote service
389             */
390            public void setUserService(
391                    com.liferay.portal.service.UserService userService) {
392                    this.userService = userService;
393            }
394    
395            /**
396             * Returns the user persistence.
397             *
398             * @return the user persistence
399             */
400            public UserPersistence getUserPersistence() {
401                    return userPersistence;
402            }
403    
404            /**
405             * Sets the user persistence.
406             *
407             * @param userPersistence the user persistence
408             */
409            public void setUserPersistence(UserPersistence userPersistence) {
410                    this.userPersistence = userPersistence;
411            }
412    
413            /**
414             * Returns the user finder.
415             *
416             * @return the user finder
417             */
418            public UserFinder getUserFinder() {
419                    return userFinder;
420            }
421    
422            /**
423             * Sets the user finder.
424             *
425             * @param userFinder the user finder
426             */
427            public void setUserFinder(UserFinder userFinder) {
428                    this.userFinder = userFinder;
429            }
430    
431            /**
432             * Returns the asset entry local service.
433             *
434             * @return the asset entry local service
435             */
436            public com.liferay.portlet.asset.service.AssetEntryLocalService getAssetEntryLocalService() {
437                    return assetEntryLocalService;
438            }
439    
440            /**
441             * Sets the asset entry local service.
442             *
443             * @param assetEntryLocalService the asset entry local service
444             */
445            public void setAssetEntryLocalService(
446                    com.liferay.portlet.asset.service.AssetEntryLocalService assetEntryLocalService) {
447                    this.assetEntryLocalService = assetEntryLocalService;
448            }
449    
450            /**
451             * Returns the asset entry remote service.
452             *
453             * @return the asset entry remote service
454             */
455            public com.liferay.portlet.asset.service.AssetEntryService getAssetEntryService() {
456                    return assetEntryService;
457            }
458    
459            /**
460             * Sets the asset entry remote service.
461             *
462             * @param assetEntryService the asset entry remote service
463             */
464            public void setAssetEntryService(
465                    com.liferay.portlet.asset.service.AssetEntryService assetEntryService) {
466                    this.assetEntryService = assetEntryService;
467            }
468    
469            /**
470             * Returns the asset entry persistence.
471             *
472             * @return the asset entry persistence
473             */
474            public AssetEntryPersistence getAssetEntryPersistence() {
475                    return assetEntryPersistence;
476            }
477    
478            /**
479             * Sets the asset entry persistence.
480             *
481             * @param assetEntryPersistence the asset entry persistence
482             */
483            public void setAssetEntryPersistence(
484                    AssetEntryPersistence assetEntryPersistence) {
485                    this.assetEntryPersistence = assetEntryPersistence;
486            }
487    
488            /**
489             * Returns the asset entry finder.
490             *
491             * @return the asset entry finder
492             */
493            public AssetEntryFinder getAssetEntryFinder() {
494                    return assetEntryFinder;
495            }
496    
497            /**
498             * Sets the asset entry finder.
499             *
500             * @param assetEntryFinder the asset entry finder
501             */
502            public void setAssetEntryFinder(AssetEntryFinder assetEntryFinder) {
503                    this.assetEntryFinder = assetEntryFinder;
504            }
505    
506            public void afterPropertiesSet() {
507                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.asset.model.AssetLink",
508                            assetLinkLocalService);
509            }
510    
511            public void destroy() {
512                    persistedModelLocalServiceRegistry.unregister(
513                            "com.liferay.portlet.asset.model.AssetLink");
514            }
515    
516            /**
517             * Returns the OSGi service identifier.
518             *
519             * @return the OSGi service identifier
520             */
521            @Override
522            public String getOSGiServiceIdentifier() {
523                    return AssetLinkLocalService.class.getName();
524            }
525    
526            protected Class<?> getModelClass() {
527                    return AssetLink.class;
528            }
529    
530            protected String getModelClassName() {
531                    return AssetLink.class.getName();
532            }
533    
534            /**
535             * Performs a SQL query.
536             *
537             * @param sql the sql query
538             */
539            protected void runSQL(String sql) {
540                    try {
541                            DataSource dataSource = assetLinkPersistence.getDataSource();
542    
543                            DB db = DBFactoryUtil.getDB();
544    
545                            sql = db.buildSQL(sql);
546                            sql = PortalUtil.transformSQL(sql);
547    
548                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
549                                            sql, new int[0]);
550    
551                            sqlUpdate.update();
552                    }
553                    catch (Exception e) {
554                            throw new SystemException(e);
555                    }
556            }
557    
558            @BeanReference(type = com.liferay.portlet.asset.service.AssetLinkLocalService.class)
559            protected AssetLinkLocalService assetLinkLocalService;
560            @BeanReference(type = AssetLinkPersistence.class)
561            protected AssetLinkPersistence assetLinkPersistence;
562            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
563            protected com.liferay.counter.service.CounterLocalService counterLocalService;
564            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
565            protected com.liferay.portal.service.UserLocalService userLocalService;
566            @BeanReference(type = com.liferay.portal.service.UserService.class)
567            protected com.liferay.portal.service.UserService userService;
568            @BeanReference(type = UserPersistence.class)
569            protected UserPersistence userPersistence;
570            @BeanReference(type = UserFinder.class)
571            protected UserFinder userFinder;
572            @BeanReference(type = com.liferay.portlet.asset.service.AssetEntryLocalService.class)
573            protected com.liferay.portlet.asset.service.AssetEntryLocalService assetEntryLocalService;
574            @BeanReference(type = com.liferay.portlet.asset.service.AssetEntryService.class)
575            protected com.liferay.portlet.asset.service.AssetEntryService assetEntryService;
576            @BeanReference(type = AssetEntryPersistence.class)
577            protected AssetEntryPersistence assetEntryPersistence;
578            @BeanReference(type = AssetEntryFinder.class)
579            protected AssetEntryFinder assetEntryFinder;
580            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
581            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
582    }