This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vehicle manufacture network initial (#145)
Signed-off-by: awjh-ibm <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ | |
], | ||
"author": "Hyperledger Composer", | ||
"license": "Apache-2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
coverage | ||
dist | ||
go | ||
node_modules | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
env: | ||
es6: true | ||
node: true | ||
mocha: true | ||
extends: 'eslint:recommended' | ||
parserOptions: | ||
ecmaVersion: 8 | ||
sourceType: | ||
- script | ||
rules: | ||
indent: | ||
- error | ||
- 4 | ||
linebreak-style: | ||
- error | ||
- unix | ||
quotes: | ||
- error | ||
- single | ||
semi: | ||
- error | ||
- always | ||
no-unused-vars: | ||
- error | ||
- args: none | ||
no-var: error | ||
no-console: off | ||
curly: error | ||
eqeqeq: error | ||
no-throw-literal: error | ||
dot-notation: error | ||
no-tabs: error | ||
no-trailing-spaces: error | ||
no-useless-call: error | ||
no-with: error | ||
operator-linebreak: error | ||
require-jsdoc: | ||
- error | ||
- require: | ||
ClassDeclaration: true | ||
MethodDefinition: true | ||
FunctionDeclaration: true | ||
yoda: error | ||
no-confusing-arrow: 2 | ||
no-constant-condition: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# JSDoc | ||
out | ||
|
||
# Mac files. | ||
**/.DS_Store | ||
|
||
*.swp | ||
|
||
# Build generated files should be ignored by git, but not by npm. | ||
dist | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# JSDoc | ||
out | ||
|
||
# Mac files. | ||
**/.DS_Store | ||
|
||
*.swp | ||
|
||
# Build generated files should be ignored by git, but not by npm. | ||
# dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Vehicle Manufacture Network | ||
|
||
> This network tracks the manufacture of vehicles from an initial order request through to their completion by the manufacturer. A regulator is able to provide oversight throughout this whole process. | ||
## Models within this business network | ||
|
||
### Participants | ||
`Person` `Manufacturer` `Regulator` | ||
|
||
### Assets | ||
|
||
`Order` `Vehicle` | ||
|
||
### Transactions | ||
|
||
`PlaceOrder` `UpdateOrderStatus` `SetupDemo` | ||
|
||
### Events | ||
|
||
`PlaceOrderEvent` `UpdateOrderStatusEvent` | ||
|
||
## Example use of this business network | ||
A `Person` uses a manufacturer's application to build their desired car and order it. The application submits a `PlaceOrder` transaction which creates a new `Order` asset containing the details of the vehicle the `Person` wishes to have made for them. The `Manufacturer` begins work on the car and as it proceeds through stages of production the `Manufacturer` submits `UpdateOrderStatus` transactions to mark the change in status for the `Order` e.g. updating the status from PLACED to SCHEDULED_FOR_MANUFACTURE. Once the `Manufacturer` has completed production for the `Order` they register the car by submitting an `UpdateOrderStatus` transaction with the status VIN_ASSIGNED (also providing the VIN to register against) and a `Vehicle` asset is formally added to the registry using the details specified in the `Order`. Once the car is registered then the `Manufacturer` submits an `UpdateOrderStatus` transaction with a status of OWNER_ASSIGNED at which point the owner field of the `Vehicle` is set to match the orderer field of the `Order`. The regulator would perform oversight over this whole process. | ||
|
||
## Testing this network within playground | ||
Navigate to the **Test** tab and then submit a `SetupDemo` transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.SetupDemo" | ||
} | ||
``` | ||
|
||
This will generate three `Manufacturer` participants, fourteen `Person` participants, a single `Regulator` participant and thirteen `Vehicle` assets. | ||
|
||
Next order your car (an orange Arium Gamora) by submitting a PlaceOrder transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.PlaceOrder", | ||
"orderId": "1234", | ||
"vehicleDetails": { | ||
"$class": "org.acme.vehicle_network.VehicleDetails", | ||
"make": "resource:org.acme.vehicle_network.Manufacturer#Arium", | ||
"modelType": "Gamora", | ||
"colour": "Sunburst Orange" | ||
}, | ||
"options": { | ||
"trim": "executive", | ||
"interior": "red rum", | ||
"extras": ["tinted windows", "extended warranty"] | ||
}, | ||
"orderer": "resource:org.acme.vehicle_network.Person#Paul" | ||
} | ||
``` | ||
|
||
This `PlaceOrder` transaction generates a new `Order` asset in the registry and emits a `PlaceOrderEvent` event. | ||
|
||
Now simulate the order being accepted by the manufacturer by submitting an `UpdateOrderStatus` transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.UpdateOrderStatus", | ||
"orderStatus": "SCHEDULED_FOR_MANUFACTURE", | ||
"order": "resource:org.acme.vehicle_network.Order#1234" | ||
} | ||
``` | ||
|
||
This `UpdateOrderStatus` transaction updates the orderStatus of the `Order` with orderId 1234 in the asset registry and emits an `UpdateOrderStatusEvent` event. | ||
|
||
Simulate the manufacturer registering the vehicle with the regulator by submitting an `UpdateOrderStatus` transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.UpdateOrderStatus", | ||
"orderStatus": "VIN_ASSIGNED", | ||
"order": "resource:org.acme.vehicle_network.Order#1234", | ||
"vin": 'abc123' | ||
} | ||
``` | ||
|
||
This `UpdateOrderStatus` transaction updates the orderStatus of the `Order` with orderId 1234 in the asset registry, create a new `Vehicle` based of that `Order` in the asset registry and emits an `UpdateOrderStatusEvent` event. At this stage as the vehicle does not have an owner assigned to it, its status is declared as OFF_THE_ROAD. | ||
|
||
Next assign the owner of the vehicle using an `UpdateOrderStatus` transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.UpdateOrderStatus", | ||
"orderStatus": "OWNER_ASSIGNED", | ||
"order": "resource:org.acme.vehicle_network.Order#1234", | ||
"vin": 'abc123' | ||
} | ||
``` | ||
|
||
This `UpdateOrderStatus` transaction updates the orderStatus of the `Order` with orderId 1234 in the asset registry, update the `Vehicle` asset with VIN abc123 to have an owner of Paul (who we intially marked as the orderer in the `PlaceOrder` transaction) and status of ACTIVE and also emits an `UpdateOrderStatusEvent` event. | ||
|
||
Finally complete the ordering process by marking the order as `DELIVERED` through submitting another `UpdateOrderStatus` transaction: | ||
|
||
``` | ||
{ | ||
"$class": "org.acme.vehicle_network.UpdateOrderStatus", | ||
"orderStatus": "DELIVERED", | ||
"order": "resource:org.acme.vehicle_network.Order#1234" | ||
} | ||
``` | ||
|
||
This `UpdateOrderStatus` transaction updates the orderStatus of the `Order` with orderId 1234 in the asset registry and emits an `UpdateOrderStatusEvent` event. | ||
|
||
This Business Network definition has been used to create demo applications that simulate the scenario outlined above. You can find more detail on these at https://github.com/hyperledger/composer-sample-applications/tree/master/packages/vehicle-manufacture | ||
|
||
## Permissions in this business network for modelled participants | ||
Within this network permissions are outlines for the participants outlining what they can and can't do. The rules in the permissions.acl file explicitly ALLOW participants to perform actions. Actions not written for a participant in that file are blocked. | ||
### Regulator | ||
`RegulatorAdminUser` - Gives the regulator permission to perform ALL actions on ALL resources | ||
|
||
### Manufacturer | ||
`ManufacturerUpdateOrder` - Allows a manufacturer to UPDATE an Order asset's data only using an UpdateOrderStatus transaction. The manufacturer must also be specified as the *vehicleDetails.make* in the Order asset. | ||
|
||
`ManufacturerUpdateOrderStatus` - Allows a manufacturer to CREATE and READ UpdateOrderStatus transactions that refer to an order that they are specified as the *vehicleDetails.make* in. | ||
|
||
`ManufacturerReadOrder` - Allows a manufacturer to READ an Order asset that they are specified as the *vehicleDetails.make* in. | ||
|
||
`ManufacturerCreateVehicle` - Allows a manufacturer to CREATE a vehicle asset only using a UpdateOrderStatus transaction. The transaction must have an *orderStatus* of VIN_ASSIGNED and the Order asset have the manufacturer specified as the *vehicleDetails.make*. | ||
|
||
`ManufacturerReadVehicle` - Allows a manufacturer to READ a Vehicle asset that they are specified as the *vehicleDetails.make* in. | ||
|
||
### Person | ||
`PersonMakeOrder` - Gives the person permission to CREATE an Order asset only using a PlaceOrder transaction. The person must also be specified as the *orderer* in the Order asset. | ||
|
||
`PersonPlaceOrder` - Gives the person permission to CREATE and READ PlaceOrder transactions that refer to an order that they are specified as *orderer* in. | ||
|
||
`PersonReadOrder` - Gives the person permission to READ an Order asset that they are specified as the *orderer* in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
|
||
"config":"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"tags": { | ||
"allowUnknownTags": true, | ||
"dictionaries": ["jsdoc","closure"] | ||
}, | ||
"source": { | ||
"include": [ | ||
"./lib" | ||
], | ||
"includePattern": ".+\\.js(doc|x)?$" | ||
}, | ||
"plugins": ["plugins/markdown"], | ||
"templates": { | ||
"logoFile": "", | ||
"cleverLinks": false, | ||
"monospaceLinks": false, | ||
"dateFormat": "ddd MMM Do YYYY", | ||
"outputSourceFiles": true, | ||
"outputSourcePath": true, | ||
"systemName": "Perishable Goods Network", | ||
"footer": "", | ||
"copyright": "Released under the Apache License v2.0", | ||
"navType": "vertical", | ||
"theme": "spacelab", | ||
"linenums": true, | ||
"collapseSymbols": false, | ||
"inverseNav": true, | ||
"protocol": "html://", | ||
"methodHeadingReturns": false | ||
}, | ||
"markdown": { | ||
"parser": "gfm", | ||
"hardwrap": true | ||
} | ||
} |
Oops, something went wrong.