1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.jpa.metadata; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import javax.persistence.CascadeType; |
22 | |
|
23 | |
import org.apache.commons.lang.StringUtils; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 0 | public class ManyToManyDescriptor extends CollectionDescriptor implements java.io.Serializable { |
29 | |
|
30 | |
private static final long serialVersionUID = 1170389265194138638L; |
31 | |
|
32 | |
private String joinTableName; |
33 | 0 | private java.util.List<JoinColumnDescriptor> joinColumnDescriptors = new ArrayList<JoinColumnDescriptor>(); |
34 | 0 | private java.util.List<JoinColumnDescriptor> inverseJoinColumnDescriptors = new ArrayList<JoinColumnDescriptor>(); |
35 | |
|
36 | |
public String getJoinTableName() { |
37 | 0 | return this.joinTableName; |
38 | |
} |
39 | |
|
40 | |
public void setJoinTableName(String joinTableName) { |
41 | 0 | this.joinTableName = joinTableName; |
42 | 0 | } |
43 | |
|
44 | |
public void addJoinColumnDescriptor(JoinColumnDescriptor joinColumnDescriptor) { |
45 | 0 | joinColumnDescriptors.add(joinColumnDescriptor); |
46 | 0 | } |
47 | |
|
48 | |
public void addInverseJoinColumnDescriptor(JoinColumnDescriptor joinColumnDescriptor) { |
49 | 0 | inverseJoinColumnDescriptors.add(joinColumnDescriptor); |
50 | 0 | } |
51 | |
|
52 | |
public String toString() { |
53 | 0 | StringBuffer sb = new StringBuffer(); |
54 | 0 | sb.append("ManyToManyDescriptor = [ "); |
55 | 0 | sb.append("targetEntity:").append(targetEntity.getName()).append(", "); |
56 | 0 | sb.append("cascade = { "); |
57 | 0 | for (CascadeType ct : cascade) { |
58 | 0 | sb.append(ct).append(" "); |
59 | |
} |
60 | 0 | sb.append("}, "); |
61 | 0 | sb.append("fetch:").append(fetch); |
62 | 0 | if (!StringUtils.isBlank(mappedBy)) { |
63 | 0 | sb.append(", mappedBy:").append(mappedBy); |
64 | |
} |
65 | 0 | if (!StringUtils.isBlank(joinTableName)) { |
66 | 0 | sb.append(", join table:").append(joinTableName); |
67 | |
} |
68 | 0 | if (!joinColumnDescriptors.isEmpty()) { |
69 | 0 | sb.append(", join columns = { "); |
70 | 0 | for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) { |
71 | 0 | sb.append(" jc = { "); |
72 | 0 | sb.append("name:").append(joinColumnDescriptor.getName()).append(", "); |
73 | 0 | sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", "); |
74 | 0 | sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", "); |
75 | 0 | sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", "); |
76 | 0 | sb.append("updateable:").append(joinColumnDescriptor.isUpdateable()); |
77 | 0 | sb.append(" }"); |
78 | |
} |
79 | 0 | sb.append(" } "); |
80 | |
} |
81 | 0 | if (!inverseJoinColumnDescriptors.isEmpty()) { |
82 | 0 | sb.append(", inverse join columns = { "); |
83 | 0 | for (JoinColumnDescriptor joinColumnDescriptor : inverseJoinColumnDescriptors) { |
84 | 0 | sb.append(" jc = { "); |
85 | 0 | sb.append("name:").append(joinColumnDescriptor.getName()).append(", "); |
86 | 0 | sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", "); |
87 | 0 | sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", "); |
88 | 0 | sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", "); |
89 | 0 | sb.append("updateable:").append(joinColumnDescriptor.isUpdateable()); |
90 | 0 | sb.append(" }"); |
91 | |
} |
92 | 0 | sb.append(" } "); |
93 | |
} |
94 | 0 | sb.append(" ]"); |
95 | 0 | return sb.toString(); |
96 | |
} |
97 | |
|
98 | |
} |