Skip to content

Commit 7e7ca83

Browse files
authored
Merge pull request #51 from DILCISBoard/rel/0.2.0
REL: v0.2.0
2 parents 8a33f02 + ada9ded commit 7e7ca83

File tree

11 files changed

+229
-165
lines changed

11 files changed

+229
-165
lines changed

pandoc/templates/eisvogel.latex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ $endif$
511511
\usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=$if(caption-justification)$$caption-justification$$else$raggedright$endif$]{caption}
512512
\setcapindent{0em}
513513
\captionsetup[longtable]{position=above}
514-
514+
\renewcommand \caption [2][]{}
515515
%
516516
% blockquote
517517
%

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>eu.dilcis</groupId>
55
<artifactId>eark-csip-profile-processor</artifactId>
6-
<version>0.1.0-SNAPSHOT</version>
6+
<version>0.2.0-SNAPSHOT</version>
77
<name>E-ARK CSIP METS Profile processor</name>
88
<description>SAX parser to generate Markdown requirement tables from the E-ARK CSIP METS Profile.</description>
99

res/md/common-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A visualisation of the current specification network can be seen here:
88
<a name="figi-dip"></a>
99
![OAIS Entities](figs/fig_1_dip.png "Diagram showing E-ARK specification dependency hierarchy")
1010

11-
**Figure I:** Diagram showing E-ARK specification dependency hierarchy. Note that the image only shows a selection of the published CITS and isn't an exhaustive list.
11+
**Figure 1:** Diagram showing E-ARK specification dependency hierarchy. Note that the image only shows a selection of the published CITS and isn't an exhaustive list.
1212

1313
### Overview of the E-ARK Specifications
1414

src/main/java/eu/dilcis/csip/MetsProfileProcessor.java

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010
import java.util.Map;
1111
import java.util.Map.Entry;
12+
import java.util.Set;
1213
import java.util.concurrent.Callable;
1314

1415
import org.xml.sax.SAXException;
@@ -50,6 +51,37 @@ public static void main(final String[] args) {
5051
System.exit(exitCode);
5152
}
5253

54+
private static void serialiseProfile(final Set<Entry<Part, List<Source>>> entries, final boolean isPdf, final Path root)
55+
throws IOException {
56+
for (final Entry<Part, List<Source>> entry : entries) {
57+
try (Writer writer = new FileWriter(root.resolve(entry.getKey().getFileName()).toFile())) {
58+
serialisePart(entry.getKey(), entry.getValue(), isPdf, writer);
59+
}
60+
}
61+
}
62+
63+
private static void serialisePart(final Part part, final List<Source> sources, final boolean isPdf,
64+
final Writer writer) throws IOException {
65+
boolean isFirst = true;
66+
for (final Source section : sources) {
67+
if (Part.APPENDICES.equals(part)) {
68+
final Map<String, Object> context = new java.util.HashMap<>();
69+
context.put("heading", section.heading);
70+
context.put("label", section.label);
71+
context.put("isFirst", isFirst);
72+
isFirst = false;
73+
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context,
74+
writer);
75+
}
76+
section.serialise(writer, isPdf);
77+
writer.write("\n");
78+
}
79+
if (Part.BODY.equals(part)) {
80+
writer.write("!INCLUDE \"appendices.md\"\n");
81+
}
82+
writer.flush();
83+
}
84+
5385
@Parameters(paramLabel = "FILE", arity = "1..*", description = "A list of METS Profile documents to be processed.")
5486
private File[] metsProfiles;
5587

@@ -75,54 +107,8 @@ public Integer call() {
75107
try {
76108
final StructFileParser structParser = StructFileParser.parserInstance(this.processProfiles());
77109
final SpecificationStructure specStructure = structParser.parseStructureFile(this.structureFile.toPath());
78-
boolean isFirst = true;
79-
for (Entry<Part, List<Source>> entry : specStructure.content.entrySet()) {
80-
try (Writer writer = new FileWriter(this.destination.resolve(entry.getKey().getFileName()).toFile())) {
81-
if (Part.BODY.equals(entry.getKey())) {
82-
writer.write("!TOC\n\n");
83-
}
84-
for (Source section : entry.getValue()) {
85-
if (Part.APPENDICES.equals(entry.getKey())) {
86-
Map<String, Object> context = new java.util.HashMap<>();
87-
context.put("heading", section.heading);
88-
context.put("label", section.label);
89-
context.put("isFirst", isFirst);
90-
isFirst = false;
91-
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context,
92-
writer);
93-
}
94-
section.serialise(writer, false);
95-
writer.write("\n");
96-
}
97-
if (Part.BODY.equals(entry.getKey())) {
98-
writer.write("!INCLUDE \"appendices.md\"\n");
99-
}
100-
writer.flush();
101-
}
102-
}
103-
for (Entry<Part, List<Source>> entry : specStructure.content.entrySet()) {
104-
isFirst = true;
105-
try (Writer writer = new FileWriter(
106-
this.destination.resolve("../pdf").resolve(entry.getKey().getFileName()).toFile())) {
107-
for (Source section : entry.getValue()) {
108-
if (Part.APPENDICES.equals(entry.getKey())) {
109-
Map<String, Object> context = new java.util.HashMap<>();
110-
context.put("heading", section.heading);
111-
context.put("label", section.label);
112-
context.put("isFirst", isFirst);
113-
isFirst = false;
114-
Utilities.serialiseToTemplate("eu/dilcis/csip/out/appendix_heading.mustache", context,
115-
writer);
116-
}
117-
section.serialise(writer, true);
118-
writer.write("\n");
119-
}
120-
if (Part.BODY.equals(entry.getKey())) {
121-
writer.write("!INCLUDE \"appendices.md\"\n");
122-
}
123-
writer.flush();
124-
}
125-
}
110+
serialiseProfile(specStructure.content.entrySet(), false, this.destination);
111+
serialiseProfile(specStructure.content.entrySet(), true, this.destination.resolve("../pdf"));
126112
} catch (SAXException | IOException excep) {
127113
// Basic for now, print the stack trace and trhow it
128114
excep.printStackTrace();
@@ -136,9 +122,9 @@ public Integer call() {
136122

137123
private List<MetsProfile> processProfiles() throws SAXException, IOException {
138124
final List<MetsProfile> profiles = new ArrayList<>();
139-
final MetsProfileParser parser = MetsProfileParser.newInstance();
140125
for (final File profileXmlFile : this.metsProfiles) {
141126
try {
127+
final MetsProfileParser parser = MetsProfileParser.newInstance();
142128
final MetsProfile profile = parser.processXmlProfile(profileXmlFile.toPath());
143129
profiles.add(profile);
144130
} catch (SAXException | IOException excep) {

src/main/java/eu/dilcis/csip/profile/Appendix.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,37 @@
77
import org.xml.sax.Attributes;
88

99
public final class Appendix {
10+
static final class Builder extends XmlFragmentGenerator {
11+
private int number;
12+
private String label;
13+
14+
Builder(final Attributes attributes) {
15+
this.number = Integer.valueOf(Utilities.getNumber(attributes));
16+
this.label = (Utilities.getLabel(attributes));
17+
}
18+
19+
Builder number(final int number) {
20+
this.number = number;
21+
return this;
22+
}
23+
24+
Builder label(final String label) {
25+
this.label = label;
26+
return this;
27+
}
28+
29+
Appendix build() {
30+
return Appendix.fromValues(number, label, content);
31+
}
32+
}
33+
1034
public static Appendix fromValues(final int number, final String label, final List<String> content) {
1135
return new Appendix(number, label, content);
1236
}
1337

1438
public final int number;
1539
public final String label;
40+
1641
public final List<String> content;
1742

1843
private Appendix(final int number, final String label, final List<String> content) {
@@ -35,28 +60,4 @@ public boolean equals(final Object obj) {
3560
final Appendix other = (Appendix) obj;
3661
return number == other.number && Objects.equals(label, other.label) && Objects.equals(content, other.content);
3762
}
38-
39-
static final class Builder extends XmlFragmentGenerator {
40-
private int number;
41-
private String label;
42-
43-
Builder(Attributes attributes) {
44-
this.number = Integer.valueOf(Utilities.getNumber(attributes));
45-
this.label = (Utilities.getLabel(attributes));
46-
}
47-
48-
Builder number(final int number) {
49-
this.number = number;
50-
return this;
51-
}
52-
53-
Builder label(final String label) {
54-
this.label = label;
55-
return this;
56-
}
57-
58-
Appendix build() {
59-
return Appendix.fromValues(number, label, content);
60-
}
61-
}
6263
}

src/main/java/eu/dilcis/csip/profile/ControlledVocabulary.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.ArrayList;
55
import java.util.Collections;
66
import java.util.List;
7+
import java.util.Objects;
78

89
/**
910
* @author <a href="mailto:carl@openpreservation.org">Carl Wilson</a>
@@ -71,7 +72,25 @@ public ControlledVocabulary build( ) {
7172
return new ControlledVocabulary(this.ident, this.nm, this.mntnceAgncy, this.ri, this.cntxt, this.desc);
7273
}
7374
}
74-
public final String id;
75+
76+
@Override
77+
public int hashCode() {
78+
return Objects.hash(id, name, maintenanceAgency, uri, context);
79+
}
80+
81+
@Override
82+
public boolean equals(Object obj) {
83+
if (this == obj)
84+
return true;
85+
if (!(obj instanceof ControlledVocabulary))
86+
return false;
87+
ControlledVocabulary other = (ControlledVocabulary) obj;
88+
return Objects.equals(id, other.id) && Objects.equals(name, other.name)
89+
&& Objects.equals(maintenanceAgency, other.maintenanceAgency) && Objects.equals(uri, other.uri)
90+
&& Objects.equals(context, other.context);
91+
}
92+
93+
public final String id;
7594
public final String name;
7695
public final String maintenanceAgency;
7796
public final URI uri;
Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
package eu.dilcis.csip.profile;
22

33
import java.util.List;
4+
import java.util.Objects;
45

56
import org.xml.sax.Attributes;
67

78
public final class Example {
8-
final String id;
9-
final String label;
10-
final List<String> content;
11-
12-
private Example(String id, String label, List<String> content) {
13-
this.id = id;
14-
this.label = label;
15-
this.content = content;
16-
}
17-
18-
static Example fromValues(String id, String label, List<String> content) {
19-
return new Example(id, label, content);
20-
}
21-
229
static class Builder extends XmlFragmentGenerator {
2310
private String id;
2411
private String label;
2512

26-
Builder(Attributes attributes) {
13+
Builder(final Attributes attributes) {
2714
this.id = Utilities.getId(attributes);
2815
this.label = Utilities.getLabel(attributes);
2916
}
3017

31-
Builder id(String id) {
18+
@Override
19+
public int hashCode() {
20+
return Objects.hash(id, label);
21+
}
22+
23+
@Override
24+
public boolean equals(final Object obj) {
25+
if (this == obj)
26+
return true;
27+
if (!(obj instanceof Builder))
28+
return false;
29+
final Builder other = (Builder) obj;
30+
return Objects.equals(id, other.id) && Objects.equals(label, other.label);
31+
}
32+
33+
Builder id(final String id) {
3234
this.id = id;
3335
return this;
3436
}
3537

36-
Builder label(String label) {
38+
Builder label(final String label) {
3739
this.label = label;
3840
return this;
3941
}
@@ -42,4 +44,36 @@ Example build() {
4244
return Example.fromValues(id, label, content);
4345
}
4446
}
47+
48+
static Example fromValues(final String id, final String label, final List<String> content) {
49+
return new Example(id, label, content);
50+
}
51+
52+
final String id;
53+
54+
final String label;
55+
56+
final List<String> content;
57+
58+
private Example(final String id, final String label, final List<String> content) {
59+
this.id = id;
60+
this.label = label;
61+
this.content = content;
62+
}
63+
64+
@Override
65+
public int hashCode() {
66+
return Objects.hash(id, label, content);
67+
}
68+
69+
@Override
70+
public boolean equals(final Object obj) {
71+
if (this == obj)
72+
return true;
73+
if (!(obj instanceof Example))
74+
return false;
75+
final Example other = (Example) obj;
76+
return Objects.equals(id, other.id) && Objects.equals(label, other.label)
77+
&& Objects.equals(content, other.content);
78+
}
4579
}

0 commit comments

Comments
 (0)