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