diff --git a/java/dev/enola/thing/gen/BUILD b/java/dev/enola/thing/gen/BUILD index 930070303..64d1c247d 100644 --- a/java/dev/enola/thing/gen/BUILD +++ b/java/dev/enola/thing/gen/BUILD @@ -49,6 +49,7 @@ java_library( "@maven//:com_google_auto_service_auto_service_annotations", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_errorprone_error_prone_type_annotations", + "@maven//:com_google_code_gson_gson", "@maven//:com_google_guava_guava", "@maven//:org_jspecify_jspecify", "@maven//:org_slf4j_slf4j_api", diff --git a/java/dev/enola/thing/gen/graphcommons/GraphCommonsJsonGenerator.java b/java/dev/enola/thing/gen/graphcommons/GraphCommonsJsonGenerator.java new file mode 100644 index 000000000..6fb03acaf --- /dev/null +++ b/java/dev/enola/thing/gen/graphcommons/GraphCommonsJsonGenerator.java @@ -0,0 +1,72 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright 2024 The Enola Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dev.enola.thing.gen.graphcommons; + +import com.google.common.io.CharStreams; +import com.google.gson.FormattingStyle; +import com.google.gson.Strictness; +import com.google.gson.stream.JsonWriter; + +import dev.enola.common.context.TLC; +import dev.enola.common.convert.ConversionException; +import dev.enola.thing.Thing; +import dev.enola.thing.gen.ThingsIntoAppendableConverter; +import dev.enola.thing.repo.StackedThingProvider; +import dev.enola.thing.repo.ThingProvider; + +import java.io.IOException; + +/** Generator of JSON Format used by Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dev.enola.thing.gen.graphcommons; + +public class GraphCommonsMediaType {} diff --git a/java/dev/enola/thing/gen/graphcommons/GraphCommonsResourceConverter.java b/java/dev/enola/thing/gen/graphcommons/GraphCommonsResourceConverter.java new file mode 100644 index 000000000..ad7d14474 --- /dev/null +++ b/java/dev/enola/thing/gen/graphcommons/GraphCommonsResourceConverter.java @@ -0,0 +1,31 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright 2024 The Enola Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dev.enola.thing.gen.graphcommons; + +import dev.enola.common.io.resource.ReadableResource; +import dev.enola.common.io.resource.WritableResource; +import dev.enola.common.io.resource.convert.CatchingResourceConverter; + +public class GraphCommonsResourceConverter implements CatchingResourceConverter { + + @Override + public boolean convertIntoThrows(ReadableResource from, WritableResource into) + throws Exception { + return false; + } +} diff --git a/java/dev/enola/thing/gen/graphviz/GraphvizGenerator.java b/java/dev/enola/thing/gen/graphviz/GraphvizGenerator.java index ef788c7c3..432665708 100644 --- a/java/dev/enola/thing/gen/graphviz/GraphvizGenerator.java +++ b/java/dev/enola/thing/gen/graphviz/GraphvizGenerator.java @@ -87,21 +87,21 @@ public boolean convertInto(Iterable from, Appendable out) ctx.push(ThingProvider.class, new StackedThingProvider(from)); for (Thing thing : from) { thingIRIs.add(thing.iri()); - printFullThing(thing, out, thingIRIs, linkIRIs); + printThing(thing, out, thingIRIs, linkIRIs); } // Remove links to all things which were processed after we processed them linkIRIs.removeAll(thingIRIs); // linkIRIs now contains things which were linked to but that have no properties for (String orphanIRI : linkIRIs) { var orphanThing = new OnlyIRIThing(orphanIRI); - printFullThing(orphanThing, out, thingIRIs, linkIRIs); + printThing(orphanThing, out, thingIRIs, linkIRIs); } } out.append("}\n"); return true; } - private void printFullThing( + private void printThing( Thing thing, Appendable out, Set thingIRIs, Set linkIRIs) throws IOException { boolean full = TLC.optional(Flags.FULL).orElse(false);