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