I'm trying to model a workflow (status and activities) to create "rules".
Let me give you an example.
The main "object" let's say are "vehicle requirements", I will have this table:
idRequirement, idVehicle,DateOfRequirement, idStatus, LastUpdate 1 2 2012-01-02 10:20:00, 1 ,2012-01-02 10:20:00
In the example above as the register is just created, the DateOfRequirement and LastUpdate is the same, LastUpdate it will be updated after every change of status.
idStatus,Status 1 New 2 Vehicle Assigned 3 Closed
idActivitie, Activitie 1 Create Vehicle Requirement 2 Assign Vehicle 3 Close requirement. 4 ReAssign Vehicle. 5 Confirm
Until the tables above I have no problems, but my problem is that for example:
I know I cannot close a requirement (update to idStatus=3 on "vehicle requirements") if the current status is not "Vehicle Assigned" (idStatus=2).
I can do that by code (or I think so), but is there anyway to model this kind of rules to tables ? I mean a table where I retrieve the next idStatus and the activitie to perform (to save a "kardex/historical" of each requirement and it's activities), checking for example the Activitie or the current status ?
The rules also will have 3 "alerts" accordin the time and status. For example the limit time "green" to assign vehicle is 30 minutes or less the yellow "alert" it will be between 31 and 45 after the requirement has been created (status new) and the red alert it will show it after 45 of being in status "new"
idRequirement,Vehicle,CurrentStatus,NextStatus, Alert 1 N/A New Vehicle Assigned Green
After 39 minutues it will something like this:
idRequirement,Vehicle,CurrentStatus,NextStatus, Alert 1 N/A New Vehicle Assigned Yellow
And after 45 minutes:
idRequirement,Vehicle,CurrentStatus,NextStatus, Alert 1 N/A New Vehicle Assigned Red
If there's no enough clear please tell me to try to explain better.
In the meantime I just need a single "workflow" I mean, always the order it will be idStatus=1, after that idStatus=2 and aftear idStatus=3, but if you want to help me considergin cases like go to idStatus=3 after idStatus=1, I'll be really grateful.
Some idea (probably bad) I had:
idRule Name idCurrentState idNextState idActivitieToPerform GreenLimit YelloLimit 1 Assign 1 2 1 30 45 2 CloseFromNew 1 3 3 30 90 3 ChangeVehicle 2 2 4 45 90 4 CloseRequirement 2 3 3 90 120 5 ConfirmVehicle 2 2 5 30 90
But I have lot of trouble because of the "idCurrentState" and "idNextState" refers to the same primary key on status table. My regards and thanks for your time.
- Remove "redLimit" (as Kevin Feasel mentioned (and I figure out a couple of hours after post, it's implied))
Add some Rules to let the sample more clear:
Add activitie "ReAssign Vehicle"
I'm 99% sure there are only 3 "colors" (so we can't ignore relationships with Colors and any other table as status/activities).
Different activities derive on the same status (ChangeVehicle and Confirm) (muliple activities)
Different activities in different status derive on same status (no linear workflow)
No linear workflow
- "CloseFromNew" perform "Close" activity and set Status to "Closed" from status "New", just as "CloseRequirement" set status to "Closed" but from status "Vehicle Assigned"
Well based on the comments of Kevin Feasel, I just extend my sample/problem (after "Update" text explain the constraints I need to accomplish)
My regards again !