BrightSide Workbench Full Report + Source Code
AssociatedObject.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 java.io.Serializable;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.Lob;
27 import javax.persistence.ManyToOne;
28 import org.turro.plugin.GenericObject;
29 
34 @Entity
35 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
36 public class AssociatedObject implements java.io.Serializable {
37 
38  @Id
39  @GeneratedValue(generator = "hibernate-uuid")
40  @Column(name="IDENTIFIER")
41  private String id;
42 
43  @Column(name="ASOCOBJ_KEY")
44  private String key;
45 
46  @Lob
47  @Column(name="ASOCOBJ_VALUE")
48  private byte[] value;
49 
50  @ManyToOne
51  @JoinColumn(name="CONTACT_FK")
52  private org.turro.contacts.Contact contact;
53 
54  public Contact getContact() {
55  return contact;
56  }
57 
58  public void setContact(Contact contact) {
59  this.contact = contact;
60  }
61 
62  public String getId() {
63  return id;
64  }
65 
66  public void setId(String id) {
67  this.id = id;
68  }
69 
70  public String getKey() {
71  return key;
72  }
73 
74  public void setKey(String key) {
75  this.key = key;
76  }
77 
78  public byte[] getValue() {
79  return value;
80  }
81 
82  public void setValue(byte[] value) {
83  this.value = value;
84  }
85 
86  /* Helpers */
87 
88  public Object getObject() {
89  GenericObject go = new GenericObject();
90  go.bytesToObject(value);
91  return go.getObject();
92  }
93 
94  public void setObject(Serializable object) {
95  GenericObject go = new GenericObject();
96  go.setObject(object);
97  setValue(go.objectToBytes());
98  }
99 
100 }
void setObject(Serializable object)