This commit is contained in:
crusader 2017-06-23 15:00:44 +09:00
commit 2611e33327
15 changed files with 374 additions and 510 deletions

View File

@ -3,7 +3,7 @@ package com.loafle.overflow.module.infra;
import com.loafle.overflow.meta.model.MetaInfraType; import com.loafle.overflow.meta.model.MetaInfraType;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.util.Date;
/** /**
* Created by root on 17. 6. 22. * Created by root on 17. 6. 22.
@ -14,7 +14,7 @@ public class Infra {
private long id; private long id;
private MetaInfraType type; private MetaInfraType type;
private long childId; private long childId;
private Timestamp createDate; private Date createDate;
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
@ -46,13 +46,13 @@ public class Infra {
this.childId = childId; this.childId = childId;
} }
@Basic @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")
public Timestamp getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }
public void setCreateDate(Timestamp createDate) { public void setCreateDate(Date createDate) {
this.createDate = createDate; this.createDate = createDate;
} }

View File

@ -1,7 +1,7 @@
package com.loafle.overflow.module.infra; package com.loafle.overflow.module.infra;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.util.Date;
/** /**
* Created by root on 17. 6. 22. * Created by root on 17. 6. 22.
@ -10,10 +10,10 @@ import java.sql.Timestamp;
@Table(name = "INFRA_HOST", schema = "public", catalog = "postgres") @Table(name = "INFRA_HOST", schema = "public", catalog = "postgres")
public class InfraHost { public class InfraHost {
private long id; private long id;
private long osId; private InfraOS os;
private int ip; private int ip;
private int mac; private int mac;
private Timestamp createDate; private Date createDate;
@Id @Id
@Column(name = "ID", nullable = false) @Column(name = "ID", nullable = false)
@ -25,14 +25,14 @@ public class InfraHost {
this.id = id; this.id = id;
} }
@Basic @ManyToOne
@Column(name = "OS_ID", nullable = false) @JoinColumn(name = "OS_ID", nullable = false)
public long getOsId() { public InfraOS getOs() {
return osId; return os;
} }
public void setOsId(long osId) { public void setOs(InfraOS os) {
this.osId = osId; this.os = os;
} }
@Basic @Basic
@ -55,39 +55,14 @@ public class InfraHost {
this.mac = mac; this.mac = mac;
} }
@Basic @Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
public Timestamp getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }
public void setCreateDate(Timestamp createDate) { public void setCreateDate(Date createDate) {
this.createDate = 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;
}
} }

View File

@ -1,7 +1,9 @@
package com.loafle.overflow.module.infra; package com.loafle.overflow.module.infra;
import com.loafle.overflow.module.probe.model.Probe;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.util.Date;
/** /**
* Created by root on 17. 6. 22. * Created by root on 17. 6. 22.
@ -10,9 +12,9 @@ import java.sql.Timestamp;
@Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres") @Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres")
public class InfraMachine { public class InfraMachine {
private long id; private long id;
private long probeId; private Probe probe;
private String meta; private String meta;
private Timestamp createDate; private Date createDate;
@Id @Id
@Column(name = "ID", nullable = false) @Column(name = "ID", nullable = false)
@ -24,14 +26,14 @@ public class InfraMachine {
this.id = id; this.id = id;
} }
@Basic @ManyToOne
@Column(name = "PROBE_ID", nullable = false) @JoinColumn(name = "PROBE_ID", nullable = false)
public long getProbeId() { public Probe getProbe() {
return probeId; return probe;
} }
public void setProbeId(long probeId) { public void setProbe(Probe probe) {
this.probeId = probeId; this.probe = probe;
} }
@Basic @Basic
@ -44,37 +46,14 @@ public class InfraMachine {
this.meta = meta; this.meta = meta;
} }
@Basic @Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
public Timestamp getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }
public void setCreateDate(Timestamp createDate) { public void setCreateDate(Date createDate) {
this.createDate = 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;
}
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -1,7 +1,9 @@
package com.loafle.overflow.module.infra; package com.loafle.overflow.module.infra;
import com.loafle.overflow.meta.model.MetaInfraVendor;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.util.Date;
/** /**
* Created by root on 17. 6. 22. * Created by root on 17. 6. 22.
@ -10,11 +12,11 @@ import java.sql.Timestamp;
@Table(name = "INFRA_SERVICE", schema = "public", catalog = "postgres") @Table(name = "INFRA_SERVICE", schema = "public", catalog = "postgres")
public class InfraService { public class InfraService {
private long id; private long id;
private long hostId; private InfraHost host;
private String portType; private String portType;
private Integer port; private Integer port;
private int vendorId; private MetaInfraVendor vendor;
private Timestamp createDate; private Date createDate;
private boolean tlsType; private boolean tlsType;
@Id @Id
@ -27,14 +29,14 @@ public class InfraService {
this.id = id; this.id = id;
} }
@Basic @ManyToOne
@Column(name = "HOST_ID", nullable = false) @JoinColumn(name = "HOST_ID", nullable = false)
public long getHostId() { public InfraHost getHost() {
return hostId; return host;
} }
public void setHostId(long hostId) { public void setHost(InfraHost host) {
this.hostId = hostId; this.host = host;
} }
@Basic @Basic
@ -57,23 +59,23 @@ public class InfraService {
this.port = port; this.port = port;
} }
@Basic @ManyToOne
@Column(name = "VENDOR_ID", nullable = false) @JoinColumn(name = "VENDOR_ID", nullable = false)
public int getVendorId() { public MetaInfraVendor getVendor() {
return vendorId; return vendor;
} }
public void setVendorId(int vendorId) { public void setVendor(MetaInfraVendor vendor) {
this.vendorId = vendorId; this.vendor = vendor;
} }
@Basic @Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
public Timestamp getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }
public void setCreateDate(Timestamp createDate) { public void setCreateDate(Date createDate) {
this.createDate = createDate; this.createDate = createDate;
} }
@ -86,34 +88,4 @@ public class InfraService {
public void setTlsType(boolean tlsType) { public void setTlsType(boolean tlsType) {
this.tlsType = 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;
}
} }

View File

@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* Created by root on 17. 5. 30. * Created by root on 17. 5. 30.
*/ */
@ -14,6 +16,9 @@ public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent); // NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent);
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent); // List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
// NoAuthProbe findByTempKey(@Param("tempProbeKey")String tempProbeKey); NoAuthProbe findByTempKey(@Param("tempProbeKey")String tempProbeKey);
@Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :domainId")
List<NoAuthProbe> findAllByDomainId(@Param("domainId")long domainId);
} }

View File

@ -3,6 +3,7 @@ package com.loafle.overflow.module.domain.dao;
import com.loafle.overflow.AppConfig; import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration; import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.module.domain.Domain; import com.loafle.overflow.module.domain.Domain;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -28,12 +29,12 @@ public class DomainDAOTest {
Domain domain = new Domain(); Domain domain = new Domain();
domain.setCreateDate(new Date());
domain.setName("snoop's domain"); domain.setName("snoop's domain");
this.domainDAO.save(domain); this.domainDAO.save(domain);
Assert.assertNotEquals(domain.getId(), 0);
} }
} }

View File

@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@ -30,8 +32,13 @@ public class NoAuthProbeDAOTest {
@Test @Test
public void testFindTempKey() { public void testFindTempKey() {
NoAuthProbe probe = this.noAuthProbeDAO.findByTempKey("1cf2555c57d511e79714080027658d13");
Assert.assertNotEquals(probe, null);
System.out.println(probe.getTempProbeKey());
} }
// @Ignore // @Ignore
@ -40,21 +47,43 @@ public class NoAuthProbeDAOTest {
NoAuthProbe noAuthProbe = new NoAuthProbe(); NoAuthProbe noAuthProbe = new NoAuthProbe();
noAuthProbe.setApiKey("11111111111111");
noAuthProbe.setHostName("snooop"); noAuthProbe.setHostName("snooop");
noAuthProbe.setIpAddress(44444); noAuthProbe.setIpAddress(3232235980L);
noAuthProbe.setMacAddress(222222); noAuthProbe.setMacAddress(8796753988883L);
noAuthProbe.setStatus(AuthType.PROCESS); noAuthProbe.setStatus(AuthType.PROCESS);
noAuthProbe.setTempProbeKey("4444"); noAuthProbe.setTempProbeKey("1cf2555c57d511e79714080027658d13");
Domain d = new Domain(); Domain d = new Domain();
d.setId(1); d.setId(1);
noAuthProbe.setDomain(d); noAuthProbe.setDomain(d);
System.out.println(noAuthProbe.getId()); this.noAuthProbeDAO.save(noAuthProbe);
Assert.assertNotEquals(noAuthProbe.getId(), 0); Assert.assertNotEquals(noAuthProbe.getId(), 0);
} }
@Test
public void update() {
NoAuthProbe probe = this.noAuthProbeDAO.findByTempKey("1cf2555c57d511e79714080027658d13");
probe.setStatus(AuthType.ACCEPT);
this.noAuthProbeDAO.save(probe);
}
@Test
public void list() {
List<NoAuthProbe> probes = this.noAuthProbeDAO.findAllByDomainId(1);
Assert.assertNotEquals(probes.size(), 0);
}
} }