/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.service.impl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.ListTypeConstants;
import com.liferay.portal.kernel.model.OrgLabor;
import com.liferay.portal.service.base.OrgLaborLocalServiceBaseImpl;
import java.util.List;
/**
* @author Brian Wing Shun Chan
*/
public class OrgLaborLocalServiceImpl extends OrgLaborLocalServiceBaseImpl {
@Override
public OrgLabor addOrgLabor(
long organizationId, long typeId, int sunOpen, int sunClose,
int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
int satOpen, int satClose)
throws PortalException {
validate(typeId);
long orgLaborId = counterLocalService.increment();
OrgLabor orgLabor = orgLaborPersistence.create(orgLaborId);
orgLabor.setOrganizationId(organizationId);
orgLabor.setTypeId(typeId);
orgLabor.setSunOpen(sunOpen);
orgLabor.setSunClose(sunClose);
orgLabor.setMonOpen(monOpen);
orgLabor.setMonClose(monClose);
orgLabor.setTueOpen(tueOpen);
orgLabor.setTueClose(tueClose);
orgLabor.setWedOpen(wedOpen);
orgLabor.setWedClose(wedClose);
orgLabor.setThuOpen(thuOpen);
orgLabor.setThuClose(thuClose);
orgLabor.setFriOpen(friOpen);
orgLabor.setFriClose(friClose);
orgLabor.setSatOpen(satOpen);
orgLabor.setSatClose(satClose);
orgLaborPersistence.update(orgLabor);
return orgLabor;
}
@Override
public List<OrgLabor> getOrgLabors(long organizationId) {
return orgLaborPersistence.findByOrganizationId(organizationId);
}
@Override
public OrgLabor updateOrgLabor(
long orgLaborId, long typeId, int sunOpen, int sunClose,
int monOpen, int monClose, int tueOpen, int tueClose, int wedOpen,
int wedClose, int thuOpen, int thuClose, int friOpen, int friClose,
int satOpen, int satClose)
throws PortalException {
validate(typeId);
OrgLabor orgLabor = orgLaborPersistence.findByPrimaryKey(orgLaborId);
orgLabor.setTypeId(typeId);
orgLabor.setSunOpen(sunOpen);
orgLabor.setSunClose(sunClose);
orgLabor.setMonOpen(monOpen);
orgLabor.setMonClose(monClose);
orgLabor.setTueOpen(tueOpen);
orgLabor.setTueClose(tueClose);
orgLabor.setWedOpen(wedOpen);
orgLabor.setWedClose(wedClose);
orgLabor.setThuOpen(thuOpen);
orgLabor.setThuClose(thuClose);
orgLabor.setFriOpen(friOpen);
orgLabor.setFriClose(friClose);
orgLabor.setSatOpen(satOpen);
orgLabor.setSatClose(satClose);
orgLaborPersistence.update(orgLabor);
return orgLabor;
}
protected void validate(long typeId) throws PortalException {
listTypeLocalService.validate(
typeId, ListTypeConstants.ORGANIZATION_SERVICE);
}
}