From 6ca68e17171b3ed01b1cb7d2f2780ed6a892dd3f Mon Sep 17 00:00:00 2001
From: Alexander Kreft <akreft@trineo.org>
Date: Thu, 26 Aug 2021 10:51:43 +0000
Subject: [PATCH] ENH: Add functions for file upload + code style

---
 src/CaosDB.jl      |  4 +++-
 src/Entity.jl      | 37 ++++++++++++++++++++++++++++++++++++-
 src/Transaction.jl | 21 +++++++++++++++++----
 3 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/src/CaosDB.jl b/src/CaosDB.jl
index 0409f4d..224c48e 100644
--- a/src/CaosDB.jl
+++ b/src/CaosDB.jl
@@ -75,7 +75,9 @@ export append_parent,
     set_datatype,
     set_unit,
     set_value,
-    set_importance
+    set_importance,
+    set_local_path,
+    set_file_path
 
 # helper functions
 export has_errors, has_warnings
diff --git a/src/Entity.jl b/src/Entity.jl
index 119729b..f8d6d0b 100644
--- a/src/Entity.jl
+++ b/src/Entity.jl
@@ -62,7 +62,9 @@ export append_parent,
     set_datatype,
     set_unit,
     set_value,
-    set_importance
+    set_importance,
+    set_local_path,
+    set_file_path
 
 # helper functions
 export has_errors, has_warnings
@@ -1733,6 +1735,39 @@ function set_importance(property::Ref{_Property}, importance::AbstractString)
 
     CaosDB.Exceptions.evaluate_return_code(err_code)
 end
+"""
+    function set_local_path(entity::Ref{_Entity}, path::AbstractString)
+
+Set the local path of the given `entity` object.
+"""
+function set_local_path(entity::Ref{_Entity}, path::AbstractString)
+    err_code = ccall(
+        (:caosdb_entity_entity_set_local_path, CaosDB.library_name),
+        Cint,
+        (Ref{_Entity}, Cstring),
+        entity,
+        path,
+    )
+
+    CaosDB.Exceptions.evaluate_return_code(err_code)
+end
+
+"""
+    function set_file_path(entity::Ref{_Entity}, path::AbstractString)
+
+Set the file path of the given `entity` object.
+"""
+function set_file_path(entity::Ref{_Entity}, path::AbstractString)
+    err_code = ccall(
+        (:caosdb_entity_entity_set_file_path, CaosDB.library_name),
+        Cint,
+        (Ref{_Entity}, Cstring),
+        entity,
+        path,
+    )
+
+    CaosDB.Exceptions.evaluate_return_code(err_code)
+end
 
 """
     function append_parent(entity::Ref{_Entity}, parent::Ref{_Parent})
diff --git a/src/Transaction.jl b/src/Transaction.jl
index 5e33578..cbffb50 100644
--- a/src/Transaction.jl
+++ b/src/Transaction.jl
@@ -150,7 +150,10 @@ Add a sub-request to insert a single entity to the given `transaction`.
 
     This does not execute the transaction.
 """
-function add_insert_entity(transaction::Ref{_Transaction}, entity::Ref{CaosDB.Entity._Entity})
+function add_insert_entity(
+    transaction::Ref{_Transaction},
+    entity::Ref{CaosDB.Entity._Entity},
+)
 
     err_code = ccall(
         (:caosdb_transaction_transaction_insert_entity, CaosDB.library_name),
@@ -171,7 +174,10 @@ Add a sub-request to update a single entity to the given `transaction`.
 
     This does not execute the transaction.
 """
-function add_update_entity(transaction::Ref{_Transaction}, entity::Ref{CaosDB.Entity._Entity})
+function add_update_entity(
+    transaction::Ref{_Transaction},
+    entity::Ref{CaosDB.Entity._Entity},
+)
 
     err_code = ccall(
         (:caosdb_transaction_transaction_update_entity, CaosDB.library_name),
@@ -245,10 +251,17 @@ Add a sub-request to delete a single entity to the given `transaction`.
 
     This does not execute the transaction.
 """
-function add_retrieve_and_download_file_by_id(transaction::Ref{_Transaction}, id::AbstractString, path::AbstractString)
+function add_retrieve_and_download_file_by_id(
+    transaction::Ref{_Transaction},
+    id::AbstractString,
+    path::AbstractString,
+)
 
     err_code = ccall(
-        (:caosdb_transaction_transaction_retrieve_and_download_file_by_id, CaosDB.library_name),
+        (
+            :caosdb_transaction_transaction_retrieve_and_download_file_by_id,
+            CaosDB.library_name,
+        ),
         Cint,
         (Ref{_Transaction}, Cstring, Cstring),
         transaction,
-- 
GitLab