Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-julialib
Commits
379a133b
Commit
379a133b
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add convenience wrappers for Integer indices
parent
0be053a7
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
ENH: Implement queries and entity retrieval
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Entity.jl
+83
-10
83 additions, 10 deletions
src/Entity.jl
test/runtests.jl
+2
-1
2 additions, 1 deletion
test/runtests.jl
with
85 additions
and
11 deletions
src/Entity.jl
+
83
−
10
View file @
379a133b
...
...
@@ -305,7 +305,7 @@ function create_property(;
set_id
(
property
,
id
)
end
if
value
if
value
!=
""
set_value
(
property
,
value
)
end
...
...
@@ -805,7 +805,7 @@ function get_error(entity::Ref{_Entity}, index::Cint)
Cint
,
(
Ref
{
_Entity
},
Cint
),
entity
,
index
-
1
,
index
-
Cint
(
1
)
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -817,6 +817,19 @@ function get_error(entity::Ref{_Entity}, index::Cint)
return
CaosDB
.
Exceptions
.
CaosDBMessage
(
message_text
,
code
)
end
"""
function get_error(entity::Ref{_Entity}, index::Integer)
Convenience wrapper for `get_error(::Ref{_Entity}, ::Cint)`. Convert
`index` to Int32 and return the error at position `index` of the given
`entity`.
"""
function
get_error
(
entity
::
Ref
{
_Entity
},
index
::
Integer
)
return
get_error
(
entity
,
Cint
(
index
))
end
"""
function get_warning(entity::Ref{_Entity}, index::Cint)
...
...
@@ -832,7 +845,7 @@ function get_warning(entity::Ref{_Entity}, index::Cint)
Cint
,
(
Ref
{
_Entity
},
Cint
),
entity
,
index
-
1
,
index
-
Cint
(
1
)
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -844,6 +857,18 @@ function get_warning(entity::Ref{_Entity}, index::Cint)
return
CaosDB
.
Exceptions
.
CaosDBMessage
(
message_text
,
code
)
end
"""
function get_warning(entity::Ref{_Entity}, index::Integer)
Convenience wrapper for `get_warning(::Ref{_Entity}, ::Cint)`. Convert
`index` to Int32 and return the warning at position `index` of the given
`entity`.
"""
function
get_warning
(
entity
::
Ref
{
_Entity
},
index
::
Integer
)
return
get_warning
(
entity
,
Cint
(
index
))
end
"""
function get_info(entity::Ref{_Entity}, index::Cint)
...
...
@@ -860,7 +885,7 @@ function get_info(entity::Ref{_Entity}, index::Cint)
Cint
,
(
Ref
{
_Entity
},
Cint
),
entity
,
index
-
1
,
index
-
Cint
(
1
)
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -872,6 +897,20 @@ function get_info(entity::Ref{_Entity}, index::Cint)
return
CaosDB
.
Exceptions
.
CaosDBMessage
(
message_text
,
code
)
end
"""
function get_info(entity::Ref{_Entity}, index::Integer)
Convenience wrapper for `get_info(::Ref{_Entity}, ::Cint)`. Convert
`index` to Int32 and return the info at position `index` of the given
`entity`.
"""
function
get_info
(
entity
::
Ref
{
_Entity
},
index
::
Integer
)
return
get_info
(
entity
,
Cint
(
index
))
end
"""
function get_errors(entity::Ref{_Entity})
...
...
@@ -954,12 +993,16 @@ function get_parent(entity::Ref{_Entity}, index::Cint)
parent
=
Ref
{
_Parent
}(
_Parent
())
println
(
index
-
Cint
(
1
))
println
(
typeof
(
index
-
Cint
(
1
)))
err_code
=
ccall
(
(
:
caosdb_entity_entity_get_parent
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Entity
},
Ref
{
Cint
}),
(
Ref
{
_Entity
},
Ref
{
_Parent
},
Ref
{
Cint
}),
entity
,
index
-
1
,
parent
,
index
-
Cint
(
1
),
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -967,6 +1010,20 @@ function get_parent(entity::Ref{_Entity}, index::Cint)
return
parent
end
"""
function get_parent(entity::Ref{_Entity}, index::Integer)
Convenience wrapper for `get_parent(::Ref{_Entity}, ::Cint)`. Convert
`index` to Int32 and return the parent at position `index` of the given
`entity`.
"""
function
get_parent
(
entity
::
Ref
{
_Entity
},
index
::
Integer
)
return
get_parent
(
entity
,
Cint
(
index
))
end
"""
function get_parents(entity::Ref{_Entity})
...
...
@@ -1003,9 +1060,10 @@ function get_property(entity::Ref{_Entity}, index::Cint)
err_code
=
ccall
(
(
:
caosdb_entity_entity_get_property
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Entity
},
Ref
{
Cint
}),
(
Ref
{
_Entity
},
Ref
{
_Property
},
Ref
{
Cint
}),
entity
,
index
-
1
,
property
,
index
-
Cint
(
1
),
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -1013,6 +1071,21 @@ function get_property(entity::Ref{_Entity}, index::Cint)
return
property
end
"""
function get_property(entity::Ref{_Entity}, index::Integer)
Convenience wrapper for `get_property(::Ref{_Entity}, ::Cint)`. Convert
`index` to Int32 and return the property at position `index` of the given
`entity`.
"""
function
get_property
(
entity
::
Ref
{
_Entity
},
index
::
Integer
)
return
get_property
(
entity
,
Cint
(
index
))
end
"""
function get_properties(entity::Ref{_Entity})
...
...
@@ -1339,7 +1412,7 @@ function remove_parent(entity::Ref{_Entity}, index::Cint)
Cint
,
(
Ref
{
_Entity
},
Cint
),
entity
,
index
-
1
,
index
-
Cint
(
1
)
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
@@ -1391,7 +1464,7 @@ function remove_property(entity::Ref{_Entity}, index::Cint)
Cint
,
(
Ref
{
_Entity
},
Cint
),
entity
,
index
-
1
,
index
-
Cint
(
1
)
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
2
−
1
View file @
379a133b
...
...
@@ -116,11 +116,12 @@ using CaosDB
par2
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent2"
,
id
=
"id_of_parent_2"
)
CaosDB
.
Entity
.
append_parents
(
rec_with_parent_and_props
,
[
par1
,
par2
])
@test
length
(
CaosDB
.
Entity
.
get_parents
(
rec_with_parent_and_props
))
==
2
# Getting has to work with all Integers that can be cast to Cint
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
Cint
(
1
)),
)
==
"Parent1"
@test
CaosDB
.
Entity
.
get_name
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
Cint
(
2
)
),
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
2
),
)
==
"Parent2"
@test
CaosDB
.
Entity
.
get_id
(
CaosDB
.
Entity
.
get_parent
(
rec_with_parent_and_props
,
Cint
(
2
)),
...
...
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