This commit is contained in:
crusader 2018-06-15 12:16:24 +09:00
parent b08d513524
commit 1afea3de2f
8 changed files with 29 additions and 53 deletions

View File

@ -13,7 +13,7 @@
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId> <artifactId>commons-java</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0.71-SNAPSHOT</version> <version>1.0.72-SNAPSHOT</version>
<name>com.loafle.overflow.commons-java</name> <name>com.loafle.overflow.commons-java</name>
<properties> <properties>

View File

@ -6,6 +6,10 @@ import javax.persistence.*;
import com.loafle.overflow.model.meta.MetaTargetHostType; import com.loafle.overflow.model.meta.MetaTargetHostType;
import org.codehaus.jackson.annotate.JsonBackReference;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
/** /**
* Created by root on 17. 6. 22. * Created by root on 17. 6. 22.
*/ */
@ -18,8 +22,11 @@ public class InfraHost extends Infra {
private InfraHostMachine infraHostMachine; private InfraHostMachine infraHostMachine;
private InfraHostOS infraHostOS; private InfraHostOS infraHostOS;
@JsonBackReference
private List<InfraHostIP> infraHostIPs; private List<InfraHostIP> infraHostIPs;
private List<InfraHostPort> infraHostPorts;
private InfraHost containerInfraHost;
public InfraHost() { public InfraHost() {
super(); super();
@ -30,7 +37,7 @@ public class InfraHost extends Infra {
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "INFRA_ZONE_ID", nullable = true) @JoinColumn(name = "INFRA_ZONE_ID", nullable = false)
public InfraZone getInfraZone() { public InfraZone getInfraZone() {
return infraZone; return infraZone;
} }
@ -85,7 +92,7 @@ public class InfraHost extends Infra {
* @return the infraHostIPs * @return the infraHostIPs
*/ */
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "infraHost") @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "infraHost")
@OrderColumn(name = "ID") @Fetch(FetchMode.SELECT)
public List<InfraHostIP> getInfraHostIPs() { public List<InfraHostIP> getInfraHostIPs() {
return infraHostIPs; return infraHostIPs;
} }
@ -98,18 +105,19 @@ public class InfraHost extends Infra {
} }
/** /**
* @return the infraHostPorts * @return the containerInfraHost
*/ */
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "infraHost") @ManyToOne
@OrderColumn(name = "PORT") @JoinColumn(name = "CONTAINER_INFRA_HOST_ID", nullable = true)
public List<InfraHostPort> getInfraHostPorts() { public InfraHost getContainerInfraHost() {
return infraHostPorts; return containerInfraHost;
} }
/** /**
* @param infraHostPorts the infraHostPorts to set * @param containerInfraHost the containerInfraHost to set
*/ */
public void setInfraHostPorts(List<InfraHostPort> infraHostPorts) { public void setContainerInfraHost(InfraHost containerInfraHost) {
this.infraHostPorts = infraHostPorts; this.containerInfraHost = containerInfraHost;
} }
} }

View File

@ -4,6 +4,8 @@ import javax.persistence.*;
import com.loafle.overflow.model.meta.MetaIPType; import com.loafle.overflow.model.meta.MetaIPType;
import org.codehaus.jackson.annotate.JsonManagedReference;
import java.util.Date; import java.util.Date;
/** /**
@ -13,6 +15,7 @@ import java.util.Date;
@Table(name = "INFRA_HOST_IP", schema = "public") @Table(name = "INFRA_HOST_IP", schema = "public")
public class InfraHostIP { public class InfraHostIP {
private Long id; private Long id;
@JsonManagedReference
private InfraHost infraHost; private InfraHost infraHost;
private MetaIPType metaIPType; private MetaIPType metaIPType;
private String address; private String address;

View File

@ -11,7 +11,6 @@ import java.util.Date;
@Table(name = "INFRA_HOST_MACHINE", schema = "public") @Table(name = "INFRA_HOST_MACHINE", schema = "public")
public class InfraHostMachine { public class InfraHostMachine {
private Long id; private Long id;
private InfraHost infraHost;
private String meta; private String meta;
private Date createDate; private Date createDate;
@ -25,16 +24,6 @@ public class InfraHostMachine {
this.id = id; this.id = id;
} }
@OneToOne
@JoinColumn(name = "INFRA_HOST_ID", nullable = false)
public InfraHost getInfraHost() {
return infraHost;
}
public void setInfraHost(InfraHost infraHost) {
this.infraHost = infraHost;
}
@Basic @Basic
@Column(name = "META", nullable = true, length = 2000) @Column(name = "META", nullable = true, length = 2000)
public String getMeta() { public String getMeta() {
@ -45,7 +34,6 @@ public class InfraHostMachine {
this.meta = meta; this.meta = meta;
} }
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() { public Date getCreateDate() {

View File

@ -11,7 +11,6 @@ import java.util.Date;
@Table(name = "INFRA_HOST_OS", schema = "public") @Table(name = "INFRA_HOST_OS", schema = "public")
public class InfraHostOS { public class InfraHostOS {
private Long id; private Long id;
private InfraHost infraHost;
private String name; private String name;
private String os; private String os;
private String platform; private String platform;
@ -32,16 +31,6 @@ public class InfraHostOS {
this.id = id; this.id = id;
} }
@OneToOne
@JoinColumn(name = "INFRA_HOST_ID", nullable = false)
public InfraHost getInfraHost() {
return infraHost;
}
public void setInfraHost(InfraHost infraHost) {
this.infraHost = infraHost;
}
/** /**
* @return the name * @return the name
*/ */

View File

@ -13,7 +13,7 @@ import java.util.Date;
@Table(name = "INFRA_HOST_PORT", schema = "public") @Table(name = "INFRA_HOST_PORT", schema = "public")
public class InfraHostPort { public class InfraHostPort {
private Long id; private Long id;
private InfraHost infraHost; private InfraHostIP infraHostIP;
private MetaPortType metaPortType; private MetaPortType metaPortType;
private Integer port; private Integer port;
private Date createDate; private Date createDate;
@ -29,13 +29,13 @@ public class InfraHostPort {
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "INFRA_HOST_ID", nullable = false) @JoinColumn(name = "INFRA_HOST_IP_ID", nullable = false)
public InfraHost getInfraHost() { public InfraHostIP getInfraHostIP() {
return infraHost; return infraHostIP;
} }
public void setInfraHost(InfraHost infraHost) { public void setInfraHostIP(InfraHostIP infraHostIP) {
this.infraHost = infraHost; this.infraHostIP = infraHostIP;
} }
@ManyToOne @ManyToOne

View File

@ -14,7 +14,6 @@ import com.loafle.overflow.model.meta.MetaTargetServiceType;
public class InfraService extends Infra { public class InfraService extends Infra {
private MetaTargetServiceType metaTargetServiceType; private MetaTargetServiceType metaTargetServiceType;
private InfraHostIP infraHostIP;
private InfraHostPort infraHostPort; private InfraHostPort infraHostPort;
private MetaCryptoType metaCryptoType; private MetaCryptoType metaCryptoType;
@ -36,16 +35,6 @@ public class InfraService extends Infra {
this.metaTargetServiceType = metaTargetServiceType; this.metaTargetServiceType = metaTargetServiceType;
} }
@ManyToOne
@JoinColumn(name = "INFRA_HOST_IP_ID", nullable = true)
public InfraHostIP getInfraHostIP() {
return infraHostIP;
}
public void setInfraHostIP(InfraHostIP infraHostIP) {
this.infraHostIP = infraHostIP;
}
@OneToOne @OneToOne
@JoinColumn(name = "INFRA_HOST_PORT_ID", nullable = true) @JoinColumn(name = "INFRA_HOST_PORT_ID", nullable = true)
public InfraHostPort getInfraHostPort() { public InfraHostPort getInfraHostPort() {

View File

@ -38,7 +38,6 @@ public class InfraZone extends Infra {
this.metaTargetZoneType = metaTargetZoneType; this.metaTargetZoneType = metaTargetZoneType;
} }
@Basic @Basic
@Column(name = "NETWORK", nullable = true) @Column(name = "NETWORK", nullable = true)
public String getNetwork() { public String getNetwork() {