Skip to content
Snippets Groups Projects
Verified Commit cc35e3fe authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: SELECT for GRPC API

parent 09412397
No related branches found
No related tags found
2 merge requests!80Release 0.9,!72F grpc select
Pipeline #29853 failed
......@@ -622,7 +622,7 @@ public class CaosDBToGrpcConverters {
String selector = s.getSelector();
switch (selector) {
case "name":
if (e.getName() != null) {
if (e.hasName()) {
result.setScalarValue(ScalarValue.newBuilder().setStringValue(e.getName()));
}
break;
......@@ -631,22 +631,72 @@ public class CaosDBToGrpcConverters {
result.setScalarValue(ScalarValue.newBuilder().setStringValue(e.getId().toString()));
break;
case "description":
if (e.hasDescription()) {
result.setScalarValue(ScalarValue.newBuilder().setStringValue(e.getDescription()));
}
break;
case "unit":
if (e.hasUnit()) {
final String unit = getStringUnit(e);
result.setScalarValue(ScalarValue.newBuilder().setStringValue(unit));
}
break;
// TODO path, hash
default:
// selector for a normal property
for (Property p : e.getProperties()) {
if (p.getName() != null && p.getName().equals(selector) && s.getSubselection() == null) {
try {
p.parseValue();
} catch (Message m) {
throw new TransactionException(m);
}
if (!p.hasValue()) {
continue;
} else if (p.getValue() instanceof CollectionValue) {
if (p.getName() != null && p.getName().equals(selector)) {
if (s.getSubselection() == null) {
// no subselection -> just return the actual value
try {
p.parseValue();
} catch (Message m) {
throw new TransactionException(m);
}
if (!p.hasValue()) {
continue;
} else if (p.getValue() instanceof CollectionValue) {
} else if (p.getValue() instanceof GenericValue) {
if (((GenericValue) p.getValue()).getValue() instanceof Double) {
result.setScalarValue(
ScalarValue.newBuilder()
.setDoubleValue((Double) ((GenericValue) p.getValue()).getValue()));
} else if (((GenericValue) p.getValue()).getValue() instanceof Integer) {
result.setScalarValue(
ScalarValue.newBuilder()
.setIntegerValue((Integer) ((GenericValue) p.getValue()).getValue()));
} else {
result.setScalarValue(
ScalarValue.newBuilder().setStringValue(p.getValue().toString()));
}
} else if (p.getValue() instanceof BooleanValue) {
result.setScalarValue(
ScalarValue.newBuilder()
.setBooleanValue(((BooleanValue) p.getValue()).getValue()));
} else {
result.setScalarValue(
ScalarValue.newBuilder().setStringValue(p.getValue().toString()));
}
} else {
result.setScalarValue(
ScalarValue.newBuilder().setStringValue(p.getValue().toString()));
// with subselection, e.g. p1.unit, site.geolocation.longitude
switch (s.getSubselection().getSelector()) {
case "unit":
final String unit = getStringUnit(p);
if (unit != null) {
result.setScalarValue(ScalarValue.newBuilder().setStringValue(unit));
}
break;
// TODO name, description, id
default:
break;
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment