本文介绍了如何重新present与骨干-关系UML关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的类图看起来像这样:

  MODELA 1 ------ * ModelB 1 ------ * ModelC 1 ------ * ModelD

编辑:

数据看起来像

数据:

  {影片名称:MODELA
    MODELA:[
        {
          影片名称:ModelB1,
          ModelB1:[
                              {
              影片名称:ModelC1,
                              ModelC1:[
                                {影片名称:ModelD1},
                                {影片名称:ModelD2},
                                {影片名称:ModelD3}
                              },
                              {
              影片名称:ModelC2,
                              ModelC2:[
                                {影片名称:ModelD21},
                                {影片名称:ModelD22},
                                {影片名称:ModelD23}
                              },
                              ]
                 },
                 {
          影片名称:ModelB2,
          ModelB2:[
                              {
              影片名称:ModelC1,
                              ModelC1:[
                                {影片名称:ModelD1},
                                {影片名称:ModelD2},
                                {影片名称:ModelD3}
                              },
                              {
              影片名称:ModelC2,
                              ModelC2:[
                                {影片名称:ModelD21},
                                {影片名称:ModelD22},
                                {影片名称:ModelD23}
                              },
                              ]
                 }]
 }

我创建这些RelationalModel:

MODELA:

  MODELA = Backbone.RelationalModel.extend({  关系:[{
    类型:Backbone.HasMany,
    键:modelb',
    relatedModel:ModelB',
    collectionType:ModelBCollection',
    reverseRelation:{
      键:属于,
      includeInJSON:ID
    }
  }]});

ModelB:

  ModelB = Backbone.RelationalModel.extend({  关系:[{
    类型:Backbone.HasMany,
    键:modelc',
    relatedModel:ModelC',
    collectionType:ModelCCollection',
    reverseRelation:{
      键:属于,
      includeInJSON:ID
    }
  }]});

ModelC:

  ModelC = Backbone.RelationalModel.extend({  关系:[{
    类型:Backbone.HasMany,
    键:modeld',
    relatedModel:ModelD',
    collectionType:ModelDCollection',
    reverseRelation:{
      键:属于,
      includeInJSON:ID
    }
  }]});

ModelD:

  ModelD = Backbone.Model.extend({});

类别:

  ModelACollection = Backbone.Collection.extend({模式:MODELA});
 ModelBCollection = Backbone.Collection.extend({模式:ModelB});
 ModelCCollection = Backbone.Collection.extend({模式:ModelC});
 ModelDCollection = Backbone.Collection.extend({模式:ModelD});

和我这样做的路由器:

路由器:

  VAR obja =新ModelACollection(数据);
VAR objb =新ModelBCollection(data.objb);
VAR objc =新ModelCCollection(data.objc);
VAR objd =新ModelDCollection(data.objd);

都得到牵强,但有许多警告(火狐,Chrome)看起来是这样的:

警告:

  =的关系%O;没有模型,钥匙或relatedModel(‰, - ‰, - ‰)....


  1. 这是什么警告的含义是什么?

  2. 这是重新present权与主干关系这种阶级关系是不是?

如果不呢?

我怎样才能重新present以此为骨干ModelRelational?


解决方案

在A型要定义

键:modelb

可链接到模型B然而,关键应该是字符串。引用在relatedModel属性名称(基于文档)。我不能看到并呼吁modelb模型领域

I have Class Diagram looking like this :

ModelA 1------* ModelB 1------* ModelC 1------* ModelD

Edit :

The Data looks like that

Data :

{   "Titel" : "ModelA",
    "ModelA" : [
        {
          "Titel" : "ModelB1",
          "ModelB1" : [
                              {
              "Titel" : "ModelC1",
                              "ModelC1":[
                                { "Titel" : "ModelD1"   },
                                { "Titel" : "ModelD2"   },
                                { "Titel" : "ModelD3"   }
                              },
                              {
              "Titel" : "ModelC2",
                              "ModelC2":[
                                { "Titel" : "ModelD21"   },
                                { "Titel" : "ModelD22"   },
                                { "Titel" : "ModelD23"   }
                              },
                              ]
                 },
                 {
          "Titel" : "ModelB2",
          "ModelB2" : [
                              {
              "Titel" : "ModelC1",
                              "ModelC1":[
                                { "Titel" : "ModelD1"   },
                                { "Titel" : "ModelD2"   },
                                { "Titel" : "ModelD3"   }
                              },
                              {
              "Titel" : "ModelC2",
                              "ModelC2":[
                                { "Titel" : "ModelD21"   },
                                { "Titel" : "ModelD22"   },
                                { "Titel" : "ModelD23"   }
                              },
                              ]
                 }]
 }

I create those RelationalModel :

ModelA :

ModelA = Backbone.RelationalModel.extend({

  relations:[{
    type: Backbone.HasMany,
    key: 'modelb',
    relatedModel: 'ModelB',
    collectionType: 'ModelBCollection',
    reverseRelation:{
      key: 'belong To',
      includeInJSON: 'id'
    }
  }] });

ModelB :

ModelB = Backbone.RelationalModel.extend({

  relations:[{
    type: Backbone.HasMany,
    key: 'modelc',
    relatedModel: 'ModelC',
    collectionType: 'ModelCCollection',
    reverseRelation:{
      key: 'belong To',
      includeInJSON: 'id'
    }
  }] });

ModelC :

ModelC = Backbone.RelationalModel.extend({

  relations:[{
    type: Backbone.HasMany,
    key: 'modeld',
    relatedModel: 'ModelD',
    collectionType: 'ModelDCollection',
    reverseRelation:{
      key: 'belong To',
      includeInJSON: 'id'
    }
  }] });

ModelD :

ModelD = Backbone.Model.extend({ });

Collections :

 ModelACollection = Backbone.Collection.extend({ model: ModelA });
 ModelBCollection = Backbone.Collection.extend({ model: ModelB });
 ModelCCollection = Backbone.Collection.extend({ model: ModelC });
 ModelDCollection = Backbone.Collection.extend({ model: ModelD });

and i do this in the Router :

Router :

var obja = new ModelACollection(data);
var objb = new ModelBCollection(data.objb);
var objc = new ModelCCollection(data.objc);
var objd = new ModelDCollection(data.objd);

all get fetched but with many warning (firefox, chrome) looks like this :

Warning :

Relation=%o; no model, key or relatedModel (%o, %o, %o) ....
  1. What is the meaning of this Warning?
  2. That's the right to represent this Class Relation with Backbone-relational isn't?

if not?

How can i represent this as a Backbone ModelRelational?

解决方案

In Model A you are defining

key: 'modelb'

which links to Model B. However, key should be "a string. References an attribute name on relatedModel" (based on the docs). And I cannot see and model field called modelb

这篇关于如何重新present与骨干-关系UML关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:32