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.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.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.GroupFinder;
042    import com.liferay.portal.service.persistence.GroupPersistence;
043    import com.liferay.portal.service.persistence.LayoutSetPersistence;
044    import com.liferay.portal.service.persistence.VirtualHostPersistence;
045    import com.liferay.portal.util.PortalUtil;
046    
047    import java.io.Serializable;
048    
049    import java.util.List;
050    
051    import javax.sql.DataSource;
052    
053    /**
054     * Provides the base implementation for the virtual host local service.
055     *
056     * <p>
057     * 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}.
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see com.liferay.portal.service.impl.VirtualHostLocalServiceImpl
062     * @see com.liferay.portal.service.VirtualHostLocalServiceUtil
063     * @generated
064     */
065    @ProviderType
066    public abstract class VirtualHostLocalServiceBaseImpl
067            extends BaseLocalServiceImpl implements VirtualHostLocalService,
068                    IdentifiableOSGiService {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link com.liferay.portal.service.VirtualHostLocalServiceUtil} to access the virtual host local service.
073             */
074    
075            /**
076             * Adds the virtual host to the database. Also notifies the appropriate model listeners.
077             *
078             * @param virtualHost the virtual host
079             * @return the virtual host that was added
080             */
081            @Indexable(type = IndexableType.REINDEX)
082            @Override
083            public VirtualHost addVirtualHost(VirtualHost virtualHost) {
084                    virtualHost.setNew(true);
085    
086                    return virtualHostPersistence.update(virtualHost);
087            }
088    
089            /**
090             * Creates a new virtual host with the primary key. Does not add the virtual host to the database.
091             *
092             * @param virtualHostId the primary key for the new virtual host
093             * @return the new virtual host
094             */
095            @Override
096            public VirtualHost createVirtualHost(long virtualHostId) {
097                    return virtualHostPersistence.create(virtualHostId);
098            }
099    
100            /**
101             * Deletes the virtual host with the primary key from the database. Also notifies the appropriate model listeners.
102             *
103             * @param virtualHostId the primary key of the virtual host
104             * @return the virtual host that was removed
105             * @throws PortalException if a virtual host with the primary key could not be found
106             */
107            @Indexable(type = IndexableType.DELETE)
108            @Override
109            public VirtualHost deleteVirtualHost(long virtualHostId)
110                    throws PortalException {
111                    return virtualHostPersistence.remove(virtualHostId);
112            }
113    
114            /**
115             * Deletes the virtual host from the database. Also notifies the appropriate model listeners.
116             *
117             * @param virtualHost the virtual host
118             * @return the virtual host that was removed
119             */
120            @Indexable(type = IndexableType.DELETE)
121            @Override
122            public VirtualHost deleteVirtualHost(VirtualHost virtualHost) {
123                    return virtualHostPersistence.remove(virtualHost);
124            }
125    
126            @Override
127            public DynamicQuery dynamicQuery() {
128                    Class<?> clazz = getClass();
129    
130                    return DynamicQueryFactoryUtil.forClass(VirtualHost.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 virtualHostPersistence.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.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.
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 virtualHostPersistence.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.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.
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 virtualHostPersistence.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 virtualHostPersistence.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 virtualHostPersistence.countWithDynamicQuery(dynamicQuery,
206                            projection);
207            }
208    
209            @Override
210            public VirtualHost fetchVirtualHost(long virtualHostId) {
211                    return virtualHostPersistence.fetchByPrimaryKey(virtualHostId);
212            }
213    
214            /**
215             * Returns the virtual host with the primary key.
216             *
217             * @param virtualHostId the primary key of the virtual host
218             * @return the virtual host
219             * @throws PortalException if a virtual host with the primary key could not be found
220             */
221            @Override
222            public VirtualHost getVirtualHost(long virtualHostId)
223                    throws PortalException {
224                    return virtualHostPersistence.findByPrimaryKey(virtualHostId);
225            }
226    
227            @Override
228            public ActionableDynamicQuery getActionableDynamicQuery() {
229                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
230    
231                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.VirtualHostLocalServiceUtil.getService());
232                    actionableDynamicQuery.setClass(VirtualHost.class);
233                    actionableDynamicQuery.setClassLoader(getClassLoader());
234    
235                    actionableDynamicQuery.setPrimaryKeyPropertyName("virtualHostId");
236    
237                    return actionableDynamicQuery;
238            }
239    
240            protected void initActionableDynamicQuery(
241                    ActionableDynamicQuery actionableDynamicQuery) {
242                    actionableDynamicQuery.setBaseLocalService(com.liferay.portal.service.VirtualHostLocalServiceUtil.getService());
243                    actionableDynamicQuery.setClass(VirtualHost.class);
244                    actionableDynamicQuery.setClassLoader(getClassLoader());
245    
246                    actionableDynamicQuery.setPrimaryKeyPropertyName("virtualHostId");
247            }
248    
249            /**
250             * @throws PortalException
251             */
252            @Override
253            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
254                    throws PortalException {
255                    return virtualHostLocalService.deleteVirtualHost((VirtualHost)persistedModel);
256            }
257    
258            @Override
259            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
260                    throws PortalException {
261                    return virtualHostPersistence.findByPrimaryKey(primaryKeyObj);
262            }
263    
264            /**
265             * Returns a range of all the virtual hosts.
266             *
267             * <p>
268             * 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.
269             * </p>
270             *
271             * @param start the lower bound of the range of virtual hosts
272             * @param end the upper bound of the range of virtual hosts (not inclusive)
273             * @return the range of virtual hosts
274             */
275            @Override
276            public List<VirtualHost> getVirtualHosts(int start, int end) {
277                    return virtualHostPersistence.findAll(start, end);
278            }
279    
280            /**
281             * Returns the number of virtual hosts.
282             *
283             * @return the number of virtual hosts
284             */
285            @Override
286            public int getVirtualHostsCount() {
287                    return virtualHostPersistence.countAll();
288            }
289    
290            /**
291             * Updates the virtual host in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
292             *
293             * @param virtualHost the virtual host
294             * @return the virtual host that was updated
295             */
296            @Indexable(type = IndexableType.REINDEX)
297            @Override
298            public VirtualHost updateVirtualHost(VirtualHost virtualHost) {
299                    return virtualHostPersistence.update(virtualHost);
300            }
301    
302            /**
303             * Returns the virtual host local service.
304             *
305             * @return the virtual host local service
306             */
307            public VirtualHostLocalService getVirtualHostLocalService() {
308                    return virtualHostLocalService;
309            }
310    
311            /**
312             * Sets the virtual host local service.
313             *
314             * @param virtualHostLocalService the virtual host local service
315             */
316            public void setVirtualHostLocalService(
317                    VirtualHostLocalService virtualHostLocalService) {
318                    this.virtualHostLocalService = virtualHostLocalService;
319            }
320    
321            /**
322             * Returns the virtual host persistence.
323             *
324             * @return the virtual host persistence
325             */
326            public VirtualHostPersistence getVirtualHostPersistence() {
327                    return virtualHostPersistence;
328            }
329    
330            /**
331             * Sets the virtual host persistence.
332             *
333             * @param virtualHostPersistence the virtual host persistence
334             */
335            public void setVirtualHostPersistence(
336                    VirtualHostPersistence virtualHostPersistence) {
337                    this.virtualHostPersistence = virtualHostPersistence;
338            }
339    
340            /**
341             * Returns the counter local service.
342             *
343             * @return the counter local service
344             */
345            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
346                    return counterLocalService;
347            }
348    
349            /**
350             * Sets the counter local service.
351             *
352             * @param counterLocalService the counter local service
353             */
354            public void setCounterLocalService(
355                    com.liferay.counter.service.CounterLocalService counterLocalService) {
356                    this.counterLocalService = counterLocalService;
357            }
358    
359            /**
360             * Returns the company local service.
361             *
362             * @return the company local service
363             */
364            public com.liferay.portal.service.CompanyLocalService getCompanyLocalService() {
365                    return companyLocalService;
366            }
367    
368            /**
369             * Sets the company local service.
370             *
371             * @param companyLocalService the company local service
372             */
373            public void setCompanyLocalService(
374                    com.liferay.portal.service.CompanyLocalService companyLocalService) {
375                    this.companyLocalService = companyLocalService;
376            }
377    
378            /**
379             * Returns the company remote service.
380             *
381             * @return the company remote service
382             */
383            public com.liferay.portal.service.CompanyService getCompanyService() {
384                    return companyService;
385            }
386    
387            /**
388             * Sets the company remote service.
389             *
390             * @param companyService the company remote service
391             */
392            public void setCompanyService(
393                    com.liferay.portal.service.CompanyService companyService) {
394                    this.companyService = companyService;
395            }
396    
397            /**
398             * Returns the company persistence.
399             *
400             * @return the company persistence
401             */
402            public CompanyPersistence getCompanyPersistence() {
403                    return companyPersistence;
404            }
405    
406            /**
407             * Sets the company persistence.
408             *
409             * @param companyPersistence the company persistence
410             */
411            public void setCompanyPersistence(CompanyPersistence companyPersistence) {
412                    this.companyPersistence = companyPersistence;
413            }
414    
415            /**
416             * Returns the group local service.
417             *
418             * @return the group local service
419             */
420            public com.liferay.portal.service.GroupLocalService getGroupLocalService() {
421                    return groupLocalService;
422            }
423    
424            /**
425             * Sets the group local service.
426             *
427             * @param groupLocalService the group local service
428             */
429            public void setGroupLocalService(
430                    com.liferay.portal.service.GroupLocalService groupLocalService) {
431                    this.groupLocalService = groupLocalService;
432            }
433    
434            /**
435             * Returns the group remote service.
436             *
437             * @return the group remote service
438             */
439            public com.liferay.portal.service.GroupService getGroupService() {
440                    return groupService;
441            }
442    
443            /**
444             * Sets the group remote service.
445             *
446             * @param groupService the group remote service
447             */
448            public void setGroupService(
449                    com.liferay.portal.service.GroupService groupService) {
450                    this.groupService = groupService;
451            }
452    
453            /**
454             * Returns the group persistence.
455             *
456             * @return the group persistence
457             */
458            public GroupPersistence getGroupPersistence() {
459                    return groupPersistence;
460            }
461    
462            /**
463             * Sets the group persistence.
464             *
465             * @param groupPersistence the group persistence
466             */
467            public void setGroupPersistence(GroupPersistence groupPersistence) {
468                    this.groupPersistence = groupPersistence;
469            }
470    
471            /**
472             * Returns the group finder.
473             *
474             * @return the group finder
475             */
476            public GroupFinder getGroupFinder() {
477                    return groupFinder;
478            }
479    
480            /**
481             * Sets the group finder.
482             *
483             * @param groupFinder the group finder
484             */
485            public void setGroupFinder(GroupFinder groupFinder) {
486                    this.groupFinder = groupFinder;
487            }
488    
489            /**
490             * Returns the layout set local service.
491             *
492             * @return the layout set local service
493             */
494            public com.liferay.portal.service.LayoutSetLocalService getLayoutSetLocalService() {
495                    return layoutSetLocalService;
496            }
497    
498            /**
499             * Sets the layout set local service.
500             *
501             * @param layoutSetLocalService the layout set local service
502             */
503            public void setLayoutSetLocalService(
504                    com.liferay.portal.service.LayoutSetLocalService layoutSetLocalService) {
505                    this.layoutSetLocalService = layoutSetLocalService;
506            }
507    
508            /**
509             * Returns the layout set remote service.
510             *
511             * @return the layout set remote service
512             */
513            public com.liferay.portal.service.LayoutSetService getLayoutSetService() {
514                    return layoutSetService;
515            }
516    
517            /**
518             * Sets the layout set remote service.
519             *
520             * @param layoutSetService the layout set remote service
521             */
522            public void setLayoutSetService(
523                    com.liferay.portal.service.LayoutSetService layoutSetService) {
524                    this.layoutSetService = layoutSetService;
525            }
526    
527            /**
528             * Returns the layout set persistence.
529             *
530             * @return the layout set persistence
531             */
532            public LayoutSetPersistence getLayoutSetPersistence() {
533                    return layoutSetPersistence;
534            }
535    
536            /**
537             * Sets the layout set persistence.
538             *
539             * @param layoutSetPersistence the layout set persistence
540             */
541            public void setLayoutSetPersistence(
542                    LayoutSetPersistence layoutSetPersistence) {
543                    this.layoutSetPersistence = layoutSetPersistence;
544            }
545    
546            public void afterPropertiesSet() {
547                    persistedModelLocalServiceRegistry.register("com.liferay.portal.model.VirtualHost",
548                            virtualHostLocalService);
549            }
550    
551            public void destroy() {
552                    persistedModelLocalServiceRegistry.unregister(
553                            "com.liferay.portal.model.VirtualHost");
554            }
555    
556            /**
557             * Returns the OSGi service identifier.
558             *
559             * @return the OSGi service identifier
560             */
561            @Override
562            public String getOSGiServiceIdentifier() {
563                    return VirtualHostLocalService.class.getName();
564            }
565    
566            protected Class<?> getModelClass() {
567                    return VirtualHost.class;
568            }
569    
570            protected String getModelClassName() {
571                    return VirtualHost.class.getName();
572            }
573    
574            /**
575             * Performs a SQL query.
576             *
577             * @param sql the sql query
578             */
579            protected void runSQL(String sql) {
580                    try {
581                            DataSource dataSource = virtualHostPersistence.getDataSource();
582    
583                            DB db = DBFactoryUtil.getDB();
584    
585                            sql = db.buildSQL(sql);
586                            sql = PortalUtil.transformSQL(sql);
587    
588                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
589                                            sql, new int[0]);
590    
591                            sqlUpdate.update();
592                    }
593                    catch (Exception e) {
594                            throw new SystemException(e);
595                    }
596            }
597    
598            @BeanReference(type = com.liferay.portal.service.VirtualHostLocalService.class)
599            protected VirtualHostLocalService virtualHostLocalService;
600            @BeanReference(type = VirtualHostPersistence.class)
601            protected VirtualHostPersistence virtualHostPersistence;
602            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
603            protected com.liferay.counter.service.CounterLocalService counterLocalService;
604            @BeanReference(type = com.liferay.portal.service.CompanyLocalService.class)
605            protected com.liferay.portal.service.CompanyLocalService companyLocalService;
606            @BeanReference(type = com.liferay.portal.service.CompanyService.class)
607            protected com.liferay.portal.service.CompanyService companyService;
608            @BeanReference(type = CompanyPersistence.class)
609            protected CompanyPersistence companyPersistence;
610            @BeanReference(type = com.liferay.portal.service.GroupLocalService.class)
611            protected com.liferay.portal.service.GroupLocalService groupLocalService;
612            @BeanReference(type = com.liferay.portal.service.GroupService.class)
613            protected com.liferay.portal.service.GroupService groupService;
614            @BeanReference(type = GroupPersistence.class)
615            protected GroupPersistence groupPersistence;
616            @BeanReference(type = GroupFinder.class)
617            protected GroupFinder groupFinder;
618            @BeanReference(type = com.liferay.portal.service.LayoutSetLocalService.class)
619            protected com.liferay.portal.service.LayoutSetLocalService layoutSetLocalService;
620            @BeanReference(type = com.liferay.portal.service.LayoutSetService.class)
621            protected com.liferay.portal.service.LayoutSetService layoutSetService;
622            @BeanReference(type = LayoutSetPersistence.class)
623            protected LayoutSetPersistence layoutSetPersistence;
624            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
625            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
626    }