Search in sources :

Example 6 with RelationshipDescriptor

use of org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor in project Payara by payara.

the class EJBBundleInfoHelper method getRelationshipsForEjb.

/**
 * @see EJBInfoHelper#getRelationshipsForEjb
 */
public Collection getRelationshipsForEjb(String ejbName) {
    Iterator iterator = getBundleDescriptor().getRelationships().iterator();
    ArrayList returnList = new ArrayList();
    // getFieldsForEjb)
    while (iterator.hasNext()) {
        RelationshipDescriptor relD = (RelationshipDescriptor) iterator.next();
        RelationRoleDescriptor testRole = relD.getSource();
        String cmrField = null;
        if (ejbName.equals(testRole.getOwner().getName())) {
            cmrField = testRole.getCMRField();
            if (cmrField != null)
                returnList.add(cmrField);
        }
        testRole = relD.getSink();
        if (ejbName.equals(testRole.getOwner().getName())) {
            cmrField = testRole.getCMRField();
            if (cmrField != null)
                returnList.add(cmrField);
        }
    }
    return returnList;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) RelationRoleDescriptor(org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor)

Example 7 with RelationshipDescriptor

use of org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor in project Payara by payara.

the class CmrFieldTest method check.

/**
 * @param descriptor the Enterprise Java Bean deployment descriptor
 *
 * @return <code>Result</code> the results for this assertion
 */
public Result check(EjbCMPEntityDescriptor descriptor) {
    Result result = getInitializedResult();
    addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    boolean found = false;
    Class c = loadEjbClass(descriptor, result);
    if (c != null) {
        Set cmrFields = ((EjbCMPEntityDescriptor) descriptor).getPersistenceDescriptor().getRelationships();
        Iterator cmrIterator = cmrFields.iterator();
        if (cmrIterator.hasNext()) {
            while (cmrIterator.hasNext()) {
                RelationshipDescriptor cmfDescriptor = (RelationshipDescriptor) cmrIterator.next();
                {
                    // test if this bean is the source in this relationship
                    RelationRoleDescriptor role = cmfDescriptor.getSource();
                    if (role.getOwner().equals(descriptor) && role.getCMRField() != null) {
                        found = true;
                        if (!runIndividualCmrTest(descriptor, role, c, result)) {
                            oneFailed = true;
                        }
                    }
                }
                // we need to test for both source and sink because of self references
                {
                    // test if this bean is the sink in this relationship
                    RelationRoleDescriptor role = cmfDescriptor.getSink();
                    if (role.getOwner().equals(descriptor) && role.getCMRField() != null) {
                        found = true;
                        if (!runIndividualCmrTest(descriptor, role, c, result)) {
                            oneFailed = true;
                        }
                    }
                }
            }
            if (oneFailed)
                result.setStatus(Result.FAILED);
            else if (found == false) {
                result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldTest.notApplicable", "Not Applicable : The EJB has no CMR fields declared", new Object[] {}));
            } else
                result.setStatus(Result.PASSED);
        } else {
            result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2.CmrFieldTest.notApplicable", "Not Applicable : The EJB has no CMR fields declared", new Object[] {}));
        }
    }
    return result;
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) RelationshipDescriptor(org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result) RelationRoleDescriptor(org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor)

Aggregations

RelationshipDescriptor (org.glassfish.ejb.deployment.descriptor.RelationshipDescriptor)7 Iterator (java.util.Iterator)4 RelationRoleDescriptor (org.glassfish.ejb.deployment.descriptor.RelationRoleDescriptor)4 ArrayList (java.util.ArrayList)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 WebService (com.sun.enterprise.deployment.WebService)2 Set (java.util.Set)2 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)2 InjectionCapable (com.sun.enterprise.deployment.InjectionCapable)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 Result (com.sun.enterprise.tools.verifier.Result)1 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DummyEjbDescriptor (org.glassfish.ejb.deployment.descriptor.DummyEjbDescriptor)1 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)1 PersistenceDescriptor (org.glassfish.ejb.deployment.descriptor.PersistenceDescriptor)1 Node (org.w3c.dom.Node)1