TemplateInfo.java
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.jpa.jpademo.domain;
import lombok.Data;
import org.springframework.util.StringUtils;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* 模版类:
* 意在表述一个模版由多个指令组成,并且一个模版可以被多个资源进行绑定;
* 在巡检中,同一个模版下可绑定多个资源,并且他们的采集频率应该是相同的;
* 在监控中,同一个模版每次绑定一个资源,而监控中的采集模版是根据指令的采集频率来进行调度的,因此,任务调度时以指令中频率为准。
*/
@Data
@Entity
@Table(name = "TEMPLATE_INFO")
public class TemplateInfo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id;
@Column(name = "TEMPLATE_ID")
String templateId;
@Column(name = "TEMPLATE_NAME")
String templateName;
// 指令集合
/*@NotNull
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(name="TEMPLATE_DIRECTIVE",
joinColumns={@JoinColumn(name="template_id",referencedColumnName="template_id")},
inverseJoinColumns={@JoinColumn(name="directive_id",referencedColumnName="directive_id")})
List<DirectiveModel> directiveModelList;*/
// 资源集合
@NotNull
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(name="TEMPLATE_RESOURCE",
joinColumns={@JoinColumn(name="template_id",referencedColumnName="template_id")},
inverseJoinColumns={@JoinColumn(name="resource_id",referencedColumnName="id")})
List<ResourceModel> resourceModels;
public String getTemplateId(){
if(StringUtils.isEmpty(templateId)) return "default-template";
return templateId;
}
}