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