Skip to content

Commit 9030ca8

Browse files
committed
v2.1.5
1 parent fd7d001 commit 9030ca8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2182
-42222
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ src/main/java/tla/error
1616
src/main/resources/static/vendor/
1717
src/main/resources/static/font/
1818

19+
# ignore TLA css
20+
src/main/resources/static/css/tla-styles.css
21+
1922
# ignore new JSesh Glyphs
2023
src/main/resources/static/jsesh
2124

src/main/java/tla/web/model/Annotation.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import tla.domain.model.meta.TLADTO;
1616
import tla.web.model.mappings.Util;
1717
import tla.web.model.meta.BTSObject;
18+
import tla.web.model.meta.TLAObject;
1819

1920
@Getter
2021
@Setter
@@ -74,5 +75,13 @@ private Collection<String> extractBody() {
7475
}
7576
return Collections.emptyList();
7677
}
78+
79+
@Override
80+
public <T extends TLAObject> int compareObjects(T b) {
81+
if(this.getId() != null && b.getId() != null) {
82+
return this.getId().compareTo(b.getId());
83+
}
84+
return 0;
85+
}
7786

7887
}

src/main/java/tla/web/model/Comment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import tla.domain.model.meta.TLADTO;
1616
import tla.web.model.mappings.Util;
1717
import tla.web.model.meta.BTSObject;
18+
import tla.web.model.meta.TLAObject;
1819

1920
@Getter
2021
@Setter
@@ -38,5 +39,13 @@ public String getBody() {
3839
//return this.body;
3940
return Util.escapeMarkup(this.body);
4041
}
42+
43+
@Override
44+
public <T extends TLAObject> int compareObjects(T b) {
45+
if(this.getId() != null && b.getId() != null) {
46+
return this.getId().compareTo(b.getId());
47+
}
48+
return 0;
49+
}
4150

4251
}

src/main/java/tla/web/model/CorpusObject.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,20 +524,31 @@ public List<String> getContextComment() {
524524
return this.contextComment;
525525
}
526526

527-
// Object type
527+
// Object Description_Of_Object type
528528

529529
public static final String PASSPORT_PROP_OBJ_TYPE = "object.description_of_object.type";
530-
531530
@Setter(AccessLevel.NONE)
532531
private ObjectReference objType;
533-
534532
public ObjectReference getObjType() {
535533
if (this.objType == null) {
536534
this.objType = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_TYPE);
537535
}
538536
return this.objType;
539537
}
538+
539+
// Object Description_Of_Object description
540540

541+
public static final String PASSPORT_PROP_OBJ_DESCRIPTION = "object.description_of_object.description";
542+
//Maybe new Datatype description_of_object
543+
@Setter(AccessLevel.NONE)
544+
private List<String> objectDescription;
545+
public List<String> getObjectDescription(){
546+
if(this.objectDescription == null) {
547+
this.objectDescription = extractMultilineText(this.getPassport(), PASSPORT_PROP_OBJ_DESCRIPTION);
548+
}
549+
return this.objectDescription;
550+
}
551+
541552
// Object component
542553

543554
public static final String PASSPORT_PROP_OBJ_COMPONENT = "object.description_of_object.component";
@@ -614,4 +625,5 @@ private static List<String> extractDimensions(CorpusObject corpusobj) {
614625
return dimensions;
615626
}
616627

628+
617629
}

src/main/java/tla/web/model/Sentence.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public class Sentence extends TLAObject implements Hierarchic {
5050

5151
@Singular
5252
private SortedMap<Language, List<String>> translations;
53+
54+
@Override
55+
public <T extends TLAObject> int compareObjects(T b) {
56+
return 0;
57+
}
5358

5459
/**
5560
* Determine whether any of a sentence's tokens have any hieroglyph encodings.

src/main/java/tla/web/model/Text.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class Text extends CorpusObject {
4747
public static final String PASSPORT_PROP_HIEROGLYPHIC_ENCODING = "definition.main_group.hieroglyphic_encoding";
4848
public static final String PASSPORT_PROP_HIEROGLYPHS_SEQUENTIAL = "definition.main_group.hieroglyphs_sequential";
4949
public static final String PASSPORT_PROP_TRANSLATIONS = "definition.main_group.translations";
50-
50+
public static final String PASSPORT_PROP_LINE_COUNT = "definition.main_group.line_count";
51+
5152
//TODO prüfen ob doppelt, da bereits in CorpusObject.java
5253
public static final String PASSPORT_PROP_ORIGPLACE ="find_spot.find_spot.place.place";
5354
public static final String PASSPORT_PROP_ISORIG ="find_spot.find_spot.place.is_origin";
@@ -93,6 +94,8 @@ public class Text extends CorpusObject {
9394
private String hieroglyphs_sequential;
9495
@Setter(AccessLevel.NONE)
9596
private List<TranslationGroup> translations;
97+
@Setter(AccessLevel.NONE)
98+
private List<String> lineCountInfo;
9699

97100
public static class TranslationGroup {
98101
private String language;
@@ -256,6 +259,13 @@ public List<TranslationGroup> getTranslations() {
256259
return this.translations;
257260
}
258261

262+
public List<String> getLineCountInfo() {
263+
if(this.lineCountInfo== null) {
264+
this.lineCountInfo = extractMultilineText(this.getPassport(), PASSPORT_PROP_LINE_COUNT);
265+
}
266+
return this.lineCountInfo;
267+
}
268+
259269

260270

261271
//TODO generic

src/main/java/tla/web/model/ThsEntry.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
@TLADTO(ThsEntryDto.class)
3333
public class ThsEntry extends BTSObject implements Hierarchic {
3434

35-
@Singular
36-
private SortedMap<Language, List<String>> translations;
37-
3835
private List<ObjectPath> paths;
3936

4037
//

src/main/java/tla/web/model/mappings/Util.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ public class Util {
2828

2929
public static final String TRANSLITERATION_FONT_MARKUP_REGEX = "\\$([^$]*?)\\$";
3030
public static final String GREEK_FONT_MARKUP_VITTMANN_REGEX = "#g\\+([^#]*?)#g\\-";
31-
public static final String GREEK_FONT_MARKUP_REGEX = "<gr>([<]*?)</gr>";
32-
public static final String HIERO_FONT_MARKUP_REGEX = "<hiero>([<]*?)</hiero>";
31+
public static final String GREEK_FONT_MARKUP_REGEX = "<gr>([^<]*?)</gr>";
32+
public static final String HIERO_FONT_MARKUP_REGEX = "<hiero>([^<]*?)</hiero>";
33+
public static final String TLA_ID_REF_REGEX = "<(sentence|lemma|text|object|thesaurus|token)(ID|Id|id)>\\s*([^<\\s]*?)\\s*</(sentence|lemma|text|object|thesaurus|token)(ID|Id|id)>";
34+
public static final String URL_PATTERN_REGEX = "(?<!href=\")((https?|ftp)\\:\\/\\/[-A-Za-z0-9+&@#\\/%?=~_|!:,.;]*[-A-Za-z0-9+&@#\\/%=~_|])";
35+
// TODO: result corrupt without lookahead (recursive replacement??)
36+
37+
public static final String URL_WITH_BRACKETS_REGEX = "<" + URL_PATTERN_REGEX + ">";
3338

3439
public static final String MULTILING_FONT_MARKUP_REPLACEMENT = "<span class=\"bbaw-libertine\">$1</span>";
3540
public static final String HIERO_FONT_MARKUP_REPLACEMENT = "<span class=\"unicode-hieroglyphs\">$1</span>";
41+
public static final String URL_PATTERN_REGEX_REPLACEMENT = "<a href=\"$1\" target=\"_blank\">$1</a>";
42+
public static final String TLA_ID_REF_REGEX_REPLACEMENT = "<a href=\"https://thesaurus-linguae-aegyptiae.de/$1/$3\">$3</a>";
3643

3744
public static final String XML_HEAD = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>";
3845
public static final String SVG_ATTR_REGEX = "width=.([0-9.]+). height=.([0-9.]+).";
@@ -152,6 +159,9 @@ public static String escapeMarkup(String text) {
152159
text = text.replaceAll(GREEK_FONT_MARKUP_REGEX, MULTILING_FONT_MARKUP_REPLACEMENT);
153160
text = text.replaceAll(HIERO_FONT_MARKUP_REGEX, HIERO_FONT_MARKUP_REPLACEMENT);
154161
text = text.replaceAll(TRANSLITERATION_FONT_MARKUP_REGEX, MULTILING_FONT_MARKUP_REPLACEMENT);
162+
text = text.replaceAll(URL_WITH_BRACKETS_REGEX, "&lt;$1&gt;"); // replace < and > around URLs
163+
text = text.replaceAll(URL_PATTERN_REGEX, URL_PATTERN_REGEX_REPLACEMENT); // add href to URL
164+
text = text.replaceAll(TLA_ID_REF_REGEX, TLA_ID_REF_REGEX_REPLACEMENT);
155165

156166
// line breaks to HTML
157167
text = text.replaceAll("\\r?\\n", "<br/>");

src/main/java/tla/web/model/meta/BTSObject.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@ public class BTSObject extends TLAObject { // earlier: abstract
2929

3030
private String subtype;
3131

32-
private String name;
33-
3432
private TreeMap<String, List<ExternalReference>> externalReferences;
3533

3634
public static final String PASSPORT_PROP_METADATA_EDITING = "definition.main_group.metadata_editing";
3735

3836
@Setter(AccessLevel.NONE)
3937
private List<String> metadata_editing;
38+
39+
@Override
40+
public <T extends TLAObject> int compareObjects(T b) {
41+
if(this.getName() != null && b.getName() != null) {
42+
return this.getName().compareTo(b.getName());
43+
}
44+
return 0;
45+
}
4046

4147
public List<String> getMetadata_editing() {
4248
if (this.metadata_editing == null) {

src/main/java/tla/web/model/meta/ObjectDetails.java

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,69 @@
22

33
import java.util.List;
44
import java.util.Map;
5+
import java.util.Map.Entry;
56
import java.util.stream.Collectors;
7+
import java.util.Comparator;
8+
import java.util.HashMap;
69

710
import lombok.Getter;
811
import tla.domain.dto.extern.SingleDocumentWrapper;
912
import tla.domain.dto.meta.AbstractDto;
13+
import tla.web.model.Lemma;
1014
import tla.web.model.mappings.MappingConfig;
1115

1216
@Getter
1317
public class ObjectDetails<T extends TLAObject> extends ObjectsContainer {
1418

15-
private T object;
16-
17-
public ObjectDetails(T object) {
18-
this.object = object;
19-
}
20-
21-
@SuppressWarnings("unchecked")
22-
public ObjectDetails(SingleDocumentWrapper<?> dto) {
23-
super(dto);
24-
this.object = (T) MappingConfig.convertDTO(
25-
dto.getDoc()
26-
);
27-
}
28-
29-
public ObjectDetails(T object, Map<String, Map<String, TLAObject>> related) {
30-
super(related);
31-
this.object = object;
32-
}
33-
34-
/**
35-
* Map payload and related objects from DTO to domain model types.
36-
*/
37-
public static ObjectDetails<? extends TLAObject> from(SingleDocumentWrapper<? extends AbstractDto> wrapper) {
38-
var container = new ObjectDetails<>(wrapper);
39-
return container;
40-
}
41-
42-
/**
43-
* Projects objects in a single object details container's <code>related</code>
44-
* map to the wrapped object's <code>relations</code> (which are {@link TLAObject} stubs
45-
* in objects freshly converted from DTO).
46-
*/
47-
public Map<String, List<TLAObject>> extractRelatedObjects() {
48-
return this.getObject().getRelations().entrySet().stream().collect(
49-
Collectors.toMap(
50-
entry -> entry.getKey(),
51-
entry -> entry.getValue().stream().map(
52-
reference -> this.expandRelatedObject(reference)
53-
).filter(
54-
o -> o != null
55-
).collect(
56-
Collectors.toList()
57-
)
58-
)
59-
);
60-
}
61-
62-
}
19+
private T object;
20+
21+
public ObjectDetails(T object) {
22+
this.object = object;
23+
}
24+
25+
@SuppressWarnings("unchecked")
26+
public ObjectDetails(SingleDocumentWrapper<?> dto) {
27+
super(dto);
28+
this.object = (T) MappingConfig.convertDTO(dto.getDoc());
29+
}
30+
31+
public ObjectDetails(T object, Map<String, Map<String, TLAObject>> related) {
32+
super(related);
33+
this.object = object;
34+
}
35+
36+
/**
37+
* Map payload and related objects from DTO to domain model types.
38+
*/
39+
public static ObjectDetails<? extends TLAObject> from(SingleDocumentWrapper<? extends AbstractDto> wrapper) {
40+
var container = new ObjectDetails<>(wrapper);
41+
return container;
42+
}
43+
44+
/**
45+
* Projects objects in a single object details container's <code>related</code>
46+
* map to the wrapped object's <code>relations</code> (which are
47+
* {@link TLAObject} stubs in objects freshly converted from DTO).
48+
*/
49+
50+
public Map<String, List<TLAObject>> extractRelatedObjects() {
51+
Map<String, List<TLAObject>> extractedRelations = new HashMap<String, List<TLAObject>>();
52+
53+
extractedRelations = this.getObject().getRelations().entrySet().stream()
54+
.collect(Collectors.toMap(entry -> entry.getKey(),
55+
entry -> entry.getValue().stream().map(reference -> this.expandRelatedObject(reference))
56+
.filter(o -> o != null).collect(Collectors.toList())));
57+
for (String key : extractedRelations.keySet()) {
58+
List<TLAObject> value = extractedRelations.get(key);
59+
value.sort(new NameComparator());
60+
}
61+
return extractedRelations;
62+
}
63+
64+
class NameComparator implements Comparator<TLAObject> {
65+
@Override
66+
public int compare(TLAObject a, TLAObject b) {
67+
return a.compareObjects(b);
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)