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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
7f39f3bd
Verified
Commit
7f39f3bd
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: entity-id
parent
f1b03a16
No related branches found
No related tags found
1 merge request
!70
Refactory the entity id
Pipeline
#27291
failed
2 years ago
Stage: info
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/caosdb/server/database/DatabaseUtils.java
+12
-12
12 additions, 12 deletions
src/main/java/org/caosdb/server/database/DatabaseUtils.java
with
12 additions
and
12 deletions
src/main/java/org/caosdb/server/database/DatabaseUtils.java
+
12
−
12
View file @
7f39f3bd
...
...
@@ -37,8 +37,10 @@ import org.caosdb.server.datatype.CollectionValue;
import
org.caosdb.server.datatype.IndexedSingleValue
;
import
org.caosdb.server.datatype.ReferenceValue
;
import
org.caosdb.server.datatype.SingleValue
;
import
org.caosdb.server.entity.EntityID
;
import
org.caosdb.server.entity.EntityInterface
;
import
org.caosdb.server.entity.Message
;
import
org.caosdb.server.entity.RetrieveEntity
;
import
org.caosdb.server.entity.Role
;
import
org.caosdb.server.entity.StatementStatus
;
import
org.caosdb.server.entity.wrapper.Domain
;
...
...
@@ -72,8 +74,7 @@ public class DatabaseUtils {
final
List
<
EntityInterface
>
stage1Inserts
,
final
EntityInterface
e
)
{
// entity value
if
(
e
.
hasValue
())
{
final
Property
p
=
new
Property
();
p
.
setId
(
e
.
getId
());
final
Property
p
=
new
Property
(
e
);
p
.
setStatementStatus
(
StatementStatus
.
FIX
);
p
.
setPIdx
(
0
);
p
.
setDatatype
(
e
.
getDatatype
());
...
...
@@ -116,7 +117,7 @@ public class DatabaseUtils {
}
private
static
boolean
hasUniquePropertyId
(
final
EntityInterface
p
,
final
EntityInterface
e
)
{
final
I
nt
eger
id
=
p
.
getId
();
final
E
nt
ityID
id
=
p
.
getId
();
for
(
final
EntityInterface
p2
:
e
.
getProperties
())
{
if
(
Objects
.
equal
(
p2
.
getId
(),
id
)
&&
p2
!=
p
)
{
return
false
;
...
...
@@ -189,7 +190,7 @@ public class DatabaseUtils {
*
* <p>Never returns null.
*/
public
static
SparseEntity
parseNameRoleACL
(
ResultSet
rs
)
throws
SQLException
{
public
static
SparseEntity
parseNameRoleACL
(
final
ResultSet
rs
)
throws
SQLException
{
final
SparseEntity
ret
=
new
SparseEntity
();
ret
.
role
=
bytes2UTF8
(
rs
.
getBytes
(
"EntityRole"
));
ret
.
name
=
bytes2UTF8
(
rs
.
getBytes
(
"EntityName"
));
...
...
@@ -206,7 +207,7 @@ public class DatabaseUtils {
* <p>Never returns null.
*/
public
static
SparseEntity
parseEntityResultSet
(
final
ResultSet
rs
)
throws
SQLException
{
SparseEntity
ret
=
parseNameRoleACL
(
rs
);
final
SparseEntity
ret
=
parseNameRoleACL
(
rs
);
ret
.
id
=
rs
.
getInt
(
"EntityID"
);
ret
.
description
=
bytes2UTF8
(
rs
.
getBytes
(
"EntityDesc"
));
ret
.
datatype
=
bytes2UTF8
(
rs
.
getBytes
(
"Datatype"
));
...
...
@@ -247,8 +248,7 @@ public class DatabaseUtils {
public
static
void
parseParentsFromVerySparseEntity
(
final
EntityInterface
entity
,
final
List
<
VerySparseEntity
>
pars
)
{
for
(
final
VerySparseEntity
vsp
:
pars
)
{
final
Parent
p
=
new
Parent
();
p
.
setId
(
vsp
.
id
);
final
Parent
p
=
new
Parent
(
new
RetrieveEntity
(
new
EntityID
(
vsp
.
id
)));
p
.
setName
(
vsp
.
name
);
p
.
setDescription
(
vsp
.
description
);
entity
.
addParent
(
p
);
...
...
@@ -256,7 +256,7 @@ public class DatabaseUtils {
}
private
static
void
replace
(
final
Property
p
,
final
Hash
Map
<
I
nt
eger
,
Property
>
domainMap
,
boolean
isHead
)
{
final
Property
p
,
final
Map
<
E
nt
ityID
,
Property
>
domainMap
,
final
boolean
isHead
)
{
// ... find the corresponding domain and replace it
ReferenceValue
ref
;
try
{
...
...
@@ -264,7 +264,7 @@ public class DatabaseUtils {
}
catch
(
final
Message
e
)
{
throw
new
RuntimeException
(
"This should never happen."
);
}
final
EntityInterface
replacement
=
domainMap
.
get
(
(
ref
.
getId
())
)
;
final
EntityInterface
replacement
=
domainMap
.
get
(
ref
.
getId
());
if
(
replacement
==
null
)
{
if
(
isHead
)
{
throw
new
NullPointerException
(
"Replacement was null"
);
...
...
@@ -297,7 +297,7 @@ public class DatabaseUtils {
final
EntityInterface
e
,
final
List
<
Property
>
protoProperties
)
{
// here we will store every domain we can find and we will index it by
// its id.
final
Hash
Map
<
I
nt
eger
,
Property
>
domainMap
=
new
HashMap
<
Integer
,
Property
>();
final
Map
<
E
nt
ityID
,
Property
>
domainMap
=
new
HashMap
<>();
// loop over all properties and collect the domains
for
(
final
Property
p
:
protoProperties
)
{
...
...
@@ -323,7 +323,7 @@ public class DatabaseUtils {
}
// loop over all properties
boolean
isHead
=
final
boolean
isHead
=
e
.
getVersion
().
getSuccessors
()
==
null
||
e
.
getVersion
().
getSuccessors
().
isEmpty
();
for
(
final
Property
p
:
protoProperties
)
{
...
...
@@ -368,7 +368,7 @@ public class DatabaseUtils {
}
private
static
Property
parseFlatProperty
(
final
FlatProperty
fp
)
{
final
Property
property
=
new
Property
();
final
Property
property
=
new
Property
(
new
RetrieveEntity
()
);
property
.
parseFlatProperty
(
fp
);
return
property
;
}
...
...
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