# Need help with how to involving calculations

Connie Kamrowski
Greenhorn
Posts: 23
Ok here goes.

I have a database which stores details of resources and their availability for projects.

In the main table it stores a staff id and an availability percentage which is the default time each resource has available for allocation (ie 85%)

In a second table it stores entries for start and end dates of allocations and the percentages of each allocation ie 01/01/2005 03/03/2005 35%, 10/02/2005 15/02/2005 15%)

I need to create a manager which will take a start and end date and then check to see which resources are not fully allocated in these dates and return an array of available resources. I also need to warn the user if they are allocating more than 100% for a resource.

So I basically need to get all the resources intop an array, test to see if they are available between the dates (their records do not total 100%) and then throw the available ones into a second array to populate the list, when the user chooses one of these and adds it I have to check that the entires now do not total over 1oo% and warn if they do.

I am at a loss as to how to work this, all suggestions appreciated.

Connie

marc weber
Sheriff
Posts: 11343
My approach would be to consider defining your "resources" as objects. For example, you might define a class called StaffResource with methods like...

String getID() returns staff ID.

int[] dedicated(Date startDate, Date endDate) returns an array of ints, where each element represents a date within the indicated range, and the value represents the resource's allocated time for that date. For example, if you entered a range of 4 days, you might get back { 85, 85, 100, 60, } indicating how busy that person is on each of those 4 days. (Or instead of simple ints, you might return a Map with Date/Allocation pairs.)

Map[] projectBreakdown(Date d) returns a Map of project/allocation pairs for the indicated date. For example, for a specific date, the Map might be (ProjectA, 10), (ProjectF, 25), (ProjectQ, 50). You might use this for a "close up" look at a particular date.

boolean validateAllocation(Date validationDate) returns a boolean indicating whether the resource's allocations on an indicated date surpass 100. Probably called internally by set methods.

etc.

Then you could define another class that manages a List of StaffResource objects, with something like...

Map[] resourcesFor(Date d) returns a Map of StaffResource/Availability pairs for the indicated date. For example, (ID99999, 10), (ID99998, 25), ... indicating that staff member 99999 has 10% of their time free on the given date, and staff member 99998 has 25% of their time free.

:roll:

Connie Kamrowski
Greenhorn
Posts: 23
Thankyou

That actually helps a lot.

Sometimes the hardest part is getting started.