Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB WebUI Entity Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB WebUI Entity Service
Commits
cd27431f
Commit
cd27431f
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
FIX: Use correct ValueCase in getValue
parent
cd37d913
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
ENH: Add property and entity classes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Property.js
+11
-22
11 additions, 22 deletions
src/Property.js
with
11 additions
and
22 deletions
src/Property.js
+
11
−
22
View file @
cd27431f
...
...
@@ -37,23 +37,15 @@ function _getScalarValue(value) {
return
value
.
getBooleanValue
();
case
valueCases
.
STRING_VALUE
:
return
value
.
getStringValue
();
case
valueCases
.
SPECIAL_VALUE
:
return
value
.
getSpecialValue
();
default
:
throw
`Unkown value type
${
value
.
getScalarValueCase
()}
.`
;
}
}
function
_getListValue
(
listDataType
,
values
)
{
const
listCases
=
api
.
v1
.
ListDataType
.
ListDataTypeCase
;
switch
(
listDataType
.
getListDataTypeCase
())
{
case
listCases
.
LIST_DATA_TYPE_NOT_SET
:
return
undefined
;
case
listCases
.
ATOMIC_DATA_TYPE
:
return
values
.
map
(
value
=>
_getScalarValue
(
value
));
case
listCases
.
REFERENCE_DATA_TYPE
:
function
_getListValue
(
values
)
{
return
values
.
map
(
value
=>
_getScalarValue
(
value
));
default
:
throw
`Unknown list data type
${
listDataType
.
getListDataTypeCase
()}
.`
}
}
export
class
Property
{
...
...
@@ -80,19 +72,16 @@ export class Property {
// Empty values are undefined regardless of data type
return
undefined
;
}
const
wrappedDataType
=
this
.
wrappedProperty
.
getDataType
();
const
dtypeCases
=
api
.
v1
.
DataType
.
DataTypeCase
;
switch
(
wrappedDataType
.
getDataTypeCase
())
{
case
dtypeCases
.
DATA_TYPE_NOT_SET
:
const
valueCases
=
api
.
v1
.
Value
.
ValueCase
;
switch
(
wrappedValue
.
getValueCase
())
{
case
valueCases
.
VALUE_NOT_SET
:
return
undefined
;
case
dtypeCases
.
ATOMIC_DATA_TYPE
:
return
_getScalarValue
(
wrappedValue
.
getScalarValue
());
case
dtypeCases
.
LIST_DATA_TYPE
:
return
_getListValue
(
wrappedDataType
.
getListDataType
(),
wrappedValue
.
getListValues
().
getValuesList
());
case
dtypeCases
.
REFERENCE_DATA_TYPE
:
case
valueCases
.
SCALAR_VALUE
:
return
_getScalarValue
(
wrappedValue
.
getScalarValue
());
case
valueCases
.
LIST_VALUES
:
return
_getListValue
(
wrappedValue
.
getListValues
().
getValuesList
());
default
:
throw
`Unknown
data
type
${
wrapped
DataType
.
getDataTyp
eCase
()}
.`
;
throw
`Unknown
value
type
${
wrapped
Value
.
getValu
eCase
()}
.`
;
}
}
...
...
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