Skip to content

Commit

Permalink
More object metadata; file creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerning committed Jul 8, 2023
2 parents daf8279 + 66dbc25 commit 43e5929
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 31 deletions.
118 changes: 102 additions & 16 deletions src/main/java/tla/web/model/CorpusObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,56 @@ public class CorpusObject extends BTSObject implements Hierarchic {

public static final String PASSPORT_PROP_BIBL = "bibliography.bibliographical_text_field";
public static final String PASSPORT_PROP_DATE = "date.date.date";
public static final String PASSPORT_PROP_PRESLOC = "present_location.location.location";
public static final String PASSPORT_PROP_ORIGIN = "find_spot.find_spot.place.place";
public static final String PASSPORT_PROP_OBJTYPE = "object.description_of_object.type";

@Setter(AccessLevel.NONE)
private List<String> bibliography;
@Setter(AccessLevel.NONE)
private List<String> date;
@Setter(AccessLevel.NONE)
private List<String> locations;
@Setter(AccessLevel.NONE)
private List<String> origin;
@Setter(AccessLevel.NONE)
private List<String> objType;

public List<String> getBibliography() {
if (this.bibliography == null) {
this.bibliography = extractBibliography(this);
}
return this.bibliography;
}

public List<String> getLocations() {
if (this.locations == null) {
this.locations = extractLocations(this);
}
return this.locations;
}

public List<String> getOrigin() {
if (this.origin == null) {
this.origin = extractOrigin(this);
}
return this.origin;
}

public List<String> getObjType() {
if (this.objType == null) {
this.objType = extractObjType(this);
}
return this.objType;
}

public List<String> getDate() {
if (this.date == null) {
this.date = extractDate(this);
}
return this.date;
}

/**
* Extract bibliographic information from coprus object passport.
*
Expand All @@ -67,37 +106,84 @@ private static List<String> extractBibliography(CorpusObject corpusobj) {
)
);
} catch (Exception e) {
System.out.println("could not extract bibliography from object {} "+corpusobj.getId());
System.out.println("INFO: Could not extract bibliography from object "+corpusobj.getId());
}
return bibliography;
}

private static List<String> extractDate(CorpusObject corpus) {
List<String> datierung = new ArrayList<String>();
private static List<String> extractLocations(CorpusObject corpusobj) {
List<String> locations = new ArrayList<String>();
try {

List<Passport> dates =corpus.getPassport().extractProperty(PASSPORT_PROP_DATE);
List<Passport> locationsPassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_PRESLOC);

for(int i=0;i<dates.size();i++) {
for(int j=0;j<dates.get(i).extractObjectReferences().size();j++) {
for(int i=0;i<locationsPassports.size();i++) {
for(int j=0;j<locationsPassports.get(i).extractObjectReferences().size();j++) {

datierung.add(dates.get(i).extractObjectReferences().get(j).getName());
locations.add(locationsPassports.get(i).extractObjectReferences().get(j).getName());
}
}

} catch (Exception e) {
// log.debug("could not extract date from text {}", text.getId());
System.out.println("could not extract date from object ");
System.out.println("INFO: Could not extract locations from object "+corpusobj.getId());
}
return datierung;
return locations;
}


public List<String> getDate() {
if (this.date == null) {
this.date = extractDate(this);
private static List<String> extractOrigin(CorpusObject corpusobj) {
List<String> origin = new ArrayList<String>();
try {

List<Passport> findSpotPassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_ORIGIN);

for(int i=0;i<findSpotPassports.size();i++) {
for(int j=0;j<findSpotPassports.get(i).extractObjectReferences().size();j++) {

origin.add(findSpotPassports.get(i).extractObjectReferences().get(j).getName());
}
}
} catch (Exception e) {
System.out.println("INFO: Could not extract find spot (origin) from object "+corpusobj.getId());
}
return this.date;
return origin;
}

private static List<String> extractObjType(CorpusObject corpusobj) {
List<String> objType = new ArrayList<String>();
try {

List<Passport> objTypePassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_OBJTYPE);

for(int i=0;i<objTypePassports.size();i++) {
for(int j=0;j<objTypePassports.get(i).extractObjectReferences().size();j++) {

objType.add(objTypePassports.get(i).extractObjectReferences().get(j).getName());
}
}
} catch (Exception e) {
System.out.println("INFO: Could not extract object type from object "+corpusobj.getId());
}
return objType;
}

private static List<String> extractDate(CorpusObject corpusobj) {
List<String> dates = new ArrayList<String>();
try {

List<Passport> datesPassport =corpusobj.getPassport().extractProperty(PASSPORT_PROP_DATE);

for(int i=0;i<datesPassport.size();i++) {
for(int j=0;j<datesPassport.get(i).extractObjectReferences().size();j++) {

dates.add(datesPassport.get(i).extractObjectReferences().get(j).getName());
}
}

} catch (Exception e) {
System.out.println("INFO: Could not extract date from object "+corpusobj.getId());
}
return dates;
}



}
7 changes: 5 additions & 2 deletions src/main/resources/i18n/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ object_property_editors_author=Autor:innen
object_property_editors_editor=Editor:innen
object_property_editors_author_commentary=Autor:in des Kommentars
object_property_editors=unter Mitarbeit von
object_property_editors_updated=Letzte Revision
object_property_editors_created=Datensatz erstellt
object_property_editors_updated=letzte Revision
object_property_review_state=Redaktionsstatus
object_property_annotations=Kommentare
object_property_annotation=Kommentar
Expand All @@ -279,6 +280,7 @@ object_property_language=Sprache
object_property_origplace=Fundort
object_property_isorigplace=ist auch ursprünglicher Nutzungsort
object_property_presentlocation=Aktueller Ort
object_property_objecttype=Objekttyp

object_property_aux_attestation_time_from=von
object_property_aux_attestation_time_to=bis
Expand Down Expand Up @@ -523,7 +525,8 @@ button_label_hide_property_dating=Datierung
button_label_hide_property_texteditor=Text-Editor:innen
sentence_main_editor=Autor:innen
sentence_contributors=unter Mitarbeit von
sentence_latest_access=letzte Textänderung
sentence_created=Textdatensatz erstellt am
sentence_latest_access=letzte Änderung
sentence_date=Datierung
sentence_variants1=Eine von
sentence_variants2=Lesevarianten dieses Satzes
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ object_property_editors_author=Author(s)
object_property_editors_editor=Editor(s)
object_property_editors_author_commentary=Commentary author
object_property_editors=with contributions by
object_property_editors_updated=Latest revision
object_property_editors_created=Data file created
object_property_editors_updated=latest revision
object_property_review_state=Editorial state
object_property_annotations=Comments
object_property_annotation=Comment
Expand All @@ -279,6 +280,7 @@ object_property_language=Language
object_property_origplace=Finding place
object_property_isorigplace=is also original place of use
object_property_presentlocation=Current location
object_property_objecttype=Object type

object_property_aux_attestation_time_from=from
object_property_aux_attestation_time_to=to
Expand Down Expand Up @@ -522,7 +524,8 @@ button_label_hide_property_dating=Dating of Text
button_label_hide_property_texteditor=Text editor
sentence_main_editor=Author(s)
sentence_contributors=with contributions by
sentence_latest_access=latest changes to text
sentence_created=Text data file created
sentence_latest_access=latest changes
sentence_date=Dating (time frame)
sentence_variants1=One of
sentence_variants2=reading variants of this sentence
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/fragments/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ <h5 class="modal-title" id="exampleModalLongTitle" th:text="#{modal_share_title}
<span th:each="contributor, nr : *{getEdited.contributors}" th:utext="${nr.first} ? ${contributor} : ', ' + ${contributor}"/>
</span>
<!-- fehlt hier: <span th:text="#{|review_state_${obj.reviewState}|}">status</span>-->
<span th:utext="' (' + #{sentence_latest_access} + ': ' + ${#calendars.format(obj.edited.updated, formatter)} + ')'" />
<span th:utext="' (' + #{sentence_created} + ': ' + ${#calendars.format(obj.edited.created, formatter)} + ', ' + #{sentence_latest_access} + ': ' + ${#calendars.format(obj.edited.updated, formatter)} + ')'" />
</span>
</div>

Expand Down
35 changes: 27 additions & 8 deletions src/main/resources/templates/fragments/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,29 @@ <h2 class="id ml-3 mt-sm-1">
</span>
</p>
</div>

<!-- Object type -->

<div class="object-type" th:fragment="object-type" id="object-type" th:unless="${#lists.isEmpty(obj.objType)}">
<hr/>

<p>
<strong th:text="#{object_property_objecttype}" class="details-property-label">Original place</strong>:
<span th:each="otype, otypeStat : ${obj.objType}">
<span th:text="${otype}"></span>
<span th:unless="${otypeStat.last}">, </span>
</span>
</p>
</div>

<!-- Original place -->

<div class="origplace" th:fragment="origplace" id="origplace" th:unless="${#lists.isEmpty(obj.origplace)}">
<div class="origin" th:fragment="origin" id="origin" th:unless="${#lists.isEmpty(obj.origin)}">
<hr/>

<p>
<strong th:text="#{object_property_origplace}" class="details-property-label">Original place</strong>:
<span th:each="orig, origStat : ${obj.origplace}">
<span th:each="orig, origStat : ${obj.origin}">
<span th:text="${orig}"></span>
<!-- to be discussed what this info means (label)
<span th:if="${obj.isorig !=null}" class="details-property-label" th:text="'('+#{object_property_isorigplace}+')'">
Expand All @@ -151,14 +166,14 @@ <h2 class="id ml-3 mt-sm-1">
</p>
</div>

<!-- present location -->
<!-- present location -->

<div class="presloc" th:fragment="presloc" id="presloc" th:unless="${#lists.isEmpty(obj.presloc)}">
<div class="present-location" th:fragment="present-location" id="present-location" th:unless="${#lists.isEmpty(obj.locations)}">
<hr/>

<p>
<strong th:text="#{object_property_presentlocation}" class="details-property-label">Present Location</strong>:
<span th:each="ploc, plocStat : ${obj.presloc}">
<span th:each="ploc, plocStat : ${obj.locations}">
<span th:text="${ploc}"></span>
<span th:unless="${plocStat.last}">, </span>
</span>
Expand Down Expand Up @@ -232,7 +247,9 @@ <h2 class="id ml-3 mt-sm-1">
<span class="details-property-label" th:text="#{object_property_editors_author_commentary}">Commentary author</span>:
<span th:text="${annotation.edited.author}">author</span>,
</th:block>
<span class="details-property-label" th:text="#{object_property_editors_updated}">Latest revision</span>:
<span class="details-property-label" th:text="#{object_property_editors_created}">File created</span>:
<span th:text="${#calendars.format(annotation.edited.created, formatter)}">xx.xx.20xx</span>,
<span class="details-property-label" th:text="#{object_property_editors_updated}">latest revision</span>:
<span th:text="${#calendars.format(annotation.edited.updated, formatter)}">xx.xx.20xx</span>
</p>
</div>
Expand All @@ -256,8 +273,10 @@ <h2 class="id ml-3 mt-sm-1">
</span>
</div>
<div class="updated" th:with="formatter=#{date_formatter}">
<strong class="details-property-label" th:text="#{object_property_editors_updated}">Latest revision</strong>:
<span th:text="${#calendars.format(obj.edited.updated, formatter)}">date</span>
<strong class="details-property-label" th:text="#{object_property_editors_created}">File created</strong>:
<span th:text="${#calendars.format(obj.edited.created, formatter)}">xx.xx.20xx</span>,
<strong class="details-property-label" th:text="#{object_property_editors_updated}">latest revision</strong>:
<span th:text="${#calendars.format(obj.edited.updated, formatter)}">xx.xx.20xx</span>
</div>
</th:block>
<div class="review-state">
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/templates/object/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

<div th:replace="fragments/details :: property-pid('object')"/>
<div th:replace="fragments/details :: object-property-type-subtype('object')"/>
<div th:replace="fragments/details :: object-type"/>
<div th:replace="fragments/details :: present-location"/>
<div th:replace="fragments/details :: origin"/>
<div th:replace="fragments/details :: date"/>

<div th:replace="fragments/details :: bibliography"/>
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/templates/text/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
<div th:replace="fragments/details :: date"/>
<div th:replace="fragments/details :: textscript"/>
<div th:replace="fragments/details :: language"/>
<div th:replace="fragments/details :: origplace"/>
<div th:replace="fragments/details :: presloc"/>
<div th:replace="fragments/details :: bibliography"/>
<div th:replace="fragments/details :: external-references"/>
<div th:replace="fragments/details :: object-property-object-paths('ths')"/>
Expand Down

0 comments on commit 43e5929

Please sign in to comment.