class MbcCaractSalaEspRN extends BaseBusiness {

	protected void verificarHorarioTurno(MbcCaractSalaEsp mbcCaractSalaEsp) throws ApplicationBusinessException {
		if(mbcCaractSalaEsp.getHoraInicioEquipe() != null && mbcCaractSalaEsp.getHoraFimEquipe() != null) {
			Calendar calHrIni = DateUtil.getCalendarBy(mbcCaractSalaEsp.getHoraInicioEquipe());
			Calendar calHrFim = DateUtil.getCalendarBy(mbcCaractSalaEsp.getHoraFimEquipe());
			final int novoHrIni = calHrIni.get(Calendar.HOUR_OF_DAY) * 60 + calHrIni.get(Calendar.MINUTE);
			final int novoHrFim = calHrFim.get(Calendar.HOUR_OF_DAY) * 60 + calHrFim.get(Calendar.MINUTE);
			
			MbcHorarioTurnoCirg horarioTurno = mbcCaractSalaEsp.getMbcCaracteristicaSalaCirg().getMbcHorarioTurnoCirg();
			
			if(horarioTurno == null) {
				throw new ApplicationBusinessException(MbcCaractSalaEspRNExceptionCode.MBC_01137);
			}
			
			calHrIni = DateUtil.getCalendarBy(horarioTurno.getHorarioInicial());
			calHrFim = DateUtil.getCalendarBy(horarioTurno.getHorarioFinal());
			final int hrIniTurno = calHrIni.get(Calendar.HOUR_OF_DAY) * 60 + calHrIni.get(Calendar.MINUTE);
			final int hrFimTurno = calHrFim.get(Calendar.HOUR_OF_DAY) * 60 + calHrFim.get(Calendar.MINUTE);
			final int hora_fim_cse;
			final int hora_fim_param;
			if (hrFimTurno == 0) {
				hora_fim_cse = HORA_MIN_FINAL_DIA;
			} else {
				hora_fim_cse = hrFimTurno;
			}
			if (novoHrFim == 0) {
				hora_fim_param = HORA_MIN_FINAL_DIA;
			} else {
				hora_fim_param = novoHrFim;
			}
			
			if (hrIniTurno > novoHrIni || hrIniTurno > hora_fim_param || hora_fim_cse < novoHrIni || hora_fim_cse < hora_fim_param) {
				throw new ApplicationBusinessException(MbcCaractSalaEspRNExceptionCode.MBC_01138);
			}
		}
	}

}