diff --git a/src/main/java/com/loafle/bridge/discoveryhistory/DiscoveriyHistoryController.java b/src/main/java/com/loafle/bridge/discoveryhistory/DiscoveriyHistoryController.java index cfbf27c..0f527c4 100644 --- a/src/main/java/com/loafle/bridge/discoveryhistory/DiscoveriyHistoryController.java +++ b/src/main/java/com/loafle/bridge/discoveryhistory/DiscoveriyHistoryController.java @@ -20,7 +20,7 @@ public class DiscoveriyHistoryController { DiscoveryZone zone = history.getZone(); if (zone != null) { - zone.mappingChildren(); + zone.mappingChildren(history); } discoveryHistoryRepository.save(history); } diff --git a/src/main/java/com/loafle/bridge/discoveryhost/DiscoveryHost.java b/src/main/java/com/loafle/bridge/discoveryhost/DiscoveryHost.java index 4fce7c5..a74546d 100644 --- a/src/main/java/com/loafle/bridge/discoveryhost/DiscoveryHost.java +++ b/src/main/java/com/loafle/bridge/discoveryhost/DiscoveryHost.java @@ -35,7 +35,7 @@ public class DiscoveryHost { this.zone = zone; } - @OneToMany(mappedBy = "host") + @OneToMany(mappedBy = "host", cascade = CascadeType.ALL) private List histories; public List getHistories() { diff --git a/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPortController.java b/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPortController.java index 08b5ad8..96a2e54 100644 --- a/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPortController.java +++ b/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPortController.java @@ -81,7 +81,7 @@ public class DiscoveryPortController { hostScanHistories.add(hostScanHistory); } - z.setHostScanHistories(hostScanHistories); + z.setHistories(hostScanHistories); List hl = new ArrayList<>(); diff --git a/src/main/java/com/loafle/bridge/discoveryport/ServiceScanHistory.java b/src/main/java/com/loafle/bridge/discoveryport/ServiceScanHistory.java index fc6554d..fd590a9 100644 --- a/src/main/java/com/loafle/bridge/discoveryport/ServiceScanHistory.java +++ b/src/main/java/com/loafle/bridge/discoveryport/ServiceScanHistory.java @@ -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() { diff --git a/src/main/java/com/loafle/bridge/discoveryservice/DiscoveryService.java b/src/main/java/com/loafle/bridge/discoveryservice/DiscoveryService.java index a110544..7c124f7 100644 --- a/src/main/java/com/loafle/bridge/discoveryservice/DiscoveryService.java +++ b/src/main/java/com/loafle/bridge/discoveryservice/DiscoveryService.java @@ -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; } diff --git a/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java index 02c21ae..b3b7aa6 100644 --- a/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java +++ b/src/main/java/com/loafle/bridge/discoveryzone/DiscoveryZone.java @@ -82,8 +82,8 @@ public class DiscoveryZone { } - public void mappingChildren() { - + public void mappingChildren(DiscoveryHistory history) { + this.setDiscovery(history); List hostScanHistories = this.getHistories(); if (hostScanHistories != null) { for (int i =0 ; i < hostScanHistories.size() ; ++i) { diff --git a/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java b/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java index f5fedb1..f5e2dd1 100644 --- a/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java +++ b/src/test/java/com/loafle/bridge/discoveryHistory/repository/DiscoveryHistoryRepositoryTest.java @@ -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);