From b9c856cb371b5d538d5e1cf0aba36ef62d84f037 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 14:35:23 +0900 Subject: [PATCH 1/6] added method --- .../overflow/module/noauthprobe/dao/NoAuthProbeDAO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java b/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java index bf34fe7..7b70fda 100644 --- a/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java +++ b/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java @@ -14,6 +14,6 @@ public interface NoAuthProbeDAO extends JpaRepository { // NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent); // List findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent); -// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") -// NoAuthProbe findByTempKey(@Param("tempProbeKey")String tempProbeKey); + @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") + NoAuthProbe findByTempKey(@Param("tempProbeKey")String tempProbeKey); } From 47bacb0629892ccf1d0c43b6cd8b74981743ca47 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 14:35:41 +0900 Subject: [PATCH 2/6] added test --- .../overflow/module/domain/dao/DomainDAOTest.java | 3 ++- .../noauthprobe/dao/NoAuthProbeDAOTest.java | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java b/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java index f4b26c3..e3b24f3 100644 --- a/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/domain/dao/DomainDAOTest.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.domain.dao; import com.loafle.overflow.AppConfig; import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.module.domain.Domain; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -28,12 +29,12 @@ public class DomainDAOTest { Domain domain = new Domain(); - domain.setCreateDate(new Date()); domain.setName("snoop's domain"); this.domainDAO.save(domain); + Assert.assertNotEquals(domain.getId(), 0); } } \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java index f8e10e4..6901ffa 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java @@ -30,8 +30,13 @@ public class NoAuthProbeDAOTest { @Test public void testFindTempKey() { + NoAuthProbe probe = this.noAuthProbeDAO.findByTempKey("1cf2555c57d511e79714080027658d13"); + Assert.assertNotEquals(probe, null); + + System.out.println(probe.getTempProbeKey()); + } // @Ignore @@ -40,18 +45,18 @@ public class NoAuthProbeDAOTest { NoAuthProbe noAuthProbe = new NoAuthProbe(); - noAuthProbe.setApiKey("11111111111111"); + noAuthProbe.setHostName("snooop"); - noAuthProbe.setIpAddress(44444); - noAuthProbe.setMacAddress(222222); + noAuthProbe.setIpAddress(3232235980L); + noAuthProbe.setMacAddress(8796753988883L); noAuthProbe.setStatus(AuthType.PROCESS); - noAuthProbe.setTempProbeKey("4444"); + noAuthProbe.setTempProbeKey("1cf2555c57d511e79714080027658d13"); Domain d = new Domain(); d.setId(1); noAuthProbe.setDomain(d); - System.out.println(noAuthProbe.getId()); + this.noAuthProbeDAO.save(noAuthProbe); Assert.assertNotEquals(noAuthProbe.getId(), 0); From b32762c3ed8acb060b88e4bb2e63021ff6c75936 Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 23 Jun 2017 14:39:06 +0900 Subject: [PATCH 3/6] 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; - } } From af36a690b152594643065c83e2482af740bfe1c7 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 14:39:29 +0900 Subject: [PATCH 4/6] added test --- .../module/noauthprobe/dao/NoAuthProbeDAOTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java index 6901ffa..3a4bbb6 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java @@ -62,4 +62,15 @@ public class NoAuthProbeDAOTest { } + @Test + public void update() { + + NoAuthProbe probe = this.noAuthProbeDAO.findByTempKey("1cf2555c57d511e79714080027658d13"); + + probe.setStatus(AuthType.ACCEPT); + + this.noAuthProbeDAO.save(probe); + + } + } \ No newline at end of file From 63d78e1f1ec213e983070c5f12a4da1f6389ab8a Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 14:45:51 +0900 Subject: [PATCH 5/6] added test --- .../module/noauthprobe/dao/NoAuthProbeDAOTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java index 3a4bbb6..0417c8b 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAOTest.java @@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.List; + import static org.junit.Assert.*; /** @@ -73,4 +75,15 @@ public class NoAuthProbeDAOTest { } + @Test + public void list() { + + + List probes = this.noAuthProbeDAO.findAllByDomainId(1); + + + Assert.assertNotEquals(probes.size(), 0); + + } + } \ No newline at end of file From 3431b718b06fc71bbfef6113a2e5204b131c2dde Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 14:46:03 +0900 Subject: [PATCH 6/6] added list --- .../overflow/module/noauthprobe/dao/NoAuthProbeDAO.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java b/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java index 7b70fda..2b00ae3 100644 --- a/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java +++ b/src/main/java/com/loafle/overflow/module/noauthprobe/dao/NoAuthProbeDAO.java @@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** * Created by root on 17. 5. 30. */ @@ -16,4 +18,7 @@ public interface NoAuthProbeDAO extends JpaRepository { @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") NoAuthProbe findByTempKey(@Param("tempProbeKey")String tempProbeKey); + + @Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :domainId") + List findAllByDomainId(@Param("domainId")long domainId); }