Skip to content

Commit

Permalink
feat: read support of @type, @SiZe record attributes and fixed @Version
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 20, 2024
1 parent 32ae0f5 commit fb3d768
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ public OResult calculateSingle(OCommandContext iContext, OResult iRecord) {
continue;
}
if (item.isAll()) {
iRecord
.getElement()
.ifPresent(
(e) -> {
if (e.getRecord() instanceof ODocument) {
((ODocument) e.getRecord()).deserializeFields();
}
});
Optional<OElement> element = iRecord.getElement();
element.ifPresent(
(e) -> {
if (e.getRecord() instanceof ODocument) {
((ODocument) e.getRecord()).deserializeFields();
}
});
for (String alias : iRecord.getPropertyNames()) {
if (this.excludes.contains(alias)) {
continue;
Expand All @@ -152,8 +151,8 @@ public OResult calculateSingle(OCommandContext iContext, OResult iRecord) {
}
result.setProperty(alias, val);
}
if (iRecord.getElement().isPresent()) {
OElement x = iRecord.getElement().get();
if (element.isPresent()) {
OElement x = element.get();
if (!this.excludes.contains("@rid")) {
result.setProperty("@rid", x.getIdentity());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,29 @@ public Object evaluate(OResult iCurrentRecord, OCommandContext ctx) {
return iCurrentRecord.getProperty(name);
});
} else if (name.equalsIgnoreCase("@version")) {
iCurrentRecord
return iCurrentRecord
.getRecord()
.map(r -> r.getVersion())
.orElseGet(
() -> {
return iCurrentRecord.getProperty(name);
});
} else if (name.equalsIgnoreCase("@type")) {
if (iCurrentRecord.isElement()) {
return "document";
} else if (iCurrentRecord.isBlob()) {
return "blog";
} else {
return "projection";
}
} else if (name.equalsIgnoreCase("@size")) {
return iCurrentRecord
.getRecord()
.map(r -> r.getSize())
.orElseGet(
() -> {
return iCurrentRecord.getProperty(name);
});
}
return null;
}
Expand All @@ -114,6 +130,11 @@ public Object evaluate(OElement iCurrentRecord, OCommandContext ctx) {
return null;
}
return record.getVersion();
} else if (name.equalsIgnoreCase("@type")) {
return "document";

} else if (name.equalsIgnoreCase("@size")) {
return iCurrentRecord.getSize();
}
return null;
}
Expand Down

0 comments on commit fb3d768

Please sign in to comment.