package com.gurkensalat.osm.entity;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "DITIB_PLACES")
public class DitibPlace extends OsmPlaceBase
{
    @Column(name = "D_CODE", length = 80)
    private String ditibCode;

    @Column(name = "GEOCODED")
    private boolean geocoded;

    @Column(name = "LAST_GEOCODE_ATTEMT")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime lastGeocodeAttemt;

    @Transient
    private String humanReadableLastGeocodeAttemt;


    protected DitibPlace()
    {
    }

    public DitibPlace(String key)
    {
        super();
        this.setKey(key);
        this.setAddress(new Address());
        this.setContact(new Contact());

        if (getCreationTime() == null)
        {
            setCreationTime(DateTime.now());
        }

        if (getModificationTime() == null)
        {
            setModificationTime(DateTime.now());
        }
    }

    public String getDitibCode()
    {
        return ditibCode;
    }

    public void setDitibCode(String ditibCode)
    {
        this.ditibCode = ditibCode;
    }

    public boolean isGeocoded()
    {
        return geocoded;
    }

    public void setGeocoded(boolean geocoded)
    {
        this.geocoded = geocoded;
    }

    public DateTime getLastGeocodeAttemt()
    {
        return lastGeocodeAttemt;
    }

    public void setLastGeocodeAttemt(DateTime lastGeocodeAttemt)
    {
        this.lastGeocodeAttemt = lastGeocodeAttemt;
    }

    public String getHumanReadableLastGeocodeAttemt()
    {
        return humanReadableLastGeocodeAttemt;
    }

    public void setHumanReadableLastGeocodeAttemt(String humanReadableLastGeocodeAttemt)
    {
        this.humanReadableLastGeocodeAttemt = humanReadableLastGeocodeAttemt;
    }

    public String toString()
    {
        return new ToStringBuilder(this).
                append("ditibCode", ditibCode).
                append("geocoded", geocoded).
                append("name", getName()).
                append("address", getAddress()).
                append("contact", getContact()).
                toString();
    }
}

@@ -551,16 +551,17 @@
 DE_ATTEM
+P
 T%22)%0A    
@@ -665,24 +665,25 @@
 GeocodeAttem
+p
 t;%0A%0A    @Tra
@@ -737,16 +737,17 @@
 odeAttem
+p
 t;%0A%0A%0A   
@@ -1533,32 +1533,33 @@
 LastGeocodeAttem
+p
 t()%0A    %7B%0A      
@@ -1575,32 +1575,33 @@
 lastGeocodeAttem
+p
 t;%0A    %7D%0A%0A    pu
@@ -1629,16 +1629,17 @@
 odeAttem
+p
 t(DateTi
@@ -1649,32 +1649,33 @@
 lastGeocodeAttem
+p
 t)%0A    %7B%0A       
@@ -1692,24 +1692,25 @@
 GeocodeAttem
+p
 t = lastGeoc
@@ -1709,32 +1709,33 @@
 lastGeocodeAttem
+p
 t;%0A    %7D%0A%0A    pu
@@ -1778,16 +1778,17 @@
 odeAttem
+p
 t()%0A    
@@ -1825,32 +1825,33 @@
 LastGeocodeAttem
+p
 t;%0A    %7D%0A%0A    pu
@@ -1892,16 +1892,17 @@
 odeAttem
+p
 t(String
@@ -1931,16 +1931,17 @@
 odeAttem
+p
 t)%0A    %7B
@@ -1983,16 +1983,17 @@
 odeAttem
+p
 t = huma
@@ -2017,16 +2017,17 @@
 odeAttem
+p
 t;%0A    %7D

Fix typo in attribute name