From baabeebd2c1de979766cd80dbbb294b26362654d Mon Sep 17 00:00:00 2001 From: Thorsten Vitt Date: Tue, 31 Mar 2020 18:03:05 +0200 Subject: [PATCH] write a simple json file with all data to render maybe we can re-use our browser ... --- .../gen/DiplomaticConversion.java | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/faustedition/gen/DiplomaticConversion.java b/src/main/java/net/faustedition/gen/DiplomaticConversion.java index 8039f6b..12dfcde 100644 --- a/src/main/java/net/faustedition/gen/DiplomaticConversion.java +++ b/src/main/java/net/faustedition/gen/DiplomaticConversion.java @@ -48,6 +48,7 @@ import net.sf.saxon.s9api.XdmAtomicValue; import net.sf.saxon.s9api.XsltExecutable; import net.sf.saxon.s9api.XsltTransformer; +import org.codehaus.jackson.map.ObjectMapper; public class DiplomaticConversion { @@ -233,6 +234,63 @@ public Stream transcripts() { } } + public static void writeJob(final Stream documents) throws IOException { + class TranscriptRepr { + private final String json; + private final int pageNo; + private final String links; + private final String out; + + public TranscriptRepr(TranscriptPage page) { + this.json = page.getJsonPath().toString(); + this.pageNo = page.pageNo; + this.out = String.valueOf(page.getPagePath("svg")); + this.links = page.getImageLinkPath().isPresent()? page.getImageLinkPath().get().toString(): null; + + } + + public String getJson() { + return json; + } + + public int getPageNo() { + return pageNo; + } + + public String getLinks() { + return links; + } + + public String getOut() { + return out; + } + } + class DocumentRepr { + + private final String sigil; + + public Object[] getTranscripts() { + return transcripts; + } + + private final Object[] transcripts; + + public DocumentRepr(Document doc) { + this.transcripts = doc.transcripts().map(TranscriptRepr::new).toArray(); + this.sigil = doc.sigil; + } + + public String getSigil() { + return sigil; + } + } + + final Object[] docReprs = documents.map(DocumentRepr::new).toArray(); + final ObjectMapper objectMapper = new ObjectMapper(); + logger.info(docReprs[0].toString()); + objectMapper.writeValue(target.resolve("render-job.json").toFile(), docReprs); + } + public static void main(final String[] args) throws IOException { Properties properties = System.getProperties(); System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%n"); @@ -262,7 +320,9 @@ public static void main(final String[] args) throws IOException { .map(page -> page.writeTranscriptJson()) .collect(Collectors.toList()); ImmutableList allPages = ImmutableList.copyOf(transcriptPages); - + + logger.info("Writing render job description"); + writeJob(getDocuments()); int nThreads = Integer.valueOf(System.getProperty("faust.diplo.threads", "0"));