1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.util.List;
32  
33  /**
34   * <a href="OrgLaborLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class OrgLaborLocalServiceImpl extends OrgLaborLocalServiceBaseImpl {
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          validate(typeId);
49  
50          long orgLaborId = counterLocalService.increment();
51  
52          OrgLabor orgLabor = orgLaborPersistence.create(orgLaborId);
53  
54          orgLabor.setOrganizationId(organizationId);
55          orgLabor.setTypeId(typeId);
56          orgLabor.setSunOpen(sunOpen);
57          orgLabor.setSunClose(sunClose);
58          orgLabor.setMonOpen(monOpen);
59          orgLabor.setMonClose(monClose);
60          orgLabor.setTueOpen(tueOpen);
61          orgLabor.setTueClose(tueClose);
62          orgLabor.setWedOpen(wedOpen);
63          orgLabor.setWedClose(wedClose);
64          orgLabor.setThuOpen(thuOpen);
65          orgLabor.setThuClose(thuClose);
66          orgLabor.setFriOpen(friOpen);
67          orgLabor.setFriClose(friClose);
68          orgLabor.setSatOpen(satOpen);
69          orgLabor.setSatClose(satClose);
70  
71          orgLaborPersistence.update(orgLabor, false);
72  
73          return orgLabor;
74      }
75  
76      public void deleteOrgLabor(long orgLaborId)
77          throws PortalException, SystemException {
78  
79          orgLaborPersistence.remove(orgLaborId);
80      }
81  
82      public OrgLabor getOrgLabor(long orgLaborId)
83          throws PortalException, SystemException {
84  
85          return orgLaborPersistence.findByPrimaryKey(orgLaborId);
86      }
87  
88      public List<OrgLabor> getOrgLabors(long organizationId)
89          throws SystemException {
90  
91          return orgLaborPersistence.findByOrganizationId(organizationId);
92      }
93  
94      public OrgLabor updateOrgLabor(
95              long orgLaborId, int typeId, int sunOpen, int sunClose, int monOpen,
96              int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
97              int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
98              int satClose)
99          throws PortalException, SystemException {
100 
101         validate(typeId);
102 
103         OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
104 
105         orgLabor.setTypeId(typeId);
106         orgLabor.setSunOpen(sunOpen);
107         orgLabor.setSunClose(sunClose);
108         orgLabor.setMonOpen(monOpen);
109         orgLabor.setMonClose(monClose);
110         orgLabor.setTueOpen(tueOpen);
111         orgLabor.setTueClose(tueClose);
112         orgLabor.setWedOpen(wedOpen);
113         orgLabor.setWedClose(wedClose);
114         orgLabor.setThuOpen(thuOpen);
115         orgLabor.setThuClose(thuClose);
116         orgLabor.setFriOpen(friOpen);
117         orgLabor.setFriClose(friClose);
118         orgLabor.setSatOpen(satOpen);
119         orgLabor.setSatClose(satClose);
120 
121         orgLaborPersistence.update(orgLabor, false);
122 
123         return orgLabor;
124     }
125 
126     protected void validate(int typeId)
127         throws PortalException, SystemException {
128 
129         listTypeService.validate(typeId, ListTypeImpl.ORGANIZATION_SERVICE);
130     }
131 
132 }