-
Notifications
You must be signed in to change notification settings - Fork 1
/
modelFile.cto
253 lines (222 loc) · 5.35 KB
/
modelFile.cto
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/**
* A business network for shipping perishable goods
* The cargo is temperature controlled and contracts
* can be negociated based on the temperature
* readings received for the cargo
*/
namespace org.acme.shipping.perishable
/**
* The type of perishable product being shipped
*/
enum ProductType {
o BANANAS
o APPLES
o PEARS
o PEACHES
o COFFEE
}
/**
* The shipment status of a production lot
*/
enum ShipmentStatus {
o CREATED
o IN_TRANSIT
o ARRIVED
}
/**
* An abstract transaction that is related to a production lot
*/
abstract transaction ProductionLotTransaction {
--> ProductionLot productionLot
}
/**
* An abstract transaction that is related to a batch
*/
abstract transaction BatchTransaction {
--> Batch batch
}
transaction setup{
}
/**
* A transaction to create a contract
*/
transaction CreateContract {
o String contractId
--> Grower grower
--> Shipper shipper
--> Importer importer
o DateTime arrivalDateTime
o Double unitPrice
o Double minTemperature
o Double maxTemperature
o Double minPenaltyFactor
o Double maxPenaltyFactor
}
/**
* A transaction to create a batch
*/
transaction CreateProductionLot {
--> Grower grower
o String productionLotId
o ProductType productType
o DateTime expirationDate
o Long quantity
--> Contract contract
}
/**
* A temperature reading for a shipment. E.g. received from a
* device within a temperature controlled shipping container
*/
transaction TemperatureReading extends ProductionLotTransaction {
o Double centigrade
}
/**
* Quality inspection certificate for production lot.
*/
transaction CertificateGranted extends ProductionLotTransaction {
}
/**
* Customs clearance from customs.
*/
transaction ClearanceGranted extends ProductionLotTransaction {
}
/**
* A notification that a shipment has been issued by the
* shipper
*/
transaction ShipmentIssued extends ProductionLotTransaction {
}
/**
* A notification that a shipment has been received by the
* importer and that funds should be transferred from the importer
* to the grower to pay for the shipment.
*/
transaction ShipmentReceived extends ProductionLotTransaction {
--> Importer importer
}
/**
* A transaction to change ownership and transfer funds
*/
transaction PurchaseLot extends ProductionLotTransaction {
}
/**
* A transaction to change ownership and transfer funds
*/
transaction PurchaseBatch extends BatchTransaction {
--> Supermarket supermarket
}
/**
* A transaction to create a batch
*/
transaction CreateBatch extends ProductionLotTransaction {
o String batchId
o Long quantity
o Long soldQuantity
}
/**
* A transaction to purchase a quantity of a batch
*/
transaction PurchaseProducts extends BatchTransaction {
o String productId
o Long quantity
--> Consumer consumer
}
/**
* A productionlot being tracked as an asset on the ledger
*/
asset ProductionLot identified by productionLotId {
--> Grower grower
--> Importer importer optional
o String productionLotId
o ProductType productType
o DateTime expirationDate
o ShipmentStatus shipmentStatus
o Long quantity
o CertificateGranted[] certificateGranted optional
o ClearanceGranted[] clearanceGranted optional
o TemperatureReading[] temperatureReadings optional
--> Contract contract
}
/**
* Defines a contract between a Grower and an Importer to ship using
* a Shipper, paying a set unit price. The unit price is multiplied by
* a penality factor proportional to the deviation from the min and max
* negociated temperatures for the shipment.
*/
asset Contract identified by contractId {
o String contractId
--> Grower grower
--> Shipper shipper
--> Importer importer
o DateTime arrivalDateTime
o Double unitPrice
o Double minTemperature
o Double maxTemperature
o Double minPenaltyFactor
o Double maxPenaltyFactor
}
asset Batch identified by batchId {
o String batchId
--> ProductionLot productionLot
o Long quantity
o Long soldQuantity
--> Supermarket supermarket optional
}
asset Products identified by productId {
o String productId
--> Batch batch
--> Consumer consumer
o Long quantity
}
/**
* A concept for a simple street address
*/
concept Address {
o String city optional
o String country
o String street optional
o String zip optional
}
/**
* An abstract participant type in this business network
*/
abstract participant Business identified by name {
o String name
o Address address
o Double accountBalance
}
/**
* A Grower is a type of participant in the network
*/
participant Grower extends Business {
}
/**
* A QualityInspector is a type of participant in the network
*/
participant QualityInspector extends Business {
}
/**
* A Customs is a type of participant in the network
*/
participant Customs extends Business {
}
/**
* A Consumer is a type of participant in the network
*/
participant Consumer extends Business {
}
/**
* A Shipper is a type of participant in the network
*/
participant Shipper extends Business {
}
/**
* An Importer is a type of participant in the network
*/
participant Importer extends Business {
}
/**
* A Supermarket is a type of participant in the network
*/
participant Supermarket extends Business {
}