Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
c8ff205f
Commit
c8ff205f
authored
8 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
modelId must be int
parent
dcf82c16
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Frontend refactor
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend-js/src/main/js/map/data/IdentifiedElement.js
+15
-7
15 additions, 7 deletions
frontend-js/src/main/js/map/data/IdentifiedElement.js
frontend-js/src/test/js/map/data/IdentifiedElement-test.js
+143
-143
143 additions, 143 deletions
frontend-js/src/test/js/map/data/IdentifiedElement-test.js
with
158 additions
and
150 deletions
frontend-js/src/main/js/map/data/IdentifiedElement.js
+
15
−
7
View file @
c8ff205f
...
...
@@ -20,15 +20,15 @@ var logger = require('../../logger');
function
IdentifiedElement
(
javaObject
)
{
if
(
javaObject
instanceof
Alias
)
{
this
.
setId
(
javaObject
.
getId
());
this
.
m
odelId
=
javaObject
.
getModelId
();
this
.
setM
odelId
(
javaObject
.
getModelId
()
)
;
this
.
type
=
"
ALIAS
"
;
}
else
if
(
javaObject
instanceof
Reaction
)
{
this
.
setId
(
javaObject
.
getId
());
this
.
m
odelId
=
javaObject
.
getModelId
();
this
.
setM
odelId
(
javaObject
.
getModelId
()
)
;
this
.
type
=
"
REACTION
"
;
}
else
if
(
javaObject
instanceof
PointData
)
{
this
.
setId
(
javaObject
.
getId
());
this
.
m
odelId
=
javaObject
.
getModelId
();
this
.
setM
odelId
(
javaObject
.
getModelId
()
)
;
this
.
type
=
"
POINT
"
;
}
else
{
// identifier of the object to visualize
...
...
@@ -36,7 +36,7 @@ function IdentifiedElement(javaObject) {
// which marker should be used to show this object
this
.
icon
=
javaObject
.
icon
;
// on which model the element is located
this
.
m
odelId
=
javaObject
.
modelId
;
this
.
setM
odelId
(
javaObject
.
modelId
)
;
// what kind of object we are talking about
this
.
type
=
javaObject
.
type
;
}
...
...
@@ -66,9 +66,6 @@ function IdentifiedElement(javaObject) {
if
(
this
.
getId
()
===
undefined
||
this
.
getId
()
===
null
)
{
throw
"
Id not defined for element:
"
+
javaObject
;
}
if
(
this
.
modelId
===
undefined
||
this
.
modelId
===
null
)
{
throw
"
Model id not defined for element:
"
+
javaObject
;
}
}
/**
...
...
@@ -106,6 +103,17 @@ IdentifiedElement.prototype.setId = function(id) {
this
.
id
=
id
;
};
IdentifiedElement
.
prototype
.
getModelId
=
function
()
{
return
this
.
id
;
};
IdentifiedElement
.
prototype
.
setModelId
=
function
(
modelId
)
{
if
(
modelId
===
undefined
||
modelId
===
null
)
{
throw
"
ModelId is invalid
"
;
}
this
.
modelId
=
parseInt
(
modelId
);
};
/**
* Returns model identifier where element is placed.
*
...
...
This diff is collapsed.
Click to expand it.
frontend-js/src/test/js/map/data/IdentifiedElement-test.js
+
143
−
143
View file @
c8ff205f
...
...
@@ -11,146 +11,146 @@ var chai = require('chai');
var
assert
=
chai
.
assert
;
var
expect
=
chai
.
expect
;
describe
(
'
IdentifiedElement
'
,
function
()
{
beforeEach
(
function
()
{
logger
.
flushBuffer
();
});
it
(
"
simple contructor
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
31165
"
,
modelId
:
269
,
type
:
"
alias
"
,
icon
:
"
marker/marker/marker_red_1.png
"
}
;
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
);
assert
.
equal
(
31165
,
ie
.
get
Id
());
assert
.
equal
(
269
,
ie
.
get
ModelId
());
assert
.
equal
(
"
ALIAS
"
,
ie
.
getType
()
);
assert
.
equal
(
"
marker/marker/marker_red_1.png
"
,
ie
.
getIcon
());
});
it
(
"
point contructor
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
Point2D.Double[117.685546875, 204.6923828125001]
"
,
modelId
:
269
,
type
:
"
POINT
"
,
icon
:
"
icons/comment.png
"
}
;
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
);
assert
.
ok
(
ie
.
getPoint
());
});
it
(
"
point contructor 2
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
(117.685546875, 204.6923828125001)
"
,
modelId
:
269
,
type
:
"
POINT
"
,
icon
:
"
empty.png
"
}
;
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
);
assert
.
ok
(
ie
.
getPoint
());
})
;
it
(
"
contructor from alias
"
,
function
()
{
var
jsonString
=
'
{"bounds":{"x":190,"y":44,"width":80,"height":40},"modelId":57,"idObject":18554}
'
;
var
javaObject
=
JSON
.
parse
(
jsonString
);
var
alias
=
new
Alias
(
javaObject
);
var
ie
=
new
IdentifiedElement
(
alias
);
assert
.
ok
(
ie
);
assert
.
equal
(
ie
.
getType
(),
"
ALIAS
"
);
});
it
(
"
contructor from Reaction
"
,
function
()
{
var
javaObject
=
{
lines
:
[
{
start
:
Object
,
end
:
Object
,
type
:
"
START
"
},
{
start
:
Object
,
end
:
Object
,
type
:
"
END
"
},
{
start
:
Object
,
end
:
Object
,
type
:
"
MIDDLE
"
}
],
modelId
:
319
,
idObject
:
"
13178
"
,
centerPoint
:
{}
}
;
var
reaction
=
new
Reaction
(
javaObject
);
var
ie
=
new
IdentifiedElement
(
reaction
);
assert
.
ok
(
ie
);
assert
.
equal
(
ie
.
getType
(),
"
REACTION
"
);
});
it
(
"
contructor from invalid object
"
,
function
()
{
var
javaObject
=
[]
;
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
);
};
assert
.
throws
(
code
,
new
RegExp
(
"
Type not defined
"
));
});
it
(
"
contructor from PointData
"
,
function
()
{
var
modelId
=
3
;
var
point
=
new
google
.
maps
.
Point
(
2
,
3.45
);
var
pointData
=
new
PointData
(
point
,
modelId
);
var
ie
=
new
IdentifiedElement
(
pointData
);
assert
.
ok
(
ie
);
assert
.
equal
(
ie
.
getType
(),
"
POINT
"
);
});
it
(
"
contructor from invalid object 2
"
,
function
()
{
var
javaObject
=
{
type
:
"
unk_type
"
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
)
;
}
;
assert
.
throws
(
code
,
new
RegExp
(
"
Unknown type
"
)
);
});
it
(
"
contructor from invalid object 3
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
,
objectId
:
"
el_id
"
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
)
;
}
;
assert
.
throws
(
code
,
new
RegExp
(
"
Model id not defined
"
)
);
});
it
(
"
contructor from invalid object 4
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
);
};
assert
.
throws
(
code
,
new
RegExp
(
"
Id not defined
"
));
});
it
(
"
contructor from artifitial obj
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
,
objectId
:
"
el_id
"
,
modelId
:
"
m_id
"
};
var
ie
=
new
IdentifiedElement
(
javaObject
);
var
point
=
ie
.
getPoint
();
expect
(
point
).
to
.
equal
(
null
);
assert
.
equal
(
logger
.
getWarnings
().
length
,
1
);
});
});
describe
(
'
IdentifiedElement
'
,
function
()
{
beforeEach
(
function
()
{
logger
.
flushBuffer
();
});
it
(
"
simple contructor
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
31165
"
,
modelId
:
269
,
type
:
"
alias
"
,
icon
:
"
marker/marker/marker_red_1.png
"
};
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
)
;
assert
.
equal
(
31165
,
ie
.
getId
()
);
assert
.
equal
(
269
,
ie
.
getModelId
()
);
assert
.
equal
(
"
ALIAS
"
,
ie
.
get
Type
());
assert
.
equal
(
"
marker/marker/marker_red_1.png
"
,
ie
.
get
Icon
());
}
);
it
(
"
point contructor
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
Point2D.Double[117.685546875, 204.6923828125001]
"
,
modelId
:
269
,
type
:
"
POINT
"
,
icon
:
"
icons/comment.png
"
};
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
)
;
assert
.
ok
(
ie
.
getPoint
()
);
}
);
it
(
"
point contructor 2
"
,
function
()
{
var
javaObj
=
{
objectId
:
"
(117.685546875, 204.6923828125001)
"
,
modelId
:
269
,
type
:
"
POINT
"
,
icon
:
"
empty.png
"
};
var
ie
=
new
IdentifiedElement
(
javaObj
);
assert
.
ok
(
ie
)
;
assert
.
ok
(
ie
.
getPoint
()
);
}
);
it
(
"
contructor from alias
"
,
function
()
{
var
jsonString
=
'
{"bounds":{"x":190,"y":44,"width":80,"height":40},"modelId":57,"idObject":18554}
'
;
var
javaObject
=
JSON
.
parse
(
jsonString
);
var
alias
=
new
Alias
(
javaObject
);
var
ie
=
new
IdentifiedElement
(
alias
);
assert
.
ok
(
ie
)
;
assert
.
equal
(
ie
.
getType
(),
"
ALIAS
"
);
}
);
it
(
"
contructor from Reaction
"
,
function
()
{
var
javaObject
=
{
lines
:
[
{
start
:
Object
,
end
:
Object
,
type
:
"
START
"
},
{
start
:
Object
,
end
:
Object
,
type
:
"
END
"
},
{
start
:
Object
,
end
:
Object
,
type
:
"
MIDDLE
"
}
],
modelId
:
319
,
idObject
:
"
13178
"
,
centerPoint
:
{}
}
;
var
reaction
=
new
Reaction
(
javaObject
);
var
ie
=
new
IdentifiedElement
(
reaction
);
assert
.
ok
(
ie
)
;
assert
.
equal
(
ie
.
getType
(),
"
REACTION
"
);
});
it
(
"
contructor from invalid object
"
,
function
()
{
var
javaObject
=
{
modelId
:
2
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
)
;
};
assert
.
throws
(
code
,
new
RegExp
(
"
Type not defined
"
)
);
}
)
;
it
(
"
contructor from PointData
"
,
function
()
{
var
modelId
=
3
;
var
point
=
new
google
.
maps
.
Point
(
2
,
3.45
);
var
pointData
=
new
PointData
(
point
,
modelId
)
;
var
ie
=
new
IdentifiedElement
(
pointData
);
assert
.
ok
(
ie
);
assert
.
equal
(
ie
.
getType
(),
"
POINT
"
);
}
);
it
(
"
contructor from invalid object 2
"
,
function
()
{
var
javaObject
=
{
modelId
:
2
,
type
:
"
unk_type
"
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
);
}
;
assert
.
throws
(
code
,
new
RegExp
(
"
Unknown type
"
))
;
}
);
it
(
"
contructor from invalid object 3
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
,
objectId
:
"
el_id
"
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
);
}
;
assert
.
throws
(
code
,
new
RegExp
(
"
ModelId is invalid
"
))
;
}
);
it
(
"
contructor from invalid object 4
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
,
modelId
:
4
,
};
var
code
=
function
()
{
new
IdentifiedElement
(
javaObject
);
};
assert
.
throws
(
code
,
new
RegExp
(
"
Id not defined
"
));
});
it
(
"
contructor from artifitial obj
"
,
function
()
{
var
javaObject
=
{
type
:
"
alias
"
,
objectId
:
"
el_id
"
,
modelId
:
"
m_id
"
};
var
ie
=
new
IdentifiedElement
(
javaObject
);
var
point
=
ie
.
getPoint
();
expect
(
point
).
to
.
equal
(
null
);
assert
.
equal
(
logger
.
getWarnings
().
length
,
1
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment