From bc1105e98dab32c315213bac518e2050cd250e26 Mon Sep 17 00:00:00 2001 From: insanity Date: Mon, 21 Aug 2017 19:27:59 +0900 Subject: [PATCH] infra type string to int(child id) --- .../overflow/module/infra/model/Infra.java | 23 +++++++++--------- .../module/infra/model/InfraHost.java | 2 +- .../module/infra/model/InfraMachine.java | 2 +- .../overflow/module/infra/model/InfraOS.java | 2 +- .../infra/model/InfraOSApplication.java | 2 +- .../module/infra/model/InfraOSDaemon.java | 2 +- .../module/infra/model/InfraOSPort.java | 2 +- .../module/infra/model/InfraService.java | 2 +- src/main/resources/init.sql | 24 +++++++++---------- .../infra/service/InfraHostServiceTest.java | 5 ---- .../service/InfraMachineServiceTest.java | 4 ---- .../InfraOSApplicationServiceTest.java | 4 ---- .../service/InfraOSDaemonServiceTest.java | 4 ---- .../infra/service/InfraOSPortServiceTest.java | 4 ---- .../infra/service/InfraOSServiceTest.java | 2 -- .../service/InfraServiceServiceTest.java | 4 ---- 16 files changed, 30 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/infra/model/Infra.java b/src/main/java/com/loafle/overflow/module/infra/model/Infra.java index 3195de6..3e4d17d 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/Infra.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/Infra.java @@ -1,7 +1,6 @@ package com.loafle.overflow.module.infra.model; -import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.target.model.Target; @@ -14,10 +13,10 @@ import java.util.Date; @Entity(name = "INFRA") @Table(name = "INFRA", schema = "public") @Inheritance(strategy = InheritanceType.JOINED) -@DiscriminatorColumn(name = "INFRA_TYPE") +@DiscriminatorColumn(name = "INFRA_TYPE", discriminatorType = DiscriminatorType.INTEGER) public abstract class Infra { private long id; - private MetaInfraType infraType; +// private MetaInfraType infraType; // private long childId; private Date createDate; private Probe probe; @@ -97,15 +96,15 @@ public abstract class Infra { this.id = id; } - @ManyToOne - @JoinColumn(name = "TYPE_ID", nullable = false) - public MetaInfraType getInfraType() { - return infraType; - } - - public void setInfraType(MetaInfraType infraType) { - this.infraType = infraType; - } +// @ManyToOne +// @JoinColumn(name = "TYPE_ID", nullable = false) +// public MetaInfraType getInfraType() { +// return infraType; +// } +// +// public void setInfraType(MetaInfraType infraType) { +// this.infraType = infraType; +// } // @Basic // @Column(name = "CHILD_ID", nullable = false) diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraHost.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraHost.java index fd2eac6..3f1ae5b 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraHost.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraHost.java @@ -8,7 +8,7 @@ import java.util.Date; */ @Entity(name = "INFRA_HOST") @Table(name = "INFRA_HOST", schema = "public") -@DiscriminatorValue("INFRA_HOST") +@DiscriminatorValue("2") public class InfraHost extends Infra { // private long id; private InfraOS os; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java index 20cb15e..3516fb4 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraMachine.java @@ -8,7 +8,7 @@ import java.util.Date; */ @Entity(name = "INFRA_MACHINE") @Table(name = "INFRA_MACHINE", schema = "public") -@DiscriminatorValue("INFRA_MACHINE") +@DiscriminatorValue("1") public class InfraMachine extends Infra { // private long id; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraOS.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraOS.java index b79c9c3..c06086c 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraOS.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraOS.java @@ -11,7 +11,7 @@ import java.util.Date; */ @Entity(name = "INFRA_OS") @Table(name = "INFRA_OS", schema = "public") -@DiscriminatorValue("INFRA_OS") +@DiscriminatorValue("3") public class InfraOS extends Infra { // private long id; private InfraMachine machine; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSApplication.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSApplication.java index 37f8504..0790b23 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSApplication.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSApplication.java @@ -8,7 +8,7 @@ import java.util.Date; */ @Entity(name = "INFRA_OS_APPLICATION") @Table(name = "INFRA_OS_APPLICATION", schema = "public") -@DiscriminatorValue("INFRA_OS_APPLICATION") +@DiscriminatorValue("4") public class InfraOSApplication extends Infra { // private long id; private InfraOS os; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSDaemon.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSDaemon.java index 531411d..834c547 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSDaemon.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSDaemon.java @@ -8,7 +8,7 @@ import java.util.Date; */ @Entity(name = "INFRA_OS_DAEMON") @Table(name = "INFRA_OS_DAEMON", schema = "public") -@DiscriminatorValue("INFRA_OS_DAEMON") +@DiscriminatorValue("5") public class InfraOSDaemon extends Infra { // private long id; private InfraOS os; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSPort.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSPort.java index f276549..c368dba 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraOSPort.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraOSPort.java @@ -11,7 +11,7 @@ import java.util.Date; */ @Entity(name = "INFRA_OS_PORT") @Table(name = "INFRA_OS_PORT", schema = "public") -@DiscriminatorValue("INFRA_OS_PORT") +@DiscriminatorValue("6") public class InfraOSPort extends Infra { // private long id; private InfraOS os; diff --git a/src/main/java/com/loafle/overflow/module/infra/model/InfraService.java b/src/main/java/com/loafle/overflow/module/infra/model/InfraService.java index e19e7d9..f1fce56 100644 --- a/src/main/java/com/loafle/overflow/module/infra/model/InfraService.java +++ b/src/main/java/com/loafle/overflow/module/infra/model/InfraService.java @@ -11,7 +11,7 @@ import java.util.Date; */ @Entity(name = "INFRA_SERVICE") @Table(name = "INFRA_SERVICE", schema = "public") -@DiscriminatorValue("INFRA_SERVICE") +@DiscriminatorValue("7") public class InfraService extends Infra{ // private long id; private InfraHost host; diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index 04f78eb..8e18d90 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -406,18 +406,18 @@ INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_na INSERT INTO public.target (create_date,description,display_name) VALUES ( '2017-07-27 20:18:09.555','i am target','ghost target'); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_MACHINE','2017-08-21 12:59:10.244',1,1,1); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_OS','2017-08-21 13:05:24.883',3,1,1); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_HOST','2017-08-21 14:20:01.830',2,1,1); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_SERVICE','2017-08-21 14:24:26.525',7,1,1); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_OS_APPLICATION','2017-08-21 14:27:19.474',4,1,1); -INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( -'INFRA_OS_DAEMON','2017-08-21 14:28:48.761',5,1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +1,'2017-08-21 12:59:10.244',1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +3,'2017-08-21 13:05:24.883',1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +2,'2017-08-21 14:20:01.830',1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +7,'2017-08-21 14:24:26.525',1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +4,'2017-08-21 14:27:19.474',1,1); +INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES ( +5,'2017-08-21 14:28:48.761',1,1); INSERT INTO public.infra_machine (meta,id) VALUES ( diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java index 5e8f999..6bb746b 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraHostServiceTest.java @@ -1,14 +1,11 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraHost; - import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.meta.model.MetaInfraType; -import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -43,8 +40,6 @@ public class InfraHostServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(2); - infraHost.setInfraType(metaInfraType); - this.infraHostService.regist(infraHost); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java index 48154cb..6c697e2 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraMachineServiceTest.java @@ -1,13 +1,10 @@ package com.loafle.overflow.module.infra.service; import com.loafle.overflow.module.infra.model.InfraMachine; - import com.loafle.overflow.module.meta.model.MetaInfraType; -import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -36,7 +33,6 @@ public class InfraMachineServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(1); - infraMachine.setInfraType(metaInfraType); this.infraMachineService.regist(infraMachine); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java index 8c68fc7..4bd99fe 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSApplicationServiceTest.java @@ -6,15 +6,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.*; - /** * Created by snoop on 17. 7. 28. */ @@ -39,7 +36,6 @@ public class InfraOSApplicationServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(4); - infraOSApplication.setInfraType(metaInfraType); this.infraOSApplicationService.regist(infraOSApplication); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java index bde4797..0ae8316 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSDaemonServiceTest.java @@ -6,15 +6,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.*; - /** * Created by snoop on 17. 7. 28. */ @@ -40,7 +37,6 @@ public class InfraOSDaemonServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(5); - infraOSDaemon.setInfraType(metaInfraType); this.infraOSDaemonService.regist(infraOSDaemon); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java index 1b51ef8..e841058 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSPortServiceTest.java @@ -4,15 +4,12 @@ import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOSPort; import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.spring.AppConfigTest; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.*; - /** * Created by snoop on 17. 7. 28. */ @@ -37,7 +34,6 @@ public class InfraOSPortServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(2); - infraOSPort.setInfraType(metaInfraType); infraOSPort.setOs(infraOS); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java index f39c7f1..c60d855 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraOSServiceTest.java @@ -6,7 +6,6 @@ import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.codehaus.jackson.map.ObjectMapper; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +40,6 @@ public class InfraOSServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(3); - infraOS.setInfraType(metaInfraType); infraOS.setMachine(infraMachine); diff --git a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java index e3a6c1f..8ee7311 100644 --- a/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/infra/service/InfraServiceServiceTest.java @@ -7,15 +7,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.spring.AppConfigTest; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.*; - /** * Created by snoop on 17. 7. 28. */ @@ -49,7 +46,6 @@ public class InfraServiceServiceTest { MetaInfraType metaInfraType = new MetaInfraType(); metaInfraType.setId(7); - infraService.setInfraType(metaInfraType); this.infraServiceService.regist(infraService);