Methods Summary |
---|
public EjbBundleDescriptor | getBundleDescriptor()Gets the EjbBundleDescriptor which defines the universe of
names for this application.
return _bundleDescriptor;
|
public abstract java.lang.String | getConcreteBeanClassForEjbName(java.lang.String name)Gets the name of the concrete bean class which corresponds to the
specified ejb.
|
public abstract EjbCMPEntityDescriptor | getDescriptorForEjbName(java.lang.String name)Gets the EjbCMPEntityDescriptor which represents the ejb
with the specified name.
|
public abstract java.lang.String | getEjbNameForAbstractSchema(java.lang.String schemaName)Gets the name of the ejb which corresponds to the specified abstract
schema name.
|
protected java.util.Map | getGeneratedFieldsMap()
return _generatedRelToInverseRelMap;
|
protected java.util.Map | getInverseFieldsMap() return _relToInverseGeneratedRelMap;
|
public int | getKeyClassTypeForEjbName(java.lang.String name)Get the type of key class of this ejb.
String keyClass = getKeyClassForEjbName(name);
if (!"java.lang.Object".equals(keyClass)) // NOI18N
{
EjbCMPEntityDescriptor descriptor = getDescriptorForEjbName(name);
return ((descriptor.getPrimaryKeyFieldDesc() != null) ?
PRIMARY_KEY_FIELD : USER_DEFINED_KEY_CLASS);
}
return UNKNOWN_KEY_CLASS;
|
private boolean | hasField(PersistenceDescriptor persistenceDescriptor, java.lang.String fieldName)
Class fieldType = null;
try
{
fieldType = persistenceDescriptor.getTypeFor(fieldName);
}
catch (RuntimeException e)
{
// fieldType will be null - there is no such field
}
return (fieldType != null);
|
private void | initGeneratedRelationshipMaps()
EjbBundleDescriptor bundleDescriptor = getBundleDescriptor();
Set relationships = bundleDescriptor.getRelationships();
_generatedRelToInverseRelMap = new HashMap();
_relToInverseGeneratedRelMap = new HashMap();
// during development time this code may attempt to get the
// iterator even with no relationships, so protect it by a
// null check
if (relationships != null)
{
Iterator iterator = relationships.iterator();
List generatedRels = new ArrayList();
int counter = 0;
// gather list of generated cmr fields by examining source and sink
while (iterator.hasNext())
{
RelationshipDescriptor relationship =
(RelationshipDescriptor)iterator.next();
if (relationship.getSource().getCMRField() == null)
generatedRels.add(relationship);
if (relationship.getSink().getCMRField() == null)
generatedRels.add(relationship);
}
// now update the maps to contain this info
iterator = generatedRels.iterator();
while (iterator.hasNext())
{
RelationshipDescriptor relationship =
(RelationshipDescriptor)iterator.next();
RelationRoleDescriptor source = relationship.getSource();
String sourceEjbName = source.getOwner().getName();
String sourceCMRField = source.getCMRField();
boolean sourceIsNull = (sourceCMRField == null);
RelationRoleDescriptor sink = relationship.getSink();
String sinkEjbName = sink.getOwner().getName();
String ejbName = (sourceIsNull ? sourceEjbName : sinkEjbName);
String otherEjbName =
(sourceIsNull ? sinkEjbName : sourceEjbName);
List ejbField = Arrays.asList(new String[]{otherEjbName,
(sourceIsNull ? sink.getCMRField() : sourceCMRField)});
PersistenceDescriptor pDescriptor = ((EjbCMPEntityDescriptor)
bundleDescriptor.getEjbByName(ejbName)).
getPersistenceDescriptor();
List generatedField = null;
String uniqueName = null;
// make sure the user doesn't already have a field
// with this name
do
{
counter++;
uniqueName = GENERATED_CMR_FIELD_PREFIX + counter;
} while (hasField(pDescriptor, uniqueName));
generatedField =
Arrays.asList(new String[]{ejbName, uniqueName});
_generatedRelToInverseRelMap.put(generatedField, ejbField);
_relToInverseGeneratedRelMap.put(ejbField, generatedField);
}
}
|