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
2b379aff
Commit
2b379aff
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
DRAFT: Begin implementation of entities
parent
475a378f
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
ENH: Implement queries and entity retrieval
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Entity.jl
+146
-0
146 additions, 0 deletions
src/Entity.jl
with
146 additions
and
0 deletions
src/Entity.jl
+
146
−
0
View file @
2b379aff
...
...
@@ -144,4 +144,150 @@ function create_entity(name::AbstractString = "")
end
"""
function create_recordtype(name::AbstractString = "")
Return a new entity object with role RecordType. If a `name` was
provided, its name is set accordingly.
"""
function
create_recordtype
(
name
::
AbstractString
=
""
)
record_type
=
create_entity
(
name
)
set_role
(
record_type
,
"RecordType"
)
return
record_type
end
"""
function create_record(name::AbstractString = "")
Return a new entity object with role Record. If a `name` was provided,
its name is set accordingly.
"""
function
create_record
(
name
::
AbstractString
=
""
)
record
=
create_entity
(
name
)
set_role
(
record
,
"Record"
)
return
record
end
"""
function create_property_entity(;
name::AbstractString = "",
datatype::AbstractString = "",
unit::AbstractString = "",
)
Return a new entity object with role Record. If `name`, `datatype`, or
`unit` were provided, its name, datatype, or unit are set accordingly.
"""
function
create_property_entity
(;
name
::
AbstractString
=
""
,
datatype
::
AbstractString
=
""
,
unit
::
AbstractString
=
""
,
)
property
=
create_entity
(
name
)
set_role
(
property
,
"Property"
)
if
datatype
!=
""
set_datatype
(
property
,
datatype
)
end
if
unit
!=
""
set_unit
(
property
,
unit
)
end
return
property
end
"""
function create_property(;
name::AbstractString = "",
id::AbstractString = "",
value::AbstractString = "",
)
Create a property object that can be appended to another `_Entity`. If
`name`, `id`, or `value` are given, the property's name, id, or value
are set accordingly.
!!! info
This is not an `_Entity` that could be inserted or updated by its
own but a `_Property` that is to be appended to another `_Entity`.
"""
function
create_property
(;
name
::
AbstractString
=
""
,
id
::
AbstractString
=
""
,
value
::
AbstractString
=
""
,
)
property
=
Ref
{
_Property
}(
_Property
(
true
))
err_code
=
ccall
(
(
:
caosdb_entity_create_property
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Property
},),
property
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
if
name
!=
""
set_name
(
property
,
name
)
end
if
id
!=
""
set_id
(
property
,
id
)
end
if
value
set_value
(
property
,
value
)
end
return
property
end
"""
function create_parent(; name::AbstractString = "", id::AbstractString = "")
Create a parent object that can be appended to another `_Entity`. If
`name`, `id`, or `value` are given, the parent's name, id, or value
are set accordingly.
!!! info
This is not an `_Entity` that could be inserted or updated by its
own but a `_Parent` that is to be appended to another `_Entity`.
"""
function
create_parent
(;
name
::
AbstractString
=
""
,
id
::
AbstractString
=
""
)
parent
=
Ref
{
_Parent
}(
_Parent
(
true
))
err_code
=
ccall
(
(
:
caosdb_entity_create_parent
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Parent
},)
parent
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
if
name
!=
""
set_name
(
parent
,
name
)
end
if
id
!=
""
set_id
(
parent
,
id
)
end
return
parent
end
end
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