MResourceType:

* added more helper methods, useful for libero but they have general application
This commit is contained in:
teo_sarca 2009-02-16 17:15:31 +00:00
parent 8354d827f1
commit 6caee9c9dd
1 changed files with 47 additions and 1 deletions

View File

@ -167,13 +167,59 @@ public class MResourceType extends X_S_ResourceType
} }
} }
/**
* Get how many hours/day a is available.
* Minutes, secords and millis are discarded.
* @return available hours
*/
public int getTimeSlotHours()
{
long hours;
if (isTimeSlot())
hours = (getTimeSlotEnd().getTime() - getTimeSlotStart().getTime()) / (60 * 60 * 1000);
else
hours = 24;
return (int) hours;
}
/**
* Get available days / week.
* @return available days / week
*/
public int getAvailableDaysWeek()
{
int availableDays = 0;
if (isDateSlot())
{
if (isOnMonday())
availableDays += 1;
if (isOnTuesday())
availableDays += 1;
if (isOnThursday())
availableDays += 1;
if (isOnWednesday())
availableDays += 1;
if (isOnFriday())
availableDays += 1;
if (isOnSaturday())
availableDays += 1;
if (isOnSunday())
availableDays += 1;
}
else
{
availableDays = 7;
}
return availableDays;
}
public boolean isDayAvailable(Timestamp dateTime) public boolean isDayAvailable(Timestamp dateTime)
{ {
if (!isActive()) if (!isActive())
{ {
return false; return false;
} }
if(isDateSlot()) if(!isDateSlot())
{ {
return true; return true;
} }