BrightSide Workbench Full Report + Source Code
Connector.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.contacts ;
19 
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.ManyToOne;
26 import org.turro.contacts.util.TypeByValues;
27 import org.turro.jpa.entity.IDaoEntity;
28 import org.zkoss.lang.Strings;
29 
30 @Entity
31 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
32 public class Connector implements java.io.Serializable, IDaoEntity {
33 
34  @Id
35  @GeneratedValue(generator = "hibernate-uuid")
36  @Column(name="IDENTIFIER")
37  private String id;
38 
39  private String owner;
40 
41  private boolean onlyOwner;
42 
43  private String description;
44 
45  @Column(name="CONNECTOR_VALUE")
46  private String value;
47 
48  @ManyToOne
49  @JoinColumn(name="CONTACT_FK")
50  private org.turro.contacts.Contact contact;
51 
52  public String getFullConnector() {
53  String result = "";
54  if(getDescription() != null) result = getDescription() + ":";
55  if(getValue() != null) result += " " + getValue();
56  return result;
57  }
58 
59  public String getId() {
60  return id;
61  }
62 
63  protected void setId(String id) {
64  this.id = id;
65  }
66 
67  public String getOwner() {
68  return owner;
69  }
70 
71  public void setOwner(String owner) {
72  this.owner = owner;
73  }
74 
75  public boolean isOnlyOwner() {
76  return onlyOwner;
77  }
78 
79  public void setOnlyOwner(boolean onlyOwner) {
80  this.onlyOwner = onlyOwner;
81  }
82 
83  public String getDescription() {
84  return description;
85  }
86 
87  public void setDescription(String description) {
88  this.description = description;
89  }
90 
91  public String getValue() {
92  return value;
93  }
94 
95  public void setValue(String value) {
96  this.value = value;
97  }
98 
99  public org.turro.contacts.Contact getContact() {
100  return contact;
101  }
102 
103  public void setContact(org.turro.contacts.Contact contact) {
104  this.contact = contact;
105  }
106 
107  public boolean getCanShow(String userId) {
108  return true;
109  }
110 
111  /* IDaoEntity */
112 
113  @Override
114  public Object entityId() {
115  return id;
116  }
117 
118  @Override
119  public boolean isEmpty() {
120  return Strings.isEmpty(description) || Strings.isEmpty(value);
121  }
122 
123  /* Type helpers */
124 
125  public String getType() {
126  String type = TypeByValues.getType(value);
127  return type == null ? description : type;
128  }
129 
130 }
void setContact(org.turro.contacts.Contact contact)
Definition: Connector.java:103
boolean getCanShow(String userId)
Definition: Connector.java:107
void setOnlyOwner(boolean onlyOwner)
Definition: Connector.java:79
org.turro.contacts.Contact getContact()
Definition: Connector.java:99
void setOwner(String owner)
Definition: Connector.java:71
void setDescription(String description)
Definition: Connector.java:87
void setValue(String value)
Definition: Connector.java:95
static String getType(String value)