package de.ddb.pdc.metadata;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;

@JsonIgnoreProperties(ignoreUnknown = true)
class EntitiesResultItem {

  private String preferredName;
  @JsonProperty("dateOfBirth_de")
  private String dateOfBirth;
  @JsonProperty("dateOfDeath_de")
  private String dateOfDeath;
  private ArrayList<String> placeOfBirth;

  public String getName() {
    return preferredName;
  }

  public int getYearOfBirth() {
    if (dateOfBirth == null) {
      return -1;
    }
    return Integer.parseInt(dateOfBirth.split(" ")[2]);
  }

  public int getYearOfDeath() {
    if (dateOfDeath == null) {
      return -1;
    }
    return Integer.parseInt(dateOfDeath.split(" ")[2]);
  }

  public String getPlaceOfBirth() {
    return placeOfBirth.get(0);
  }
}

@@ -531,24 +531,61 @@
 OfBirth() %7B%0A
+    System.out.println(dateOfBirth);%0A
     if (date
@@ -634,203 +634,308 @@
     
-return Integer.parseInt(dateOfBirth.split(%22 %22)%5B2%5D);%0A  %7D%0A%0A  public int getYearOfDeath() %7B%0A    if (dateOfDeath == null) %7B%0A      return -1;%0A    %7D%0A    return Integer.parseInt(dateOfDeath.split(%22 %22)%5B2
+String%5B%5D splitDob = dateOfBirth.split(%22 %22);%0A%0A    return Integer.parseInt(splitDob%5BsplitDob.length - 1%5D);%0A  %7D%0A%0A  public int getYearOfDeath() %7B%0A    if (dateOfDeath == null) %7B%0A      return -1;%0A    %7D%0A    String%5B%5D splitDod = dateOfDeath.split(%22 %22);%0A    return Integer.parseInt(splitDod%5BsplitDod.length - 1
 %5D);%0A
@@ -971,24 +971,58 @@
 OfBirth() %7B%0A
+    if (placeOfBirth != null) %7B%0A  
     return p
@@ -1041,14 +1041,37 @@
 get(0);%0A
+    %7D%0A    return null;%0A
   %7D%0A%7D%0A

change death and birthYear because of differed ddb formats