Skip to content

Commit

Permalink
Text-Metadaten vervollständigt
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerning authored Sep 14, 2023
2 parents cdf7637 + 1c7dde2 commit 2edfacd
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 55 deletions.
177 changes: 132 additions & 45 deletions src/main/java/tla/web/model/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import tla.domain.dto.TextDto;
import tla.domain.model.ObjectReference;
import tla.domain.model.Passport;
import tla.domain.model.meta.BTSeClass;
import tla.domain.model.meta.TLADTO;
Expand All @@ -25,22 +26,44 @@
public class Text extends CorpusObject {

private TextDto.WordCount wordCount;
// private List<Sentence> sentence;
public static final String PASSPORT_PROP_BIBL = "bibliography.bibliographical_text_field";
public static final String PASSPORT_PROP_SCRIPT = "text.textual_metadata.script";
public static final String PASSPORT_PROP_DATE = "date.date.date";
public static final String PASSPORT_PROP_LANGUAGE ="text.textual_metadata.language";
public static final String PASSPORT_PROP_SCRIPT = "text.textual_metadata.script";
public static final String PASSPORT_PROP_EGYTEXTNAME ="text.textual_metadata.egytextname";
public static final String PASSPORT_PROP_COMMENTLANGUAGE ="text.textual_metadata.comment_on_language";
public static final String PASSPORT_PROP_COMMENTTEXTTYPE ="text.textual_metadata.comment_on_texttype";
public static final String PASSPORT_PROP_COMMENTSCRIPT ="text.textual_metadata.comment_on_script";
public static final String PASSPORT_PROP_TEXTTYPE ="text.textual_metadata.texttype";
public static final String PASSPORT_PROP_SECINSCRIPTION ="text.textual_metadata.secondary_inscription";


//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";
public static final String PASSPORT_PROP_PRESLOC ="present_location.location.location";
@Setter(AccessLevel.NONE)
private List<String> bibliography;
private List<String> bibliography;
@Setter(AccessLevel.NONE)
private List<String>skript;
private String textualMetadata;
@Setter(AccessLevel.NONE)
private List<String> date;
private ObjectReference language;
@Setter(AccessLevel.NONE)
private ObjectReference skript;
@Setter(AccessLevel.NONE)
private String egytextname;
@Setter(AccessLevel.NONE)
private String commentlanguage;
@Setter(AccessLevel.NONE)
private List<String>language;
private String commenttexttype;
@Setter(AccessLevel.NONE)
private String commentscript;
@Setter(AccessLevel.NONE)
private ObjectReference texttype;
@Setter(AccessLevel.NONE)
private String secinscription;
@Setter(AccessLevel.NONE)
private List<String> date;
@Setter(AccessLevel.NONE)
private List<String>origplace;
@Setter(AccessLevel.NONE)
Expand All @@ -56,24 +79,74 @@ public List<String> getBibliography() {
if (this.bibliography == null) {
this.bibliography = extractBibliography(this);
}
// System.out.println("First Sentence "+ getOneSentence());
return this.bibliography;
}
public List<String> getSkript() {

//TODO prüfen auf schematischeren Weg
public boolean isEmptyTextualMetadata(){
this.textualMetadata = extractString(this, "text.textual_metadata");
if (this.textualMetadata == null) { return true;}
else { return false;}
}

//TODO Check if generic function could replace extractLanguage
public ObjectReference getLanguage() {
if (this.language == null) {
this.language = extractObjectReference(this,PASSPORT_PROP_LANGUAGE);
}
return this.language;
}

//TODO Skript vs. Script vereinheitlichen mit details.html und Datenmodell
public ObjectReference getSkript() {
if (this.skript == null) {
this.skript = extractScript(this);
this.skript = extractObjectReference(this,PASSPORT_PROP_SCRIPT);
}
//System.out.println ("Skript "+this.skript.toString());
return this.skript;
}

public List<String> getLanguage() {
if (this.language == null) {
this.language = extractLanguage(this);
}

return this.language;
public String getEgytextname() {
if (this.egytextname == null) {
this.egytextname = extractString(this, PASSPORT_PROP_EGYTEXTNAME);
}
return this.egytextname;
}

public String getCommentlanguage() {
if(this.commentlanguage == null) {
this.commentlanguage = extractString(this, PASSPORT_PROP_COMMENTLANGUAGE);
}
return this.commentlanguage;
}

public String getCommenttexttype() {
if (this.commenttexttype == null) {
this.commenttexttype = extractString(this,PASSPORT_PROP_COMMENTTEXTTYPE);
}
return this.commenttexttype;
}

public String getCommentscript() {
if(this.commentscript == null) {
this.commentscript = extractString(this,PASSPORT_PROP_COMMENTSCRIPT );
}
return this.commentscript;
}

public ObjectReference getTexttype(){
if(this.texttype == null) {
this.texttype = extractObjectReference(this, PASSPORT_PROP_TEXTTYPE);
}
return this.texttype;
}

public String getSecinscription() {
if(this.secinscription == null) {
this.secinscription = extractString(this,PASSPORT_PROP_SECINSCRIPTION);
}
return this.secinscription;
}

public List<String> getOrigplace() {
if (this.origplace == null) {
this.origplace = extractOrigplace(this);
Expand Down Expand Up @@ -127,39 +200,55 @@ private static List<String> extractBibliography(Text text) {
}
return bibliography;
}
/* Extract Script von Passport */

private static List<String> extractScript(Text text) {
List<String> skript = new ArrayList<>();

//Extracts a single ObjectReference (Ths-Entry) from the first found passport according to searchString
private static ObjectReference extractObjectReference(Text text, String searchString) {
ObjectReference objectReference = null;
try {
List<Passport> pass= text.getPassport().extractProperty(PASSPORT_PROP_SCRIPT);
for(int i=0;i<pass.size();i++) {
skript.add(pass.get(i).extractObjectReferences().get(0).getName());
}


Passport pass= text.getPassport().extractProperty(searchString).get(0);
objectReference = pass.extractObjectReferences().get(0);
} catch (Exception e) {
System.out.println("could not extract script from text {} "+text.getId());
System.out.println("could not extract language from text {} "+text.getId());
}
return skript;
return objectReference;
}


private static List<String> extractLanguage(Text text) {
List<String> language = new ArrayList<>();
try {
List<Passport> pass= text.getPassport().extractProperty(PASSPORT_PROP_LANGUAGE);
for(int i=0;i<pass.size();i++) {
language.add(pass.get(i).extractObjectReferences().get(0).getName());

//Function to return a List of names form a passport Array
//TODO think of move to passport.java
private static List<String> extractNamesOfArray(Text text, String searchField) {
List<String> values = new ArrayList<>();
try {
List<Passport> pass= text.getPassport().extractProperty(searchField);
for(int i=0;i<pass.size();i++) {
values.add(pass.get(i).extractObjectReferences().get(0).getName());
}
} catch (Exception e) {
System.out.println("could not extract" + searchField + "from text {} "+text.getId());
}


} catch (Exception e) {
System.out.println("could not extract language from text {} "+text.getId());
return values;
}
return language;
}

//Function to return a string from passport. Takes value from element number position
//TODO think of move to passport.java
private static String extractString(Text text, String searchField, Integer number) {
String value = new String();
try {
List<Passport> pass = text.getPassport().extractProperty(searchField);
value = pass.get(number).toString();
}catch (Exception e) {
System.out.println("could not extract " + searchField + " from text {} "+text.getId());
}
return value;
}

//Function to return a string from passport with default number 0. Takes value from first element
private static String extractString(Text text, String searchField) {
return extractString( text, searchField, 0);
}



//TODO prüfen auf unnötig
private static String extractIsOrigPlace(Text text) {
String isOrigPl = new String();
try {
Expand All @@ -168,9 +257,7 @@ private static String extractIsOrigPlace(Text text) {
isOrigPl=pass.get(0).toString();
//System.out.println("isOrig "+ isOrigPl);
if (isOrigPl.equals("true")) isOrigPl="original";
else isOrigPl=null;


else isOrigPl=null;
} catch (Exception e) {
System.out.println("could not extract is orig place from text {} "+text.getId());isOrigPl=null;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/i18n/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ object_property_technique=Herstellungstechnik
object_property_condition=Zustand
object_property_materiality_comment=Kommentar zur Materialität

object_property_commentlanguage=Kommentar zur Sprache
object_property_commenttexttype=Kommentar zur Text-Kategorie
object_property_commentscript=Kommentar zur Schrift
object_property_texttype=Text-Kategorie
object_property_is_secinscription=Ist eine sekundäre Inschrift

object_property_aux_attestation_time_from=von
object_property_aux_attestation_time_to=bis
object_property_aux_attestation_time_bce=v.Chr.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ object_property_technique=Production technique
object_property_condition=Condition
object_property_materiality_comment=Comment on materiality

object_property_commentlanguage=Comment on language
object_property_commenttexttype=Comment on text category
object_property_commentscript=Comment on script
object_property_texttype=Text category
object_property_is_secinscription=Is a secondary inscription

object_property_aux_attestation_time_from=from
object_property_aux_attestation_time_to=to
object_property_aux_attestation_time_bce=BCE
Expand Down
70 changes: 60 additions & 10 deletions src/main/resources/templates/fragments/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,77 @@ <h2 class="id ml-3 mt-sm-1">
<!-- Script -->

<div class="textscript" th:fragment="textscript" id="textscript" th:unless="${#lists.isEmpty(obj.skript)}">
<hr/>
<hr/>
<p>
<strong th:text="#{object_property_script}" class="details-property-label">Script</strong>:
<span th:each="elem, elemStat : ${obj.skript}">
<span th:text="${elem}"></span><th:block th:unless="${elemStat.last}">, </th:block>
</span>
<strong th:text="#{object_property_script}" class="details-property-label">Skript</strong>:
<a th:href="${'/thesaurus/'+obj.getSkript.id}" th:text="${obj.getSkript.name}"></a>
</p>
</div>

<!-- Language -->
<!-- Comment on Script -->

<div class="textscript-comment" th:fragment="textscript-comment" id="textscript-comment" th:unless="${#lists.isEmpty(obj.Commentscript)}">
<hr th:if="${#lists.isEmpty(obj.skript)}"/>
<p>
<strong th:text="#{object_property_commentscript}" class="details-property-label">Comment on script</strong>:
<br/>
<span th:utext="${obj.getCommentscript}"></span>
</p>
</div>

<!-- Language -->

<div class="language" th:fragment="language" id="language" th:unless="${#lists.isEmpty(obj.language)}">
<hr th:if="${#lists.isEmpty(obj.skript)}"/>
<hr>
<p>
<strong th:text="#{object_property_language}" class="details-property-label">Language</strong>:
<span th:each="elem, elemStat : ${obj.language}">
<span th:text="${elem}"></span><th:block th:unless="${elemStat.last}">, </th:block>
</span>
<a th:href="${'/thesaurus/'+obj.getLanguage.id}" th:text="${obj.getLanguage.name}"></a>
</p>
</div>

<!-- Comment on Language -->

<div class="language-comment" th:fragment="language-comment" id="language-coomment" th:unless="${#lists.isEmpty(obj.Commentlanguage)}">
<hr th:if="${#lists.isEmpty(obj.language)}"/>
<p>
<strong th:text="#{object_property_commentlanguage}" class="details-property-label">Comment on language</strong>:
<br/>
<span th:utext="${obj.getCommentlanguage}"></span>
</p>
</div>

<!-- Texttype -->

<div class="texttype" th:fragment="texttype" id="texttype" th:unless="${#lists.isEmpty(obj.texttype)}">
<hr>
<p>
<strong th:text="#{object_property_texttype}" class="details-property-label">Texttype</strong>:
<a th:href="${'/thesaurus/'+obj.getTexttype.id}" th:text="${obj.getTexttype.name}"></a>
</p>
</div>


<!-- Comment on Texttype -->

<div class="texttype-comment" th:fragment="texttype-comment" id="texttype-coomment" th:unless="${#lists.isEmpty(obj.Commenttexttype)}">
<hr th:if="${#lists.isEmpty(obj.texttype)}"/>
<p>
<strong th:text="#{object_property_commenttexttype}" class="details-property-label">Comment on texttype</strong>:
<br/>
<span th:utext="${obj.getCommenttexttype}"></span>
</p>
</div>

<!-- Is secondary Inscription -->
<div class="is-secondary-inscription" th:fragment="is-secondary-inscription" id="is-secondary-inscription" th:unless="${#lists.isEmpty(obj.Secinscription)}">
<hr/>
<p>
<strong th:text="#{object_property_is_secinscription}" class="details-property-label">Is a secondary Inscription</strong>
</p>
</th:block>
</div>


<!-- Object type -->

<div class="object-type" th:fragment="object-type" id="object-type" th:if="${obj.objType}">
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/templates/text/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
<div th:replace="fragments/details :: property-pid('text', ${obj.id})"/>
<div th:replace="fragments/details :: object-property-type-subtype('object')"/>
<div th:replace="fragments/details :: synonyms"/>
<div th:replace="fragments/details :: is-secondary-inscription"/>
<div th:replace="fragments/details :: textscript"/>
<div th:replace="fragments/details :: textscript-comment"/>
<div th:replace="fragments/details :: language"/>
<div th:replace="fragments/details :: language-comment"/>
<div th:replace="fragments/details :: texttype"/>
<div th:replace="fragments/details :: texttype-comment"/>
<div th:replace="fragments/details :: date"/>
<div th:replace="fragments/details :: date-comment"/>
<div th:replace="fragments/details :: bibliography"/>
Expand Down

0 comments on commit 2edfacd

Please sign in to comment.