/*
 *
 *  * (C) Copyright 2016 NUBOMEDIA (http://www.nubomedia.eu)
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  *   http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *  *
 *
 */

package org.project.openbaton.nubomedia.paas.model.persistence.openbaton;

import org.openbaton.catalogue.util.IdGenerator;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by maa on 21.10.15.
 */
@Entity
public class MediaServerGroup {

  @Id private String id;
  private String nsdID;
  private String nsrID;

  @ElementCollection(fetch = FetchType.EAGER)
  private Set<String> floatingIPs;

  @ElementCollection(fetch = FetchType.EAGER)
  private Set<String> hostnames;

  public MediaServerGroup() {}

  @PrePersist
  public void ensureId() {
    id = IdGenerator.createUUID();
  }

  public String getId() {
    return id;
  }

  public String getNsdID() {
    return nsdID;
  }

  public void setNsdID(String nsdID) {
    this.nsdID = nsdID;
  }

  public String getNsrID() {
    return nsrID;
  }

  public void setNsrID(String nsrID) {
    this.nsrID = nsrID;
  }

  public Set<String> getFloatingIPs() {
    return floatingIPs;
  }

  public void setFloatingIPs(Set<String> floatingIPs) {
    this.floatingIPs = floatingIPs;
  }

  public Set<String> getHostnames() {
    return hostnames;
  }

  public void setHostnames(Set<String> hostnames) {
    this.hostnames = hostnames;
  }

  @Override
  public String toString() {
    return "MediaServerGroup{"
        + "id='"
        + id
        + '\''
        + ", nsdID='"
        + nsdID
        + '\''
        + ", nsrID='"
        + nsrID
        + '\''
        + ", floatingIPs="
        + floatingIPs
        + ", hostnames="
        + hostnames
        + '}';
  }
}

@@ -741,16 +741,67 @@
 baton;%0A%0A
+import org.openbaton.catalogue.mano.record.Status;%0A
 import o
@@ -1047,16 +1047,46 @@
 nsrID;%0A%0A
+  private Status status;%0A%0A  //
   @Eleme
@@ -1115,32 +1115,36 @@
 etchType.EAGER)%0A
+  //
   private Set%3CSt
@@ -1166,34 +1166,53 @@
 Ps;%0A%0A  @
-ElementCollection(
+OneToMany(cascade = CascadeType.ALL, 
 fetch = 
@@ -1242,32 +1242,26 @@
 ate Set%3C
-String
+Host
 %3E host
-name
 s;%0A%0A  pu
@@ -1647,32 +1647,288 @@
 D = nsrID;%0A  %7D%0A%0A
+  public Status getStatus() %7B%0A    return status;%0A  %7D%0A%0A  public void setStatus(Status status) %7B%0A    this.status = status;%0A  %7D%0A%0A  public Set%3CHost%3E getHosts() %7B%0A    return hosts;%0A  %7D%0A%0A  public void setHosts(Set%3CHost%3E hosts) %7B%0A    this.hosts = hosts;%0A  %7D%0A%0A  //
   public Set%3CStr
@@ -1948,27 +1948,31 @@
 ingIPs() %7B%0A 
+ //
    
+ 
 return float
@@ -1973,35 +1973,47 @@
  floatingIPs;%0A  
-%7D%0A%0A
+//  %7D%0A  //%0A  //
   public void se
@@ -2048,24 +2048,28 @@
 atingIPs) %7B%0A
+  //
     this.flo
@@ -2090,27 +2090,39 @@
 atingIPs;%0A  
-%7D%0A%0A
+//  %7D%0A  //%0A  //
   public Set
@@ -2143,24 +2143,28 @@
 stnames() %7B%0A
+  //
     return h
@@ -2171,27 +2171,39 @@
 ostnames;%0A  
-%7D%0A%0A
+//  %7D%0A  //%0A  //
   public voi
@@ -2238,24 +2238,28 @@
 ostnames) %7B%0A
+  //
     this.hos
@@ -2278,16 +2278,20 @@
 tnames;%0A
+  //
   %7D%0A%0A  @
@@ -2523,26 +2523,21 @@
    + %22, 
-floatingIP
+statu
 s=%22%0A    
@@ -2542,26 +2542,21 @@
       + 
-floatingIP
+statu
 s%0A      
@@ -2566,20 +2566,16 @@
  %22, host
-name
 s=%22%0A    
@@ -2584,20 +2584,16 @@
   + host
-name
 s%0A      

Add host to MediaServerGroup