Skip to content
Snippets Groups Projects
Commit e2dd155a authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-fix-deleted-old-reference' into 'dev'

f-fix-deleted-old-reference -> dev

See merge request caosdb/caosdb-server!61
parents cea10c57 fa634504
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -25,6 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
* Semi-fixed a bug which occurs when retrieving old versions of entities which
reference entities which have been deleted in the mean time. The current fix
adds a warning message to the reference property in question and sets the
value to NULL. This might even be desired behavior, however this would have
to finally specified during the Delete/Forget phase of the implementation of
the versioning.
- Inheritance job cannot handle inheritance from same container (!54) - Inheritance job cannot handle inheritance from same container (!54)
* Bug in the query parser (MR!56) - The parser would throw an error when the * Bug in the query parser (MR!56) - The parser would throw an error when the
query contains a conjunction or disjunction filter with a first element which query contains a conjunction or disjunction filter with a first element which
......
...@@ -258,7 +258,8 @@ public class DatabaseUtils { ...@@ -258,7 +258,8 @@ public class DatabaseUtils {
} }
} }
private static void replace(final Property p, final HashMap<Integer, Property> domainMap) { private static void replace(
final Property p, final HashMap<Integer, Property> domainMap, boolean isHead) {
// ... find the corresponding domain and replace it // ... find the corresponding domain and replace it
ReferenceValue ref; ReferenceValue ref;
try { try {
...@@ -267,6 +268,17 @@ public class DatabaseUtils { ...@@ -267,6 +268,17 @@ public class DatabaseUtils {
throw new RuntimeException("This should never happen."); 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");
}
// entity has been deleted (we are processing properties of an old entity version)
p.setValue(null);
p.addWarning(
new Message(
"The referenced entity has been deleted in the mean time and is not longer available."));
return;
}
if (replacement.isDescOverride()) { if (replacement.isDescOverride()) {
p.setDescOverride(true); p.setDescOverride(true);
p.setDescription(replacement.getDescription()); p.setDescription(replacement.getDescription());
...@@ -314,15 +326,18 @@ public class DatabaseUtils { ...@@ -314,15 +326,18 @@ public class DatabaseUtils {
} }
// loop over all properties // loop over all properties
boolean isHead =
e.getVersion().getSuccessors() == null || e.getVersion().getSuccessors().isEmpty();
for (final Property p : protoProperties) { for (final Property p : protoProperties) {
// if this is a replacement // if this is a replacement
if (p.getStatementStatus() == StatementStatus.REPLACEMENT) { if (p.getStatementStatus() == StatementStatus.REPLACEMENT) {
replace(p, domainMap); replace(p, domainMap, isHead);
} }
for (final Property subP : p.getProperties()) { for (final Property subP : p.getProperties()) {
if (subP.getStatementStatus() == StatementStatus.REPLACEMENT) { if (subP.getStatementStatus() == StatementStatus.REPLACEMENT) {
replace(subP, domainMap); replace(subP, domainMap, isHead);
} }
} }
......
...@@ -102,12 +102,12 @@ public class RetrieveFullEntity extends BackendTransaction { ...@@ -102,12 +102,12 @@ public class RetrieveFullEntity extends BackendTransaction {
execute(new RetrieveSparseEntity(e)); execute(new RetrieveSparseEntity(e));
if (e.getEntityStatus() == EntityStatus.VALID) { if (e.getEntityStatus() == EntityStatus.VALID) {
execute(new RetrieveVersionInfo(e));
if (e.getRole() == Role.QueryTemplate) { if (e.getRole() == Role.QueryTemplate) {
execute(new RetrieveQueryTemplateDefinition(e)); execute(new RetrieveQueryTemplateDefinition(e));
} }
execute(new RetrieveParents(e)); execute(new RetrieveParents(e));
execute(new RetrieveProperties(e)); execute(new RetrieveProperties(e));
execute(new RetrieveVersionInfo(e));
// recursion! retrieveSubEntities calls retrieveFull sometimes, but with reduced selectors. // recursion! retrieveSubEntities calls retrieveFull sometimes, but with reduced selectors.
if (selections != null && !selections.isEmpty()) { if (selections != null && !selections.isEmpty()) {
......
...@@ -957,7 +957,8 @@ public class Entity extends AbstractObservable implements EntityInterface { ...@@ -957,7 +957,8 @@ public class Entity extends AbstractObservable implements EntityInterface {
@Override @Override
public String toString() { public String toString() {
return (hasId() ? "(" + getId().toString() + ")" : "()") return (getRole().toString())
+ (hasId() ? "(" + getId().toString() + ")" : "()")
+ (hasCuid() ? "[" + getCuid() + "]" : "[]") + (hasCuid() ? "[" + getCuid() + "]" : "[]")
+ (hasName() ? "(" + getName() + ")" : "()") + (hasName() ? "(" + getName() + ")" : "()")
+ (hasDatatype() ? "{" + getDatatype().toString() + "}" : "{}"); + (hasDatatype() ? "{" + getDatatype().toString() + "}" : "{}");
......
...@@ -120,7 +120,7 @@ public class Property extends EntityWrapper { ...@@ -120,7 +120,7 @@ public class Property extends EntityWrapper {
@Override @Override
public String toString() { public String toString() {
return "IMPLPROPERTY " + this.entity.toString(); return "IMPLPROPERTY (" + this.getStatementStatus() + ")" + this.entity.toString();
} }
public void setIsName(final boolean b) { public void setIsName(final boolean b) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment