infra-target relation

This commit is contained in:
insanity 2018-06-05 18:03:20 +09:00
parent 09d9e28016
commit b3b052b5bd
2 changed files with 15 additions and 120 deletions

View File

@ -3,8 +3,6 @@ package com.loafle.overflow.model.infra;
import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.target.Target;
import javax.persistence.*;
import java.util.Date;
@ -18,74 +16,8 @@ import java.util.Date;
public abstract class Infra {
private Long id;
private MetaInfraType infraType;
// private Long childId;
private Date createDate;
private Probe probe;
private Target target;
// private InfraChild infraChild;
// private InfraHost infraHost;
// private InfraMachine infraMachine;
// private InfraOS infraOS;
/*
private Long id;
private MetaInfraType infraType;
private Long childId;
private Date createDate;
private Probe probeId;
private Target targetId;
*/
// @ManyToOne
// @JoinColumn(name = "CHILD_ID", nullable = false, insertable = false, updatable = false)
// public InfraHost getInfraChild() {
// return infraChild;
// }
//
// public void setInfraChild(InfraChild infraChild) {
// this.infraChild = infraChild;
// }
// @OneToOne
// @JoinColumn(name = "CHILD_ID")
// public InfraChild getInfraChild() {
// return infraChild;
// }
//
// public void setInfraChild(InfraChild infraChild) {
// this.infraChild = infraChild;
// }
// @ManyToOne
// @JoinColumn(name = "HOST_ID")
// public InfraHost getInfraHost() {
// return infraHost;
// }
//
// public void setInfraHost(InfraHost infraHost) {
// this.infraHost = infraHost;
// }
// @ManyToOne
// @JoinColumn(name = "MACHINE_ID")
// public InfraMachine getInfraMachine() {
// return infraMachine;
// }
//
// public void setInfraMachine(InfraMachine infraMachine) {
// this.infraMachine = infraMachine;
// }
//
// @ManyToOne
// @JoinColumn(name = "OS_ID")
// public InfraOS getInfraOS() {
// return infraOS;
// }
//
// public void setInfraOS(InfraOS infraOS) {
// this.infraOS = infraOS;
// }
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@ -107,16 +39,6 @@ public abstract class Infra {
this.infraType = infraType;
}
// @Basic
// @Column(name = "CHILD_ID", nullable = false)
// public Long getChildId() {
// return childId;
// }
//
// public void setChildId(Long childId) {
// this.childId = childId;
// }
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
@ -137,47 +59,5 @@ public abstract class Infra {
this.probe = probe;
}
@ManyToOne
@JoinColumn(name = "TARGET_ID", nullable = true)
public Target getTarget() {
return target;
}
public void setTarget(Target target) {
this.target = target;
}
// public static Infra CreateInfraByType(Long id, Class c) {
//
// Infra infra = new Infra();
//// infra.setChildId(id);
//
// MetaInfraType infraType = new MetaInfraType();
// if(c == InfraMachine.class) {
// infraType.setId(1);
// }
// else if(c == InfraHost.class) {
// infraType.setId(2);
// }
// else if(c == InfraOS.class) {
// infraType.setId(3);
// }
// else if(c == InfraOSApplication.class) {
// infraType.setId(4);
// }
// else if(c == InfraOSDaemon.class) {
// infraType.setId(5);
// }
// else if(c == InfraOSPort.class) {
// infraType.setId(6);
// }
// else if(c == InfraService.class) {
// infraType.setId(7);
// }
//
// infra.setInfraType(infraType);
//
// return infra;
// }
}

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.model.target;
import javax.persistence.*;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.sensor.Sensor;
import java.util.Date;
@ -19,6 +20,7 @@ public class Target {
private String displayName;
private String description;
private Integer sensorCount;
private Infra infra;
// Transient property
private List<Sensor> sensors;
@ -86,6 +88,19 @@ public class Target {
this.sensorCount = 0;
}
@OneToOne
@JoinColumn(name = "INFRA_ID", nullable = false)
public Infra getInfra() {
return infra;
}
/**
* @param infra the infra to set
*/
public void setInfra(Infra infra) {
this.infra = infra;
}
// @ManyToOne
// @JoinColumn(name = "PROBE_ID", nullable = false)