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