Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
20aecd061d
|
@ -25,7 +25,7 @@ public class DiscoveryHistory
|
||||||
private Boolean result;
|
private Boolean result;
|
||||||
|
|
||||||
@JoinColumn
|
@JoinColumn
|
||||||
@OneToOne
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
private DiscoveryZone zone;
|
private DiscoveryZone zone;
|
||||||
|
|
||||||
public DiscoveryZone getZone() {
|
public DiscoveryZone getZone() {
|
||||||
|
|
|
@ -2,11 +2,8 @@ package com.loafle.bridge.discoveryhost;
|
||||||
|
|
||||||
import com.loafle.bridge.discoveryport.DiscoveryPort;
|
import com.loafle.bridge.discoveryport.DiscoveryPort;
|
||||||
import com.loafle.bridge.discoveryzone.DiscoveryZone;
|
import com.loafle.bridge.discoveryzone.DiscoveryZone;
|
||||||
import org.hibernate.annotations.*;
|
|
||||||
import org.hibernate.annotations.CascadeType;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -20,11 +17,11 @@ public class DiscoveryHost {
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@Column(name = "IP_ADDRESS",nullable = false)
|
@Column(name = "IP",nullable = false)
|
||||||
private long ipAddress;
|
private long ip;
|
||||||
|
|
||||||
@Column(name = "MAC_ADDRESS",nullable = false)
|
@Column(name = "MAC",nullable = false)
|
||||||
private long macAddress;
|
private long mac;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "ZONE_ID", nullable = false)
|
@JoinColumn(name = "ZONE_ID", nullable = false)
|
||||||
|
@ -49,8 +46,7 @@ public class DiscoveryHost {
|
||||||
this.histories = histories;
|
this.histories = histories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToMany(mappedBy = "host")
|
@OneToMany(mappedBy = "host",cascade = CascadeType.ALL)
|
||||||
@Cascade(CascadeType.ALL)
|
|
||||||
private List<DiscoveryPort> ports;
|
private List<DiscoveryPort> ports;
|
||||||
|
|
||||||
public List<DiscoveryPort> getPorts() {
|
public List<DiscoveryPort> getPorts() {
|
||||||
|
@ -70,8 +66,8 @@ public class DiscoveryHost {
|
||||||
|
|
||||||
public DiscoveryHost(){}
|
public DiscoveryHost(){}
|
||||||
public DiscoveryHost(long ip, long mac){
|
public DiscoveryHost(long ip, long mac){
|
||||||
this.ipAddress = ip;
|
this.ip = ip;
|
||||||
this.macAddress = mac;
|
this.mac = mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -82,24 +78,22 @@ public class DiscoveryHost {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getIpAddress() {
|
public long getIp() {
|
||||||
return ipAddress;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIpAddress(long ipAddress) {
|
public void setIp(long ip) {
|
||||||
this.ipAddress = ipAddress;
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMacAddress() {
|
public long getMac() {
|
||||||
return macAddress;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMacAddress(long macAddress) {
|
public void setMac(long mac) {
|
||||||
this.macAddress = macAddress;
|
this.mac = mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package com.loafle.bridge.discoveryport;
|
package com.loafle.bridge.discoveryport;
|
||||||
|
|
||||||
|
import com.loafle.bridge.discoveryhistory.DiscoveryHistory;
|
||||||
|
import com.loafle.bridge.discoveryhistory.DiscoveryHistoryRepository;
|
||||||
|
import com.loafle.bridge.discoveryhost.DiscoveryHost;
|
||||||
import com.loafle.bridge.discoveryport.type.PortType;
|
import com.loafle.bridge.discoveryport.type.PortType;
|
||||||
import com.loafle.bridge.discoveryservice.DiscoveryService;
|
import com.loafle.bridge.discoveryservice.DiscoveryService;
|
||||||
|
import com.loafle.bridge.discoveryzone.DiscoveryZone;
|
||||||
|
import com.loafle.bridge.discoveryzone.HostScanHistory;
|
||||||
|
import com.loafle.bridge.discoveryzone.ResultType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -10,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,26 +29,88 @@ public class DiscoveryPortController {
|
||||||
@Autowired
|
@Autowired
|
||||||
DiscoveryPortRepository repository;
|
DiscoveryPortRepository repository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DiscoveryHistoryRepository repo;
|
||||||
|
|
||||||
@RequestMapping(value = "/discoveryPort/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/discoveryPort/{id}", method = RequestMethod.GET)
|
||||||
public DiscoveryPort get(@PathVariable(value = "id") long id) {
|
public DiscoveryPort get(@PathVariable(value = "id") long id) {
|
||||||
return repository.findOne(id);
|
return repository.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value ="/index")
|
@RequestMapping(value ="/jack")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void index() {
|
public void index() {
|
||||||
DiscoveryPort p = new DiscoveryPort(PortType.TCP,(short)12786);
|
// DiscoveryPort p = new DiscoveryPort(PortType.TCP,(short)12786);
|
||||||
|
//
|
||||||
|
// List<DiscoveryService> ss = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// repository.save(p);
|
||||||
|
//
|
||||||
|
// ss.add(new DiscoveryService(p,PortType.TCP,"DNS"));
|
||||||
|
// ss.add(new DiscoveryService(p,PortType.TCP,"TEST"));
|
||||||
|
// ss.add(new DiscoveryService(p,PortType.TCP,"ABB"));
|
||||||
|
//
|
||||||
|
// p.setServices(ss);
|
||||||
|
//
|
||||||
|
// repository.save(p);
|
||||||
|
|
||||||
|
DiscoveryHistory d = new DiscoveryHistory();
|
||||||
|
d.setResult(true);
|
||||||
|
d.setStartDate(new Date());
|
||||||
|
d.setEndDate(new Date());
|
||||||
|
|
||||||
|
DiscoveryZone z = new DiscoveryZone();
|
||||||
|
String cidr = "827452358680";
|
||||||
|
String ip = "3232235983";
|
||||||
|
z.setCidr(Long.parseLong(cidr));
|
||||||
|
z.setIp(Long.parseLong(ip));
|
||||||
|
|
||||||
|
d.setZone(z);
|
||||||
|
// host scan histories
|
||||||
|
List<HostScanHistory> hostScanHistories = new ArrayList<HostScanHistory>();
|
||||||
|
for( int indexI = 0 ; indexI < 5; ++indexI) {
|
||||||
|
HostScanHistory hostScanHistory = new HostScanHistory();
|
||||||
|
hostScanHistory.setIp(Long.parseLong(ip));
|
||||||
|
hostScanHistory.setCreateDate(new Date());
|
||||||
|
hostScanHistory.setSendDate(new Date());
|
||||||
|
hostScanHistory.setResultDate(new Date());
|
||||||
|
hostScanHistory.setDescription("hgihihihih");
|
||||||
|
hostScanHistory.setResultType(ResultType.Success);
|
||||||
|
hostScanHistory.setZone(z);
|
||||||
|
hostScanHistories.add(hostScanHistory);
|
||||||
|
}
|
||||||
|
|
||||||
|
z.setHostScanHistories(hostScanHistories);
|
||||||
|
|
||||||
|
List<DiscoveryHost> hl = new ArrayList<>();
|
||||||
|
|
||||||
|
//add host
|
||||||
|
for (int i =0 ; i < 10 ; ++i) {
|
||||||
|
DiscoveryHost host = new DiscoveryHost(3232235986l,52242420297l);
|
||||||
|
host.setZone(z);
|
||||||
|
|
||||||
|
List<DiscoveryPort> p = new ArrayList<DiscoveryPort>();
|
||||||
|
host.setPorts(p);
|
||||||
|
|
||||||
|
//add port
|
||||||
|
for (int j =0 ; j < 10 ; ++j) {
|
||||||
|
DiscoveryPort port = new DiscoveryPort(host, PortType.TCP, 9840);
|
||||||
|
p.add(port);
|
||||||
|
|
||||||
List<DiscoveryService> ss = new ArrayList<>();
|
List<DiscoveryService> ss = new ArrayList<>();
|
||||||
|
|
||||||
repository.save(p);
|
ss.add(new DiscoveryService(port,PortType.TCP,"DNS"));
|
||||||
|
ss.add(new DiscoveryService(port,PortType.TCP,"TEST"));
|
||||||
|
ss.add(new DiscoveryService(port,PortType.TCP,"ABB"));
|
||||||
|
|
||||||
ss.add(new DiscoveryService(p,PortType.TCP,"DNS"));
|
port.setServices(ss);
|
||||||
ss.add(new DiscoveryService(p,PortType.TCP,"TEST"));
|
}
|
||||||
ss.add(new DiscoveryService(p,PortType.TCP,"ABB"));
|
hl.add(host);
|
||||||
|
}
|
||||||
|
z.setDiscoveryHosts(hl);
|
||||||
|
|
||||||
p.setServices(ss);
|
repo.save(d);
|
||||||
|
|
||||||
repository.save(p);
|
DiscoveryHistory find = repo.findOne(d.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user