use of com.sun.jdo.spi.persistence.support.ejb.model.util.NameMapper in project Payara by payara.
the class DeploymentDescriptorModel method getFields.
/**
* Returns a list of names of all the declared field elements in the
* class with the specified name. If the specified className represents
* a persistence-capable class, the list of field names from the
* corresponding ejb is returned (even if there is a Class object
* available for the persistence-capable).
* @param className the fully qualified name of the class to be checked
* @return the names of the field elements for the specified class
*/
public List getFields(final String className) {
final EjbCMPEntityDescriptor descriptor = getCMPDescriptor(className);
String testClass = className;
if (// need to get names of ejb fields
descriptor != null) {
Iterator iterator = descriptor.getFieldDescriptors().iterator();
List returnList = new ArrayList();
while (iterator.hasNext()) returnList.add(((FieldDescriptor) iterator.next()).getName());
return returnList;
} else {
NameMapper nameMapper = getNameMapper();
String ejbName = nameMapper.getEjbNameForPersistenceKeyClass(className);
switch(getPersistenceKeyClassType(className)) {
// ejb key class
case NameMapper.USER_DEFINED_KEY_CLASS:
testClass = nameMapper.getKeyClassForEjbName(ejbName);
break;
// find the field name we need in the abstract bean
case NameMapper.PRIMARY_KEY_FIELD:
return Arrays.asList(new String[] { getCMPDescriptor(ejbName).getPrimaryKeyFieldDesc().getName() });
// find the field name we need in the persistence capable
case NameMapper.UNKNOWN_KEY_CLASS:
String pcClassName = nameMapper.getPersistenceClassForEjbName(ejbName);
PersistenceFieldElement[] fields = getPersistenceClass(pcClassName).getFields();
int i, count = ((fields != null) ? fields.length : 0);
for (i = 0; i < count; i++) {
PersistenceFieldElement pfe = fields[i];
if (pfe.isKey())
return Arrays.asList(new String[] { pfe.getName() });
}
break;
}
}
return super.getFields(testClass);
}
Aggregations