1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package ch.hortis.sonar.model;
21
22 import java.io.Serializable;
23
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.FetchType;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.JoinColumn;
31 import javax.persistence.ManyToOne;
32 import javax.persistence.SequenceGenerator;
33 import javax.persistence.Table;
34
35 import org.apache.commons.lang.StringUtils;
36
37 @Entity(name="ProjectLink")
38 @Table(name = "project_links")
39 public class ProjectLink implements Serializable {
40
41 public static final int NAME_COLUMN_SIZE = 128;
42 public static final int HREF_COLUMN_SIZE = 2048;
43
44 public static final String LINK_HOME_PAGE = "homepage";
45 public static final String LINK_CONTINUOUS_INTEGRATION = "ci";
46 public static final String LINK_ISSUES_TRACKER = "issue";
47 public static final String LINK_SCM_URL = "scm";
48 public static final String LINK_SCM_RO_CONNECTION = "scm_ro";
49 public static final String LINK_SCM_DEV_CONNECTION = "scm_dev";
50
51 private static final long serialVersionUID = 3473761819014871039L;
52
53 @Id
54 @Column(name = "id")
55 @SequenceGenerator(name= "PROJECT_LINKS_SEQ", sequenceName = "PROJECT_LINKS_SEQ")
56 @GeneratedValue(strategy = GenerationType.AUTO, generator = "PROJECT_LINKS_SEQ")
57 private Integer id;
58
59 @ManyToOne(fetch = FetchType.LAZY)
60 @JoinColumn(name = "project_id", updatable = false, nullable = false)
61 private MavenProject mavenProject;
62
63 @Column(name = "link_type", updatable = true, nullable = true, length = 20)
64 private String type;
65
66 @Column(name = "name", updatable = true, nullable = true, length = NAME_COLUMN_SIZE)
67 private String name;
68
69 @Column(name = "href", updatable = true, nullable = false, length = HREF_COLUMN_SIZE)
70 private String href;
71
72 public ProjectLink() {
73 }
74
75 public ProjectLink(String type, String name, String href) {
76 this.type = type;
77 setName(name);
78 setHref(href);
79 }
80
81 public ProjectLink(MavenProject mavenProject, String type, String name, String href) {
82 this.mavenProject = mavenProject;
83 this.type = type;
84 this.name = name;
85 this.href = href;
86 }
87
88 public Integer getId() {
89 return id;
90 }
91
92 public void setId(Integer id) {
93 this.id = id;
94 }
95
96 public MavenProject getMavenProject() {
97 return mavenProject;
98 }
99
100 public void setMavenProject(MavenProject mavenProject) {
101 this.mavenProject = mavenProject;
102 }
103
104 public String getName() {
105 return name;
106 }
107
108 public void setName(String name) {
109 this.name = StringUtils.abbreviate(name, NAME_COLUMN_SIZE);
110 }
111
112 public String getHref() {
113 return href;
114 }
115
116 public void setHref(String href) {
117 this.href = StringUtils.abbreviate(href, HREF_COLUMN_SIZE);
118 }
119
120 public String getType() {
121 return type;
122 }
123
124 public void setType(String type) {
125 this.type = type;
126 }
127 }