1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.model.OrgLabor;
20  import com.liferay.portal.model.impl.ListTypeImpl;
21  import com.liferay.portal.service.base.OrgLaborLocalServiceBaseImpl;
22  
23  import java.util.List;
24  
25  /**
26   * <a href="OrgLaborLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class OrgLaborLocalServiceImpl extends OrgLaborLocalServiceBaseImpl {
31  
32      public OrgLabor addOrgLabor(
33              long organizationId, int typeId, int sunOpen, int sunClose,
34              int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
35              int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
36              int satOpen, int satClose)
37          throws PortalException, SystemException {
38  
39          validate(typeId);
40  
41          long orgLaborId = counterLocalService.increment();
42  
43          OrgLabor orgLabor = orgLaborPersistence.create(orgLaborId);
44  
45          orgLabor.setOrganizationId(organizationId);
46          orgLabor.setTypeId(typeId);
47          orgLabor.setSunOpen(sunOpen);
48          orgLabor.setSunClose(sunClose);
49          orgLabor.setMonOpen(monOpen);
50          orgLabor.setMonClose(monClose);
51          orgLabor.setTueOpen(tueOpen);
52          orgLabor.setTueClose(tueClose);
53          orgLabor.setWedOpen(wedOpen);
54          orgLabor.setWedClose(wedClose);
55          orgLabor.setThuOpen(thuOpen);
56          orgLabor.setThuClose(thuClose);
57          orgLabor.setFriOpen(friOpen);
58          orgLabor.setFriClose(friClose);
59          orgLabor.setSatOpen(satOpen);
60          orgLabor.setSatClose(satClose);
61  
62          orgLaborPersistence.update(orgLabor, false);
63  
64          return orgLabor;
65      }
66  
67      public void deleteOrgLabor(long orgLaborId)
68          throws PortalException, SystemException {
69  
70          orgLaborPersistence.remove(orgLaborId);
71      }
72  
73      public OrgLabor getOrgLabor(long orgLaborId)
74          throws PortalException, SystemException {
75  
76          return orgLaborPersistence.findByPrimaryKey(orgLaborId);
77      }
78  
79      public List<OrgLabor> getOrgLabors(long organizationId)
80          throws SystemException {
81  
82          return orgLaborPersistence.findByOrganizationId(organizationId);
83      }
84  
85      public OrgLabor updateOrgLabor(
86              long orgLaborId, int typeId, int sunOpen, int sunClose, int monOpen,
87              int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
88              int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
89              int satClose)
90          throws PortalException, SystemException {
91  
92          validate(typeId);
93  
94          OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
95  
96          orgLabor.setTypeId(typeId);
97          orgLabor.setSunOpen(sunOpen);
98          orgLabor.setSunClose(sunClose);
99          orgLabor.setMonOpen(monOpen);
100         orgLabor.setMonClose(monClose);
101         orgLabor.setTueOpen(tueOpen);
102         orgLabor.setTueClose(tueClose);
103         orgLabor.setWedOpen(wedOpen);
104         orgLabor.setWedClose(wedClose);
105         orgLabor.setThuOpen(thuOpen);
106         orgLabor.setThuClose(thuClose);
107         orgLabor.setFriOpen(friOpen);
108         orgLabor.setFriClose(friClose);
109         orgLabor.setSatOpen(satOpen);
110         orgLabor.setSatClose(satClose);
111 
112         orgLaborPersistence.update(orgLabor, false);
113 
114         return orgLabor;
115     }
116 
117     protected void validate(int typeId)
118         throws PortalException, SystemException {
119 
120         listTypeService.validate(typeId, ListTypeImpl.ORGANIZATION_SERVICE);
121     }
122 
123 }