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