package com.faforever.api.data.domain;

import com.faforever.api.security.elide.permission.WriteMatchmakerMapCheck;
import com.yahoo.elide.annotation.CreatePermission;
import com.yahoo.elide.annotation.DeletePermission;
import com.yahoo.elide.annotation.Include;
import lombok.Setter;

import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@CreatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)
@DeletePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)
@Entity
@Setter
@Table(name = "matchmaker_queue_map_pool")
@Include(rootLevel = true, type = MatchmakerQueueMapPool.TYPE_NAME)
public class MatchmakerQueueMapPool extends AbstractEntity {

  public static final String TYPE_NAME = "matchmakerQueueMapPool";

  private MatchmakerQueue matchmakerQueue;
  private Double minRating;
  private Double maxRating;
  private MapPool mapPool;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "matchmaker_queue_id")
  public MatchmakerQueue getMatchmakerQueue() {
    return matchmakerQueue;
  }

  @Nullable
  @Column(name = "min_rating")
  public Double getMinRating() {
    return minRating;
  }

  @Nullable
  @Column(name = "max_rating")
  public Double getMaxRating() {
    return maxRating;
  }

  @OneToOne
  @JoinColumn(name = "map_pool_id")
  public MapPool getMapPool() {
    return mapPool;
  }
}

@@ -256,16 +256,68 @@
 nclude;%0A
+import com.yahoo.elide.annotation.UpdatePermission;%0A
 import l
@@ -1323,32 +1323,101 @@
 = %22min_rating%22)%0A
+  @UpdatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)%0A
   public Double 
@@ -1425,32 +1425,32 @@
 etMinRating() %7B%0A
-
     return minRa
@@ -1503,16 +1503,85 @@
 ating%22)%0A
+  @UpdatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)%0A
   public
@@ -1644,16 +1644,16 @@
 neToOne%0A
-
   @JoinC
@@ -1676,24 +1676,93 @@
 p_pool_id%22)%0A
+  @UpdatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)%0A
   public Map

Add @UpdatePermission to MatchmakerQueueMapPool