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
12eaa7fa
Commit
12eaa7fa
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Use enums for role and importance
parent
c181530c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!13
ENH: Use new value and datatype structs
Pipeline
#13890
failed
3 years ago
Stage: info
Stage: code-style
Stage: setup
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Entity.jl
+25
-20
25 additions, 20 deletions
src/Entity.jl
with
25 additions
and
20 deletions
src/Entity.jl
+
25
−
20
View file @
12eaa7fa
...
@@ -82,11 +82,6 @@ using CaosDB
...
@@ -82,11 +82,6 @@ using CaosDB
# especially in case of a property which I might want to specify by
# especially in case of a property which I might want to specify by
# name, add a value, append it to a Record, and then insert it and
# name, add a value, append it to a Record, and then insert it and
# might expect the server to care for the datatype.
# might expect the server to care for the datatype.
#
# Also, how much do we want to support them with typos. Currently, C
# and C++ only understand all-capital strings for datatypes,
# importances, roles. What about user input like "record_type",
# "RecordType", "recordtype"?
"""
"""
Struct containing a pointer to the wrapped cpp entity
Struct containing a pointer to the wrapped cpp entity
object. Meant for internal use; use `CaosDB.Entity.create_entity` to
object. Meant for internal use; use `CaosDB.Entity.create_entity` to
...
@@ -291,7 +286,7 @@ function create_recordtype(name::AbstractString = "")
...
@@ -291,7 +286,7 @@ function create_recordtype(name::AbstractString = "")
record_type
=
create_entity
(
name
)
record_type
=
create_entity
(
name
)
set_role
(
record_type
,
"
RECORD_TYPE
"
)
set_role
(
record_type
,
CaosDB
.
Constants
.
ROLE
.
RECORD_TYPE
)
return
record_type
return
record_type
...
@@ -307,7 +302,7 @@ function create_record(name::AbstractString = "")
...
@@ -307,7 +302,7 @@ function create_record(name::AbstractString = "")
record
=
create_entity
(
name
)
record
=
create_entity
(
name
)
set_role
(
record
,
"
RECORD
"
)
set_role
(
record
,
CaosDB
.
Constants
.
ROLE
.
RECORD
)
return
record
return
record
...
@@ -336,7 +331,7 @@ function create_property_entity(;
...
@@ -336,7 +331,7 @@ function create_property_entity(;
property
=
create_entity
(
name
)
property
=
create_entity
(
name
)
set_role
(
property
,
"
PROPERTY
"
)
set_role
(
property
,
CaosDB
.
Constants
.
ROLE
.
PROPERTY
)
if
datatype
!=
""
if
datatype
!=
""
set_datatype
(
property
,
datatype
,
is_list
=
is_list
,
is_reference
=
is_reference
)
set_datatype
(
property
,
datatype
,
is_list
=
is_list
,
is_reference
=
is_reference
)
...
@@ -432,7 +427,7 @@ function create_file_entity(;
...
@@ -432,7 +427,7 @@ function create_file_entity(;
end
end
file_entity
=
create_entity
(
name
)
file_entity
=
create_entity
(
name
)
set_role
(
file_entity
,
"
FILE
"
)
set_role
(
file_entity
,
CaosDB
.
Constants
.
ROLE
.
FILE
)
set_local_path
(
file_entity
,
local_path
)
set_local_path
(
file_entity
,
local_path
)
set_remote_path
(
file_entity
,
remote_path
)
set_remote_path
(
file_entity
,
remote_path
)
...
@@ -739,7 +734,9 @@ function get_role(entity::Ref{_Entity})
...
@@ -739,7 +734,9 @@ function get_role(entity::Ref{_Entity})
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
return
unsafe_string
(
out
[])
rolename
=
unsafe_string
(
out
[])
role
=
getproperty
(
CaosDB
.
Constants
.
ROLE
,
Symbol
(
rolename
))
return
role
end
end
"""
"""
...
@@ -1279,14 +1276,16 @@ function get_importance(property::Ref{_Property})
...
@@ -1279,14 +1276,16 @@ function get_importance(property::Ref{_Property})
err_code
=
ccall
(
err_code
=
ccall
(
(
:
caosdb_entity_property_get_importance
,
CaosDB
.
library_name
),
(
:
caosdb_entity_property_get_importance
,
CaosDB
.
library_name
),
Cint
,
Cint
,
(
Ref
{
_
Enti
ty
},
Ref
{
Ptr
{
UInt8
}}),
(
Ref
{
_
Proper
ty
},
Ref
{
Ptr
{
UInt8
}}),
property
,
property
,
out
,
out
,
)
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
return
unsafe_string
(
out
[])
imp_name
=
unsafe_string
(
out
[])
imp
=
getproperty
(
CaosDB
.
Constants
.
IMPORTANCE
,
Symbol
(
imp_name
))
return
imp
end
end
"""
"""
...
@@ -1776,17 +1775,17 @@ function set_id(property::Ref{_Property}, id::AbstractString)
...
@@ -1776,17 +1775,17 @@ function set_id(property::Ref{_Property}, id::AbstractString)
end
end
"""
"""
function set_role(entity::Ref{_Entity}, role::
AbstractString
)
function set_role(entity::Ref{_Entity}, role::
CaosDB.Constants.ROLE._ROLE
)
Set the role of the given `entity` object.
Set the role of the given `entity` object.
"""
"""
function
set_role
(
entity
::
Ref
{
_Entity
},
role
::
AbstractString
)
function
set_role
(
entity
::
Ref
{
_Entity
},
role
::
CaosDB
.
Constants
.
ROLE
.
_ROLE
)
err_code
=
ccall
(
err_code
=
ccall
(
(
:
caosdb_entity_entity_set_role
,
CaosDB
.
library_name
),
(
:
caosdb_entity_entity_set_role
,
CaosDB
.
library_name
),
Cint
,
Cint
,
(
Ref
{
_Entity
},
Cstring
),
(
Ref
{
_Entity
},
Cstring
),
entity
,
entity
,
role
,
string
(
role
)
,
)
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
@@ -1887,7 +1886,7 @@ function set_datatype(
...
@@ -1887,7 +1886,7 @@ function set_datatype(
is_reference
::
Bool
=
false
,
is_reference
::
Bool
=
false
,
)
)
if
get_role
(
entity
)
!=
"
PROPERTY
"
if
get_role
(
entity
)
!=
CaosDB
.
Constants
.
ROLE
.
PROPERTY
throw
(
throw
(
CaosDB
.
Exceptions
.
ClientException
(
CaosDB
.
Exceptions
.
ClientException
(
"Only entities with role PROPERTY can be assigned a datatype."
,
"Only entities with role PROPERTY can be assigned a datatype."
,
...
@@ -1994,7 +1993,7 @@ function set_value(
...
@@ -1994,7 +1993,7 @@ function set_value(
value
::
Union
{
AbstractString
,
Number
,
Bool
,
Vector
{
T
}},
value
::
Union
{
AbstractString
,
Number
,
Bool
,
Vector
{
T
}},
)
where
{
T
<:
Union
{
AbstractString
,
Number
,
Bool
}}
)
where
{
T
<:
Union
{
AbstractString
,
Number
,
Bool
}}
if
get_role
(
entity
)
!=
"
PROPERTY
"
if
get_role
(
entity
)
!=
CaosDB
.
Constants
.
ROLE
.
PROPERTY
throw
(
throw
(
CaosDB
.
Exceptions
.
ClientException
(
CaosDB
.
Exceptions
.
ClientException
(
"Only entites with role PROPERTY may be assigned a value."
,
"Only entites with role PROPERTY may be assigned a value."
,
...
@@ -2040,17 +2039,23 @@ function set_value(
...
@@ -2040,17 +2039,23 @@ function set_value(
end
end
"""
"""
function set_importance(property::Ref{_Property}, importance::AbstractString)
function set_importance(
property::Ref{_Property},
importance::CaosDB.Constants.IMPORTANCE._IMPORTANCE
)
Set the importance of the given `property` object.
Set the importance of the given `property` object.
"""
"""
function
set_importance
(
property
::
Ref
{
_Property
},
importance
::
AbstractString
)
function
set_importance
(
property
::
Ref
{
_Property
},
importance
::
CaosDB
.
Constants
.
IMPORTANCE
.
_IMPORTANCE
,
)
err_code
=
ccall
(
err_code
=
ccall
(
(
:
caosdb_entity_property_set_importance
,
CaosDB
.
library_name
),
(
:
caosdb_entity_property_set_importance
,
CaosDB
.
library_name
),
Cint
,
Cint
,
(
Ref
{
_Property
},
Cstring
),
(
Ref
{
_Property
},
Cstring
),
property
,
property
,
importance
,
string
(
importance
)
,
)
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
...
...
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