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