1 23 24 25 package com.sun.enterprise.deployment; 26 27 import java.util.*; 28 import java.lang.reflect.*; 29 import com.sun.enterprise.util.LocalStringManagerImpl; 30 31 32 39 40 public final class RelationRoleDescriptor extends Descriptor { 41 42 private static LocalStringManagerImpl localStrings = 43 new LocalStringManagerImpl(RelationRoleDescriptor.class); 44 45 private EjbCMPEntityDescriptor owner; 48 private PersistenceDescriptor pers; 49 private RelationshipDescriptor relnDesc; 50 51 private String roleSourceDescription; 52 private String cmrField; private String cmrFieldDescription; 54 private String cmrFieldType; private boolean isMany; 56 private RelationRoleDescriptor partner; 57 private boolean cascadeDelete; 58 private CMRFieldInfo cmrFieldInfo; 59 private String relationRoleName; 60 61 public RelationRoleDescriptor() {} 62 63 64 68 public PersistenceDescriptor getPersistenceDescriptor() 69 { 70 return pers; 71 } 72 73 76 public void setPersistenceDescriptor(PersistenceDescriptor newPers) 77 { 78 if( this.pers != null ) { 79 this.pers.invalidate(); 81 } 82 83 this.pers = newPers; 84 if( newPers != null ) { 85 this.owner = (EjbCMPEntityDescriptor)newPers.getParentDescriptor(); 86 } 87 invalidateCMRFieldStuff(); 88 } 89 90 private void invalidateCMRFieldStuff() { 91 cmrFieldInfo = null; 92 if( pers != null ) { 93 pers.invalidate(); 94 } 95 } 96 97 public RelationshipDescriptor getRelationshipDescriptor() 98 { 99 return relnDesc; 100 } 101 102 public void setRelationshipDescriptor(RelationshipDescriptor relnDesc) 103 { 104 this.relnDesc = relnDesc; 105 } 106 107 public void setOwner(EjbCMPEntityDescriptor owner) 108 { 109 this.owner = owner; 110 invalidateCMRFieldStuff(); 111 } 112 113 public EjbCMPEntityDescriptor getOwner() 114 { 115 return owner; 116 } 117 118 121 public RelationRoleDescriptor getPartner() 122 { 123 return partner; 124 } 125 public void setPartner(RelationRoleDescriptor partner) 126 { 127 this.partner = partner; 128 } 129 130 public String getRelationRoleName() 131 { 132 return relationRoleName; 133 } 134 public void setRelationRoleName(String relationRoleName) 135 { 136 this.relationRoleName = relationRoleName; 137 } 138 139 public void setRoleSourceDescription(String roleSourceDescription) 140 { 141 this.roleSourceDescription = roleSourceDescription; 142 } 143 public String getRoleSourceDescription() 144 { 145 if ( roleSourceDescription == null ) 146 roleSourceDescription = ""; 147 return roleSourceDescription; 148 } 149 150 153 public void setCMRField(String cmrField) 154 { 155 this.cmrField = cmrField; 156 invalidateCMRFieldStuff(); 157 } 158 public String getCMRField() 159 { 160 return cmrField; 161 } 162 163 public void setCMRFieldDescription(String cmrFieldDescription) 164 { 165 this.cmrFieldDescription = cmrFieldDescription; 166 } 167 public String getCMRFieldDescription() 168 { 169 if ( cmrFieldDescription == null ) 170 cmrFieldDescription = ""; 171 return cmrFieldDescription; 172 } 173 174 178 public void setCMRFieldType(String newCmrFieldType) 179 { 180 if( newCmrFieldType == null ) { 181 this.cmrFieldType = null; 182 invalidateCMRFieldStuff(); 183 } else if ( newCmrFieldType.equals("java.util.Collection") 184 || newCmrFieldType.equals("java.util.Set") ) { 185 this.cmrFieldType = newCmrFieldType; 186 invalidateCMRFieldStuff(); 187 } else { 188 throw new IllegalArgumentException 189 ("cmr-field-type is " + newCmrFieldType + 190 ", must be java.util.Collection or java.util.Set"); 191 } 192 } 193 public String getCMRFieldType() 194 { 195 return cmrFieldType; 196 } 197 198 public void setIsMany(boolean isMany) 199 { 200 this.isMany = isMany; 201 invalidateCMRFieldStuff(); 202 } 203 public boolean getIsMany() 204 { 205 return isMany; 206 } 207 208 public void setCascadeDelete(boolean cascadeDelete) 209 { 210 this.cascadeDelete = cascadeDelete; 211 } 212 public boolean getCascadeDelete() 213 { 214 return cascadeDelete; 215 } 216 217 public void setCMRFieldInfo(CMRFieldInfo cmrFieldInfo) 218 { 219 this.cmrFieldInfo = cmrFieldInfo; 220 } 221 public CMRFieldInfo getCMRFieldInfo() 222 { 223 if ( cmrFieldInfo == null && pers != null ) 224 pers.getCMRFieldInfo(); return cmrFieldInfo; 226 } 227 228 public String composeReverseCmrFieldName() { 229 EjbCMPEntityDescriptor cmpDesc = getPartner().getOwner(); 230 String reverseCmrFieldName = "_" + cmpDesc.getName() + 231 "_" + getPartner().getCMRField(); 232 return reverseCmrFieldName; 233 } 234 } 235 236 | Popular Tags |