package fr.insee.rmes.modeles.operations.documentations;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;

import fr.insee.rmes.config.Configuration;
import fr.insee.rmes.modeles.StringWithLang;
import fr.insee.rmes.utils.Lang;

@JsonClassDescription("Objet représentant un document ou un lien vers une page internet")
public class Document {
    private List<StringWithLang> label = new ArrayList<>();
    private String dateMiseAJour;
    private String langue;
    private String url;

    @JacksonXmlProperty(localName = "label")
    @JacksonXmlElementWrapper(useWrapping = false)
    public List<StringWithLang> getLabel() {
        return label;
    }

    public void setLabelLg1(String labelLg1) {
        label.add(new StringWithLang(labelLg1, Lang.FR));
    }

    public void setLabelLg2(String labelLg2) {
        if (StringUtils.isNotEmpty(labelLg2)) {
            label.add(new StringWithLang(labelLg2, Lang.EN));
        }
    }

    public String getDateMiseAJour() {
        return dateMiseAJour;
    }

    public void setDateMiseAJour(String dateMiseAJour) {
        this.dateMiseAJour = dateMiseAJour;
    }

    public String getLangue() {
        return langue;
    }

    public void setLangue(String langue) {
        this.langue = langue;
    }

    public String getUrl() {
        if (url != null && url.contains(Configuration.getFileStorage())) {
            String[] temp = url.split(Configuration.getFileStorage());
            return temp[temp.length - 1];
        }
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

	@Override
	public int hashCode() {
		return Objects.hash(dateMiseAJour, label, langue, url);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Document other = (Document) obj;
		return Objects.equals(dateMiseAJour, other.dateMiseAJour) && Objects.equals(label, other.label)
				&& Objects.equals(langue, other.langue) && Objects.equals(url, other.url);
	}

}

@@ -813,17 +813,17 @@
 Name = %22
-l
+L
 abel%22)%0A 
@@ -1224,32 +1224,90 @@
        %7D%0A    %7D%0A%0A
+    %0A    @JacksonXmlProperty(localName = %22DateMiseAJour%22)%0A
     public Strin
@@ -1466,32 +1466,78 @@
 seAJour;%0A    %7D%0A%0A
+    @JacksonXmlProperty(localName = %22Langue%22)%0A
     public Strin
@@ -1654,32 +1654,75 @@
  langue;%0A    %7D%0A%0A
+    @JacksonXmlProperty(localName = %22Url%22)%0A
     public Strin

Fix minor issue