Could somebody please give their input into the following scenario:
I have an Administrator
class and a Technician
class (both extending a User
class but that is besides the point). I also have a RepairJob
class which represents an item through its varying stages of being repaired {received|being repaired|waiting for part, etc.}.
Only administrator users will be able to add a new repair job to the system and will also be able to view the status of all the repair jobs currently ongoing.
Technicians will need to be able to accept repair jobs from a view of the list of any repair jobs which have not yet been accepted by other technicians. Technician uses will also have to be able to update the status of a repair job accepted by themselves until it's ready to be returned to the Customer (another class).
An administrator will be able to accept any repair job in the system, even those already accepted by a Technician at which point they will no longer be able to update the status of the repair job. (To take account of employees being off work)
Could somebody give me an insight into how you would collect together the RepairJob
instances. I had thought at first that since the administrator user would be adding these instances that it would be a good idea to model the collection inside the Administrator
class however the Technician class will also have to be able to access a limited collection of repair jobs. I had also though of creating a RepairJobs
class which had the list and was available to either class but I'm not sure if this would be a good design.
I think it ought to be separate from Admin and Tech classes. RepairJob is for a single task; what you're describing sounds like a RepairJobManager that maintains a collection of RepairJobs and tracks their status. It executes your rules according to the Role of the particular User that interacts with it.
package model;
public class RepairJobManager
{
private Map<String, RepairJob> jobs;
public void add(RepairJob job, Role role)
{
// Only allow Admin to do certain things.
}
public void update(RepairJob job, Status status, Role role)
{
// Only allow Admin to do certain things.
}
}