/*
 *
 *  * (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.mano.record.Status;
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;
  private String msVnfrId;

  private Status status;

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

  @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  private Set<Host> hosts;

  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 Status getStatus() {
    return status;
  }

  public void setStatus(Status status) {
    this.status = status;
  }

  public Set<Host> getHosts() {
    return hosts;
  }

  public void setHosts(Set<Host> hosts) {
    this.hosts = hosts;
  }

  //  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 + '\'' +
            ", msVnfrId='" + msVnfrId + '\'' +
            ", status=" + status +
            ", hosts=" + hosts +
            '}';
  }

  public String getMsVnfrId() {
    return msVnfrId;
  }

  public void setMsVnfrId(String msVnfrId) {
    this.msVnfrId = msVnfrId;
  }
}

@@ -2385,29 +2385,25 @@
 rGroup%7B%22
- +%0A  
+%0A
         
   %22id='%22
@@ -2398,30 +2398,44 @@
     
- 
++
  %22id='%22
- + id
+%0A        + id%0A       
  + '%5C''
- +
 %0A   
@@ -2435,27 +2435,25 @@
 %5C''%0A        
-   
++
  %22, nsdID='%22
@@ -2456,25 +2456,39 @@
 D='%22
- + nsdID
+%0A        + nsdID%0A       
  + '%5C''
- +
 %0A   
@@ -2488,27 +2488,25 @@
 %5C''%0A        
-   
++
  %22, nsrID='%22
@@ -2509,35 +2509,48 @@
 D='%22
- + nsrID
+%0A        + nsrID%0A       
  + '%5C''
- +%0A 
+%0A
         
    %22
@@ -2541,26 +2541,25 @@
 %5C''%0A        
-  
++
  %22, msVnfrId
@@ -2561,16 +2561,24 @@
 nfrId='%22
+%0A       
  + msVnf
@@ -2584,17 +2584,23 @@
 frId
+%0A       
  + '%5C''
- +
 %0A   
@@ -2600,27 +2600,25 @@
 %5C''%0A        
-   
++
  %22, status=%22
@@ -2617,16 +2617,24 @@
 status=%22
+%0A       
  + statu
@@ -2634,30 +2634,25 @@
 + status
- +%0A   
+%0A
         
  %22, host
@@ -2643,16 +2643,17 @@
         
++
  %22, host
@@ -2659,16 +2659,24 @@
 ts=%22
+%0A       
  + hosts
  +%0A 
@@ -2671,18 +2671,16 @@
  + hosts
- +
 %0A       
@@ -2680,19 +2680,17 @@
         
-   
++
  '%7D';%0A  

reformat class