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