mapping method

This commit is contained in:
jackdaw 2016-11-17 18:57:17 +09:00
parent e985f0921e
commit cd5464a5cf
7 changed files with 24 additions and 8 deletions

View File

@ -20,7 +20,7 @@ public class DiscoveriyHistoryController {
DiscoveryZone zone = history.getZone();
if (zone != null) {
zone.mappingChildren();
zone.mappingChildren(history);
}
discoveryHistoryRepository.save(history);
}

View File

@ -35,7 +35,7 @@ public class DiscoveryHost {
this.zone = zone;
}
@OneToMany(mappedBy = "host")
@OneToMany(mappedBy = "host", cascade = CascadeType.ALL)
private List<PortScanHistory> histories;
public List<PortScanHistory> getHistories() {

View File

@ -81,7 +81,7 @@ public class DiscoveryPortController {
hostScanHistories.add(hostScanHistory);
}
z.setHostScanHistories(hostScanHistories);
z.setHistories(hostScanHistories);
List<DiscoveryHost> hl = new ArrayList<>();

View File

@ -16,7 +16,7 @@ public class ServiceScanHistory {
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(nullable = false, insertable = false, updatable = false)
@Column(nullable = false, updatable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date createDate;
@ -56,6 +56,7 @@ public class ServiceScanHistory {
this.serviceName = serviceName;
this.direction = direction;
this.packet = packet;
this.createDate = createAt;
}
public long getId() {

View File

@ -47,6 +47,22 @@ public class DiscoveryService {
this.serviceName = serviceName;
}
public PortType getPortType() {
return portType;
}
public void setPortType(PortType portType) {
this.portType = portType;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public long getId() {
return id;
}

View File

@ -82,8 +82,8 @@ public class DiscoveryZone {
}
public void mappingChildren() {
public void mappingChildren(DiscoveryHistory history) {
this.setDiscovery(history);
List<HostScanHistory> hostScanHistories = this.getHistories();
if (hostScanHistories != null) {
for (int i =0 ; i < hostScanHistories.size() ; ++i) {

View File

@ -16,7 +16,6 @@ import com.loafle.bridge.discoveryzone.ResultType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@ -100,7 +99,7 @@ public class DiscoveryHistoryRepositoryTest {
hostScanHistories.add(hostScanHistory);
}
zone.setHostScanHistories(hostScanHistories);
zone.setHistories(hostScanHistories);