Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
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-cpplib
Commits
ebe07acd
Commit
ebe07acd
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add file download
parent
897da977
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!15
ENH: Allow insert/update/delete and files in Extern C
Pipeline
#12436
passed with warnings
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#12437
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ccaosdb.h
+6
-0
6 additions, 0 deletions
include/ccaosdb.h
src/ccaosdb.cpp
+25
-0
25 additions, 0 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+12
-0
12 additions, 0 deletions
test/test_ccaosdb.cpp
with
43 additions
and
0 deletions
include/ccaosdb.h
+
6
−
0
View file @
ebe07acd
...
...
@@ -279,6 +279,9 @@ int caosdb_connection_connection_create_transaction(caosdb_connection_connection
int
caosdb_transaction_delete_transaction
(
caosdb_transaction_transaction
*
transaction
);
int
caosdb_transaction_transaction_retrieve_by_id
(
caosdb_transaction_transaction
*
transaction
,
const
char
*
id
);
int
caosdb_transaction_transaction_retrieve_and_download_file_by_id
(
caosdb_transaction_transaction
*
transaction
,
const
char
*
id
,
const
char
*
path
);
int
caosdb_transaction_transaction_retrieve_by_ids
(
caosdb_transaction_transaction
*
transaction
,
const
char
*
ids
[],
int
length
);
int
caosdb_transaction_transaction_query
(
caosdb_transaction_transaction
*
transaction
,
...
...
@@ -332,6 +335,7 @@ int caosdb_entity_entity_get_id(caosdb_entity_entity *entity, char **out);
int
caosdb_entity_entity_get_role
(
caosdb_entity_entity
*
entity
,
char
**
out
);
int
caosdb_entity_entity_get_name
(
caosdb_entity_entity
*
entity
,
char
**
out
);
int
caosdb_entity_entity_get_description
(
caosdb_entity_entity
*
entity
,
char
**
out
);
int
caosdb_entity_entity_get_local_path
(
caosdb_entity_entity
*
entity
,
char
**
out
);
/**
* Get the name of the entity's datatype, whether it is a reference, and whether it is a list.
*/
...
...
@@ -414,6 +418,8 @@ int caosdb_entity_delete_parent(caosdb_entity_parent *out);
int
caosdb_entity_entity_set_role
(
caosdb_entity_entity
*
entity
,
const
char
*
role
);
int
caosdb_entity_entity_set_name
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
int
caosdb_entity_entity_set_description
(
caosdb_entity_entity
*
entity
,
const
char
*
description
);
int
caosdb_entity_entity_set_local_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
int
caosdb_entity_entity_set_file_path
(
caosdb_entity_entity
*
entity
,
const
char
*
name
);
/**
* Set the entity's datatype by name, and whether it is a reference or a list.
*/
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
25
−
0
View file @
ebe07acd
...
...
@@ -413,6 +413,16 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
return
wrapped_transaction
->
RetrieveById
(
std
::
string
(
id
));
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_transaction_transaction_retrieve_and_download_file_by_id
(
caosdb_transaction_transaction
*
transaction
,
const
char
*
id
,
const
char
*
path
),
{
auto
*
wrapped_transaction
=
static_cast
<
caosdb
::
transaction
::
Transaction
*>
(
transaction
->
wrapped_transaction
);
return
wrapped_transaction
->
RetrieveAndDownloadFileById
(
std
::
string
(
id
),
std
::
string
(
path
));
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_transaction_transaction_retrieve_by_ids
(
caosdb_transaction_transaction
*
transaction
,
const
char
*
ids
[],
int
length
),
...
...
@@ -585,6 +595,18 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
return
0
;
})
CAOSDB_ENTITY_GET
(
name
,
GetName
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_local_path
(
caosdb_entity_entity
*
entity
,
char
**
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
path
=
wrapped_entity
->
GetLocalPath
().
string
();
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
path
.
length
()
+
1
);
strcpy
(
tmp
,
path
.
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
// CAOSDB_ENTITY_GET(file_path, GetFilePath()) TODO(henrik)
CAOSDB_ENTITY_GET
(
description
,
GetDescription
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_datatype
(
caosdb_entity_entity
*
entity
,
char
**
name
,
...
...
@@ -983,6 +1005,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
}
})
CAOSDB_ENTITY_SET
(
name
,
name
,
wrapped_entity
->
SetName
(
std
::
string
(
name
));)
CAOSDB_ENTITY_SET
(
local_path
,
local_path
,
return
wrapped_entity
->
SetLocalPath
(
boost
::
filesystem
::
path
(
local_path
));)
CAOSDB_ENTITY_SET
(
file_path
,
file_path
,
wrapped_entity
->
SetFilePath
(
std
::
string
(
file_path
));)
CAOSDB_ENTITY_SET
(
description
,
description
,
wrapped_entity
->
SetDescription
(
std
::
string
(
description
));)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
...
...
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
12
−
0
View file @
ebe07acd
...
...
@@ -152,6 +152,16 @@ TEST_F(test_ccaosdb, test_entity) {
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
out
,
"length"
),
0
);
// test call without validation of result
return_code
=
caosdb_entity_entity_set_role
(
&
entity
,
"FILE"
);
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_entity_set_local_path
(
&
entity
,
(
TEST_DATA_DIR
+
"/test_caosdb_client.json"
).
c_str
());
EXPECT_EQ
(
return_code
,
0
);
return_code
=
caosdb_entity_entity_get_local_path
(
&
entity
,
&
out
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
out
,
(
TEST_DATA_DIR
+
"/test_caosdb_client.json"
).
c_str
()),
0
);
// invalid role
return_code
=
caosdb_entity_entity_set_role
(
&
entity
,
"Role does not exist"
);
EXPECT_EQ
(
return_code
,
caosdb
::
StatusCode
::
ENUM_MAPPING_ERROR
);
...
...
@@ -466,6 +476,8 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
caosdb_entity_entity
entity
;
caosdb_entity_create_entity
(
&
entity
);
caosdb_entity_entity_set_name
(
&
entity
,
"some_name"
);
caosdb_entity_entity_set_local_path
(
&
entity
,
"some_name"
);
caosdb_entity_entity_set_file_path
(
&
entity
,
"some_name"
);
int
return_code
(
caosdb_transaction_transaction_insert_entity
(
&
insert_transaction
,
&
entity
));
// For now, nothing further can be done here, so it should be READY
...
...
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