001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.OrgLabor;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.base.OrgLaborServiceBaseImpl;
022    import com.liferay.portal.service.permission.OrganizationPermissionUtil;
023    
024    import java.util.List;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class OrgLaborServiceImpl extends OrgLaborServiceBaseImpl {
030    
031            @Override
032            public OrgLabor addOrgLabor(
033                            long organizationId, int typeId, int sunOpen, int sunClose,
034                            int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
035                            int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
036                            int satOpen, int satClose)
037                    throws PortalException, SystemException {
038    
039                    OrganizationPermissionUtil.check(
040                            getPermissionChecker(), organizationId, ActionKeys.UPDATE);
041    
042                    return orgLaborLocalService.addOrgLabor(
043                            organizationId, typeId, sunOpen, sunClose, monOpen, monClose,
044                            tueOpen, tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen,
045                            friClose, satOpen, satClose);
046            }
047    
048            @Override
049            public void deleteOrgLabor(long orgLaborId)
050                    throws PortalException, SystemException {
051    
052                    OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
053    
054                    OrganizationPermissionUtil.check(
055                            getPermissionChecker(), orgLabor.getOrganizationId(),
056                            ActionKeys.UPDATE);
057    
058                    orgLaborLocalService.deleteOrgLabor(orgLaborId);
059            }
060    
061            @Override
062            public OrgLabor getOrgLabor(long orgLaborId)
063                    throws PortalException, SystemException {
064    
065                    OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
066    
067                    OrganizationPermissionUtil.check(
068                            getPermissionChecker(), orgLabor.getOrganizationId(),
069                            ActionKeys.VIEW);
070    
071                    return orgLabor;
072            }
073    
074            @Override
075            public List<OrgLabor> getOrgLabors(long organizationId)
076                    throws PortalException, SystemException {
077    
078                    OrganizationPermissionUtil.check(
079                            getPermissionChecker(), organizationId, ActionKeys.VIEW);
080    
081                    return orgLaborLocalService.getOrgLabors(organizationId);
082            }
083    
084            @Override
085            public OrgLabor updateOrgLabor(
086                            long orgLaborId, int typeId, int sunOpen, int sunClose, int monOpen,
087                            int monClose, int tueOpen, int tueClose, int wedOpen, int wedClose,
088                            int thuOpen, int thuClose, int friOpen, int friClose, int satOpen,
089                            int satClose)
090                    throws PortalException, SystemException {
091    
092                    OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
093    
094                    OrganizationPermissionUtil.check(
095                            getPermissionChecker(), orgLabor.getOrganizationId(),
096                            ActionKeys.UPDATE);
097    
098                    return orgLaborLocalService.updateOrgLabor(
099                            orgLaborId, typeId, sunOpen, sunClose, monOpen, monClose, tueOpen,
100                            tueClose, wedOpen, wedClose, thuOpen, thuClose, friOpen, friClose,
101                            satOpen, satClose);
102            }
103    
104    }