View Javadoc

1   /*
2    * Sonar, entreprise quality control tool.
3    * Copyright (C) 2007-2008 Hortis-GRC SA
4    * mailto:be_agile HAT hortis DOT ch
5    *
6    * Sonar is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 3 of the License, or (at your option) any later version.
10   *
11   * Sonar is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with {library}; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
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 }