Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityZeroState.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityZeroState.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityZeroState.vb (revision 1729) @@ -0,0 +1,13 @@ +Public Class ActivityZeroState + Inherits ActivityState + + 'Can't go from another state into this one. + Public Sub New(activity As IActivity) + Me.Activity = activity + End Sub + + ''' + Public Overrides Function ActivityStateEnum() As ActivityStateEnum + Return ActiviteitenOpvolging.ActivityStateEnum.Zero + End Function +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivityActions.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivityActions.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivityActions.vb (revision 1729) @@ -0,0 +1,19 @@ +Public Interface IActivityActions + ''' + ''' The employee starts the activity. + ''' + ''' + Sub StartActivity(employee As IEmployee) + + ''' + ''' The employee stops the activity. + ''' + ''' + Sub StopActivity(employee As IEmployee) + + ''' + ''' The employee finishes the activity. + ''' + ''' + Sub FinishActivity(employee As IEmployee) +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings =================================================================== diff -u -r1717 -r1729 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1717) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1729) @@ -2,7 +2,9 @@ False True True + True True + True True True True Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityStartedState.vb (revision 1729) @@ -0,0 +1,27 @@ +Public Class ActivityStartedState + inherits ActivityState + + Private ReadOnly _employee As IEmployee + + 'Not from other state. + Public Sub New(activity As IActivity, employee As IEmployee) + Me.Activity = activity + _employee = employee + End Sub + + 'From other state. + Public Sub New(state As ActivityState, employee As IEmployee) + Activity = state.Activity + _employee = employee + End Sub + + ''' + Public Overrides Function ActivityStateEnum() As ActivityStateEnum + Return ActiviteitenOpvolging.ActivityStateEnum.Started + End Function + + ''' + Public Overrides Function GetEmployee() As IEmployee + Return _employee + End Function +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Activity.vb =================================================================== diff -u -r1727 -r1729 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Activity.vb (.../Activity.vb) (revision 1727) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/Activity.vb (.../Activity.vb) (revision 1729) @@ -1,9 +1,10 @@ Public Class Activity - implements IActivity + Implements IActivity Public Property Id As String Implements IActivity.Id Public Property QuantityToProduce As Integer Implements IActivity.QuantityToProduce Public Property Label As String Implements IActivity.Label Public Property Status As ActivityStateEnum Implements IActivity.Status + 'todo get enum state from state Public Property IsReadOnly As Boolean Implements IActivity.IsReadOnly Public Property StartBeforeTimestamp As DateTime Implements IActivity.StartBeforeTimestamp Public Property StartAlmostTimeStamp As DateTime Implements IActivity.StartAlmostTimeStamp @@ -12,4 +13,27 @@ Public Property EmployeeInitials As String Implements IActivity.EmployeeInitials Public Property WorkItem As IWorkItem Implements IActivity.WorkItem + + Public Property State As ActivityState Implements IActivity.State + + Public ReadOnly Property CurrentEmployee As IEmployee Implements IActivity.CurrentEmployee + Get + Return State.GetEmployee() + End Get + End Property + + ''' + Public Sub StartActivity(employee As IEmployee) Implements IActivityActions.StartActivity + State.StartActivity(employee) + End Sub + + ''' + Public Sub StopActivity(employee As IEmployee) Implements IActivityActions.StopActivity + State.StopActivity(employee) + End Sub + + ''' + Public Sub FinishActivity(employee As IEmployee) Implements IActivityActions.FinishActivity + State.FinishActivity(employee) + End Sub End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivity.vb =================================================================== diff -u -r1728 -r1729 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivity.vb (.../IActivity.vb) (revision 1728) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/IActivity.vb (.../IActivity.vb) (revision 1729) @@ -1,4 +1,6 @@ Public Interface IActivity + inherits IActivityActions + Property Id As String Property QuantityToProduce As Integer Property Label As String @@ -10,4 +12,7 @@ Property StartTimeStamp As DateTime Property WorkItem As IWorkItem + + Property State As ActivityState + ReadOnly Property CurrentEmployee As IEmployee End interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityState.vb (revision 1729) @@ -0,0 +1,30 @@ +Public MustInherit Class ActivityState + Implements IActivityActions + + Public Activity As IActivity + + ''' + ''' The for the current state. + ''' + ''' + Public MustOverride Function ActivityStateEnum() As ActivityStateEnum + + Public Overridable Function GetEmployee() As IEmployee + Throw New Exception("No employee present.") + End Function + + ''' + Public Overridable Sub StartActivity(employee As IEmployee) Implements IActivityActions.StartActivity + Throw New Exception("Can't start the activity in this state.") + End Sub + + ''' + Public Overridable Sub StopActivity(employee As IEmployee) Implements IActivityActions.StopActivity + Throw New Exception("Can't stop the activity in this state.") + End Sub + + ''' + Public Overridable Sub FinishActivity(employee As IEmployee) Implements IActivityActions.FinishActivity + Throw New Exception("Can't finish the activity in this state.") + End Sub +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityDefaultedState.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityDefaultedState.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/classes/implementations/activity state/ActivityDefaultedState.vb (revision 1729) @@ -0,0 +1,20 @@ +Public Class ActivityDefaultedState + Inherits ActivityState + + 'Not from other state. + Public Sub New(activity As IActivity) + Me.Activity = activity + End Sub + + ''' + Public Overrides Function ActivityStateEnum() As ActivityStateEnum + Return ActiviteitenOpvolging.ActivityStateEnum.Defaulted + End Function + + ''' + Public Overrides Sub StartActivity(employee As IEmployee) + 'Change state. + Activity.State = New ActivityStartedState(Me, employee) + End Sub + +End Class