infra type string to int(child id)

This commit is contained in:
insanity 2017-08-21 19:27:59 +09:00
parent bc2623e41f
commit bc1105e98d
16 changed files with 30 additions and 58 deletions

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.module.infra.model; 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.probe.model.Probe;
import com.loafle.overflow.module.target.model.Target; import com.loafle.overflow.module.target.model.Target;
@ -14,10 +13,10 @@ import java.util.Date;
@Entity(name = "INFRA") @Entity(name = "INFRA")
@Table(name = "INFRA", schema = "public") @Table(name = "INFRA", schema = "public")
@Inheritance(strategy = InheritanceType.JOINED) @Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "INFRA_TYPE") @DiscriminatorColumn(name = "INFRA_TYPE", discriminatorType = DiscriminatorType.INTEGER)
public abstract class Infra { public abstract class Infra {
private long id; private long id;
private MetaInfraType infraType; // private MetaInfraType infraType;
// private long childId; // private long childId;
private Date createDate; private Date createDate;
private Probe probe; private Probe probe;
@ -97,15 +96,15 @@ public abstract class Infra {
this.id = id; this.id = id;
} }
@ManyToOne // @ManyToOne
@JoinColumn(name = "TYPE_ID", nullable = false) // @JoinColumn(name = "TYPE_ID", nullable = false)
public MetaInfraType getInfraType() { // public MetaInfraType getInfraType() {
return infraType; // return infraType;
} // }
//
public void setInfraType(MetaInfraType infraType) { // public void setInfraType(MetaInfraType infraType) {
this.infraType = infraType; // this.infraType = infraType;
} // }
// @Basic // @Basic
// @Column(name = "CHILD_ID", nullable = false) // @Column(name = "CHILD_ID", nullable = false)

View File

@ -8,7 +8,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_HOST") @Entity(name = "INFRA_HOST")
@Table(name = "INFRA_HOST", schema = "public") @Table(name = "INFRA_HOST", schema = "public")
@DiscriminatorValue("INFRA_HOST") @DiscriminatorValue("2")
public class InfraHost extends Infra { public class InfraHost extends Infra {
// private long id; // private long id;
private InfraOS os; private InfraOS os;

View File

@ -8,7 +8,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_MACHINE") @Entity(name = "INFRA_MACHINE")
@Table(name = "INFRA_MACHINE", schema = "public") @Table(name = "INFRA_MACHINE", schema = "public")
@DiscriminatorValue("INFRA_MACHINE") @DiscriminatorValue("1")
public class InfraMachine extends Infra { public class InfraMachine extends Infra {
// private long id; // private long id;

View File

@ -11,7 +11,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_OS") @Entity(name = "INFRA_OS")
@Table(name = "INFRA_OS", schema = "public") @Table(name = "INFRA_OS", schema = "public")
@DiscriminatorValue("INFRA_OS") @DiscriminatorValue("3")
public class InfraOS extends Infra { public class InfraOS extends Infra {
// private long id; // private long id;
private InfraMachine machine; private InfraMachine machine;

View File

@ -8,7 +8,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_OS_APPLICATION") @Entity(name = "INFRA_OS_APPLICATION")
@Table(name = "INFRA_OS_APPLICATION", schema = "public") @Table(name = "INFRA_OS_APPLICATION", schema = "public")
@DiscriminatorValue("INFRA_OS_APPLICATION") @DiscriminatorValue("4")
public class InfraOSApplication extends Infra { public class InfraOSApplication extends Infra {
// private long id; // private long id;
private InfraOS os; private InfraOS os;

View File

@ -8,7 +8,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_OS_DAEMON") @Entity(name = "INFRA_OS_DAEMON")
@Table(name = "INFRA_OS_DAEMON", schema = "public") @Table(name = "INFRA_OS_DAEMON", schema = "public")
@DiscriminatorValue("INFRA_OS_DAEMON") @DiscriminatorValue("5")
public class InfraOSDaemon extends Infra { public class InfraOSDaemon extends Infra {
// private long id; // private long id;
private InfraOS os; private InfraOS os;

View File

@ -11,7 +11,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_OS_PORT") @Entity(name = "INFRA_OS_PORT")
@Table(name = "INFRA_OS_PORT", schema = "public") @Table(name = "INFRA_OS_PORT", schema = "public")
@DiscriminatorValue("INFRA_OS_PORT") @DiscriminatorValue("6")
public class InfraOSPort extends Infra { public class InfraOSPort extends Infra {
// private long id; // private long id;
private InfraOS os; private InfraOS os;

View File

@ -11,7 +11,7 @@ import java.util.Date;
*/ */
@Entity(name = "INFRA_SERVICE") @Entity(name = "INFRA_SERVICE")
@Table(name = "INFRA_SERVICE", schema = "public") @Table(name = "INFRA_SERVICE", schema = "public")
@DiscriminatorValue("INFRA_SERVICE") @DiscriminatorValue("7")
public class InfraService extends Infra{ public class InfraService extends Infra{
// private long id; // private long id;
private InfraHost host; private InfraHost host;

View File

@ -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 ( INSERT INTO public.target (create_date,description,display_name) VALUES (
'2017-07-27 20:18:09.555','i am target','ghost target'); '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 ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_MACHINE','2017-08-21 12:59:10.244',1,1,1); 1,'2017-08-21 12:59:10.244',1,1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_OS','2017-08-21 13:05:24.883',3,1,1); 3,'2017-08-21 13:05:24.883',1,1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_HOST','2017-08-21 14:20:01.830',2,1,1); 2,'2017-08-21 14:20:01.830',1,1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_SERVICE','2017-08-21 14:24:26.525',7,1,1); 7,'2017-08-21 14:24:26.525',1,1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_OS_APPLICATION','2017-08-21 14:27:19.474',4,1,1); 4,'2017-08-21 14:27:19.474',1,1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( INSERT INTO public.infra (infra_type,create_date,probe_id,target_id) VALUES (
'INFRA_OS_DAEMON','2017-08-21 14:28:48.761',5,1,1); 5,'2017-08-21 14:28:48.761',1,1);
INSERT INTO public.infra_machine (meta,id) VALUES ( INSERT INTO public.infra_machine (meta,id) VALUES (

View File

@ -1,14 +1,11 @@
package com.loafle.overflow.module.infra.service; package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraHost; import com.loafle.overflow.module.infra.model.InfraHost;
import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -43,8 +40,6 @@ public class InfraHostServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(2); metaInfraType.setId(2);
infraHost.setInfraType(metaInfraType);
this.infraHostService.regist(infraHost); this.infraHostService.regist(infraHost);

View File

@ -1,13 +1,10 @@
package com.loafle.overflow.module.infra.service; package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraMachine; import com.loafle.overflow.module.infra.model.InfraMachine;
import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,7 +33,6 @@ public class InfraMachineServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(1); metaInfraType.setId(1);
infraMachine.setInfraType(metaInfraType);
this.infraMachineService.regist(infraMachine); this.infraMachineService.regist(infraMachine);

View File

@ -6,15 +6,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;
/** /**
* Created by snoop on 17. 7. 28. * Created by snoop on 17. 7. 28.
*/ */
@ -39,7 +36,6 @@ public class InfraOSApplicationServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(4); metaInfraType.setId(4);
infraOSApplication.setInfraType(metaInfraType);
this.infraOSApplicationService.regist(infraOSApplication); this.infraOSApplicationService.regist(infraOSApplication);

View File

@ -6,15 +6,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;
/** /**
* Created by snoop on 17. 7. 28. * Created by snoop on 17. 7. 28.
*/ */
@ -40,7 +37,6 @@ public class InfraOSDaemonServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(5); metaInfraType.setId(5);
infraOSDaemon.setInfraType(metaInfraType);
this.infraOSDaemonService.regist(infraOSDaemon); this.infraOSDaemonService.regist(infraOSDaemon);

View File

@ -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.infra.model.InfraOSPort;
import com.loafle.overflow.module.meta.model.MetaInfraType; import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;
/** /**
* Created by snoop on 17. 7. 28. * Created by snoop on 17. 7. 28.
*/ */
@ -37,7 +34,6 @@ public class InfraOSPortServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(2); metaInfraType.setId(2);
infraOSPort.setInfraType(metaInfraType);
infraOSPort.setOs(infraOS); infraOSPort.setOs(infraOS);

View File

@ -6,7 +6,6 @@ import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -41,7 +40,6 @@ public class InfraOSServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(3); metaInfraType.setId(3);
infraOS.setInfraType(metaInfraType);
infraOS.setMachine(infraMachine); infraOS.setMachine(infraMachine);

View File

@ -7,15 +7,12 @@ import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.*;
/** /**
* Created by snoop on 17. 7. 28. * Created by snoop on 17. 7. 28.
*/ */
@ -49,7 +46,6 @@ public class InfraServiceServiceTest {
MetaInfraType metaInfraType = new MetaInfraType(); MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(7); metaInfraType.setId(7);
infraService.setInfraType(metaInfraType);
this.infraServiceService.regist(infraService); this.infraServiceService.regist(infraService);