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

The following are Jave code examples for showing how to use getTotalMinutes() 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
protected void onImbCalculateClick() throws ims.framework.exceptions.PresentationLogicException
{
	Time startTime = form.timStart().getValue();
	Time endTime = form.getGlobalContext().Scheduling.getProfileEndTime();

	//this is mandatory for dialog
	if(form.getGlobalContext().Scheduling.getProfileEndTime() == null)
		return;
	
	if(startTime == null || (form.intSlotInterval().getValue() == null || form.intSlotInterval().getValue() == 0))
	{
		engine.showErrors(new String[] {"Start Time and Slot Interval need to be provided for calculation"});
		return;
	}
	
	int iDuration = form.intSlotInterval().getValue();
	
	int iTime = endTime.getTotalMinutes() - startTime.getTotalMinutes(); 
	form.intNoSlots().setValue(iTime/iDuration);
}
 
Example 2
Project: AvoinApotti   File: Logic.java   View Source Code Vote up 6 votes
protected void onImbCalculateClick() throws PresentationLogicException
{
	Time startTime = form.timStart().getValue();
	Time endTime = form.getGlobalContext().Scheduling.getProfileEndTime();

	//this is mandatory for dialog
	if(form.getGlobalContext().Scheduling.getProfileEndTime() == null)
		return;
	
	if(startTime == null || (form.intSlotInterval().getValue() == null || form.intSlotInterval().getValue() == 0))
	{
		engine.showErrors(new String[] {"Start Time and Slot Interval need to be provided for calculation"});
		return;
	}
	
	int iDuration = form.intSlotInterval().getValue();
	
	int iTime = endTime.getTotalMinutes() - startTime.getTotalMinutes(); 
	form.intNoSlots().setValue(iTime/iDuration);
}
 
Example 3
Project: AvoinApotti   File: Logic.java   View Source Code Vote up 5 votes
private int calculateDuration(Time startTime, Time endTime)
{
	if (startTime == null || endTime == null)
		throw new CodingRuntimeException("startTime or endTime is null in method calculateDuration");

	int mins = endTime.getTotalMinutes() - startTime.getTotalMinutes();
	if(endTime.isLessThan(startTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - startTime.getTotalMinutes() + endTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 4
Project: AvoinApotti   File: Logic.java   View Source Code Vote up 5 votes
private int calculateApptDuration(Time startTime, Time endTime)
{
	if (startTime == null || endTime == null)
		throw new CodingRuntimeException("apptStartTime or apptEndTime is null in method calculateApptDuration");

	int mins = endTime.getTotalMinutes() - startTime.getTotalMinutes();
	//appt has gone past midnight
	if(endTime.isLessThan(startTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - startTime.getTotalMinutes() + endTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 5
Project: AvoinApotti   File: Logic.java   View Source Code Vote up 5 votes
private int calculateApptDuration(Time apptStartTime, Time apptEndTime)
{
	if (apptStartTime == null || apptEndTime == null)
		throw new CodingRuntimeException("apptStartTime or apptEndTime is null in method calculateApptDuration");

	int mins = apptEndTime.getTotalMinutes() - apptStartTime.getTotalMinutes();
	//appt has gone past midnight
	if(apptEndTime.isLessThan(apptStartTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - apptStartTime.getTotalMinutes() + apptEndTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 6
Project: AvoinApotti   File: BookAppointmentImpl.java   View Source Code Vote up 5 votes
private int calculateApptDuration(Time startTime, Time endTime)
{
	if (startTime == null || endTime == null)
		throw new CodingRuntimeException("apptStartTime or apptEndTime is null in method calculateApptDuration");

	int mins = endTime.getTotalMinutes() - startTime.getTotalMinutes();
	//appt has gone past midnight
	if(endTime.isLessThan(startTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - startTime.getTotalMinutes() + endTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 7
Project: AvoinApotti   File: GenerateSessionsImpl.java   View Source Code Vote up 5 votes
private int calculateDuration(Time startTime, Time endTime)
{
	if (startTime == null || endTime == null)
		throw new CodingRuntimeException("startTime or endTime is null in method calculateDuration");

	int mins = endTime.getTotalMinutes() - startTime.getTotalMinutes();
	if(endTime.isLessThan(startTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - startTime.getTotalMinutes() + endTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 8
Project: AvoinApotti   File: SessionAdminImpl.java   View Source Code Vote up 5 votes
private int calculateApptDuration(Time startTime, Time endTime)
{
	if (startTime == null || endTime == null)
		throw new CodingRuntimeException("apptStartTime or apptEndTime is null in method calculateApptDuration");

	int mins = endTime.getTotalMinutes() - startTime.getTotalMinutes();
	//appt has gone past midnight
	if(endTime.isLessThan(startTime))	
	{
		Time midNight = new Time(23,59);
		mins = midNight.getTotalMinutes() + 1 - startTime.getTotalMinutes() + endTime.getTotalMinutes(); 
	}
		
	return mins;
}
 
Example 9
Project: AvoinApotti   File: Logic.java   View Source Code Vote up 4 votes
private int calculatePercentage(Date dateSession)
{
	SessionShortVoCollection voCollSessionShort = form.getLocalContext().getSessions();
	SessionShortVoCollection voCollSelectedSessions = new SessionShortVoCollection();

	// WDEV-9391 - calculation needs to be done on remaining time for session
	// go through Sessions Collection get matching ones for this day
	
	int totalTime = 0;
	int remainingTime = 0;
	for (int i = 0; i < voCollSessionShort.size(); i++)
	{
		if (voCollSessionShort.get(i).getSessionDate().equals(dateSession))
		{
			voCollSelectedSessions.add(voCollSessionShort.get(i));
			//get total time of sessions
			if(voCollSessionShort.get(i).getIsFixedIsNotNull())
			{
				if(!voCollSessionShort.get(i).getIsFixed())
				{
					if(voCollSessionShort.get(i).getStartTmIsNotNull() && voCollSessionShort.get(i).getEndTmIsNotNull())
					{
						//flexible - time remaining field
						Time startTime = (Time)voCollSessionShort.get(i).getStartTm().clone();
						Time endTime = (Time)voCollSessionShort.get(i).getEndTm().clone();
						
						totalTime += endTime.getTotalMinutes() - startTime.getTotalMinutes();
						remainingTime += voCollSessionShort.get(i).getRemainingTime();
					}
				}
			}
		}
	}
	
	//fixed
	if(totalTime == 0)
		return 0;
	
	int bookedTime = totalTime - remainingTime;
	return (int) (bookedTime * 100.0f / totalTime);	
}