1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.model.OrgLabor;
28  import com.liferay.portal.security.permission.ActionKeys;
29  import com.liferay.portal.service.base.OrgLaborServiceBaseImpl;
30  import com.liferay.portal.service.permission.OrganizationPermissionUtil;
31  
32  import java.util.List;
33  
34  /**
35   * <a href="OrgLaborServiceImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   */
39  public class OrgLaborServiceImpl extends OrgLaborServiceBaseImpl {
40  
41      public OrgLabor addOrgLabor(
42              long organizationId, int typeId, int sunOpen, int sunClose,
43              int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
44              int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
45              int satOpen, int satClose)
46          throws PortalException, SystemException {
47  
48          OrganizationPermissionUtil.check(
49              getPermissionChecker(), organizationId, ActionKeys.UPDATE);
50  
51          return orgLaborLocalService.addOrgLabor(
52              organizationId, typeId, sunOpen, sunClose, monOpen, monClose,
53              tueOpen, tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen,
54              friClose, satOpen, satClose);
55      }
56  
57      public void deleteOrgLabor(long orgLaborId)
58          throws PortalException, SystemException {
59  
60          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
61  
62          OrganizationPermissionUtil.check(
63              getPermissionChecker(), orgLabor.getOrganizationId(),
64              ActionKeys.UPDATE);
65  
66          orgLaborLocalService.deleteOrgLabor(orgLaborId);
67      }
68  
69      public OrgLabor getOrgLabor(long orgLaborId)
70          throws PortalException, SystemException {
71  
72          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
73  
74          OrganizationPermissionUtil.check(
75              getPermissionChecker(), orgLabor.getOrganizationId(),
76              ActionKeys.VIEW);
77  
78          return orgLabor;
79      }
80  
81      public List<OrgLabor> getOrgLabors(long organizationId)
82          throws PortalException, SystemException {
83  
84          OrganizationPermissionUtil.check(
85              getPermissionChecker(), organizationId, ActionKeys.VIEW);
86  
87          return orgLaborLocalService.getOrgLabors(organizationId);
88      }
89  
90      public OrgLabor updateOrgLabor(
91              long orgLaborId, int typeId, int sunOpen, int sunClose, int monOpen,
92              int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
93              int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
94              int satClose)
95          throws PortalException, SystemException {
96  
97          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
98  
99          OrganizationPermissionUtil.check(
100             getPermissionChecker(), orgLabor.getOrganizationId(),
101             ActionKeys.UPDATE);
102 
103         return orgLaborLocalService.updateOrgLabor(
104             orgLaborId, typeId ,sunOpen, sunClose, monOpen, monClose, tueOpen,
105             tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen, friClose,
106             satOpen, satClose);
107     }
108 
109 }