| 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 | |
import javax.persistence.FetchType; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | 0 | public class ObjectDescriptor implements java.io.Serializable { |
| 30 | |
|
| 31 | |
private static final long serialVersionUID = -6414242817173646832L; |
| 32 | |
|
| 33 | |
protected String attributeName; |
| 34 | |
protected Class targetEntity; |
| 35 | 0 | protected CascadeType [] cascade = new CascadeType[0]; |
| 36 | 0 | protected FetchType fetch = FetchType.EAGER; |
| 37 | 0 | protected boolean optional = true; |
| 38 | 0 | protected List<JoinColumnDescriptor> joinColumnDescriptors = new ArrayList<JoinColumnDescriptor>(); |
| 39 | 0 | protected List<String> fkFields = new ArrayList<String>(); |
| 40 | |
protected boolean insertable; |
| 41 | |
protected boolean updateable; |
| 42 | |
|
| 43 | |
public boolean isInsertable() { |
| 44 | 0 | return this.insertable; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public void setInsertable(boolean insertable) { |
| 48 | 0 | this.insertable = insertable; |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
public boolean isUpdateable() { |
| 52 | 0 | return this.updateable; |
| 53 | |
} |
| 54 | |
|
| 55 | |
public void setUpdateable(boolean updateable) { |
| 56 | 0 | this.updateable = updateable; |
| 57 | 0 | } |
| 58 | |
|
| 59 | |
public Class getTargetEntity() { |
| 60 | 0 | return this.targetEntity; |
| 61 | |
} |
| 62 | |
|
| 63 | |
public void setTargetEntity(Class targetEntity) { |
| 64 | 0 | this.targetEntity = targetEntity; |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
public CascadeType[] getCascade() { |
| 68 | 0 | return this.cascade; |
| 69 | |
} |
| 70 | |
|
| 71 | |
public void setCascade(CascadeType[] cascade) { |
| 72 | 0 | this.cascade = cascade; |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
public FetchType getFetch() { |
| 76 | 0 | return this.fetch; |
| 77 | |
} |
| 78 | |
|
| 79 | |
public void setFetch(FetchType fetch) { |
| 80 | 0 | this.fetch = fetch; |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
public boolean isOptional() { |
| 84 | 0 | return this.optional; |
| 85 | |
} |
| 86 | |
|
| 87 | |
public void setOptional(boolean optional) { |
| 88 | 0 | this.optional = optional; |
| 89 | 0 | } |
| 90 | |
|
| 91 | |
public String getAttributeName() { |
| 92 | 0 | return this.attributeName; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public void setAttributeName(String attributeName) { |
| 96 | 0 | this.attributeName = attributeName; |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
public void addJoinColumnDescriptor(JoinColumnDescriptor joinColumnDescriptor) { |
| 100 | 0 | joinColumnDescriptors.add(joinColumnDescriptor); |
| 101 | 0 | } |
| 102 | |
|
| 103 | |
public void addFkField(String fk) { |
| 104 | 0 | fkFields.add(fk); |
| 105 | 0 | } |
| 106 | |
|
| 107 | |
public List<JoinColumnDescriptor> getJoinColumnDescriptors() { |
| 108 | 0 | return joinColumnDescriptors; |
| 109 | |
} |
| 110 | |
|
| 111 | |
public List<String> getForeignKeyFields() { |
| 112 | 0 | return fkFields; |
| 113 | |
} |
| 114 | |
|
| 115 | |
public String toString() { |
| 116 | 0 | StringBuffer sb = new StringBuffer(); |
| 117 | 0 | sb.append("ObjectDescriptor = [ "); |
| 118 | 0 | sb.append("targetEntity:").append(targetEntity.getName()).append(", "); |
| 119 | 0 | sb.append("cascade = { "); |
| 120 | 0 | for (CascadeType ct : cascade) { |
| 121 | 0 | sb.append(ct).append(" "); |
| 122 | |
} |
| 123 | 0 | sb.append("}, "); |
| 124 | 0 | sb.append("fetch:").append(fetch).append(", "); |
| 125 | 0 | sb.append("optional:").append(optional); |
| 126 | 0 | if (!joinColumnDescriptors.isEmpty()) { |
| 127 | 0 | sb.append(", join columns = { "); |
| 128 | 0 | for (JoinColumnDescriptor joinColumnDescriptor : joinColumnDescriptors) { |
| 129 | 0 | sb.append(" jc = { "); |
| 130 | 0 | sb.append("name:").append(joinColumnDescriptor.getName()).append(", "); |
| 131 | 0 | sb.append("insertable:").append(joinColumnDescriptor.isInsertable()).append(", "); |
| 132 | 0 | sb.append("nullable:").append(joinColumnDescriptor.isNullable()).append(", "); |
| 133 | 0 | sb.append("unique:").append(joinColumnDescriptor.isUnique()).append(", "); |
| 134 | 0 | sb.append("updateable:").append(joinColumnDescriptor.isUpdateable()); |
| 135 | 0 | sb.append(" }"); |
| 136 | |
} |
| 137 | 0 | sb.append(" } "); |
| 138 | |
} |
| 139 | 0 | sb.append(" ]"); |
| 140 | 0 | return sb.toString(); |
| 141 | |
} |
| 142 | |
|
| 143 | |
} |