package org.project.neutrino.nfvo.catalogue.nfvo;

import org.project.neutrino.nfvo.catalogue.util.IdGenerator;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lto on 20/05/15.
 */
@Entity
public class Network {
    @Id
    private String id = IdGenerator.createUUID();
    @Version
    private int version = 0;
    private String name;
    private String extId;
    private String networkType;
    private Boolean external;
    private Boolean shared;
    @ElementCollection(fetch = FetchType.EAGER)
    private List<String> subnets;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setExtId(String extId) {
        this.extId = extId;
    }

    public String getExtId() {
        return extId;
    }

    public void setNetworkType(String networkType) {
        this.networkType = networkType;
    }

    public String getNetworkType() {
        return networkType;
    }

    public void setExternal(Boolean external) {
        this.external = external;
    }

    public Boolean getExternal() {
        return external;
    }

    public void setShared(Boolean shared) {
        this.shared = shared;
    }

    public Boolean getShared() {
        return shared;
    }

    public void setSubnets(Iterable<String> subnets) {
        List<String> tmp = new ArrayList<String>();
        for (String s : subnets){
            tmp.add(s);
        }
        this.subnets = tmp;
    }

    public Iterable<String> getSubnets() {
        return subnets;
    }
}

@@ -289,35 +289,8 @@
 g id
- = IdGenerator.createUUID()
 ;%0A  
@@ -312,16 +312,23 @@
 private 
+static 
 int vers
@@ -383,24 +383,96 @@
 ring extId;%0A
+    private int segmentationId;%0A    private String physicalNetworkName;%0A
     private 
@@ -619,23 +619,403 @@
 st%3CS
-tring%3E subnets;
+ubnet%3E subnets;%0A%0A    public Network()%7B%0A        id = IdGenerator.createUUID();%0A        name = %22%22;%0A        extId = %22%22;%0A        segmentationId = -1;%0A        physicalNetworkName = %22%22;%0A        networkType = %22%22;%0A        external = false;%0A        shared = false;%0A        subnets = new ArrayList%3CSubnet%3E();%0A    %7D%0A%0A    public String getId() %7B return id; %7D%0A%0A    public int getVersion() %7B return version; %7D
 %0A%0A  
@@ -1765,39 +1765,443 @@
 lic 
-void setSubnets(Iterable%3CString
+int getSegmentationId() %7B%0A        return segmentationId;%0A    %7D%0A%0A    public void setSegmentationId(int segmentationId) %7B%0A        this.segmentationId = segmentationId;%0A    %7D%0A%0A    public String getPhysicalNetworkName() %7B%0A        return physicalNetworkName;%0A    %7D%0A%0A    public void setPhysicalNetworkName(String physicalNetworkName) %7B%0A        this.physicalNetworkName = physicalNetworkName;%0A    %7D%0A%0A    public void setSubnets(Iterable%3CSubnet
 %3E su
@@ -2223,21 +2223,21 @@
   List%3CS
-tring
+ubnet
 %3E tmp = 
@@ -2251,21 +2251,21 @@
 ayList%3CS
-tring
+ubnet
 %3E();%0A   
@@ -2279,15 +2279,20 @@
 r (S
-tring s
+ubnet subnet
  : s
@@ -2321,16 +2321,21 @@
 mp.add(s
+ubnet
 );%0A     
@@ -2399,52 +2399,986 @@
 le%3CS
-tring%3E getSubnets() %7B%0A        return subnets
+ubnet%3E getSubnets() %7B%0A        return subnets;%0A    %7D%0A%0A    public void addSubnet(Subnet subnet) %7B%0A        this.subnets.add(subnet);%0A    %7D%0A%0A    public boolean removeSubnet(Subnet subnet) %7B%0A        return subnets.remove(subnet);%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        String subnetsString = %22%5B%22;%0A        for (Subnet subnet : subnets) %7B%0A            subnetsString = subnetsString + %22, %22 + subnet.toString();%0A        %7D%0A        subnetsString = %22%5D%22;%0A        return %22Network%7B%22 +%0A            %22id='%22 + id + '%5C'' +%0A            %22, name='%22 + name + '%5C'' +%0A            %22, version='%22 + version +%0A            %22, extId='%22 + extId + '%5C'' +%0A            %22, external='%22 + external + '%5C'' +%0A            %22, networkType='%22 + networkType + '%5C'' +%0A            %22, shared='%22 + shared + '%5C'' +%0A            %22, segmentationId='%22 + segmentationId + '%5C'' +%0A            %22, physicalNetworkName='%22 + physicalNetworkName + '%5C'' +%0A            %22, subnets='%22 + subnetsString + '%5C'' +%0A            '%7D'
 ;%0A  

add values: segmentationID, physicalNetworkName (needed for creating a new network on openstack); change type of subnets to List<Subnet>; add constructor for initialising all values; add getter/setter; update to String()