Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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-server
Commits
7648d2a6
Verified
Commit
7648d2a6
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: refactor retrieve function in EntityTransactionService
parent
99c31b63
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!80
Release 0.9
,
!72
F grpc select
Pipeline
#30708
passed
2 years ago
Stage: info
Stage: test
Stage: deploy
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
caosdb-proto
+1
-1
1 addition, 1 deletion
caosdb-proto
src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java
+36
-13
36 additions, 13 deletions
.../org/caosdb/server/grpc/EntityTransactionServiceImpl.java
with
37 additions
and
14 deletions
caosdb-proto
@
96e7a1fb
Subproject commit
fd60795f62335368255797db43eb0429ec1705fc
Subproject commit
96e7a1fb667ed1bb3b2602af6c69724519bf5118
This diff is collapsed.
Click to expand it.
src/main/java/org/caosdb/server/grpc/EntityTransactionServiceImpl.java
+
36
−
13
View file @
7648d2a6
...
@@ -33,6 +33,7 @@ import org.caosdb.api.entity.v1.Entity;
...
@@ -33,6 +33,7 @@ import org.caosdb.api.entity.v1.Entity;
import
org.caosdb.api.entity.v1.EntityRequest
;
import
org.caosdb.api.entity.v1.EntityRequest
;
import
org.caosdb.api.entity.v1.EntityResponse
;
import
org.caosdb.api.entity.v1.EntityResponse
;
import
org.caosdb.api.entity.v1.EntityTransactionServiceGrpc.EntityTransactionServiceImplBase
;
import
org.caosdb.api.entity.v1.EntityTransactionServiceGrpc.EntityTransactionServiceImplBase
;
import
org.caosdb.api.entity.v1.FindQueryResult
;
import
org.caosdb.api.entity.v1.IdResponse
;
import
org.caosdb.api.entity.v1.IdResponse
;
import
org.caosdb.api.entity.v1.InsertRequest
;
import
org.caosdb.api.entity.v1.InsertRequest
;
import
org.caosdb.api.entity.v1.InsertResponse
;
import
org.caosdb.api.entity.v1.InsertResponse
;
...
@@ -79,6 +80,24 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa
...
@@ -79,6 +80,24 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa
this
.
fileTransmissionService
=
fileTransmissionService
;
this
.
fileTransmissionService
=
fileTransmissionService
;
}
}
private
void
prepareDownload
(
EntityResponse
.
Builder
entityResponse
,
EntityInterface
entity
,
FileDownload
fileDownload
)
throws
Exception
{
try
{
entity
.
checkPermission
(
EntityPermission
.
RETRIEVE_FILE
);
if
(
fileDownload
==
null
)
{
fileDownload
=
fileTransmissionService
.
registerFileDownload
(
null
);
}
entity
.
getFileProperties
().
retrieveFromFileSystem
();
entityResponse
.
setDownloadId
(
fileTransmissionService
.
registerFileDownload
(
fileDownload
.
getId
(),
entity
.
getFileProperties
()));
}
catch
(
AuthenticationException
exc
)
{
entityResponse
.
addErrors
(
caosdbToGrpc
.
convert
(
ServerMessages
.
AUTHORIZATION_ERROR
));
entityResponse
.
addInfos
(
caosdbToGrpc
.
convert
(
new
Message
(
exc
.
getMessage
())));
}
}
/**
/**
* Handle read-only transactions. Of these only one may be a query at the moment, the others must
* Handle read-only transactions. Of these only one may be a query at the moment, the others must
* be ID retrieves.
* be ID retrieves.
...
@@ -144,25 +163,29 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa
...
@@ -144,25 +163,29 @@ public class EntityTransactionServiceImpl extends EntityTransactionServiceImplBa
builder
builder
.
addResponsesBuilder
()
.
addResponsesBuilder
()
.
setRetrieveResponse
(
RetrieveResponse
.
newBuilder
().
setSelectResult
(
selectResult
));
.
setRetrieveResponse
(
RetrieveResponse
.
newBuilder
().
setSelectResult
(
selectResult
));
}
else
if
(
container
.
getQuery
()
!=
null
&&
container
.
getQuery
().
getType
()
==
Query
.
Type
.
FIND
)
{
// this was a find query
final
boolean
download_files_container
=
container
.
getFlags
().
containsKey
(
"download_files"
);
FindQueryResult
.
Builder
findResult
=
FindQueryResult
.
newBuilder
();
for
(
final
EntityInterface
entity
:
container
)
{
final
EntityResponse
.
Builder
entityResponse
=
caosdbToGrpc
.
convert
(
entity
);
if
((
download_files_container
||
entity
.
getFlags
().
containsKey
(
"download_files"
))
&&
entity
.
hasFileProperties
())
{
prepareDownload
(
entityResponse
,
entity
,
fileDownload
);
}
findResult
.
addResultSet
(
entityResponse
);
}
builder
.
addResponsesBuilder
()
.
setRetrieveResponse
(
RetrieveResponse
.
newBuilder
().
setFindResult
(
findResult
));
}
else
{
}
else
{
// normal retrieval via id
final
boolean
download_files_container
=
container
.
getFlags
().
containsKey
(
"download_files"
);
final
boolean
download_files_container
=
container
.
getFlags
().
containsKey
(
"download_files"
);
for
(
final
EntityInterface
entity
:
container
)
{
for
(
final
EntityInterface
entity
:
container
)
{
final
EntityResponse
.
Builder
entityResponse
=
caosdbToGrpc
.
convert
(
entity
);
final
EntityResponse
.
Builder
entityResponse
=
caosdbToGrpc
.
convert
(
entity
);
if
((
download_files_container
||
entity
.
getFlags
().
containsKey
(
"download_files"
))
if
((
download_files_container
||
entity
.
getFlags
().
containsKey
(
"download_files"
))
&&
entity
.
hasFileProperties
())
{
&&
entity
.
hasFileProperties
())
{
try
{
prepareDownload
(
entityResponse
,
entity
,
fileDownload
);
entity
.
checkPermission
(
EntityPermission
.
RETRIEVE_FILE
);
if
(
fileDownload
==
null
)
{
fileDownload
=
fileTransmissionService
.
registerFileDownload
(
null
);
}
entity
.
getFileProperties
().
retrieveFromFileSystem
();
entityResponse
.
setDownloadId
(
fileTransmissionService
.
registerFileDownload
(
fileDownload
.
getId
(),
entity
.
getFileProperties
()));
}
catch
(
AuthenticationException
exc
)
{
entityResponse
.
addErrors
(
caosdbToGrpc
.
convert
(
ServerMessages
.
AUTHORIZATION_ERROR
));
entityResponse
.
addInfos
(
caosdbToGrpc
.
convert
(
new
Message
(
exc
.
getMessage
())));
}
}
}
builder
builder
.
addResponsesBuilder
()
.
addResponsesBuilder
()
...
...
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