Skip to content
Snippets Groups Projects
Commit 50cf9d24 authored by florian's avatar florian
Browse files

ENH: Add `is_list` and `is_reference` to property creators

parent eb57ac6c
No related branches found
No related tags found
1 merge request!7ENH: Implement queries and entity retrieval
......@@ -80,10 +80,10 @@ using CaosDB
# 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
object. Meant for internal use; use `CaosDB.Entity.create_entity` to
create an entity.
create an entity.
"""
mutable struct _Entity
wrapped_entity::Ptr{Cvoid}
......@@ -111,10 +111,10 @@ mutable struct _Entity
end
"""
"""
Struct containing a pointer to the wrapped cpp parent
object. Meant for internal use; use `CaosDB.Entity.create_parent` to
create an parent.
create an parent.
"""
mutable struct _Parent
wrapped_parent::Ptr{Cvoid}
......@@ -142,10 +142,10 @@ mutable struct _Parent
end
"""
"""
Struct containing a pointer to the wrapped cpp property
object. Meant for internal use; use `CaosDB.Entity.create_property` to
create an property.
create an property.
"""
mutable struct _Property
wrapped_property::Ptr{Cvoid}
......@@ -254,12 +254,15 @@ end
)
Return a new entity object with role Record. If `name`, `datatype`, or
`unit` were provided, its name, datatype, or unit are set accordingly.
`unit` were provided, its name, datatype (including whether it is a
reference or a list), or unit are set accordingly.
"""
function create_property_entity(;
name::AbstractString = "",
datatype::AbstractString = "",
unit::AbstractString = "",
is_reference::Bool = false,
is_list::Bool = false,
)
property = create_entity(name)
......@@ -267,7 +270,7 @@ function create_property_entity(;
set_role(property, "PROPERTY")
if datatype != ""
set_datatype(property, datatype)
set_datatype(property, datatype, is_list = is_list, is_reference = is_reference)
end
if unit != ""
......@@ -297,6 +300,9 @@ function create_property(;
name::AbstractString = "",
id::AbstractString = "",
value::AbstractString = "",
datatype::AbstractString = "",
is_reference::Bool = false,
is_list::Bool = false,
)
property = Ref{_Property}(_Property(true))
......@@ -317,6 +323,10 @@ function create_property(;
set_id(property, id)
end
if datatype != ""
set_datatype(property, datatype, is_reference = is_reference, is_list = is_list)
end
if value != ""
set_value(property, value)
end
......@@ -609,7 +619,7 @@ end
function get_datatype(entity::Ref{_Entity})
Return a tuple that contains the name of the datatype of the given
`entity`, whether it is a reference, and whether it is a list.
`entity`, whether it is a reference, and whether it is a list.
"""
function get_datatype(entity::Ref{_Entity})
......@@ -1264,7 +1274,7 @@ to set the id of entities.
function set_id(entity::Ref{_Entity}, id::AbstractString)
throw(
CaosDB.Exceptions.ClientException(
"You cannot set the id of an entity object.
"You cannot set the id of an entity object.
If you want to update an entity with this id, you have to retrieve it first.",
),
)
......@@ -1396,7 +1406,7 @@ end
# too?
"""
function set_datatype(
entity::Ref{_Entity},
entity::Ref{_Entity},
datatype::AbstractString;
is_list::Bool = false,
is_reference::Bool = false,
......@@ -1440,7 +1450,7 @@ end
"""
function set_datatype(
property::Ref{_Property},
property::Ref{_Property},
datatype::AbstractString;
is_list::Bool = false,
is_reference::Bool = false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment