Skip to content

Commit

Permalink
Merge pull request #37 from DILCISBoard/feat/test-parsing
Browse files Browse the repository at this point in the history
FIX: Publication niggles.
  • Loading branch information
carlwilson authored May 7, 2024
2 parents 5468db0 + 8882e20 commit 78efa3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/main/java/eu/dilcis/csip/MetsProfileProcessor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.dilcis.csip;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
Expand Down Expand Up @@ -89,7 +88,8 @@ public Integer call() {
context.put("label", section.label);
context.put("isFirst", isFirst);
isFirst = false;
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context, writer);
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context,
writer);
}
section.serialise(writer, false);
writer.write("\n");
Expand All @@ -101,9 +101,19 @@ public Integer call() {
}
}
for (Entry<Part, List<Source>> entry : specStructure.content.entrySet()) {
isFirst = true;
try (Writer writer = new FileWriter(
this.destination.resolve("../pdf").resolve(entry.getKey().getFileName()).toFile())) {
for (Source section : entry.getValue()) {
if (Part.APPENDICES.equals(entry.getKey())) {
Map<String, Object> context = new java.util.HashMap<>();
context.put("heading", section.heading);
context.put("label", section.label);
context.put("isFirst", isFirst);
isFirst = false;
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context,
writer);
}
section.serialise(writer, true);
writer.write("\n");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/eu/dilcis/csip/structure/MetsSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import eu.dilcis.csip.profile.Appendix;
import eu.dilcis.csip.profile.ControlledVocabulary;
import eu.dilcis.csip.profile.ExternalSchema;
import eu.dilcis.csip.profile.MetsProfile;
import eu.dilcis.csip.structure.Source.SourceType;

final class MetsSource extends Source {
static final MetsSource fromValues(final String name, final String heading, final String label,
Expand All @@ -39,6 +37,8 @@ public void serialise(final Writer destination, final boolean isPdf) throws IOEx
final Map<String, Object> context = new HashMap<>();
context.put("label", label);
context.put("name", name);
context.put("pdf", isPdf);

if ("Appendix".equals(section)) {
serialiseAppendices(destination, context);
} else if ("external_schema".equals(section)) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/eu/dilcis/csip/structure/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import java.io.Writer;
import java.util.Objects;

import eu.dilcis.csip.structure.Source.SourceType;

public abstract class Source {
enum SourceType {
FILE, REQUIREMENTS, METS;

static final SourceType fromString(final String type) throws ParseException {
if (type != null) {
for (final SourceType st : SourceType.values()) {
Expand All @@ -20,7 +18,7 @@ static final SourceType fromString(final String type) throws ParseException {
}
throw new ParseException("Invalid type: " + type);
}

public String delimitedName() {
return this.name().toLowerCase() + ".";
}
Expand Down

0 comments on commit 78efa3c

Please sign in to comment.