異なるモデル間で再利用されるネストされた参照との関連付けの設定に問題があります。
どうすればこれを行うことができますか?
アドレスモデル
Ext.define('POC.model.AddressModel',
{
extend: 'Ext.data.Model',
fields: [
{ name:'id', type:'string' },
{ name:'line1', type:'string' },
{ name:'line2', type:'string' },
{ name:'city', type:'string' },
{ name:'state', type:'string'},
{ name:'zip', type:'string'}
]
});
申請者モデル
Ext.define('POC.model.ApplicantModel',
{
extend: 'POC.model.Base',
requires: [
"POC.model.field.PhoneNumber",
"POC.model.AddressModel"
],
fields: [
{ name:'id', type:'string' },
{ name:'applicantName', type:'string'},
{ name:'mailingAddress', reference:'AddressModel'}
]
});
会社のモデル
Ext.define('POC.model.CompanyInfoModel',
{
requires: [
"POC.model.field.PhoneNumber",
"POC.model.AddressModel"
],
extend: 'Ext.data.Model',
fields: [
{ name:'id', type:'string'},
{ name:'contacttype', type:'string' },
{ name:'contactname', type:'string' },
{ name:'primaryphone', type:'phonenumber' },
{ name:'secphone', type:'phonenumber' },
{ name:'primaryemail', type:'string'},
{ name:'secemail', type:'string'},
{ name:'address', reference:'AddressModel'}
]
});
エージェント モデル
Ext.define('POC.model.AgentInfoModel',
{
extend: 'Ext.data.Model',
requires: [
"POC.model.field.PhoneNumber",
"POC.model.AddressModel"
],
fields: [
{ name:'id', type:'string'},
{ name:'agencyname', type:'string' },
{ name:'contactname', type:'string' },
{ name:'phone', type:'phonenumber' },
{ name:'code', type:'string'},
{ name:'email', type:'string'},
{ name:'address', reference:'AddressModel'}
]
});
すべてがアプリケーション モデルに統合されます
Ext.define('POC.model.ApplicationInfoModel',
{
requires:['POC.model.AgentInfoModel',
'POC.model.CompanyInfoModel',
'POC.model.ApplicantModel'
],
extend: 'POC.model.Base',
idProperty:'appid',
fields:[{
name:'appid',type:'string'
},
{
name:'agent',
reference:'AgentInfoModel'
},
{
name:'company',
reference:'CompanyInfoModel'
}
],
hasMany:[{
name:'applicants',
reference:'ApplicantModel'
}]
});
サーバーからの関連付けられた JSON 形式
{
"success":true,
"application" :
{
"appid":"0",
"company" :
{
"id" : "0",
"contacttype" : "",
"contactname" : "",
"primaryphone" : "",
"secphone" : "",
"primaryemail" : "",
"secemail" : "",
"address" : {
"id":"114444",
"line1" : "",
"line2" : "",
"city" : "",
"state" : "",
"zip" : ""
}
},
"agent" : {
"id" : "0",
"agencyname" : "",
"contactname" : "",
"phone" : "",
"code" : "",
"email" : "",
"address" : {
"id":"11111",
"line1" : "",
"line2" : "",
"city" : "",
"state" : "",
"zip" : ""
}
},
"applicants" :
[{
"id" : "0",
"applicantName" : "",
"mailingAddress" :
{
"id":"1132323",
"line1" : "",
"line2" : "",
"city" : "",
"state" : "",
"zip" : ""
}
}, {
"id" : "1",
"applicantName" : "",
"mailingAddress" :
{
"id":"11323666",
"line1" : "",
"line2" : "",
"city" : "",
"state" : "",
"zip" : ""
}
}
]
}
}
私が得るエラー...
**W] [Ext.define] 重複するクラス名 'POC.model.AddressModel' が指定されました。空でない文字列でなければなりません Util.js:692
[E] Ext.data.schema.Schema.addEntity(): エンティティ名「AddressModel」が重複しています: POC.model.AddressModel と POC.model.AddressModel
キャッチされないエラー: エンティティ名 "AddressModel" が重複しています: POC.model.AddressModel および POC.model.AddressModel**