From b32762c3ed8acb060b88e4bb2e63021ff6c75936 Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 23 Jun 2017 14:39:06 +0900 Subject: [PATCH] infra arrange --- .../loafle/overflow/module/infra/Infra.java | 12 +- .../overflow/module/infra/InfraHost.java | 51 ++------ .../overflow/module/infra/InfraMachine.java | 51 +++----- .../loafle/overflow/module/infra/InfraOS.java | 70 +++++++++++ .../module/infra/InfraOSApplication.java | 57 +++++++++ .../overflow/module/infra/InfraOSDaemon.java | 56 +++++++++ .../overflow/module/infra/InfraOSPort.java | 92 ++++++++++++++ .../loafle/overflow/module/infra/InfraOs.java | 93 -------------- .../module/infra/InfraOsApplication.java | 80 ------------ .../overflow/module/infra/InfraOsDaemon.java | 80 ------------ .../overflow/module/infra/InfraOsPort.java | 119 ------------------ .../overflow/module/infra/InfraService.java | 72 ++++------- 12 files changed, 331 insertions(+), 502 deletions(-) create mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOS.java create mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOSApplication.java create mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOSDaemon.java create mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOSPort.java delete mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOs.java delete mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOsApplication.java delete mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOsDaemon.java delete mode 100644 src/main/java/com/loafle/overflow/module/infra/InfraOsPort.java diff --git a/src/main/java/com/loafle/overflow/module/infra/Infra.java b/src/main/java/com/loafle/overflow/module/infra/Infra.java index c3fa7d3..fddf5fd 100644 --- a/src/main/java/com/loafle/overflow/module/infra/Infra.java +++ b/src/main/java/com/loafle/overflow/module/infra/Infra.java @@ -3,7 +3,7 @@ package com.loafle.overflow.module.infra; import com.loafle.overflow.meta.model.MetaInfraType; import javax.persistence.*; -import java.sql.Timestamp; +import java.util.Date; /** * Created by root on 17. 6. 22. @@ -14,7 +14,7 @@ public class Infra { private long id; private MetaInfraType type; private long childId; - private Timestamp createDate; + private Date createDate; @Id @GeneratedValue(strategy= GenerationType.IDENTITY) @@ -46,13 +46,13 @@ public class Infra { this.childId = childId; } - @Basic - @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) - public Timestamp getCreateDate() { + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { return createDate; } - public void setCreateDate(Timestamp createDate) { + public void setCreateDate(Date createDate) { this.createDate = createDate; } diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraHost.java b/src/main/java/com/loafle/overflow/module/infra/InfraHost.java index 427416e..5b97d22 100644 --- a/src/main/java/com/loafle/overflow/module/infra/InfraHost.java +++ b/src/main/java/com/loafle/overflow/module/infra/InfraHost.java @@ -1,7 +1,7 @@ package com.loafle.overflow.module.infra; import javax.persistence.*; -import java.sql.Timestamp; +import java.util.Date; /** * Created by root on 17. 6. 22. @@ -10,10 +10,10 @@ import java.sql.Timestamp; @Table(name = "INFRA_HOST", schema = "public", catalog = "postgres") public class InfraHost { private long id; - private long osId; + private InfraOS os; private int ip; private int mac; - private Timestamp createDate; + private Date createDate; @Id @Column(name = "ID", nullable = false) @@ -25,14 +25,14 @@ public class InfraHost { this.id = id; } - @Basic - @Column(name = "OS_ID", nullable = false) - public long getOsId() { - return osId; + @ManyToOne + @JoinColumn(name = "OS_ID", nullable = false) + public InfraOS getOs() { + return os; } - public void setOsId(long osId) { - this.osId = osId; + public void setOs(InfraOS os) { + this.os = os; } @Basic @@ -55,39 +55,14 @@ public class InfraHost { this.mac = mac; } - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { return createDate; } - public void setCreateDate(Timestamp createDate) { + public void setCreateDate(Date createDate) { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraHost that = (InfraHost) o; - - if (id != that.id) return false; - if (osId != that.osId) return false; - if (ip != that.ip) return false; - if (mac != that.mac) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (osId ^ (osId >>> 32)); - result = 31 * result + ip; - result = 31 * result + mac; - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraMachine.java b/src/main/java/com/loafle/overflow/module/infra/InfraMachine.java index 505d6df..fa482f7 100644 --- a/src/main/java/com/loafle/overflow/module/infra/InfraMachine.java +++ b/src/main/java/com/loafle/overflow/module/infra/InfraMachine.java @@ -1,7 +1,9 @@ package com.loafle.overflow.module.infra; +import com.loafle.overflow.module.probe.model.Probe; + import javax.persistence.*; -import java.sql.Timestamp; +import java.util.Date; /** * Created by root on 17. 6. 22. @@ -10,9 +12,9 @@ import java.sql.Timestamp; @Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres") public class InfraMachine { private long id; - private long probeId; + private Probe probe; private String meta; - private Timestamp createDate; + private Date createDate; @Id @Column(name = "ID", nullable = false) @@ -24,14 +26,14 @@ public class InfraMachine { this.id = id; } - @Basic - @Column(name = "PROBE_ID", nullable = false) - public long getProbeId() { - return probeId; + @ManyToOne + @JoinColumn(name = "PROBE_ID", nullable = false) + public Probe getProbe() { + return probe; } - public void setProbeId(long probeId) { - this.probeId = probeId; + public void setProbe(Probe probe) { + this.probe = probe; } @Basic @@ -44,37 +46,14 @@ public class InfraMachine { this.meta = meta; } - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { return createDate; } - public void setCreateDate(Timestamp createDate) { + public void setCreateDate(Date createDate) { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraMachine that = (InfraMachine) o; - - if (id != that.id) return false; - if (probeId != that.probeId) return false; - if (meta != null ? !meta.equals(that.meta) : that.meta != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (probeId ^ (probeId >>> 32)); - result = 31 * result + (meta != null ? meta.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOS.java b/src/main/java/com/loafle/overflow/module/infra/InfraOS.java new file mode 100644 index 0000000..de236d4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/infra/InfraOS.java @@ -0,0 +1,70 @@ +package com.loafle.overflow.module.infra; + +import com.loafle.overflow.meta.model.MetaInfraVendor; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "INFRA_OS", schema = "public", catalog = "postgres") +public class InfraOS { + private long id; + private InfraMachine machine; + private String meta; + private Date createDate; + private MetaInfraVendor vendor; + + @Id + @Column(name = "ID", nullable = false) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "MACHINE_ID", nullable = false) + public InfraMachine getMachine() { + return machine; + } + + public void setMachine(InfraMachine machine) { + this.machine = machine; + } + + @Basic + @Column(name = "META", nullable = true, length = 255) + public String getMeta() { + return meta; + } + + public void setMeta(String meta) { + this.meta = meta; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + @ManyToOne + @JoinColumn(name = "VENDOR_ID", nullable = false) + public MetaInfraVendor getVendor() { + return vendor; + } + + public void setVendor(MetaInfraVendor vendor) { + this.vendor = vendor; + } + +} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOSApplication.java b/src/main/java/com/loafle/overflow/module/infra/InfraOSApplication.java new file mode 100644 index 0000000..3abd24b --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/infra/InfraOSApplication.java @@ -0,0 +1,57 @@ +package com.loafle.overflow.module.infra; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "INFRA_OS_APPLICATION", schema = "public", catalog = "postgres") +public class InfraOSApplication { + private long id; + private InfraOS os; + private String name; + private Date createDate; + + @Id + @Column(name = "ID", nullable = false) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "OS_ID", nullable = false) + public InfraOS getOs() { + return os; + } + + public void setOs(InfraOS os) { + this.os = os; + } + + @Basic + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOSDaemon.java b/src/main/java/com/loafle/overflow/module/infra/InfraOSDaemon.java new file mode 100644 index 0000000..c20b2e7 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/infra/InfraOSDaemon.java @@ -0,0 +1,56 @@ +package com.loafle.overflow.module.infra; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "INFRA_OS_DAEMON", schema = "public", catalog = "postgres") +public class InfraOSDaemon { + private long id; + private InfraOS os; + private String name; + private Date createDate; + + @Id + @Column(name = "ID", nullable = false) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "OS_ID", nullable = false) + public InfraOS getOs() { + return os; + } + + public void setOs(InfraOS os) { + this.os = os; + } + + @Basic + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOSPort.java b/src/main/java/com/loafle/overflow/module/infra/InfraOSPort.java new file mode 100644 index 0000000..899de41 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/infra/InfraOSPort.java @@ -0,0 +1,92 @@ +package com.loafle.overflow.module.infra; + +import com.loafle.overflow.meta.model.MetaInfraVendor; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "INFRA_OS_PORT", schema = "public", catalog = "postgres") +public class InfraOSPort { + private long id; + private InfraOS os; + private Date createDate; + private Integer port; + private String portType; + private MetaInfraVendor vendor; + private boolean tlsType; + + @Id + @Column(name = "ID", nullable = false) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "OS_ID", nullable = false) + public InfraOS getOs() { + return this.os; + } + + public void setOs(InfraOS os) { + this.os = os; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + @Basic + @Column(name = "PORT", nullable = true) + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Basic + @Column(name = "PORT_TYPE", nullable = false) + public String getPortType() { + return portType; + } + + public void setPortType(String portType) { + this.portType = portType; + } + + @ManyToOne + @JoinColumn(name = "VENDOR_ID", nullable = true) + public MetaInfraVendor getVendor() { + return vendor; + } + + public void setVendor(MetaInfraVendor vendor) { + this.vendor = vendor; + } + + @Basic + @Column(name = "TLS_TYPE", nullable = false) + public boolean isTlsType() { + return tlsType; + } + + public void setTlsType(boolean tlsType) { + this.tlsType = tlsType; + } + +} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOs.java b/src/main/java/com/loafle/overflow/module/infra/InfraOs.java deleted file mode 100644 index a321737..0000000 --- a/src/main/java/com/loafle/overflow/module/infra/InfraOs.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.loafle.overflow.module.infra; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "INFRA_OS", schema = "public", catalog = "postgres") -public class InfraOs { - private long id; - private long machineId; - private String meta; - private Timestamp createDate; - private int vendorId; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "MACHINE_ID", nullable = false) - public long getMachineId() { - return machineId; - } - - public void setMachineId(long machineId) { - this.machineId = machineId; - } - - @Basic - @Column(name = "META", nullable = true, length = 255) - public String getMeta() { - return meta; - } - - public void setMeta(String meta) { - this.meta = meta; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Basic - @Column(name = "VENDOR_ID", nullable = false) - public int getVendorId() { - return vendorId; - } - - public void setVendorId(int vendorId) { - this.vendorId = vendorId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraOs that = (InfraOs) o; - - if (id != that.id) return false; - if (machineId != that.machineId) return false; - if (vendorId != that.vendorId) return false; - if (meta != null ? !meta.equals(that.meta) : that.meta != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (machineId ^ (machineId >>> 32)); - result = 31 * result + (meta != null ? meta.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + vendorId; - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOsApplication.java b/src/main/java/com/loafle/overflow/module/infra/InfraOsApplication.java deleted file mode 100644 index 00ea557..0000000 --- a/src/main/java/com/loafle/overflow/module/infra/InfraOsApplication.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.loafle.overflow.module.infra; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "INFRA_OS_APPLICATION", schema = "public", catalog = "postgres") -public class InfraOsApplication { - private long id; - private long osId; - private String name; - private Timestamp createDate; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "OS_ID", nullable = false) - public long getOsId() { - return osId; - } - - public void setOsId(long osId) { - this.osId = osId; - } - - @Basic - @Column(name = "NAME", nullable = true, length = 50) - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraOsApplication that = (InfraOsApplication) o; - - if (id != that.id) return false; - if (osId != that.osId) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (osId ^ (osId >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOsDaemon.java b/src/main/java/com/loafle/overflow/module/infra/InfraOsDaemon.java deleted file mode 100644 index 60a7935..0000000 --- a/src/main/java/com/loafle/overflow/module/infra/InfraOsDaemon.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.loafle.overflow.module.infra; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "INFRA_OS_DAEMON", schema = "public", catalog = "postgres") -public class InfraOsDaemon { - private long id; - private long osId; - private String name; - private Timestamp createDate; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "OS_ID", nullable = false) - public long getOsId() { - return osId; - } - - public void setOsId(long osId) { - this.osId = osId; - } - - @Basic - @Column(name = "NAME", nullable = true, length = 50) - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraOsDaemon that = (InfraOsDaemon) o; - - if (id != that.id) return false; - if (osId != that.osId) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (osId ^ (osId >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraOsPort.java b/src/main/java/com/loafle/overflow/module/infra/InfraOsPort.java deleted file mode 100644 index e21dbe1..0000000 --- a/src/main/java/com/loafle/overflow/module/infra/InfraOsPort.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.loafle.overflow.module.infra; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "INFRA_OS_PORT", schema = "public", catalog = "postgres") -public class InfraOsPort { - private long id; - private long osId; - private Timestamp createDate; - private Integer port; - private String portType; - private Integer vendorId; - private boolean tlsType; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "OS_ID", nullable = false) - public long getOsId() { - return osId; - } - - public void setOsId(long osId) { - this.osId = osId; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = true) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Basic - @Column(name = "PORT", nullable = true) - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - @Basic - @Column(name = "PORT_TYPE", nullable = false) - public String getPortType() { - return portType; - } - - public void setPortType(String portType) { - this.portType = portType; - } - - @Basic - @Column(name = "VENDOR_ID", nullable = true) - public Integer getVendorId() { - return vendorId; - } - - public void setVendorId(Integer vendorId) { - this.vendorId = vendorId; - } - - @Basic - @Column(name = "TLS_TYPE", nullable = false) - public boolean isTlsType() { - return tlsType; - } - - public void setTlsType(boolean tlsType) { - this.tlsType = tlsType; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraOsPort that = (InfraOsPort) o; - - if (id != that.id) return false; - if (osId != that.osId) return false; - if (tlsType != that.tlsType) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - if (port != null ? !port.equals(that.port) : that.port != null) return false; - if (portType != null ? !portType.equals(that.portType) : that.portType != null) return false; - if (vendorId != null ? !vendorId.equals(that.vendorId) : that.vendorId != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (osId ^ (osId >>> 32)); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (port != null ? port.hashCode() : 0); - result = 31 * result + (portType != null ? portType.hashCode() : 0); - result = 31 * result + (vendorId != null ? vendorId.hashCode() : 0); - result = 31 * result + (tlsType ? 1 : 0); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/infra/InfraService.java b/src/main/java/com/loafle/overflow/module/infra/InfraService.java index b034c5b..564e5be 100644 --- a/src/main/java/com/loafle/overflow/module/infra/InfraService.java +++ b/src/main/java/com/loafle/overflow/module/infra/InfraService.java @@ -1,7 +1,9 @@ package com.loafle.overflow.module.infra; +import com.loafle.overflow.meta.model.MetaInfraVendor; + import javax.persistence.*; -import java.sql.Timestamp; +import java.util.Date; /** * Created by root on 17. 6. 22. @@ -10,11 +12,11 @@ import java.sql.Timestamp; @Table(name = "INFRA_SERVICE", schema = "public", catalog = "postgres") public class InfraService { private long id; - private long hostId; + private InfraHost host; private String portType; private Integer port; - private int vendorId; - private Timestamp createDate; + private MetaInfraVendor vendor; + private Date createDate; private boolean tlsType; @Id @@ -27,14 +29,14 @@ public class InfraService { this.id = id; } - @Basic - @Column(name = "HOST_ID", nullable = false) - public long getHostId() { - return hostId; + @ManyToOne + @JoinColumn(name = "HOST_ID", nullable = false) + public InfraHost getHost() { + return host; } - public void setHostId(long hostId) { - this.hostId = hostId; + public void setHost(InfraHost host) { + this.host = host; } @Basic @@ -57,23 +59,23 @@ public class InfraService { this.port = port; } - @Basic - @Column(name = "VENDOR_ID", nullable = false) - public int getVendorId() { - return vendorId; + @ManyToOne + @JoinColumn(name = "VENDOR_ID", nullable = false) + public MetaInfraVendor getVendor() { + return vendor; } - public void setVendorId(int vendorId) { - this.vendorId = vendorId; + public void setVendor(MetaInfraVendor vendor) { + this.vendor = vendor; } - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + public Date getCreateDate() { return createDate; } - public void setCreateDate(Timestamp createDate) { + public void setCreateDate(Date createDate) { this.createDate = createDate; } @@ -86,34 +88,4 @@ public class InfraService { public void setTlsType(boolean tlsType) { this.tlsType = tlsType; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InfraService that = (InfraService) o; - - if (id != that.id) return false; - if (hostId != that.hostId) return false; - if (vendorId != that.vendorId) return false; - if (tlsType != that.tlsType) return false; - if (portType != null ? !portType.equals(that.portType) : that.portType != null) return false; - if (port != null ? !port.equals(that.port) : that.port != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (hostId ^ (hostId >>> 32)); - result = 31 * result + (portType != null ? portType.hashCode() : 0); - result = 31 * result + (port != null ? port.hashCode() : 0); - result = 31 * result + vendorId; - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (tlsType ? 1 : 0); - return result; - } }