Skip to content

Commit

Permalink
fix (core): Work around lack of RDF Collections support (see #759)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Jun 28, 2024
1 parent 1c661b6 commit 8dd09df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public boolean convertInto(ThingOrBuilder from, Builder into)
for (var entry : from.getFieldsMap().entrySet()) {
var iri = entry.getKey();
var value = entry.getValue();
if (Value.KindCase.KIND_NOT_SET.equals(value.getKindCase()))
throw new IllegalArgumentException(iri);

if (dev.enola.thing.proto.Value.KindCase.LITERAL.equals(value.getKindCase())) {
var datatypeValue = value.getLiteral().getValue();
var datatypeIRI = value.getLiteral().getDatatype();
Expand All @@ -76,6 +79,10 @@ private Object object(Value protoThingValue) {
switch (protoThingValue.getKindCase()) {
case STRING:
return protoThingValue.getString();
case LITERAL:
// TODO Rework things to this can use Thing.set(value, datatype) instead Literal
var literal = protoThingValue.getLiteral();
return new Literal(literal.getValue(), literal.getDatatype());
case LINK:
return new Link(protoThingValue.getLink());
case LANG_STRING:
Expand All @@ -100,12 +107,14 @@ private Object object(Value protoThingValue) {
for (var entry : protoStruct.getFieldsMap().entrySet()) {
var iri = entry.getKey();
var value = entry.getValue();
if (Value.KindCase.KIND_NOT_SET.equals(value.getKindCase()))
throw new IllegalArgumentException(iri);
mapBuilder.put(iri, object(value));
}
return mapBuilder.build();
}
default:
throw new IllegalArgumentException(protoThingValue.getKindCase().name());
throw new IllegalArgumentException(protoThingValue.toString());
}
}
}
3 changes: 2 additions & 1 deletion models/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ rm docs/models/{BUILD,build.bash}
# https://linkml.io
mkdir -p .built/linkml/
find docs/models/ -name "*.linkml.yaml" -print0 | xargs -n 1 -0 linkml-lint --validate --config models/.linkmllint.yaml
find docs/models/ -name "*.linkml.yaml" -print0 | xargs -n 1 -0 gen-project -X prefixmap -d .built/linkml/
find docs/models/ -name "*.linkml.yaml" -print0 | xargs -n 1 -0 gen-project -X prefixmap -X owl -X shacl -d .built/linkml/
# TODO Re-enable OWL after fixing https://github.com/enola-dev/enola/issues/759
# TODO Drop all *.linkml.* e.g. to rename file.linkml.context.jsonld to just file.linkml.context.jsonld
# TODO --no-mergeimports? https://linkml.io/linkml/schemas/imports.html#making-merged-files-for-distribution ?
# TODO https://linkml.io/linkml/generators/linkml.html ?
Expand Down

0 comments on commit 8dd09df

Please sign in to comment.