Skip to content

Commit

Permalink
fix (cli): ./enola -v get --load models/enola.dev/enola.ttl enola:/in…
Browse files Browse the repository at this point in the history
…line
  • Loading branch information
vorburger committed Oct 28, 2024
1 parent 28fafa5 commit 18eefbd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
6 changes: 0 additions & 6 deletions ToDo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,6 @@ items:
- Split Datatype pure-RegExp (with TLC, configurable in Repo) from Java Converter (with DI with @AutoService, fix):
tags: [clean]

- Make Rosetta --load multiple inputs instead of --in: &rosettaLoad

- Unify DocGen into Rosetta:
tags: [ui, docgen, rosetta]
depends: [*rosettaLoad]

- Unify UI with Rosetta:
tags: [ui, rosetta]

Expand Down
2 changes: 2 additions & 0 deletions java/dev/enola/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ java_binary(
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:info_picocli_picocli",
"@maven//:org_apache_logging_log4j_log4j_to_jul",
"@maven//:org_eclipse_rdf4j_rdf4j_model",
"@maven//:org_eclipse_rdf4j_rdf4j_rio_api",
"@maven//:org_jspecify_jspecify",
"@maven//:org_slf4j_slf4j_api",
"@maven//:org_slf4j_slf4j_jdk14",
Expand Down
29 changes: 17 additions & 12 deletions java/dev/enola/cli/CommandWithIRI.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import dev.enola.thing.proto.Things;
import dev.enola.web.EnolaThingProvider;

import org.eclipse.rdf4j.model.util.ModelBuilder;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;

import picocli.CommandLine;

import java.io.IOException;
Expand Down Expand Up @@ -84,21 +87,23 @@ protected final void run(EnolaServiceBlockingStub service) throws Exception {
protected abstract void run(EnolaServiceBlockingStub service, String eri) throws Exception;

protected void write(Message thing) throws IOException {
if (thing instanceof Thing protoThing) {
if (Format.Turtle.equals(format) || Format.JSONLD.equals(format)) {
var model = new ProtoThingRdfConverter().convert(protoThing);
new RdfWriterConverter().convertIntoOrThrow(model, resource);
return;
if (Format.Turtle.equals(format) || Format.JSONLD.equals(format)) {
var model = new ModelBuilder().build();
var statementCollector = new StatementCollector(model);
if (thing instanceof Thing protoThing) {
new ProtoThingRdfConverter().convertInto(protoThing, statementCollector);
} else if (thing instanceof Things protoThings) {
for (var protoThing : protoThings.getThingsList())
new ProtoThingRdfConverter().convertInto(protoThing, statementCollector);
}
new RdfWriterConverter().convertIntoOrThrow(model, resource);
return;
}

if (thing instanceof Things protoThings) {
if (Format.Graphviz.equals(format)) {
var javaThings = ProtoThings.proto2java(protoThings.getThingsList());
new GraphvizGenerator(thingMetadataProvider)
.convertIntoOrThrow(javaThings, resource);
return;
}
if (Format.Graphviz.equals(format) && thing instanceof Things protoThings) {
var javaThings = ProtoThings.proto2java(protoThings.getThingsList());
new GraphvizGenerator(thingMetadataProvider).convertIntoOrThrow(javaThings, resource);
return;
}

// Otherwise
Expand Down

0 comments on commit 18eefbd

Please sign in to comment.