Skip to content

Commit

Permalink
v2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerning committed Aug 12, 2024
1 parent fd7d001 commit 9030ca8
Show file tree
Hide file tree
Showing 64 changed files with 2,182 additions and 42,222 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ src/main/java/tla/error
src/main/resources/static/vendor/
src/main/resources/static/font/

# ignore TLA css
src/main/resources/static/css/tla-styles.css

# ignore new JSesh Glyphs
src/main/resources/static/jsesh

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/tla/web/model/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tla.domain.model.meta.TLADTO;
import tla.web.model.mappings.Util;
import tla.web.model.meta.BTSObject;
import tla.web.model.meta.TLAObject;

@Getter
@Setter
Expand Down Expand Up @@ -74,5 +75,13 @@ private Collection<String> extractBody() {
}
return Collections.emptyList();
}

@Override
public <T extends TLAObject> int compareObjects(T b) {
if(this.getId() != null && b.getId() != null) {
return this.getId().compareTo(b.getId());
}
return 0;
}

}
9 changes: 9 additions & 0 deletions src/main/java/tla/web/model/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tla.domain.model.meta.TLADTO;
import tla.web.model.mappings.Util;
import tla.web.model.meta.BTSObject;
import tla.web.model.meta.TLAObject;

@Getter
@Setter
Expand All @@ -38,5 +39,13 @@ public String getBody() {
//return this.body;
return Util.escapeMarkup(this.body);
}

@Override
public <T extends TLAObject> int compareObjects(T b) {
if(this.getId() != null && b.getId() != null) {
return this.getId().compareTo(b.getId());
}
return 0;
}

}
18 changes: 15 additions & 3 deletions src/main/java/tla/web/model/CorpusObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,20 +524,31 @@ public List<String> getContextComment() {
return this.contextComment;
}

// Object type
// Object Description_Of_Object type

public static final String PASSPORT_PROP_OBJ_TYPE = "object.description_of_object.type";

@Setter(AccessLevel.NONE)
private ObjectReference objType;

public ObjectReference getObjType() {
if (this.objType == null) {
this.objType = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_TYPE);
}
return this.objType;
}

// Object Description_Of_Object description

public static final String PASSPORT_PROP_OBJ_DESCRIPTION = "object.description_of_object.description";
//Maybe new Datatype description_of_object
@Setter(AccessLevel.NONE)
private List<String> objectDescription;
public List<String> getObjectDescription(){
if(this.objectDescription == null) {
this.objectDescription = extractMultilineText(this.getPassport(), PASSPORT_PROP_OBJ_DESCRIPTION);
}
return this.objectDescription;
}

// Object component

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


}
5 changes: 5 additions & 0 deletions src/main/java/tla/web/model/Sentence.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public class Sentence extends TLAObject implements Hierarchic {

@Singular
private SortedMap<Language, List<String>> translations;

@Override
public <T extends TLAObject> int compareObjects(T b) {
return 0;
}

/**
* Determine whether any of a sentence's tokens have any hieroglyph encodings.
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/tla/web/model/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class Text extends CorpusObject {
public static final String PASSPORT_PROP_HIEROGLYPHIC_ENCODING = "definition.main_group.hieroglyphic_encoding";
public static final String PASSPORT_PROP_HIEROGLYPHS_SEQUENTIAL = "definition.main_group.hieroglyphs_sequential";
public static final String PASSPORT_PROP_TRANSLATIONS = "definition.main_group.translations";

public static final String PASSPORT_PROP_LINE_COUNT = "definition.main_group.line_count";

//TODO prüfen ob doppelt, da bereits in CorpusObject.java
public static final String PASSPORT_PROP_ORIGPLACE ="find_spot.find_spot.place.place";
public static final String PASSPORT_PROP_ISORIG ="find_spot.find_spot.place.is_origin";
Expand Down Expand Up @@ -93,6 +94,8 @@ public class Text extends CorpusObject {
private String hieroglyphs_sequential;
@Setter(AccessLevel.NONE)
private List<TranslationGroup> translations;
@Setter(AccessLevel.NONE)
private List<String> lineCountInfo;

public static class TranslationGroup {
private String language;
Expand Down Expand Up @@ -256,6 +259,13 @@ public List<TranslationGroup> getTranslations() {
return this.translations;
}

public List<String> getLineCountInfo() {
if(this.lineCountInfo== null) {
this.lineCountInfo = extractMultilineText(this.getPassport(), PASSPORT_PROP_LINE_COUNT);
}
return this.lineCountInfo;
}



//TODO generic
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/tla/web/model/ThsEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
@TLADTO(ThsEntryDto.class)
public class ThsEntry extends BTSObject implements Hierarchic {

@Singular
private SortedMap<Language, List<String>> translations;

private List<ObjectPath> paths;

//
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/tla/web/model/mappings/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ public class Util {

public static final String TRANSLITERATION_FONT_MARKUP_REGEX = "\\$([^$]*?)\\$";
public static final String GREEK_FONT_MARKUP_VITTMANN_REGEX = "#g\\+([^#]*?)#g\\-";
public static final String GREEK_FONT_MARKUP_REGEX = "<gr>([<]*?)</gr>";
public static final String HIERO_FONT_MARKUP_REGEX = "<hiero>([<]*?)</hiero>";
public static final String GREEK_FONT_MARKUP_REGEX = "<gr>([^<]*?)</gr>";
public static final String HIERO_FONT_MARKUP_REGEX = "<hiero>([^<]*?)</hiero>";
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)>";
public static final String URL_PATTERN_REGEX = "(?<!href=\")((https?|ftp)\\:\\/\\/[-A-Za-z0-9+&@#\\/%?=~_|!:,.;]*[-A-Za-z0-9+&@#\\/%=~_|])";
// TODO: result corrupt without lookahead (recursive replacement??)

public static final String URL_WITH_BRACKETS_REGEX = "<" + URL_PATTERN_REGEX + ">";

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

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

// line breaks to HTML
text = text.replaceAll("\\r?\\n", "<br/>");
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/tla/web/model/meta/BTSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ public class BTSObject extends TLAObject { // earlier: abstract

private String subtype;

private String name;

private TreeMap<String, List<ExternalReference>> externalReferences;

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

@Setter(AccessLevel.NONE)
private List<String> metadata_editing;

@Override
public <T extends TLAObject> int compareObjects(T b) {
if(this.getName() != null && b.getName() != null) {
return this.getName().compareTo(b.getName());
}
return 0;
}

public List<String> getMetadata_editing() {
if (this.metadata_editing == null) {
Expand Down
104 changes: 56 additions & 48 deletions src/main/java/tla/web/model/meta/ObjectDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,69 @@

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.Comparator;
import java.util.HashMap;

import lombok.Getter;
import tla.domain.dto.extern.SingleDocumentWrapper;
import tla.domain.dto.meta.AbstractDto;
import tla.web.model.Lemma;
import tla.web.model.mappings.MappingConfig;

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

private T object;

public ObjectDetails(T object) {
this.object = object;
}

@SuppressWarnings("unchecked")
public ObjectDetails(SingleDocumentWrapper<?> dto) {
super(dto);
this.object = (T) MappingConfig.convertDTO(
dto.getDoc()
);
}

public ObjectDetails(T object, Map<String, Map<String, TLAObject>> related) {
super(related);
this.object = object;
}

/**
* Map payload and related objects from DTO to domain model types.
*/
public static ObjectDetails<? extends TLAObject> from(SingleDocumentWrapper<? extends AbstractDto> wrapper) {
var container = new ObjectDetails<>(wrapper);
return container;
}

/**
* Projects objects in a single object details container's <code>related</code>
* map to the wrapped object's <code>relations</code> (which are {@link TLAObject} stubs
* in objects freshly converted from DTO).
*/
public Map<String, List<TLAObject>> extractRelatedObjects() {
return this.getObject().getRelations().entrySet().stream().collect(
Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue().stream().map(
reference -> this.expandRelatedObject(reference)
).filter(
o -> o != null
).collect(
Collectors.toList()
)
)
);
}

}
private T object;

public ObjectDetails(T object) {
this.object = object;
}

@SuppressWarnings("unchecked")
public ObjectDetails(SingleDocumentWrapper<?> dto) {
super(dto);
this.object = (T) MappingConfig.convertDTO(dto.getDoc());
}

public ObjectDetails(T object, Map<String, Map<String, TLAObject>> related) {
super(related);
this.object = object;
}

/**
* Map payload and related objects from DTO to domain model types.
*/
public static ObjectDetails<? extends TLAObject> from(SingleDocumentWrapper<? extends AbstractDto> wrapper) {
var container = new ObjectDetails<>(wrapper);
return container;
}

/**
* Projects objects in a single object details container's <code>related</code>
* map to the wrapped object's <code>relations</code> (which are
* {@link TLAObject} stubs in objects freshly converted from DTO).
*/

public Map<String, List<TLAObject>> extractRelatedObjects() {
Map<String, List<TLAObject>> extractedRelations = new HashMap<String, List<TLAObject>>();

extractedRelations = this.getObject().getRelations().entrySet().stream()
.collect(Collectors.toMap(entry -> entry.getKey(),
entry -> entry.getValue().stream().map(reference -> this.expandRelatedObject(reference))
.filter(o -> o != null).collect(Collectors.toList())));
for (String key : extractedRelations.keySet()) {
List<TLAObject> value = extractedRelations.get(key);
value.sort(new NameComparator());
}
return extractedRelations;
}

class NameComparator implements Comparator<TLAObject> {
@Override
public int compare(TLAObject a, TLAObject b) {
return a.compareObjects(b);
}
}
}
6 changes: 6 additions & 0 deletions src/main/java/tla/web/model/meta/TLAObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ public abstract class TLAObject extends AbstractBTSBaseClass implements Relatabl
private String id;

private String type;

private String name;

private TreeMap<String, List<ObjectReference>> relations;

public <T extends TLAObject> int compareObjects(T b) {
return 0;
}

/**
* Creates an {@link ObjectReference} instance identifying this object.
Expand Down
28 changes: 0 additions & 28 deletions src/main/java/tla/web/model/parts/extra/AttestedTimespan.java

This file was deleted.

Loading

0 comments on commit 9030ca8

Please sign in to comment.