use of org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor in project Payara by payara.
the class EJBBundleInfoHelper method getEjbNames.
/**
* @see EJBInfoHelper#getEjbNames
*/
public Collection getEjbNames() {
Iterator iterator = getBundleDescriptor().getEjbs().iterator();
ArrayList returnList = new ArrayList();
while (iterator.hasNext()) {
EjbDescriptor ejb = (EjbDescriptor) iterator.next();
if (ejb instanceof EjbCMPEntityDescriptor)
returnList.add(ejb.getName());
}
return returnList;
}
use of org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor in project Payara by payara.
the class NameMapper method getDescriptorForEjbName.
/**
* Gets the EjbCMPEntityDescriptor which represents the ejb
* with the specified name.
* @param name the name of the ejb
* @return the EjbCMPEntityDescriptor which represents the ejb.
*/
public EjbCMPEntityDescriptor getDescriptorForEjbName(String name) {
Map ejbMap = (Map) getMap().get(EJB_NAME);
Object descriptor = ejbMap.get(name);
return (((descriptor != null) && (descriptor instanceof EjbCMPEntityDescriptor)) ? (EjbCMPEntityDescriptor) descriptor : null);
}
use of org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor 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);
}
use of org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor in project Payara by payara.
the class DeploymentDescriptorModel method getFieldWrapper.
private MemberWrapper getFieldWrapper(String className, String fieldName) {
EjbCMPEntityDescriptor descriptor = getCMPDescriptor(className);
MemberWrapper returnObject = null;
if (descriptor != null) {
PersistenceDescriptor persistenceDescriptor = descriptor.getPersistenceDescriptor();
if (persistenceDescriptor != null) {
Class fieldType = null;
try {
fieldType = persistenceDescriptor.getTypeFor(fieldName);
} catch (RuntimeException e) {
// fieldType will be null - there is no such field
}
returnObject = ((fieldType == null) ? null : new MemberWrapper(fieldName, fieldType, Modifier.PRIVATE, (Class) getClass(className)));
}
}
return returnObject;
}
use of org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor in project Payara by payara.
the class NameMapper method initGeneratedRelationshipMaps.
private void initGeneratedRelationshipMaps() {
EjbBundleDescriptorImpl bundleDescriptor = getBundleDescriptor();
Set relationships = bundleDescriptor.getRelationships();
_generatedRelToInverseRelMap = new HashMap();
_relToInverseGeneratedRelMap = new HashMap();
// 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;
// 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);
}
}
}
Aggregations