我正在学习hyperledger composer,我不知道如何修改链码以使以下模型工作:
这是我的首席技术官:
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{
}
链码:
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);
});
}
然后我做了两个项目:I1和I2-这是第三个项目I3的组成部分
这样地:
{
"$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"
]
}
然后,如果我使事务I3更改所有者,但其组件仍具有以前的所有者。如何使I1和I2在I3更改所有者时自动更改所有者。有可能做到这一点吗?我将感谢任何帮助或指导。