This is my cto:
asset Item identified by itemId{
o String itemId
o String name
o String idgId
o String serialNumber
o String comment
--> BU owner
--> Item [] items optional
}
abstract participant BU identified by buId{
o String buId
o String name
o String country
o String city
}
participant Manufacturer extends BU{
}
participant Assembler extends BU{
}
And chaincode:
function tradeCommodity(trade) {
trade.item.owner = trade.newOwner;
return getAssetRegistry('org.dps.track.Item')
.then(function (assetRegistry) {
var tradeNotification = getFactory().newEvent('org.dps.track', 'TradeNotification');
tradeNotification.item = trade.item;
emit(tradeNotification);
// persist the state of the commodity
return assetRegistry.update(trade.item);
});
}
then i make two items: I1 and I2 - which will be components of third item I3 like this:
{
"$class": "org.dps.track.Item",
"itemId": "I1",
"name": "c1",
"idgId": "123",
"serialNumber": "123",
"comment": "component1",
"owner": "resource:org.dps.track.Assembler#BU2"
},
{
"$class": "org.dps.track.Item",
"itemId": "I2",
"name": "c2",
"idgId": "456",
"serialNumber": "456",
"comment": "component2",
"owner": "resource:org.dps.track.Assembler#BU2"
},
{
"$class": "org.dps.track.Item",
"itemId": "I3",
"name": "complex",
"idgId": "789",
"serialNumber": "789",
"comment": "item consists of items",
"owner": "resource:org.dps.track.Assembler#BU2",
"items": [
"resource:org.dps.track.Item#I1",
"resource:org.dps.track.Item#I2"
]
}
Now, I want I1 and I2 to change owner automatically when I3 changes the owner. How can I do this?