class MbcHorarioTurnoCirgRN extends BaseBusiness {

	protected void verificarColisaoHorario(final MbcHorarioTurnoCirg novo) throws ApplicationBusinessException {
		Calendar calHrIni = DateUtil.getCalendarBy(novo.getHorarioInicial());
		Calendar calHrFim = DateUtil.getCalendarBy(novo.getHorarioFinal());
		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);
		final List<MbcHorarioTurnoCirg> horarioTurnoCirgs = this.getMbcHorarioTurnoCirgDAO().buscarHorariosCirgOutrosTurnos(
				novo.getAghUnidadesFuncionais().getSeq(), novo.getId().getTurno());
		for (final MbcHorarioTurnoCirg horarioTurnoCirg : horarioTurnoCirgs) {
			calHrIni = DateUtil.getCalendarBy(horarioTurnoCirg.getHorarioInicial());
			calHrFim = DateUtil.getCalendarBy(horarioTurnoCirg.getHorarioFinal());
			final int hrIni = calHrIni.get(Calendar.HOUR_OF_DAY) * 60 + calHrIni.get(Calendar.MINUTE);
			final int hrFim = calHrFim.get(Calendar.HOUR_OF_DAY) * 60 + calHrFim.get(Calendar.MINUTE);
			if (hrIni < hrFim) {
				if (!((novoHrIni < hrIni && novoHrFim <= hrIni) || (novoHrIni >= hrFim && novoHrFim > hrFim) || (novoHrIni >= hrFim && novoHrFim <= hrIni))) {
					throw new ApplicationBusinessException(MbcHorarioTurnoCirgRNExceptionCode.MBC_00202);
				}
			} else {
				if (!(novoHrIni < hrIni && novoHrIni >= hrFim && novoHrFim <= hrIni && novoHrFim > hrFim)) {
					throw new ApplicationBusinessException(MbcHorarioTurnoCirgRNExceptionCode.MBC_00202);
				}
			}
		}

	}

}