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
e788f178
Verified
Commit
e788f178
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
DOC: more source docs
parent
489827b2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/caosdb/server/database/backend/transaction/VersionTransaction.java
+52
-10
52 additions, 10 deletions
...rver/database/backend/transaction/VersionTransaction.java
with
52 additions
and
10 deletions
src/main/java/org/caosdb/server/database/backend/transaction/VersionTransaction.java
+
52
−
10
View file @
e788f178
...
...
@@ -34,6 +34,14 @@ import org.caosdb.server.database.proto.VersionHistoryItem;
import
org.caosdb.server.entity.EntityInterface
;
import
org.caosdb.server.entity.Version
;
/**
* Abstract base class which retrieves and caches the full, but flag version history. The
* implementations then use the flat version history to construct either single version information
* items (see {@link RetrieveVersionInfo}) or the complete history as a tree (see {@link
* RetrieveVersionHistory})
*
* @author Timm Fitschen (t.fitschen@indiscale.com)
*/
public
abstract
class
VersionTransaction
extends
CacheableBackendTransaction
<
Integer
,
HashMap
<
String
,
VersionHistoryItem
>>
{
...
...
@@ -44,6 +52,11 @@ public abstract class VersionTransaction
/** A map of all history items which belong to this entity. The keys are the version ids. */
private
HashMap
<
String
,
VersionHistoryItem
>
historyItems
;
/**
* Invalidate a cache item. This should be called upon update of entities.
*
* @param entityId
*/
public
static
void
removeCached
(
Integer
entityId
)
{
cache
.
remove
(
entityId
);
}
...
...
@@ -61,8 +74,9 @@ public abstract class VersionTransaction
/** After this method call, the version map is available to the object. */
@Override
protected
void
process
(
HashMap
<
String
,
VersionHistoryItem
>
map
)
throws
TransactionException
{
this
.
historyItems
=
map
;
protected
void
process
(
HashMap
<
String
,
VersionHistoryItem
>
historyItems
)
throws
TransactionException
{
this
.
historyItems
=
historyItems
;
}
@Override
...
...
@@ -78,11 +92,22 @@ public abstract class VersionTransaction
return
this
.
entity
;
}
/** Return a list of direct predecessors which have their direct predecessors attached */
protected
List
<
Version
>
getPredecessors
(
String
id
,
boolean
transitive
)
{
/**
* Return a list of direct predecessors. The predecessors are constructed by {@link
* #getVersion(String)}.
*
* <p>If transitive is true, this function is called recursively on the predecessors as well,
* resulting in a list of trees of predecessors, with the direct predecessors at the root(s).
*
* @param versionId
* @param transitive
* @return A list of predecessors.
*/
protected
List
<
Version
>
getPredecessors
(
String
versionId
,
boolean
transitive
)
{
LinkedList
<
Version
>
result
=
new
LinkedList
<>();
if
(
getHistoryItems
().
containsKey
(
id
)
&&
getHistoryItems
().
get
(
id
).
parents
!=
null
)
for
(
String
p
:
getHistoryItems
().
get
(
id
).
parents
)
{
if
(
getHistoryItems
().
containsKey
(
versionId
)
&&
getHistoryItems
().
get
(
versionId
).
parents
!=
null
)
for
(
String
p
:
getHistoryItems
().
get
(
versionId
).
parents
)
{
Version
predecessor
=
getVersion
(
p
);
if
(
transitive
)
{
predecessor
.
setPredecessors
(
getPredecessors
(
p
,
transitive
));
...
...
@@ -92,17 +117,34 @@ public abstract class VersionTransaction
return
result
;
}
protected
abstract
Version
getVersion
(
String
version
);
/**
* To be implemented by the base class. The idea is, that the base class decides which information
* is being included into the Version instance.
*
* @param versionId - the id of the version
* @return
*/
protected
abstract
Version
getVersion
(
String
versionId
);
/** Return a list of direct successors which have their direct successors attached */
protected
List
<
Version
>
getSuccessors
(
String
id
,
boolean
transitive
)
{
/**
* Return a list of direct successors. The successors are constructed by {@link
* #getVersion(String)}.
*
* <p>If transitive is true, this function is called recursively on the successors as well,
* resulting in a list of trees of successors, with the direct successors at the root(s).
*
* @param versionId
* @param transitive
* @return A list of successors.
*/
protected
List
<
Version
>
getSuccessors
(
String
versionId
,
boolean
transitive
)
{
LinkedList
<
Version
>
result
=
new
LinkedList
<>();
outer:
for
(
VersionHistoryItem
i
:
getHistoryItems
().
values
())
{
if
(
i
.
parents
!=
null
)
for
(
String
p
:
i
.
parents
)
{
if
(
i
d
.
equals
(
p
))
{
if
(
versionI
d
.
equals
(
p
))
{
Version
successor
=
getVersion
(
i
.
id
);
result
.
add
(
successor
);
if
(
transitive
)
{
...
...
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