annotate src/implab/data/DataContext.js @ 10:8705103f074f

Слияние
author cin
date Mon, 21 Aug 2017 18:03:00 +0300
parents fc2517695ee1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
1 define([ "dojo/_base/declare", "../safe" ], function(declare, safe) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
2 return declare(
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
3 null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
5 _params : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
7 _repositories : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
9 constructor : function(opts) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
10 this._params = opts || {};
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
11 this._repositories = {};
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
12 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
13
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
14 getRepository : function(name) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
15 safe.argumentNotEmptyString(name, "name");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
16 var repo = this._repositories[name];
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
17 if (!repo) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
18 repo = this._params[name];
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
19 if (!repo)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
20 throw new Error("The repository '" + name +
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
21 "' isn't found");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
22 if (repo instanceof Function)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
23 repo = new repo(); // factory method or constructor
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
24 if (repo.initialize) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
25 repo.initialize({
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
26 dataContext : this
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
27 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
28 } else if (repo.setDataContext) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
29 repo.setDataContext(this);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
30 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
31 this._repositories[name] = repo;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
32 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
33
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
34 return repo;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
35 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
36
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
37 dispose : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
38 for( var name in this._repositories) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
39 var r = this._repositories[name];
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
40 if (r.dispose)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
41 r.dispose();
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
42 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
43 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
44 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
45 });