Skip to content

Commit

Permalink
some random polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
JKatzwinkel authored Sep 30, 2023
1 parent e895e3a commit 14d3ad7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![build](https://github.com/JKatzwinkel/tla-web/workflows/build/badge.svg)
![deploy](https://github.com/JKatzwinkel/tla-web/workflows/deploy/badge.svg)
![LINE](https://img.shields.io/badge/line--coverage-90.99%25-brightgreen.svg)
![METHOD](https://img.shields.io/badge/method--coverage-91.33%25-brightgreen.svg)
![LINE](https://img.shields.io/badge/line--coverage-91.00%25-brightgreen.svg)
![METHOD](https://img.shields.io/badge/method--coverage-92.46%25-brightgreen.svg)

TLA web frontend.

Expand Down
42 changes: 21 additions & 21 deletions src/main/java/tla/web/model/Annotation.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tla.web.model;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import lombok.AccessLevel;
Expand Down Expand Up @@ -41,35 +40,36 @@ public String getName() {
* Escapes markup.
*/
public String getBody() {
if (this.body == null) {
this.body = this.extractBody();
}
return Util.escapeMarkup(
String.join(
"\n\n",
this.body != null ? this.body : this.extractBody()
)
String.join("\n\n", this.body)
);
}

/**
* Try to extract text content from <code>"annotation.lemma"</code> nodes in the annotation's passport.
*/
private Collection<String> extractBody() {
if (this.getPassport() != null) {
List<Passport> nodes = this.getPassport().extractProperty(
"annotation.lemma"
);
if (nodes != null) {
return nodes.stream().filter(
node -> {
return !node.isEmpty() && !node.getLeafNodeValue().isBlank();
}
).map(
Passport::getLeafNodeValue
).map(
String::trim
).toList();
}
if (this.getPassport() == null) {
return List.of();
}
return Collections.emptyList();
List<Passport> nodes = this.getPassport().extractProperty(
"annotation.lemma"
);
if (nodes == null) {
return List.of();
}
return nodes.stream().filter(
node -> {
return !node.isEmpty() && !node.getLeafNodeValue().isBlank();
}
).map(
Passport::getLeafNodeValue
).map(
String::trim
).toList();
}

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

private Transcription transcription;

private Text text;
private Text text = Text.EMPTY;

@Singular
private SortedMap<Language, List<String>> translations;
Expand All @@ -51,20 +51,20 @@ public boolean hasGlyphs() {
}

public String getName() {
return this.getText() != null ? this.getText().getName() : null;
return this.getText().getName();
}

public String reviewState() {
return this.getText() != null ? this.getText().getReviewState() : "published";
return this.getText().getReviewState();
}

public EditorInfo getEdited() {
return this.getText() != null ? this.getText().getEdited() : null;
return this.getText().getEdited();
}

@Override
public List<ObjectPath> getPaths() {
return this.getText() != null ? this.getText().getPaths() : null;
return this.getText().getPaths();
}

}
2 changes: 2 additions & 0 deletions src/main/java/tla/web/model/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@TLADTO(TextDto.class)
public class Text extends CorpusObject {

public static final Text EMPTY = new Text();

private TextDto.WordCount wordCount;

}
2 changes: 0 additions & 2 deletions src/main/java/tla/web/model/mappings/MappingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.modelmapper.ModelMapper;
import org.modelmapper.TypeMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand Down Expand Up @@ -55,7 +54,6 @@ public class MappingConfig {

private ExternalReferencesConverter externalReferencesConverter;

@Autowired
public MappingConfig(ExternalReferencesConverter externalReferencesConverter) {
this.externalReferencesConverter = externalReferencesConverter;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/tla/web/model/parts/Transcription.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import lombok.Getter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Transcription {
Expand Down

0 comments on commit 14d3ad7

Please sign in to comment.