securebox.cto
/**
* securebox tracking
*/
namespace org.acme.securebox
/**
* The types of BOX that could be moved
*/
enum BoxType {
o SecureBox
o NORMALBOX
o OTHERS
}
/**
* Status of an order
*/
enum OrderStatus {
o ORDER_PLACED
o IN_FIELD
o IN_TRANSIT
o DELIVERED
}
/**
* The production type associated with a Box
*/
enum ProductionType {
o SUGAR_MEDICINE
o BLOODPRESSURE_MEDICINE
o OTHER
}
/**
* The Lock status associated with a Box
*/
enum BoxStatusType {
o LOCK
o UNLOCK
}
/**
* A Person participant
*/
abstract participant User identified by email {
o String email
o String firstName
o String lastName
}
participant Customer identified by custId extends User {
o String custId
o String address1 optional
o String address2 optional
o String county optional
}
/**
* A manufacturer of medicine
*/
participant Manufacturer identified by companyName {
o String companyName
}
/**
* An order for a medicine/others to be fulfilled by a manufacturer
* and dispatched to an orderer (Person).
*/
asset Order identified by orderId {
o String orderId
o ProductionType productiontype
o OrderStatus orderStatus
--> Customer customer
--> Manufacturer manufacturer
}
/**
* An Medicine asset, which is related to a order
*/
asset Medicine identified by medicineName {
o String medicineName
o BoxType box
o OrderStatus movementStatus
o ProductionType productionType
--> Manufacturer owner
}
/**
* An order for a medicine/others to be fulfilled by a manufacturer
* and dispatched to an orderer (Person).
*/
asset SecureBox identified by secureBoxId {
o String secureBoxId
o BoxStatusType statustype
}
/**
* Transaction to create an order
*/
transaction PlaceOrder {
o String orderId
--> Customer customer
--> Manufacturer manufacturer
}
event PlaceOrderEvent {
o String orderId
}
securebox.js
--------------
'use strict';
/**
*
* @param {org.acme.securebox.PlaceOrder} placeOrder - the placeOrder transaction
* @transaction
*/
function PlaceOrder(placeOrder) {
console.log('placeOrder');
var factory = getFactory();
var NS_M = 'org.acme.securebox';
var NS = 'org.acme';
var order = factory.newResource(NS_M, 'Order', placeOrder.orderId);
order.productiontype = 'SUGAR_MEDICINE';
order.orderStatus = 'ORDER_PLACED';
order.manufacturer = placeOrder.manufacturer;
// save the order
return getAssetRegistry(order.getFullyQualifiedType())
.then(function (registry) {
return registry.add(order);
})
.then(function(){
var placeOrderEvent = factory.newEvent(NS_M, 'PlaceOrderEvent');
placeOrderEvent.orderId = order.orderId;
emit(placeOrderEvent);
});
}
while submit the transaction Getting the error
# Instance org.acme.securebox.Order#1234 missing required field customer
Can someone tell me the solution?