/**
 * Copyright (c) 2010 Red Hat, Inc.
 * 
 * This software is licensed to you under the GNU General Public License,
 * version 2 (GPLv2). There is NO WARRANTY for this software, express or
 * implied, including the implied warranties of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. You should have received a copy of GPLv2 along with this
 * software; if not, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 * 
 * Red Hat trademarks are not licensed under GPLv2. No permission is granted to
 * use or replicate Red Hat trademarks that are incorporated in this software or
 * its documentation.
 */
package net.openl10n.flies.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import net.openl10n.flies.common.LocaleId;
import net.openl10n.flies.model.type.LocaleIdType;

import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.validator.NotNull;

@Entity
@TypeDef(name = "localeId", typeClass = LocaleIdType.class)
public class HLocale extends AbstractFliesEntity implements Serializable
{
   private static final long serialVersionUID = 1L;
   private LocaleId localeId;
   private boolean active;
   private Set<HPerson> members;

   @NaturalId
   @NotNull
   @Type(type = "localeId")
   public LocaleId getLocaleId()
   {
      return localeId;
   }

   public void setLocaleId(LocaleId localeId)
   {
      this.localeId = localeId;
   }

   public boolean isActive()
   {
      return active;
   }

   public void setActive(boolean active)
   {
      this.active = active;
   }

   public HLocale()
   {

   }

   public HLocale(LocaleId localeId)
   {
      this.localeId = localeId;
   }

   @ManyToMany(fetch = FetchType.LAZY)
   @JoinTable(name = "HLocale_Member", joinColumns = @JoinColumn(name = "supportedLanguageId"), inverseJoinColumns = @JoinColumn(name = "personId"))
   public Set<HPerson> getMembers()
   {
      return members;
   }

   public void setMembers(Set<HPerson> members)
   {
      this.members = members;
   }

   public String retrieveNativeName()
   {
      FliesLocalePair fl = new FliesLocalePair(this.localeId);
      return fl.getuLocale().getDisplayName(fl.getuLocale());
   }

   public String retrieveDisplayName()
   {
      FliesLocalePair fl = new FliesLocalePair(this.localeId);
      return fl.getuLocale().getDisplayName();
   }

   @Override
   public int hashCode()
   {
      final int prime = 31;
      int result = super.hashCode();
      result = prime * result + ((localeId == null) ? 0 : localeId.hashCode());
      return result;
   }

   @Override
   public boolean equals(Object obj)
   {
      if (this == obj)
         return true;
      if (!super.equals(obj))
         return false;
      if (getClass() != obj.getClass())
         return false;
      HLocale other = (HLocale) obj;
      if (localeId == null)
      {
         if (other.localeId != null)
            return false;
      }
      else if (!localeId.equals(other.localeId))
         return false;
      return true;
   }

}

@@ -1,11 +1,10 @@
 /*
-*
 %0A * Copy
@@ -12,17 +12,14 @@
 ight
- (c)
  2010
+,
  Red
@@ -28,16 +28,178 @@
 at, Inc.
+ and individual contributors as indicated by the%0A * @author tags. See the copyright.txt file in the distribution for a full%0A * listing of individual contributors.
 %0A * %0A * 
@@ -203,24 +203,32 @@
  * This 
+is free 
 software
  is lice
@@ -223,160 +223,350 @@
 ware
- is licensed to you under the GNU General Public License,%0A * version 2 (GPLv2). There is NO WARRANTY for this software, express or%0A * implied, including
+; you can redistribute it and/or modify it under the%0A * terms of the GNU Lesser General Public License as published by the Free%0A * Software Foundation; either version 2.1 of the License, or (at your option)%0A * any later version.%0A * %0A * This software is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even
  the
@@ -581,19 +581,17 @@
  warrant
-ies
+y
  of MERC
@@ -616,17 +616,17 @@
 NESS
+%0A *
  FOR A
-%0A *
  PAR
@@ -646,48 +646,153 @@
 SE. 
-You should have received a copy of GPLv2
+See the GNU Lesser General Public License for more%0A * details.%0A * %0A * You should have received a copy of the GNU Lesser General Public License%0A *
  alo
@@ -803,19 +803,16 @@
 ith this
-%0A *
  softwar
@@ -826,251 +826,154 @@
 ot, 
-see http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.%0A * %0A * Red Hat trademarks are not licensed under GPLv2. No permission is granted to%0A * use or replicate Red Hat trademarks that are incorporated in this software or
+write to the Free Software Foundation,%0A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
 %0A * 
+s
 it
-s documentation
+e: http://www.fsf.org
 .%0A *

correct license info