diff --git a/docs/concepts/other.md b/docs/concepts/other.md index ee484741a..c842356b1 100644 --- a/docs/concepts/other.md +++ b/docs/concepts/other.md @@ -140,6 +140,7 @@ Vaguely related other such tools include: * [`com.google.common.graph`](https://github.com/google/guava/wiki/GraphsExplained) Java API * [JGraphT](https://jgrapht.org) Java Library +* [NetworkX](https://networkx.org/) Python package [Semantic Triple](https://en.wikipedia.org/wiki/Semantic_triple) Java libraries ([comparison](https://github.com/trellis-ldp/trellis/issues/358)): @@ -189,6 +190,7 @@ Some [db-engines.com](https://db-engines.com/en/ranking/rdf+store): ### GraphML DB +* [ArangoDB](https://arangodb.com) #GraphML #opensource #commercial * [LlamaIndex](https://www.llamaindex.ai) #GraphML #opensource? #ToDo * [varunshenoy/GraphGPT](https://github.com/varunshenoy/GraphGPT) #GraphML #opensource #demo * [HKUDS/GraphGPT](https://github.com/HKUDS/GraphGPT) #GraphML #opensource #paper diff --git a/java/dev/enola/cli/CommandWithIRI.java b/java/dev/enola/cli/CommandWithIRI.java index 786e74b5d..816d7fd70 100644 --- a/java/dev/enola/cli/CommandWithIRI.java +++ b/java/dev/enola/cli/CommandWithIRI.java @@ -30,7 +30,12 @@ import dev.enola.core.view.EnolaMessages; import dev.enola.rdf.io.RdfWriterConverter; import dev.enola.rdf.proto.ProtoThingRdfConverter; +import dev.enola.thing.gen.graphviz.GraphvizGenerator; +import dev.enola.thing.message.ProtoThings; +import dev.enola.thing.metadata.ThingMetadataProvider; import dev.enola.thing.proto.Thing; +import dev.enola.thing.proto.Things; +import dev.enola.web.EnolaThingProvider; import picocli.CommandLine; @@ -52,9 +57,12 @@ public abstract class CommandWithIRI extends CommandWithModelAndOutput { private WritableResource resource; private TypeRegistryWrapper typeRegistryWrapper; protected EnolaMessages enolaMessages; + private ThingMetadataProvider thingMetadataProvider; @Override protected final void run(EnolaServiceBlockingStub service) throws Exception { + thingMetadataProvider = getMetadataProvider(new EnolaThingProvider(service)); + var gfdsr = GetFileDescriptorSetRequest.newBuilder().build(); var fds = service.getFileDescriptorSet(gfdsr).getProtos(); typeRegistryWrapper = TypeRegistryWrapper.from(fds); @@ -76,11 +84,24 @@ 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 - && (Format.Turtle.equals(format) || Format.JSONLD.equals(format))) { - var model = new ProtoThingRdfConverter().convert(protoThing); - new RdfWriterConverter().convertIntoOrThrow(model, resource); + 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 (thing instanceof Things protoThings) { + if (Format.Graphviz.equals(format)) { + var javaThings = ProtoThings.proto2java(protoThings.getThingsList()); + new GraphvizGenerator(thingMetadataProvider) + .convertIntoOrThrow(javaThings, resource); + return; + } + } - } else new ProtoIO(typeRegistryWrapper.get()).write(thing, resource); + // Otherwise + new ProtoIO(typeRegistryWrapper.get()).write(thing, resource); } } diff --git a/java/dev/enola/cli/Format.java b/java/dev/enola/cli/Format.java index 27e5fef7a..f7b523d25 100644 --- a/java/dev/enola/cli/Format.java +++ b/java/dev/enola/cli/Format.java @@ -21,12 +21,15 @@ import dev.enola.common.protobuf.ProtobufMediaTypes; import dev.enola.rdf.io.RdfMediaTypes; +import dev.enola.thing.gen.graphviz.GraphvizMediaType; public enum Format { Turtle, JSONLD, + Graphviz, + TextProto, ProtoYAML, @@ -39,6 +42,7 @@ MediaType toMediaType() { return switch (this) { case Turtle -> RdfMediaTypes.TURTLE; case JSONLD -> RdfMediaTypes.JSON_LD; + case Graphviz -> GraphvizMediaType.GV; case TextProto -> ProtobufMediaTypes.PROTOBUF_TEXTPROTO_UTF_8; case ProtoYAML -> ProtobufMediaTypes.PROTOBUF_YAML_UTF_8;