Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
072ac62c
Commit
072ac62c
authored
Jan 22, 2019
by
Piotr Gawron
Browse files
parallel calls to fetch reaction could cause a problem
parent
c7172518
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/map/data/MapModel.js
View file @
072ac62c
...
...
@@ -237,17 +237,17 @@ MapModel.prototype.getCompleteReactionById = function (id) {
var
i
;
result
=
self
.
_reactions
[
id
];
for
(
i
=
0
;
i
<
result
.
getReactants
().
length
;
i
++
)
{
if
(
!
(
result
.
getReactants
()[
i
]
instanceof
Alias
))
{
if
(
!
(
result
.
getReactants
()[
i
]
.
getAlias
()
instanceof
Alias
))
{
result
.
getReactants
()[
i
].
setAlias
(
self
.
_aliases
[
result
.
getReactants
()[
i
].
getAlias
()]);
}
}
for
(
i
=
0
;
i
<
result
.
getProducts
().
length
;
i
++
)
{
if
(
!
(
result
.
getProducts
()[
i
]
instanceof
Alias
))
{
if
(
!
(
result
.
getProducts
()[
i
]
.
getAlias
()
instanceof
Alias
))
{
result
.
getProducts
()[
i
].
setAlias
(
self
.
_aliases
[
result
.
getProducts
()[
i
].
getAlias
()]);
}
}
for
(
i
=
0
;
i
<
result
.
getModifiers
().
length
;
i
++
)
{
if
(
!
(
result
.
getModifiers
()[
i
]
instanceof
Alias
))
{
if
(
!
(
result
.
getModifiers
()[
i
]
.
getAlias
()
instanceof
Alias
))
{
result
.
getModifiers
()[
i
].
setAlias
(
self
.
_aliases
[
result
.
getModifiers
()[
i
].
getAlias
()]);
}
}
...
...
frontend-js/src/test/js/map/data/MapModel-test.js
View file @
072ac62c
...
...
@@ -2,6 +2,7 @@
require
(
"
../../mocha-config
"
);
var
Alias
=
require
(
'
../../../../main/js/map/data/Alias
'
);
var
IdentifiedElement
=
require
(
'
../../../../main/js/map/data/IdentifiedElement
'
);
var
MapModel
=
require
(
'
../../../../main/js/map/data/MapModel
'
);
var
NetworkError
=
require
(
'
../../../../main/js/NetworkError
'
);
...
...
@@ -95,21 +96,45 @@ describe('MapModel', function () {
});
});
it
(
"
getReactionById 1
"
,
function
()
{
var
model
=
helper
.
createModel
();
var
reaction
=
helper
.
createReaction
();
describe
(
"
getReactionById
"
,
function
()
{
it
(
"
not existing
"
,
function
()
{
var
model
=
helper
.
createModel
();
var
reaction
=
helper
.
createReaction
();
return
model
.
getReactionById
(
reaction
.
getId
()).
then
(
function
(
result
)
{
assert
.
equal
(
null
,
result
);
},
function
(
exception
)
{
assert
.
ok
(
exception
instanceof
NetworkError
);
// check if this is exception about not finding file
model
.
addReaction
(
reaction
);
return
model
.
getReactionById
(
reaction
.
getId
());
}).
then
(
function
(
result
)
{
assert
.
equal
(
reaction
,
result
);
});
});
return
model
.
getReactionById
(
reaction
.
getId
()).
then
(
function
(
result
)
{
assert
.
equal
(
null
,
result
);
},
function
(
exception
)
{
assert
.
ok
(
exception
instanceof
NetworkError
);
// check if this is exception about not finding file
model
.
addReaction
(
reaction
);
return
model
.
getReactionById
(
reaction
.
getId
());
}).
then
(
function
(
result
)
{
assert
.
equal
(
reaction
,
result
);
it
(
"
check reactants
"
,
function
()
{
var
model
;
return
ServerConnector
.
getProject
().
then
(
function
(
project
)
{
model
=
project
.
getModels
()[
0
];
return
model
.
getReactionById
(
153510
,
true
);
}).
then
(
function
(
result
)
{
assert
.
ok
(
result
.
getReactants
()[
0
].
getAlias
()
instanceof
Alias
);
assert
.
ok
(
result
.
getProducts
()[
0
].
getAlias
()
instanceof
Alias
);
assert
.
ok
(
result
.
getModifiers
()[
0
].
getAlias
()
instanceof
Alias
);
//let assume we downloaded it partially
result
.
setIsComplete
(
false
);
return
model
.
getReactionById
(
153510
,
true
);
}).
then
(
function
(
result
)
{
assert
.
ok
(
result
.
getReactants
()[
0
].
getAlias
()
instanceof
Alias
);
assert
.
ok
(
result
.
getProducts
()[
0
].
getAlias
()
instanceof
Alias
);
assert
.
ok
(
result
.
getModifiers
()[
0
].
getAlias
()
instanceof
Alias
);
});
});
});
it
(
"
addReaction 2
"
,
function
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment