Skip to content

Commit 359aac4

Browse files
authored
Merge pull request #603 from thesaurus-linguae-aegyptiae/object_labels_2
Vervollständigung Metadaten Textobjekte
2 parents e17e0ce + 9f523ce commit 359aac4

File tree

5 files changed

+339
-114
lines changed

5 files changed

+339
-114
lines changed

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

Lines changed: 162 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ private static List<String> extractBibliography(CorpusObject corpusobj) {
192192
public static final String PASSPORT_PROP_FINDSPOT = "find_spot.find_spot";
193193
public static final String PASSPORT_PROP_FINDSPOT_FORMERPLACE = "former_place";
194194
public static final String PASSPORT_PROP_FINDSPOT_PLACE = "place";
195-
196195

197196
@Setter(AccessLevel.NONE)
198197
private List<FindSpot> findspots;
@@ -218,6 +217,46 @@ public static String extractValue(Passport passport, String searchString) {
218217
}
219218
return result;
220219
}
220+
221+
public static ObjectReference extractThsEntry(Passport passport, String searchString) {
222+
ObjectReference result=null;
223+
try{
224+
result = passport.extractProperty(searchString).get(0).extractObjectReferences().get(0);
225+
}catch(Exception e) {
226+
System.out.println("INFO: Could not extract " + searchString);
227+
}
228+
return result;
229+
}
230+
231+
public static List<ObjectReference> extractThsEntries(Passport passport, String searchString) {
232+
List<ObjectReference> result = new ArrayList<ObjectReference>();
233+
try {
234+
result =passport.extractProperty(searchString).get(0).extractObjectReferences();
235+
}catch(Exception e) {
236+
System.out.println("INFO: Could not extract " + searchString);
237+
}
238+
return result;
239+
}
240+
241+
private static List<String> extractComment(Passport passport, String searchString) {
242+
List<String> comment = new ArrayList<>();
243+
try {
244+
passport.extractProperty(searchString).forEach(
245+
node -> comment.addAll(
246+
Arrays.asList(
247+
node.getLeafNodeValue().replaceAll("(\\r?\\n|^)[\\s\\-]+", "$1").replaceAll("\\r?\\n[\\r?\\n\\s]*", "||").split("\\|\\|")
248+
).stream().map(
249+
para -> para.strip()
250+
).collect(
251+
Collectors.toList()
252+
)
253+
)
254+
);
255+
} catch (Exception e) {
256+
System.out.println("INFO: Could not extract "+searchString);
257+
}
258+
return comment;
259+
}
221260

222261
public static ObjectReference extractObjectReference(Passport passport) {
223262
ObjectReference object=null;
@@ -234,16 +273,16 @@ public static class Place{
234273
public Place(Passport passport) {
235274
this.certainty = extractValue(passport, "certainty");
236275
this.comment = extractValue(passport, "comment");
237-
this.isorigin= Boolean.parseBoolean(extractValue(passport, "is_origin"));
276+
this.isorigin= extractValue(passport, "is_origin");
238277
this.place = extractObjectReference(passport);
239278
}
240279
private String certainty;
241280
private String comment;
242281

243-
private boolean isorigin;
282+
private String isorigin;
244283
private ObjectReference place;
245284

246-
public boolean getIsorigin() { //TODO Lombok
285+
public String getIsorigin() { //TODO Lombok
247286
return isorigin;
248287
}
249288

@@ -313,15 +352,15 @@ public static class Location{
313352
public Location(Passport passport) {
314353
this.comment = extractValue(passport, "comment");
315354
this.inventory_number = extractValueS(passport, "inventory_number");
316-
this.is_present_location = Boolean.parseBoolean(extractValue(passport, "is_present_location"));
317-
this.in_situ = Boolean.parseBoolean(extractValue(passport, "in_situ"));
355+
this.is_present_location = extractValue(passport, "is_present_location");
356+
this.in_situ = extractValue(passport, "in_situ");
318357
this.location = extractObjectReference(passport);
319358

320359
}
321360
private String comment;
322361
private List<String> inventory_number;
323-
private Boolean is_present_location;
324-
private Boolean in_situ;
362+
private String is_present_location;
363+
private String in_situ;
325364
private ObjectReference location;
326365

327366
}
@@ -419,13 +458,13 @@ private static List<String> extractProtocol(CorpusObject corpusobj) {
419458
@Getter
420459
public static class Description{
421460
Description(Passport passport){
422-
this.reconstructed = Boolean.parseBoolean(extractValue(passport, "reconstructed"));
461+
this.reconstructed = extractValue(passport, "reconstructed");
423462
this.protocol = extractValue(passport, "protocol");
424463
this.comment = extractValue(passport, "comment");
425464
this.definition = extractValue(passport, "definition");
426465
}
427-
private Boolean reconstructed;
428-
private String protocol;
466+
private String reconstructed;
467+
private String protocol;
429468
private String comment;
430469
private String definition;
431470

@@ -495,113 +534,160 @@ private static List<String> extractFileComment(CorpusObject corpusobj) {
495534
// Object description
496535
///////////////////////////
497536
public static final String PASSPORT_PROP_OBJ_MODEL= "object.description_of_object.model";
537+
private String isModel;
538+
public String getIsModel() {
539+
if (this.isModel == null) {
540+
this.isModel = extractValue(this.getPassport(), PASSPORT_PROP_OBJ_MODEL);
541+
}
542+
return this.isModel;
543+
}
544+
498545
public static final String PASSPORT_PROP_OBJ_IMITATION= "object.description_of_object.imitation";
546+
private String isImitation;
547+
public String getIsImitation() {
548+
if (this.isImitation == null) {
549+
this.isImitation = extractValue(this.getPassport(), PASSPORT_PROP_OBJ_IMITATION);
550+
}
551+
return this.isImitation;
552+
}
553+
499554
public static final String PASSPORT_PROP_OBJ_MINIATURE= "object.description_of_object.miniature";
555+
private String isMiniature;
556+
public String getIsMiniature() {
557+
if (this.isMiniature == null) {
558+
this.isMiniature = extractValue(this.getPassport(), PASSPORT_PROP_OBJ_MINIATURE);
559+
}
560+
return this.isMiniature;
561+
}
562+
500563
public static final String PASSPORT_PROP_OBJ_SKEUO= "object.description_of_object.skeuomorph";
564+
private String isSkeuomorph;
565+
public String getIsSkeuomorph() {
566+
if (this.isSkeuomorph == null) {
567+
this.isSkeuomorph = extractValue(this.getPassport(), PASSPORT_PROP_OBJ_SKEUO);
568+
}
569+
return this.isSkeuomorph;
570+
}
571+
501572
public static final String PASSPORT_PROP_OBJ_OWNER = "object.description_of_object.owner";
573+
private ObjectReference owner;
574+
public ObjectReference getOwner() {
575+
if (this.owner == null) {
576+
this.owner = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_OWNER);
577+
}
578+
return this.owner;
579+
}
580+
502581
public static final String PASSPORT_PROP_OBJ_DESCR = "object.description_of_object.description";
503582
public static final String PASSPORT_PROP_OBJ_COMMENT = "object.description_of_object.comment";
583+
504584
public static final String PASSPORT_PROP_OBJ_CONDITION = "object.technical_details.condition";
585+
private ObjectReference condition;
586+
public ObjectReference getCondition() {
587+
if (this.condition == null) {
588+
this.condition = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_CONDITION);
589+
}
590+
return this.condition;
591+
}
592+
505593
public static final String PASSPORT_PROP_OBJ_TECH = "object.technical_details.technique";
594+
private List<ObjectReference> technique;
595+
public List<ObjectReference> getTechnique() {
596+
if (this.technique == null) {
597+
this.technique = extractThsEntries(this.getPassport(), PASSPORT_PROP_OBJ_TECH);
598+
}
599+
return this.technique;
600+
}
601+
506602
public static final String PASSPORT_PROP_OBJ_TECH_COMMENT = "object.technical_details.comment";
507-
public static final String PASSPORT_PROP_OBJ_GROUPING = "object.description_of_object.context.grouping";
508-
public static final String PASSPORT_PROP_OBJ_CONTEXT = "object.description_of_object.context.context";
509-
public static final String PASSPORT_PROP_OBJ_ARCH_COMMENT = "object.description_of_object.context.comment";
603+
604+
@Setter(AccessLevel.NONE)
605+
private List<String> materialityComment;
606+
607+
public List<String> getMaterialityComment() {
608+
if (this.materialityComment == null) {
609+
this.materialityComment = extractComment(this.getPassport(), PASSPORT_PROP_OBJ_TECH_COMMENT);
610+
}
611+
return this.materialityComment;
612+
}
613+
614+
public static final String PASSPORT_PROP_OBJ_GROUPING = "object.archaeological_cultural_context_of_object.grouping";
615+
616+
@Setter(AccessLevel.NONE)
617+
private ObjectReference grouping;
618+
619+
public ObjectReference getGrouping() {
620+
if (this.grouping == null) {
621+
this.grouping = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_GROUPING);
622+
}
623+
return this.grouping;
624+
}
625+
626+
public static final String PASSPORT_PROP_OBJ_CONTEXT = "object.archaeological_cultural_context_of_object.cultural_context";
627+
628+
@Setter(AccessLevel.NONE)
629+
private List<ObjectReference> culturalContext;
630+
631+
public List<ObjectReference> getCulturalContext() {
632+
if (this.culturalContext == null) {
633+
this.culturalContext = extractThsEntries(this.getPassport(), PASSPORT_PROP_OBJ_CONTEXT);
634+
}
635+
return this.culturalContext;
636+
}
637+
638+
public static final String PASSPORT_PROP_OBJ_ARCH_COMMENT = "object.archaeological_cultural_context_of_object.comment";
639+
640+
@Setter(AccessLevel.NONE)
641+
private List<String> contextComment;
642+
643+
public List<String> getContextComment() {
644+
if (this.contextComment == null) {
645+
this.contextComment = extractComment(this.getPassport(), PASSPORT_PROP_OBJ_ARCH_COMMENT);
646+
}
647+
return this.contextComment;
648+
}
510649

511650
// Object type
512651

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

515654
@Setter(AccessLevel.NONE)
516-
private List<String> objType;
655+
private ObjectReference objType;
517656

518-
public List<String> getObjType() {
657+
public ObjectReference getObjType() {
519658
if (this.objType == null) {
520-
this.objType = extractObjType(this);
659+
this.objType = extractThsEntry(this.getPassport(), PASSPORT_PROP_OBJ_TYPE);
521660
}
522661
return this.objType;
523662
}
524-
525-
private static List<String> extractObjType(CorpusObject corpusobj) {
526-
List<String> objType = new ArrayList<String>();
527-
try {
528-
529-
List<Passport> objTypePassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_OBJ_TYPE);
530-
531-
for(int i=0;i<objTypePassports.size();i++) {
532-
for(int j=0;j<objTypePassports.get(i).extractObjectReferences().size();j++) {
533-
534-
objType.add(objTypePassports.get(i).extractObjectReferences().get(j).getName());
535-
}
536-
}
537-
} catch (Exception e) {
538-
System.out.println("INFO: Could not extract object type from object "+corpusobj.getId());
539-
}
540-
return objType;
541-
}
542663

543664
// Object component
544665

545666
public static final String PASSPORT_PROP_OBJ_COMPONENT = "object.description_of_object.component";
546667

547668
@Setter(AccessLevel.NONE)
548-
private List<String> components;
669+
private List<ObjectReference> components;
549670

550-
public List<String> getComponents() {
671+
public List<ObjectReference> getComponents() {
551672
if (this.components == null) {
552-
this.components = extractComponents(this);
673+
this.components = extractThsEntries(this.getPassport(), PASSPORT_PROP_OBJ_COMPONENT);
553674
}
554675
return this.components;
555676
}
556-
557-
private static List<String> extractComponents(CorpusObject corpusobj) {
558-
List<String> components = new ArrayList<String>();
559-
try {
560-
561-
List<Passport> componentsPassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_OBJ_COMPONENT);
562-
563-
for(int i=0;i<componentsPassports.size();i++) {
564-
for(int j=0;j<componentsPassports.get(i).extractObjectReferences().size();j++) {
565-
566-
components.add(componentsPassports.get(i).extractObjectReferences().get(j).getName());
567-
}
568-
}
569-
} catch (Exception e) {
570-
System.out.println("INFO: Could not extract components from object "+corpusobj.getId());
571-
}
572-
return components;
573-
}
574677

575678
// Material
576679

577680
public static final String PASSPORT_PROP_OBJ_MATERIAL = "object.technical_details.material";
578681

579682
@Setter(AccessLevel.NONE)
580-
private List<String> materials;
683+
private List<ObjectReference> materials;
581684

582-
public List<String> getMaterials() {
685+
public List<ObjectReference> getMaterials() {
583686
if (this.materials == null) {
584-
this.materials = extractMaterials(this);
687+
this.materials = extractThsEntries(this.getPassport(), PASSPORT_PROP_OBJ_MATERIAL);
585688
}
586689
return this.materials;
587690
}
588-
589-
private static List<String> extractMaterials(CorpusObject corpusobj) {
590-
List<String> materials = new ArrayList<String>();
591-
try {
592-
593-
List<Passport> materialsPassports =corpusobj.getPassport().extractProperty(PASSPORT_PROP_OBJ_MATERIAL);
594-
595-
for(int i=0;i<materialsPassports.size();i++) {
596-
for(int j=0;j<materialsPassports.get(i).extractObjectReferences().size();j++) {
597-
materials.add(materialsPassports.get(i).extractObjectReferences().get(j).getName());
598-
}
599-
}
600-
} catch (Exception e) {
601-
System.out.println("INFO: Could not extract materials from object "+corpusobj.getId());
602-
}
603-
return materials;
604-
}
605691

606692
// Dimensions
607693

src/main/resources/i18n/messages_de.properties

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ object_property_dimensions=Maße (H×B(×T))
283283
object_property_origplace=Fundort
284284
object_property_formerplace=Frühere(r) Ort(e)
285285
object_property_certainty=Gewissheit
286-
object_property_isorigplace=Ist ursprünglicher Nutzungsort
286+
object_property_isorigplace=Ist der ursprünglicher Nutzungsort
287287
object_property_yes=Ja
288288
object_property_no=Nein
289289
object_property_in_situ=Ist <i>in situ</i>
@@ -294,11 +294,22 @@ object_property_inv_nos=Inventarnummer(n)
294294
object_property_inv_no=Inventarnummer(n)
295295
object_property_objecttype=Objekttyp
296296
object_property_components=Komponenten
297+
object_property_is_model=Ist ein Model
298+
object_property_is_imitation=Ist eine Imitation
299+
object_property_is_miniature=Ist eine Miniatur
300+
object_property_is_skeuomorph=Ist ein Skeuomorph
297301
object_property_protocol=Datensatz-Protokoll
298302
object_property_description=Beschreibung
299303
object_property_reconstructed=Ist rekonstruiert
300304
object_property_file_comment=Datensatz-Kommentar
301305
object_property_synonyms=Weitere Bezeichnungen
306+
object_property_owner=Besitzer
307+
object_property_context=Kultureller Kontext
308+
object_property_context_comment=Kommentar zum kulturellen Kontext
309+
object_property_grouping=Gruppierung
310+
object_property_technique=Herstellungstechnik
311+
object_property_condition=Zustand
312+
object_property_materiality_comment=Kommentar zur Materialität
302313

303314
object_property_aux_attestation_time_from=von
304315
object_property_aux_attestation_time_to=bis

0 commit comments

Comments
 (0)