FileDocCategorySizeDatePackage
CmrUseCorrectCollectionInterface.javaAPI DocGlassfish v2 API4846Fri May 04 22:33:40 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2

CmrUseCorrectCollectionInterface

public class CmrUseCorrectCollectionInterface extends CmrFieldTest
Container managed relationship type field must use of the collection interface for on-to-many or many-to-many relationships and specify it in the Deployment Descriptor
author
Jerome Dochez
version

Fields Summary
Constructors Summary
Methods Summary
protected booleanrunIndividualCmrTest(Descriptor descriptor, com.sun.enterprise.deployment.RelationRoleDescriptor rrd, java.lang.Class c, com.sun.enterprise.tools.verifier.Result result)
run an individual verifier test of a declated cmr field of the class

param
entity the descriptor for the entity bean containing the cmp-field
param
info the descriptor for the declared cmr field
param
c the class owning the cmp field
parma
r the result object to use to put the test results in
return
true if the test passed

        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        if (rrd.getPartner().getIsMany()) {
            // must be one the collection interface 
            if (rrd.getCMRFieldType()==null) {
                addErrorDetails(result, compName);
              result.addErrorDetails(smh.getLocalString
		    (getClass().getName() + ".failed2",
                    "Error : CMR field [ {0} ]  cmr-field-type must be defined for one-to-many or many-to-many relationships and the value of the cmr-field-type element must be either: java.util.Collection or java.util.Set",
	            new Object[] {rrd.getCMRField()}));                
                return false;
            } else {
                CMRFieldInfo info = rrd.getCMRFieldInfo();
                if (rrd.getCMRFieldType().equals(info.type.getName())) {
                    result.addGoodDetails(smh.getLocalString
    		    (getClass().getName() + ".passed",
                        "CMR field [ {0} ] is the same type as declared in the deployment descriptors [ {1} ]",
        	            new Object[] {info.name, info.role.getCMRFieldType()}));                
                    return true;                
                } else {
                    addErrorDetails(result, compName);
                    result.addErrorDetails(smh.getLocalString
    		    (getClass().getName() + ".failed",
                        "Error : CMR field [ {0} ] is not the same type as declared in the deployment descriptors [ {1} ]",
    	            new Object[] {info.name, info.role.getCMRFieldType()}));                
                    return false;
                }            
            }
        }
       return true;