1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.model.OrgLabor;
20  import com.liferay.portal.security.permission.ActionKeys;
21  import com.liferay.portal.service.base.OrgLaborServiceBaseImpl;
22  import com.liferay.portal.service.permission.OrganizationPermissionUtil;
23  
24  import java.util.List;
25  
26  /**
27   * <a href="OrgLaborServiceImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class OrgLaborServiceImpl extends OrgLaborServiceBaseImpl {
32  
33      public OrgLabor addOrgLabor(
34              long organizationId, int typeId, int sunOpen, int sunClose,
35              int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
36              int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
37              int satOpen, int satClose)
38          throws PortalException, SystemException {
39  
40          OrganizationPermissionUtil.check(
41              getPermissionChecker(), organizationId, ActionKeys.UPDATE);
42  
43          return orgLaborLocalService.addOrgLabor(
44              organizationId, typeId, sunOpen, sunClose, monOpen, monClose,
45              tueOpen, tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen,
46              friClose, satOpen, satClose);
47      }
48  
49      public void deleteOrgLabor(long orgLaborId)
50          throws PortalException, SystemException {
51  
52          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
53  
54          OrganizationPermissionUtil.check(
55              getPermissionChecker(), orgLabor.getOrganizationId(),
56              ActionKeys.UPDATE);
57  
58          orgLaborLocalService.deleteOrgLabor(orgLaborId);
59      }
60  
61      public OrgLabor getOrgLabor(long orgLaborId)
62          throws PortalException, SystemException {
63  
64          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
65  
66          OrganizationPermissionUtil.check(
67              getPermissionChecker(), orgLabor.getOrganizationId(),
68              ActionKeys.VIEW);
69  
70          return orgLabor;
71      }
72  
73      public List<OrgLabor> getOrgLabors(long organizationId)
74          throws PortalException, SystemException {
75  
76          OrganizationPermissionUtil.check(
77              getPermissionChecker(), organizationId, ActionKeys.VIEW);
78  
79          return orgLaborLocalService.getOrgLabors(organizationId);
80      }
81  
82      public OrgLabor updateOrgLabor(
83              long orgLaborId, int typeId, int sunOpen, int sunClose, int monOpen,
84              int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
85              int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
86              int satClose)
87          throws PortalException, SystemException {
88  
89          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
90  
91          OrganizationPermissionUtil.check(
92              getPermissionChecker(), orgLabor.getOrganizationId(),
93              ActionKeys.UPDATE);
94  
95          return orgLaborLocalService.updateOrgLabor(
96              orgLaborId, typeId ,sunOpen, sunClose, monOpen, monClose, tueOpen,
97              tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen, friClose,
98              satOpen, satClose);
99      }
100 
101 }