Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.EjbRelationshipRole


    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here


    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

                if (roles.size() != 2) {
                    continue;
                }

                // get left entity
                EjbRelationshipRole leftRole = roles.get(0);
                RelationshipRoleSource leftRoleSource = leftRole.getRelationshipRoleSource();
                String leftEjbName = leftRoleSource == null ? null : leftRoleSource.getEjbName();
                Entity leftEntity = entitiesByName.get(leftEjbName);

                // get right entity
                EjbRelationshipRole rightRole = roles.get(1);
                RelationshipRoleSource rightRoleSource = rightRole.getRelationshipRoleSource();
                String rightEjbName = rightRoleSource == null ? null : rightRoleSource.getEjbName();
                Entity rightEntity = entitiesByName.get(rightEjbName);

                // neither left or right have a mapping which is fine
                if (leftEntity == null && rightEntity == null) {
                    continue;
                }
                // left not found?
                if (leftEntity == null) {
                    throw new OpenEJBException("Role source " + leftEjbName + " defined in relationship role " +
                            relation.getEjbRelationName() + "::" + leftRole.getEjbRelationshipRoleName() + " not found");
                }
                // right not found?
                if (rightEntity == null) {
                    throw new OpenEJBException("Role source " + rightEjbName + " defined in relationship role " +
                            relation.getEjbRelationName() + "::" + rightRole.getEjbRelationshipRoleName() + " not found");
                }

                String leftFieldName = null;
                boolean leftSynthetic = false;
                if (leftRole.getCmrField() != null) {
                    leftFieldName = leftRole.getCmrField().getCmrFieldName();
                } else {
                    leftFieldName = rightEntity.getName() + "_" + rightRole.getCmrField().getCmrFieldName();
                    leftSynthetic = true;
                }
                boolean leftIsOne = leftRole.getMultiplicity() == Multiplicity.ONE;

                String rightFieldName = null;
                boolean rightSynthetic = false;
                if (rightRole.getCmrField() != null) {
                    rightFieldName = rightRole.getCmrField().getCmrFieldName();
                } else {
                    rightFieldName = leftEntity.getName() + "_" + leftRole.getCmrField().getCmrFieldName();
                    rightSynthetic = true;
                }
                boolean rightIsOne = rightRole.getMultiplicity() == Multiplicity.ONE;

                if (leftIsOne && rightIsOne) {
                    //
                    // one-to-one
                    //
View Full Code Here

    }

    private void initRelationships(final EjbModule jar, final Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (final EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            final Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            final EjbRelationshipRole left = iterator.next();
            final EjbRelationshipRole right = iterator.next();

            // left role info
            final CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            final CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

        if (roles == null || roles.size() != 2) {
          // dunno what to do with this
          continue;
        }
       
        EjbRelationshipRole left = roles.get(0);
        EjbRelationshipRole right = roles.get(1);
       
        String leftClass = getEjbClass(ejbJar, left.getRelationshipRoleSource().getEjbName());
        String rightClass = getEjbClass(ejbJar, right.getRelationshipRoleSource().getEjbName());
        String leftMethod = null;
        try {
          leftMethod = "get" + capitaliseFirstLetter(left.getCmrField().getCmrFieldName());
        } catch (Exception e) {
        }
   
        String rightMethod = null;
        try {
          rightMethod = "get" + capitaliseFirstLetter(right.getCmrField().getCmrFieldName());
        } catch (Exception e) {
        }
       
        boolean leftCascade = left.getCascadeDelete();
        boolean rightCascade = right.getCascadeDelete();
       
        Map<String, Object> leftProps = new HashMap<String, Object>();
        leftProps.put("targetEntity", rightClass);
       
        if (leftCascade) {
          leftProps.put("cascade", new Object[] { javax.persistence.CascadeType.REMOVE }); //$NON-NLS-1$
        }
       

        Map<String, Object> rightProps = new HashMap<String, Object>();
        rightProps.put("targetEntity", leftClass);
       
        if (rightCascade) {
          rightProps.put("cascade", new Object[] { javax.persistence.CascadeType.REMOVE }); //$NON-NLS-1$
        }
       
        if (Multiplicity.MANY.equals(left.getMultiplicity()) && Multiplicity.MANY.equals(right.getMultiplicity())) {
          if (leftMethod != null)
            facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.ManyToMany.class, leftProps);
          if (rightMethod != null)
            facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.ManyToMany.class, rightProps);
        } else if (Multiplicity.MANY.equals(left.getMultiplicity()) && Multiplicity.ONE.equals(right.getMultiplicity())) {
          if (leftMethod != null)
            facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.ManyToOne.class, leftProps);
          if (rightMethod != null)
            facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.OneToMany.class, rightProps);
        } else if (Multiplicity.ONE.equals(left.getMultiplicity()) && Multiplicity.MANY.equals(right.getMultiplicity())) {
          if (leftMethod != null)
            facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.OneToMany.class, leftProps);
          if (rightMethod != null)
            facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.ManyToOne.class, rightProps);
        } else if (Multiplicity.ONE.equals(left.getMultiplicity()) && Multiplicity.ONE.equals(right.getMultiplicity())) {
          if (leftMethod != null)
            facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.OneToOne.class, leftProps);
          if (rightMethod != null)
            facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.OneToOne.class, rightProps);
        }
View Full Code Here

    }

    private void initRelationships(final EjbModule jar, final Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (final EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            final Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            final EjbRelationshipRole left = iterator.next();
            final EjbRelationshipRole right = iterator.next();

            // left role info
            final CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            final CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

    }

    private void initRelationships(EjbModule jar, Map<String, EnterpriseBeanInfo> infos) throws OpenEJBException {
        for (EjbRelation ejbRelation : jar.getEjbJar().getRelationships().getEjbRelation()) {
            Iterator<EjbRelationshipRole> iterator = ejbRelation.getEjbRelationshipRole().iterator();
            EjbRelationshipRole left = iterator.next();
            EjbRelationshipRole right = iterator.next();

            // left role info
            CmrFieldInfo leftCmrFieldInfo = initRelationshipRole(left, right, infos);
            CmrFieldInfo rightCmrFieldInfo = initRelationshipRole(right, left, infos);
            leftCmrFieldInfo.mappedBy = rightCmrFieldInfo;
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.EjbRelationshipRole

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.