View Javadoc
1   /*
2    * Copyright 2012 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.model;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.List;
21  import javax.persistence.CascadeType;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.FetchType;
25  import javax.persistence.GeneratedValue;
26  import javax.persistence.GenerationType;
27  import javax.persistence.Id;
28  import javax.persistence.JoinColumn;
29  import javax.persistence.Lob;
30  import javax.persistence.ManyToOne;
31  import javax.persistence.OneToMany;
32  import javax.persistence.OrderBy;
33  import javax.persistence.Table;
34  
35  /**
36   *
37   */
38  @Entity
39  @Table(name="j3_key_data_value")
40  public class KeyDataValue implements java.io.Serializable {
41      private static final long serialVersionUID = -6353389848796421615L;
42      
43      private Long id;
44      private KeyInfo keyInfo;
45      private String keyDataType;
46      private String keyDataName;
47      private byte[] keyDataValueBytes;
48      private String keyDataValueString;
49      private KeyDataValue keyDataValue;
50      private List<KeyDataValue> keyDataValueList = new ArrayList<KeyDataValue>();
51  
52      public KeyDataValue() {
53      }
54      
55      public KeyDataValue(KeyInfo keyInfo, String keyDataType, String keyDataName, byte[] keyDataValueBytes, String keyDataValueString, KeyDataValue keyDataValue) {
56          this.keyInfo = keyInfo;
57          this.keyDataType = keyDataType;
58          this.keyDataName = keyDataName;
59          this.keyDataValueBytes = keyDataValueBytes;
60          this.keyDataValueString = keyDataValueString;
61          this.keyDataValue = keyDataValue;
62      }
63      
64      
65      
66      @Id
67      @GeneratedValue(strategy=GenerationType.AUTO)
68      public Long getId() {
69          return id;
70      }
71  
72      public void setId(Long id) {
73          this.id = id;
74      }
75      
76      @ManyToOne(fetch = FetchType.LAZY)
77      @JoinColumn(name = "key_info_key", nullable = true)
78      public KeyInfo getKeyInfo() {
79          return keyInfo;
80      }
81  
82      public void setKeyInfo(KeyInfo keyInfo) {
83          this.keyInfo = keyInfo;
84      }
85      
86      @ManyToOne(fetch = FetchType.LAZY)
87      @JoinColumn(name = "key_data_value_key", nullable = true)
88      public KeyDataValue getKeyDataValue() {
89          return keyDataValue;
90      }
91  
92      public void setKeyDataValue(KeyDataValue keyDataValue) {
93          this.keyDataValue = keyDataValue;
94      }
95      
96      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "keyDataValue")
97      @OrderBy
98      public List<KeyDataValue> getKeyDataValueList() {
99          return keyDataValueList;
100     }
101 
102     public void setKeyDataValueList(List<KeyDataValue> keyDataValueList) {
103         this.keyDataValueList = keyDataValueList;
104     }
105 
106     @Column(name="key_data_name")
107     public String getKeyDataName() {
108         return keyDataName;
109     }
110 
111     public void setKeyDataName(String keyDataName) {
112         this.keyDataName = keyDataName;
113     }
114     
115     @Column(name="key_data_type")
116     public String getKeyDataType() {
117         return keyDataType;
118     }
119 
120     public void setKeyDataType(String keyDataType) {
121         this.keyDataType = keyDataType;
122     }
123 
124     @Lob
125     @Column(name="key_data_value", length = 65636)
126     public byte[] getKeyDataValueBytes() {
127         return keyDataValueBytes;
128     }
129 
130     public void setKeyDataValueBytes(byte[] keyDataValueBytes) {
131         this.keyDataValueBytes = keyDataValueBytes;
132     }
133 
134     @Lob
135     @Column(name="key_data_value_string", length = 65636)
136     public String getKeyDataValueString() {
137         return keyDataValueString;
138     }
139 
140     public void setKeyDataValueString(String keyDataValueString) {
141         this.keyDataValueString = keyDataValueString;
142     }
143 
144     @Override
145     public String toString() {
146         return "KeyDataValue{" + "id=" + getId() + ", keyDataType=" + getKeyDataType() +
147                 ", keyDataName=" + getKeyDataName() + ", keyDataValueBytes=" 
148                 + Arrays.toString(getKeyDataValueBytes()) + ", keyDataValueString=" + getKeyDataValueString()
149                 + ", keyDataValueList=" +getKeyDataValueList()  + '}';
150     }
151 }