Java Code Examples for ims.framework.utils.Time.isGreaterOrEqualThan()

The following are Jave code examples for showing how to use isGreaterOrEqualThan() of the ims.framework.utils.Time class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AvoinApotti   File: BookAppointmentImpl.java   View Source Code Vote up 6 votes
private boolean appointmentOverlapsInterval(Booking_Appointment appointment, Time sessionStartTime, Time sessionEndTime)
{
	if (appointment == null || appointment.getApptStartTime() == null || appointment.getApptEndTime() == null)
		return false;
		
	if (sessionStartTime == null || sessionEndTime == null)
		return false;
	
	Time appointmentStartTime = new Time(appointment.getApptStartTime());
	Time appointmentEndTime = new Time(appointment.getApptEndTime());
	
	if (appointmentStartTime.isLessOrEqualThan(sessionStartTime) && appointmentEndTime.isLessOrEqualThan(sessionStartTime))
		return false;
	
	if (appointmentStartTime.isGreaterOrEqualThan(sessionEndTime) && appointmentEndTime.isGreaterOrEqualThan(sessionEndTime))
		return false;
	
	return true;
}
 
Example 2
Project: AvoinApotti   File: GenerateSessionsImpl.java   View Source Code Vote up 6 votes
private boolean isSlotTimeWithinExclusionTimes(String newStartTime, Set exclusionTimes, Integer duration)
{
	Time proposedSlotTime = new Time(newStartTime);
	Iterator it = exclusionTimes.iterator();
	while(it.hasNext())
	{
		Session_Exc_Time exTime = (Session_Exc_Time) it.next();
		Time exStartTime = new Time(exTime.getStartTime());
		Time exEndTime = new Time(exTime.getEndTime());
		
		Time proposedSlotEndTime = (Time) proposedSlotTime.clone();
		proposedSlotEndTime.addMinutes(duration);
		
		if((proposedSlotTime.isGreaterOrEqualThan(exStartTime) || proposedSlotEndTime.isGreaterThan(exStartTime)) && proposedSlotTime.isLessThan(exEndTime) )
			return true;
	}
	
	return false;
}
 
Example 3
Project: AvoinApotti   File: BookAppointmentImpl.java   View Source Code Vote up 4 votes
private void reduceRemainingSlotsOrTimes(Booking_Appointment doBookAppt) 
{
	if (doBookAppt.getSession() != null)
	{
		getDomainFactory().refresh(doBookAppt.getSession());
		
		//if flexible decrement TimeRemaining
		if(doBookAppt.getSession().isIsFixed() != null && !doBookAppt.getSession().isIsFixed())
		{
			if (doBookAppt.getApptStartTime() != null && doBookAppt.getApptEndTime() != null && doBookAppt.getSession().getStartTm() != null && doBookAppt.getSession().getEndTm() != null && doBookAppt.getSession().getRemainingTime() != null)
			{
				Time sessionStartTime = new Time(doBookAppt.getSession().getStartTm());
				Time sessionEndTime = new Time(doBookAppt.getSession().getEndTm());
				
				Time appointmentStartTime = new Time(doBookAppt.getApptStartTime());
				Time appointmentEndTime = new Time(doBookAppt.getApptEndTime());
				
				if (appointmentOverlapsInterval(doBookAppt, sessionStartTime, sessionEndTime))
				{
   					Time startTime = sessionStartTime.isGreaterOrEqualThan(appointmentStartTime) ? sessionStartTime : appointmentStartTime;
   					Time endTime = sessionEndTime.isLessOrEqualThan(appointmentEndTime) ? sessionEndTime : appointmentEndTime;
   					
					int remainingMinutes = doBookAppt.getSession().getRemainingTime();
					remainingMinutes -= calculateApptDuration(startTime, endTime);
					
					doBookAppt.getSession().setRemainingTime(remainingMinutes);
				}
			}
		}
		else
		{
			int remainingSlots = doBookAppt.getSession().getRemainingSlots();
			remainingSlots -= 1;
			
			if(remainingSlots < 0)
				remainingSlots = 0;
			
			doBookAppt.getSession().setRemainingSlots(remainingSlots);	
		}
	}
}
 
Example 4
Project: AvoinApotti   File: SessionAdminImpl.java   View Source Code Vote up 4 votes
private Booking_Appointment saveAppt(DomainFactory factory, Booking_AppointmentVo appt) throws StaleObjectException
{
	Booking_Appointment doAppt = Booking_AppointmentVoAssembler.extractBooking_Appointment(factory, appt);

	// increment slots remaining if its a cancel
	// wdev-5745 only for non-icab bookings as they will get set to
	// provisional only
	if ((doAppt.isIsCABBooking() == null || doAppt.isIsCABBooking().booleanValue() == false) && doAppt.getApptStatus().equals(getDomLookup(Status_Reason.CANCELLED)))
		doAppt.getSession().incrementRemainingSlots(1);

	// WDEV-8921 - if we are cancelling a flexible slot increment the time remaining for the session 	<- Nice try, but no
	
	// WDEV-14463 - For cancelled appointment - re add the time.
	if ((doAppt.getSession() != null && doAppt.getSession().isIsFixed() != null && !doAppt.getSession().isIsFixed()) && (doAppt.getApptStatus() != null && doAppt.getApptStatus().equals(getDomLookup(Status_Reason.CANCELLED))))
	{
		if (doAppt.getSession().getRemainingTime() != null && doAppt.getApptStartTime() != null && doAppt.getApptEndTime() != null && doAppt.getSession().getStartTm() != null && doAppt.getSession().getEndTm() != null)
		{
			Time sessionStartTime = new Time(doAppt.getSession().getStartTm());
			Time sessionEndTime = new Time(doAppt.getSession().getEndTm());
			
			Time appointmentStartTime = new Time(doAppt.getApptStartTime());
			Time appointmentEndTime = new Time(doAppt.getApptEndTime());
			
			Time startTime = sessionStartTime.isGreaterOrEqualThan(appointmentStartTime) ? sessionStartTime : appointmentStartTime;
			Time endTime = sessionEndTime.isLessOrEqualThan(appointmentEndTime) ? sessionEndTime : appointmentEndTime;
			

			if ((appointmentStartTime.isGreaterOrEqualThan(appointmentEndTime) && startTime.isGreaterOrEqualThan(endTime)) || startTime.isLessOrEqualThan(endTime))
			{
				doAppt.getSession().setRemainingTime(doAppt.getSession().getRemainingTime() + calculateApptDuration(startTime, endTime));
			}
		}
	}

	// WDEV-5745 only set to cancelled provisional at this stage
	if (doAppt.isIsCABBooking() != null && doAppt.isIsCABBooking().booleanValue() == true && ConfigFlag.GEN.ICAB_ENABLED.getValue())
		doAppt.setApptStatus(getDomLookup(Status_Reason.CANCEL_PROVISIONAL));

	// WDEV-5021
	updateJourney(doAppt, true);

	/*
	 * WDEV-11780 try { factory.save(doAppt); } catch (DomainException e) {
	 * throw new DomainRuntimeException("Domain Error occured in saveAppt "
	 * + e.getMessage(), e); }
	 */

	// WDEV-11780
	factory.save(doAppt);

	return doAppt;
}