(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / Language.java
index d223162282d82d39cacf0c6d401745a18114c141..d9a1ff8a0619e0614a4fa663ceb5556c6f566627 100644 (file)
@@ -17,6 +17,12 @@ import au.com.bytecode.opencsv.CSVWriter;
 import java.util.*;
 
 import javax.persistence.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 /**
  * list of languages according to current internet best practices as given by IANA
@@ -26,6 +32,8 @@ import javax.persistence.*;
  * @version 1.0
  * @created 08-Nov-2007 13:06:31
  */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Language")
 @Entity
 @Component
 public class Language extends DefinedTermBase {
@@ -44,6 +52,7 @@ public class Language extends DefinedTermBase {
        private static final UUID uuidItalian = UUID.fromString("fecbf0c7-fea9-465b-8a16-950517c5c0c4");
        private static final UUID uuidDutch = UUID.fromString("9965d79a-acf9-4921-a2c0-863b8c16c056");
        private static final UUID uuidPolish = UUID.fromString("3fdca387-f1b0-4ec1-808f-1bc3dc482194");
+       private static final UUID uuidLatin = UUID.fromString("160a5b6c-87f5-4422-9bda-78cd404c179e");
        
        public static Language NewInstance(){
                return new Language();
@@ -53,8 +62,9 @@ public class Language extends DefinedTermBase {
                return new Language(uuid);
        }
        
-       
+       @XmlAttribute(name = "iso639_1")
        private char[] iso639_1 = new char[2];
+       @XmlAttribute(name = "iso639_2")
        private char[] iso639_2 = new char[3];
        
        public Language() {
@@ -74,15 +84,19 @@ public class Language extends DefinedTermBase {
                }
                this.iso639_1=iso639_1;
                this.iso639_2=iso639_2;
-               this.addRepresentation(new Representation(englishLabel, String.valueOf(iso639_2), Language.ENGLISH()));
-               this.addRepresentation(new Representation(frenchLabel, String.valueOf(iso639_2), Language.FRENCH()));
+               String textEnglish = englishLabel;
+               String textFrench = englishLabel;
+               String label = String.valueOf(iso639_2);
+               String labelAbbrev = null;
+               this.addRepresentation(new Representation(textEnglish, label, labelAbbrev, Language.ENGLISH()));
+               this.addRepresentation(new Representation(textFrench, label, labelAbbrev, Language.FRENCH()));
        }
-       public Language(String text, String label, Language lang) {
+       public Language(String text, String label, String labelAbbrev, Language lang) {
                super();
-               this.addRepresentation(new Representation(text,label,lang));
+               this.addRepresentation(new Representation(text,label,labelAbbrev, lang));
        }
-       public Language(String label, String text) {
-               this(label,text, DEFAULT());
+       public Language(String label, String text, String labelAbbrev) {
+               this(label,text,labelAbbrev, DEFAULT());
        }
 
        public static final Language getByUuid(UUID uuid){
@@ -147,6 +161,10 @@ public class Language extends DefinedTermBase {
                return getByUuid(uuidPolish);
        }
        
+       public static final Language LATIN(){
+               return getByUuid(uuidLatin);
+       }
+       
        /**
         * Get the according iso639-1 alpha-2 language code 
         * http://www.loc.gov/standards/iso639-2/