class MbcCaractSalaEspRN extends BaseBusiness {

	protected void verificarColisaoHorario(final MbcCaractSalaEsp novo) throws ApplicationBusinessException {
		if(novo.getHoraInicioEquipe() != null && novo.getHoraFimEquipe() != null) {
			Calendar calHrIni = DateUtil.getCalendarBy(novo.getHoraInicioEquipe());
			Calendar calHrFim = DateUtil.getCalendarBy(novo.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);
			
			final List<MbcCaractSalaEsp> caractSalaEsp = this.getMbcCaractSalaEspDAO().buscarOutrosHorariosCaractSala(
					novo.getMbcCaracteristicaSalaCirg(), novo.getId().getSeqp(), novo.getHoraInicioEquipe(), novo.getHoraFimEquipe());
			
			for (final MbcCaractSalaEsp item : caractSalaEsp) {
				calHrIni = DateUtil.getCalendarBy(item.getHoraInicioEquipe());
				calHrFim = DateUtil.getCalendarBy(item.getHoraFimEquipe());
				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(MbcCaractSalaEspRNExceptionCode.MBC_01136);
					}
				} else {
					if (!(novoHrIni < hrIni && novoHrIni >= hrFim && novoHrFim <= hrIni && novoHrFim > hrFim)) {
						throw new ApplicationBusinessException(MbcCaractSalaEspRNExceptionCode.MBC_01322);
					}
				}
			}
		} else if((novo.getHoraInicioEquipe() != null && novo.getHoraFimEquipe() == null)
				|| (novo.getHoraInicioEquipe() == null && novo.getHoraFimEquipe() != null)) {
			throw new ApplicationBusinessException(MbcCaractSalaEspRNExceptionCode.MBC_01135);
		}

	}

}