-
Notifications
You must be signed in to change notification settings - Fork 14
/
ICargo.cs
187 lines (169 loc) · 6.69 KB
/
ICargo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//
// ICargo.cs
//
// Author:
// Giacomo Tesio <giacomo@tesio.it>
//
// Copyright (c) 2010-2011 Giacomo Tesio
//
// This file is part of Epic.NET.
//
// Epic.NET is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Epic.NET is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
using System;
using Challenge00.DDDSample.Shared;
using Challenge00.DDDSample.Voyage;
using Challenge00.DDDSample.Location;
using System.Collections.Generic;
namespace Challenge00.DDDSample.Cargo
{
/// <summary>
/// A Cargo.
/// </summary>
/// <remarks>
/// <para>
/// This is the central class in the domain model, and it is the root of the
/// Cargo-Itinerary-Leg-Delivery-RouteSpecification aggregate.
/// </para>
/// <para>
/// A cargo is identified by a unique <see cref="TrackingId"/>, and it always has an origin and a route specification.
/// </para>
/// <para>
/// The life cycle of a cargo begins with the booking procedure, when the tracking id is assigned.
/// During a (short) period of time, between booking and initial routing, the cargo has no itinerary.
/// </para>
/// <para>
/// The booking clerk requests a list of possible routes, matching the route specification,
/// and assigns the cargo to one route.
/// The route to which a cargo is assigned is described by an itinerary.
/// </para>
/// <para>
/// A cargo can be re-routed during transport, on demand of the customer, in which case a
/// new route is specified for the cargo and a new route is requested.
/// The old itinerary, being a value object, is discarded and a new one is attached.
/// </para>
/// <para>
/// It may also happen that a cargo is accidentally misrouted, which should notify the proper
/// personnel and also trigger a re-routing procedure.
/// </para>
/// <para>
/// When a cargo is handled, the status of the delivery changes.
/// Everything about the delivery of the cargo is contained in the Delivery value object,
/// which is replaced whenever a cargo is handled by an asynchronous event triggered
/// by the registration of the handling event.
/// </para>
/// <para>
/// The delivery can also be affected by routing changes, i.e. when a the route specification changes,
/// or the cargo is assigned to a new route.
/// In that case, the delivery update is performed synchronously within the cargo aggregate.
/// </para>
/// <para>
/// The life cycle of a cargo ends when the cargo is claimed by the customer.
/// </para>
/// <para>
/// The cargo aggregate, and the entre domain model, is built to solve the problem of booking and tracking cargo.
/// All important business rules for determining whether or not a cargo is misdirected,
/// what the current status of the cargo is (on board carrier, in port etc), are captured in this aggregate.
/// <para>
/// </remarks>
public interface ICargo
{
/// <summary>
/// Cargo identifier.
/// </summary>
TrackingId TrackingId { get; }
/// <summary>
/// Delivery information
/// </summary>
IDelivery Delivery { get; }
/// <summary>
/// Assigned itinerary.
/// </summary>
IItinerary Itinerary { get; }
/// <summary>
/// Route specification
/// </summary>
IRouteSpecification RouteSpecification { get; }
/// <summary>
/// Assign a new route specification to the cargo.
/// </summary>
/// <param name="routeSpecification">
/// A <see cref="IRouteSpecification"/>. May not be null.
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="routeSpecification"/> is <value>null</value></exception>
void SpecifyNewRoute (IRouteSpecification routeSpecification);
event EventHandler<ChangeEventArgs<IRouteSpecification>> NewRouteSpecified;
/// <summary>
/// Attach a new itinerary to this cargo.
/// </summary>
/// <param name="itinerary">
/// A <see cref="IItinerary"/>. May not be null.
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="itinerary"/> is <value>null</value></exception>
void AssignToRoute (IItinerary itinerary);
event EventHandler<ChangeEventArgs<IItinerary>> ItineraryChanged;
/// <summary>
/// Recieve the cargo at <paramref name="location"/>
/// </summary>
/// <param name="location">
/// A <see cref="ILocation"/>. May not be null.
/// </param>
/// <param name="date">Date of occurence.</param>
/// <exception cref="ArgumentNullException"><paramref name="location"/> is <value>null</value></exception>
void Recieve(ILocation location, DateTime date);
event EventHandler<HandlingEventArgs> Recieved;
/// <summary>
/// Clear through customs.
/// </summary>
/// <param name="location">
/// A <see cref="ILocation"/>. May not be null.
/// </param>
/// <param name="date">
/// A <see cref="DateTime"/>
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="location"/> is <value>null</value></exception>
void ClearCustoms(ILocation location, DateTime date);
event EventHandler<HandlingEventArgs> CustomsCleared;
/// <summary>
/// Claim the cargo.
/// </summary>
/// <param name="location">
/// A <see cref="ILocation"/>. May not be null.
/// </param>
/// <param name="date">Date of occurence.</param>
/// <exception cref="ArgumentNullException"><paramref name="location"/> is <value>null</value></exception>
void Claim(ILocation location, DateTime date);
event EventHandler<HandlingEventArgs> Claimed;
/// <summary>
/// Load the cargo on a vassel.
/// </summary>
/// <param name="voyage">
/// A <see cref="IVoyage"/>. May not be null.
/// </param>
/// <param name="date">Date of occurence.</param>
/// <exception cref="ArgumentNullException"><paramref name="voyage"/> is <value>null</value></exception>
void LoadOn(IVoyage voyage, DateTime date);
event EventHandler<HandlingEventArgs> Loaded;
/// <summary>
/// Unload the cargo from the current vassel.
/// </summary>
/// <param name="voyage">
/// A <see cref="IVoyage"/>. May not be null.
/// </param>
/// <param name="date">Date of occurence.</param>
/// <exception cref="ArgumentNullException"><paramref name="voyage"/> is <value>null</value></exception>
void Unload(IVoyage voyage, DateTime date);
event EventHandler<HandlingEventArgs> Unloaded;
}
}