Skip to content

Commit 7ad8891

Browse files
sebhofmannkkrebsxaher
authored
Issues/create lod tei header editor (#5)
* add initial version of header editor including schema TEI update * add body dummy * fix xpath error in searchfields and metadata view * Added missing message properties * Added metadata form to navigation xml * Update to 2023.06, fix teiContainer element, migrate stylesheets * Fix validation, added new TEI-html.xsl Stylesheet * Only include teiHeader in mycoreobjects * Fix database configuration * make xpath more specific to prevent duplicate display of metadata --------- Co-authored-by: Kathleen Neumann <neumann@gbv.de> Co-authored-by: Andre Herzog <andre.herzog@gbv.de>
1 parent 8d41b3b commit 7ad8891

36 files changed

Lines changed: 15459 additions & 1660 deletions

digital-edition-archive-module/pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
<groupId>com.google.guava</groupId>
7575
<artifactId>guava</artifactId>
7676
</dependency>
77-
<dependency>
78-
<groupId>com.mchange</groupId>
79-
<artifactId>c3p0</artifactId>
80-
</dependency>
8177
<dependency>
8278
<groupId>jakarta.servlet</groupId>
8379
<artifactId>jakarta.servlet-api</artifactId>
@@ -99,8 +95,8 @@
9995
<artifactId>solr-solrj</artifactId>
10096
</dependency>
10197
<dependency>
102-
<groupId>org.hibernate</groupId>
103-
<artifactId>hibernate-core-jakarta</artifactId>
98+
<groupId>org.hibernate.orm</groupId>
99+
<artifactId>hibernate-core</artifactId>
104100
</dependency>
105101
<dependency>
106102
<groupId>org.jdom</groupId>
@@ -138,12 +134,6 @@
138134
<groupId>org.mycore</groupId>
139135
<artifactId>mycore-mets</artifactId>
140136
</dependency>
141-
<!-- replace this with the settings of the JDBC driver for your database -->
142-
<dependency>
143-
<groupId>com.h2database</groupId>
144-
<artifactId>h2</artifactId>
145-
<scope>runtime</scope>
146-
</dependency>
147137
<dependency>
148138
<groupId>org.mycore</groupId>
149139
<artifactId>mycore-webtools</artifactId>

digital-edition-archive-module/src/main/datamodel/def/tei.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<metadata>
99
<element name="teiContainer" type="xml" style="dontknow" notinherit="true" heritable="false">
1010
<xs:sequence>
11-
<xs:element ref="tei:TEI" />
11+
<xs:element ref="tei:teiHeader" />
1212
</xs:sequence>
1313
</element>
1414
</metadata>

digital-edition-archive-module/src/main/java/de/gbv/dea/DEATEIUploadHandler.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.nio.file.Files;
1111
import java.nio.file.NoSuchFileException;
1212
import java.nio.file.Path;
13-
import java.util.Collections;
1413
import java.util.List;
1514
import java.util.Map;
1615
import java.util.Objects;
@@ -30,7 +29,12 @@
3029
import org.jdom2.output.XMLOutputter;
3130
import org.mycore.access.MCRAccessException;
3231
import org.mycore.common.MCRException;
33-
import org.mycore.datamodel.metadata.*;
32+
import org.mycore.datamodel.metadata.MCRDerivate;
33+
import org.mycore.datamodel.metadata.MCRMetaClassification;
34+
import org.mycore.datamodel.metadata.MCRMetadataManager;
35+
import org.mycore.datamodel.metadata.MCRObject;
36+
import org.mycore.datamodel.metadata.MCRObjectID;
37+
import org.mycore.datamodel.metadata.validator.MCREditorOutValidator;
3438
import org.mycore.datamodel.niofs.MCRPath;
3539
import org.mycore.datamodel.niofs.utils.MCRRecursiveDeleter;
3640
import org.mycore.datamodel.niofs.utils.MCRTreeCopier;
@@ -42,6 +46,7 @@
4246
import org.mycore.webtools.upload.exception.MCRInvalidFileException;
4347
import org.mycore.webtools.upload.exception.MCRInvalidUploadParameterException;
4448
import org.mycore.webtools.upload.exception.MCRMissingParameterException;
49+
import org.mycore.webtools.upload.exception.MCRUploadException;
4550
import org.mycore.webtools.upload.exception.MCRUploadForbiddenException;
4651
import org.mycore.webtools.upload.exception.MCRUploadServerException;
4752

@@ -212,29 +217,36 @@ public MCRObjectID getObjectIDFromFile(Path file, String project) throws Illegal
212217
}
213218

214219
public Document importOrUpdateTEIMyCoReObject(Path teiFile, MCRObjectID objectID,
215-
List<MCRMetaClassification> classifications) throws IOException {
220+
List<MCRMetaClassification> classifications) throws IOException, MCRInvalidFileException {
216221
boolean exists = MCRMetadataManager.exists(objectID);
217222
Document teiDocument = parseTEI(teiFile);
218223

219-
Document documentWithHeaderOnly = teiDocument.clone();
220-
Element rootElement = documentWithHeaderOnly.getRootElement();
221-
Element teiHeader = rootElement.getChild("teiHeader", TEI_NS).detach();
222-
rootElement.removeContent();
223-
rootElement.addContent(teiHeader);
224+
Document documentWithHeaderOnly = new Document();
225+
documentWithHeaderOnly.setRootElement(teiDocument.getRootElement().getChild("teiHeader", TEI_NS).clone());
226+
227+
Element teiHeader = documentWithHeaderOnly.getRootElement();
224228

225229
MCRObject object;
226230
if (exists) {
227231
object = MCRMetadataManager.retrieveMCRObject(objectID);
228-
DEAUtils.setTEI(object, rootElement);
232+
DEAUtils.setTEI(object, teiHeader);
229233
} else {
230234
object = new MCRObject();
231235
object.setId(objectID);
232236
object.setSchema("datamodel-tei.xsd");
233237
object.setImportMode(true);
234-
DEAUtils.setTEI(object, rootElement);
238+
DEAUtils.setTEI(object, teiHeader);
235239
}
236240
object.getService().setState("published");
237241

242+
try {
243+
MCREditorOutValidator ev = new MCREditorOutValidator(object.createXML(), objectID);
244+
ev.generateValidMyCoReObject();
245+
} catch (RuntimeException|JDOMException e) {
246+
String fileName = teiFile.getFileName().toString();
247+
throw new MCRInvalidFileException(fileName, "fileupload.tei.file.invalid", true, fileName, e.getMessage());
248+
}
249+
238250
try {
239251
MCRMetadataManager.update(object);
240252
} catch (MCRAccessException e) {
@@ -333,7 +345,7 @@ public String begin(Map<String, List<String>> parameters) throws MCRUploadForbid
333345
}
334346

335347
@Override
336-
public URI commit(MCRFileUploadBucket bucket) throws MCRUploadServerException {
348+
public URI commit(MCRFileUploadBucket bucket) throws MCRUploadException {
337349
Map<String, List<String>> parameters = bucket.getParameters();
338350
String project = getProject(bucket.getParameters());
339351
List<MCRMetaClassification> classifications = MCRDefaultUploadHandler.getClassifications(parameters);
@@ -353,7 +365,7 @@ public URI commit(MCRFileUploadBucket bucket) throws MCRUploadServerException {
353365
.findFirst()
354366
.get());
355367
} catch (MCRException e) {
356-
if (e.getCause() instanceof MCRUploadServerException muse) {
368+
if (e.getCause() instanceof MCRUploadException muse) {
357369
throw muse;
358370
} else {
359371
throw e;

digital-edition-archive-module/src/main/java/de/gbv/dea/DEAUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package de.gbv.dea;
22

3+
import java.util.List;
4+
35
import org.jdom2.Content;
46
import org.jdom2.Element;
57
import org.jdom2.Namespace;
@@ -8,12 +10,10 @@
810
import org.mycore.datamodel.metadata.MCRObject;
911
import org.mycore.datamodel.metadata.MCRObjectMetadata;
1012

11-
import java.util.Collections;
12-
import java.util.List;
13-
1413
public class DEAUtils {
1514
public static final Namespace TEI_NS = Namespace.getNamespace("http://www.tei-c.org/ns/1.0");
1615
public static final String DEF_TEI_CONTAINER = "def.teiContainer";
16+
public static final String TEI_CONTAINER = "teiContainer";
1717

1818
public static Element getTEI(MCRObject object) {
1919
try {
@@ -34,8 +34,8 @@ public static void setTEI(MCRObject object,Element tei) {
3434
if (om.getMetadataElement(DEF_TEI_CONTAINER) != null) {
3535
om.removeMetadataElement(DEF_TEI_CONTAINER);
3636
}
37-
MCRMetaXML teiContainer = new MCRMetaXML(DEF_TEI_CONTAINER, null, 0);
38-
List<MCRMetaXML> list = Collections.nCopies(1, teiContainer);
37+
MCRMetaXML teiContainer = new MCRMetaXML(TEI_CONTAINER, null, 0);
38+
List<MCRMetaXML> list = List.of(teiContainer);
3939
MCRMetaElement defTeiContainer = new MCRMetaElement(MCRMetaXML.class, DEF_TEI_CONTAINER, false, true, list);
4040
om.setMetadataElement(defTeiContainer);
4141
teiContainer.addContent(tei);

digital-edition-archive-module/src/main/resources/META-INF/resources/config/navigation.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
<label xml:lang="de">TEI Abzug für LOD einspielen</label>
4242
<label xml:lang="en">add TEI snapshot for LOD</label>
4343
</item>
44+
<item href="/content/publish/tei_lod_header.xed" type="intern">
45+
<label xml:lang="de">TEI Metadaten erfassen</label>
46+
<label xml:lang="en">Add TEI metadata</label>
47+
</item>
4448
</menu>
4549
<menu id="user">
4650
<label xml:lang="de">Nutzermenü</label>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE MyCoReWebPage>
3+
<MyCoReWebPage>
4+
<section xml:lang="all" title="Erfassungsmaske LOD-Header">
5+
6+
<xed:form xmlns:xed="http://www.mycore.de/xeditor" xmlns:tei="http://www.tei-c.org/ns/1.0" method="post" role="form" class="form-horizontal">
7+
<xed:source uri="mcrobject:{$id}" />
8+
<xed:cancel url="../index.xml" />
9+
<xed:bind xpath="/mycoreobject">
10+
<xed:bind xpath="@ID" initially="lod_tei_00000000" />
11+
<xed:bind xpath="metadata/def.teiContainer[@class='MCRMetaXML'][@notinherit='true']/teiContainer/tei:teiHeader">
12+
<div class="card">
13+
<div class="card-header">
14+
<h3><xed:output i18n="editor.legend.lod_tei" /></h3>
15+
</div>
16+
<div class="card-body">
17+
<!-- Input Title -->
18+
<xed:bind xpath="tei:fileDesc/tei:titleStmt/tei:title[@type='main']">
19+
<div class="form-group row {$xed-validation-marker}">
20+
<label class="col-md-4 control-label" for="title">
21+
<xed:output i18n="editor.label.title" />
22+
</label>
23+
<div class="col-md-6">
24+
<input id="title" placeholder="{i18n:editor.placeholder.title}" class="form-control input-md"
25+
type="text" />
26+
</div>
27+
<xed:validate display="here" required="true">
28+
<xed:output i18n="editor.validate.title" />
29+
</xed:validate>
30+
</div>
31+
</xed:bind>
32+
33+
<!-- Input Author -->
34+
<xed:bind xpath="tei:fileDesc/tei:titleStmt">
35+
<div class="form-group row">
36+
<label class="col-md-4 control-label" for="creator">
37+
<xed:output i18n="editor.label.author" />
38+
</label>
39+
<div class="col-md-6">
40+
<xed:repeat xpath="tei:author">
41+
<xed:bind xpath="tei:persName/tei:surname[@xml:lang='en']">
42+
<div class="form-group row">
43+
<div class="col-sm-8">
44+
<input id="creator" placeholder="{i18n:editor.placeholder.author}" class="form-control input-md"
45+
type="text" />
46+
</div>
47+
<div class="col-sm-4">
48+
<div class="btn-group btn-group-sm pull-right">
49+
<xed:controls />
50+
</div>
51+
</div>
52+
</div>
53+
</xed:bind>
54+
</xed:repeat>
55+
</div>
56+
</div>
57+
</xed:bind>
58+
<xed:bind xpath="tei:fileDesc/tei:publicationStmt/tei:publisher/tei:orgName[@xml:id='MWS']" default="Max-Weber-Stiftung" />
59+
<xed:bind xpath="tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:repository" default="DEA" />
60+
61+
<!-- Input Archivnummer -->
62+
<xed:bind xpath="tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:idno">
63+
<div class="form-group row {$xed-validation-marker}">
64+
<label class="col-md-4 control-label" for="archivnr">
65+
<xed:output i18n="editor.label.archivnr" />
66+
</label>
67+
<div class="col-md-6">
68+
<input id="title" placeholder="{i18n:editor.placeholder.archivnr}" class="form-control input-md"
69+
type="text" />
70+
</div>
71+
<xed:validate display="here" required="true">
72+
<xed:output i18n="editor.validate.archivnr" />
73+
</xed:validate>
74+
</div>
75+
</xed:bind>
76+
77+
<!-- Button (Double) -->
78+
<div class="form-group row">
79+
<label class="col-md-4 control-label" for="save"></label>
80+
<div class="col-md-8">
81+
<xed:choose>
82+
<xed:when test="contains(/mycoreobject/@ID, '_00000000')">
83+
<button id="save" class="btn btn-success createobject" type="submit" xed:target="servlet"
84+
xed:href="CreateObjectServlet">
85+
<xed:output i18n="common.button.save" />
86+
</button>
87+
</xed:when>
88+
<xed:otherwise>
89+
<button id="save" class="btn btn-success updateobject" type="submit" xed:target="servlet"
90+
xed:href="UpdateObjectServlet">
91+
<xed:output i18n="common.button.save" />
92+
</button>
93+
</xed:otherwise>
94+
</xed:choose>
95+
<xed:output value="'&#160;'" />
96+
<button id="cancel" class="btn btn-danger" type="submit" xed:target="cancel">
97+
<xed:output i18n="common.button.cancel" />
98+
</button>
99+
<xed:output value="'&#160;'" />
100+
<button id="debug" class="btn btn-info" type="submit" xed:target="debug">
101+
<xed:output i18n="common.button.debug" />
102+
</button>
103+
</div>
104+
</div>
105+
</div>
106+
</div>
107+
</xed:bind>
108+
</xed:bind>
109+
</xed:form>
110+
111+
</section>
112+
</MyCoReWebPage>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* This file is part of *** M y C o R e ***
3+
* See http://www.mycore.de/ for details.
4+
*
5+
* MyCoRe is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* MyCoRe is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
.fileSection {
20+
margin-top: 50px;
21+
}
22+
23+
.teiDisplaySection {
24+
padding: 15px;
25+
background-color: #fff;
26+
border: 1px solid #ddd;
27+
border-radius: 4px;
28+
margin-top: 15px;
29+
}
30+
31+
.possibleMatch{
32+
margin-top: 30px;
33+
}
34+
35+
.possibleMatch a {
36+
display: block;
37+
}
38+
39+
.possibleMatch b {
40+
margin-right: 5px;
41+
}
42+
43+
.teiLine {
44+
display: block;
45+
}
46+
47+
.teiRow {
48+
display: table-row;
49+
}
50+
51+
.teiCell {
52+
display: table-cell;
53+
padding: 5px;
54+
}
55+
56+
.teiTable {
57+
display: table;
58+
}
59+
60+
dt a {
61+
vertical-align: super;
62+
line-height: 2;
63+
}
64+
65+
dt, dd {
66+
display: inline;
67+
font-weight: normal;
68+
line-height: normal;
69+
}
70+
71+
.popupTrigger {
72+
cursor: pointer;
73+
}

0 commit comments

Comments
 (0)