Nova versao do simulador e tratamento de erros das chamadas.
[simdecs2.git] / src / java / org / ufcspa / simdecs / entities / Rede.java
CommitLineData
ae815b9b
MS
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package org.ufcspa.simdecs.entities;
6
7import java.io.Serializable;
8import java.util.List;
9import javax.persistence.Column;
10import javax.persistence.Entity;
11import javax.persistence.GeneratedValue;
12import javax.persistence.GenerationType;
13import javax.persistence.Id;
14import javax.persistence.OneToMany;
15import javax.persistence.SequenceGenerator;
16import org.hibernate.annotations.Table;
17
18/**
19 *
20 * @author maroni
21 */
22@Entity
23@Table(appliesTo="Rede")
7e20fa53 24public class Rede implements Serializable, IdHolder, Comparable<Rede> {
ae815b9b
MS
25 private static final long serialVersionUID = 1L;
26 @Id
27 @SequenceGenerator(name="seqRede", sequenceName="SQ_REDE")
28 @GeneratedValue(strategy = GenerationType.AUTO, generator="seqRede")
29 private Long id;
30
31 @Column(length=100, nullable=false)
32 private String nome;
33
34 @Column(length=100, nullable=false)
35 private String arquivo;
0bfd9a6b
MS
36
37 @Column(length=100, nullable=true)
38 private String descricao;
ae815b9b
MS
39
40 @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy="rede")
41 private List<Nodo> nodos;
42
43 public Long getId() {
7e20fa53 44 return id;
ae815b9b
MS
45 }
46
47 public void setId(Long id) {
48 this.id = id;
49 }
50
51 @Override
52 public int hashCode() {
53 int hash = 0;
54 hash += (id != null ? id.hashCode() : 0);
55 return hash;
56 }
57
58 @Override
59 public boolean equals(Object object) {
ae815b9b
MS
60 if (!(object instanceof Rede)) {
61 return false;
62 }
63 Rede other = (Rede) object;
64 if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
65 return false;
66 }
67 return true;
68 }
69
70 @Override
71 public String toString() {
72 return "org.ufcspa.simdecs.entities.Rede[ id=" + id + " ]";
73 }
74
75 public String getArquivo() {
76 return arquivo;
77 }
78
79 public void setArquivo(String arquivo) {
80 this.arquivo = arquivo;
81 }
0bfd9a6b
MS
82
83 public String getNomeArquivo() {
84 String nomeArquivo = arquivo.substring(arquivo.lastIndexOf('/') + 1);
85 return nomeArquivo.substring(nomeArquivo.indexOf("_") + 1);
86 }
ae815b9b
MS
87
88 public String getNome() {
89 return nome;
90 }
91
92 public void setNome(String nome) {
93 this.nome = nome;
94 }
95
ae815b9b
MS
96 public List<Nodo> getNodos() {
97 return nodos;
98 }
99
100 public void setNodos(List<Nodo> nodos) {
101 this.nodos = nodos;
102 }
0bfd9a6b
MS
103
104 public String getDescricao() {
105 return descricao;
106 }
107
108 public void setDescricao(String descricao) {
109 this.descricao = descricao;
110 }
7e20fa53
MS
111
112 @Override
113 public int compareTo(Rede t) {
114 return t.getId().intValue() - this.getId().intValue();
115 }
ae815b9b
MS
116
117}