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

The following are Jave code examples for showing how to use isLessOrEqualThan() 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: Logic.java   View Source Code Vote up 6 votes
private boolean checkExistingTime(DailyFluidBalanceVo voDaily, FluidBalanceInstanceVo voFluidBalInst)
{
	FluidBalanceInstanceVoCollection voFluidBalInstances = voDaily.getFluidBalanceInstances();
	boolean result = false;
	if(voFluidBalInstances != null)
	{
		for(int x=0; x<voFluidBalInstances.size(); x++)
		{
			FluidBalanceInstanceVo voFluidBalInstance = voFluidBalInstances.get(x);
			Time existingTime = voFluidBalInstance.getStartTime();
			Time newTime = voFluidBalInst.getStartTime();
		 
			if(newTime.isLessOrEqualThan(existingTime))
			{
				result = true;
				break;
			}
		}
		return result;
	}	
	return result;
}
 
Example 2
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 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: SortTheatreAppointmentsImpl.java   View Source Code Vote up 4 votes
private SessionParentChildSlot findOrCreateRelevantSlotinSession(Booking_Appointment doAppt, Set parentChildSlots)
{
	if(doAppt == null)
		throw new CodingRuntimeException("doAppt cannot be null in method findOrCreateRelevantSlotinSession");
	if (parentChildSlots == null)
		throw new CodingRuntimeException("parentChildSlots cannot be null in method findOrCreateRelevantSlotinSession");
	
	////////////////////////////////
	//sorting the set
	
	List items = new ArrayList();
	Iterator it = parentChildSlots.iterator();
	while(it.hasNext())
	{
		items.add((SessionParentChildSlot)it.next());
	}
	
	//sort the list by start time (custom comparator)
	Collections.sort(items, new Comparator<SessionParentChildSlot>() 
	{
		private int direction = 1;
	
		public int compare(SessionParentChildSlot ob1, SessionParentChildSlot ob2) 
		{
			if(ob1.getStartTime() != null )
				return  ob1.getStartTime().compareToIgnoreCase(ob2.getStartTime())*direction;
			if(ob1.getStartTime() != null)
				return (-1)*direction;
			
			return 0;
		}
	});
	
	//end list sort
	////////////////////////////
	
	SessionParentChildSlot doSlotToReturn = null;
	Iterator itSortedSlots = items.iterator();
	Time proposedApptTime = new Time(doAppt.getApptStartTime());
	while(itSortedSlots.hasNext())
	{			
		SessionParentChildSlot doSessParentChildSlot = (SessionParentChildSlot) itSortedSlots.next();
		Time proposedSlotTime = new Time(doSessParentChildSlot.getStartTime());
		
		if(proposedSlotTime.isLessOrEqualThan(proposedApptTime))
		{
			if(doSessParentChildSlot.getAppointment() == null)
				doSlotToReturn = doSessParentChildSlot;
		}
		else
			break;
	}
	
	if(doSlotToReturn != null)
	{
		//set the slot time to the new appt time
		doSlotToReturn.setStartTime(doAppt.getApptStartTime());
		doSlotToReturn.setStatus(getDomLookup(Status_Reason.APPOINTMENT_BOOKED));
		doSlotToReturn.setStatusReason(getDomLookup(Status_Reason.APPOINTMENTMOVED));
	}
	
	return doSlotToReturn;
}
 
Example 5
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;
}