FileDocCategorySizeDatePackage
CMPFieldExistence.javaAPI DocGlassfish v2 API4310Fri May 04 22:33:36 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.entity

CMPFieldExistence

public class CMPFieldExistence extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
Any CMP entity bean should have at least one cmp field defined in the DDs

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(EjbDescriptor descriptor)
Any CMP entity bean should have at least one cmp field defined in the DDs

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
        if (descriptor instanceof EjbEntityDescriptor) {
	    String persistentType = 
		((EjbEntityDescriptor)descriptor).getPersistenceType();
	    if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) {
                EjbCMPEntityDescriptor cmpDesc = (EjbCMPEntityDescriptor) descriptor;
                PersistenceDescriptor persDesc = cmpDesc.getPersistenceDescriptor();
                if (persDesc.getCMPFields().size()==0) {
                    result.failed(smh.getLocalString
                                           (getClass().getName()+"failed",
                                            "For CMP entity bean [ {0} ], no cmp field are defined",
                                            new Object[] {descriptor.getName()}));
                } else {
                    result.passed(smh.getLocalString
                                           (getClass().getName() + ".passed",
                                            "For CMP entity bean [ {0} ], some cmp fields are defined",
                                            new Object[] {descriptor.getName()}));                    
                }
                return result;
            } 
        }
        
        // everything else is NA
        result.notApplicable(smh.getLocalString
				(getClass().getName() + ".notApplicable",
				 "The EJB [ {0} ] is not an CMP entity bean",
				 new Object[] {descriptor.getName()}));    
         return result;