Examples of EjbRelationshipRole


Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

        }
        else if (element.getText().equals(elementTypes[RELATIONSHIP_ROLE])) {
            if (isEmpty(textList.get(1).getText())) {
                return false;
            }
            EjbRelationshipRole role = (EjbRelationshipRole)eObject;
            if (role == null) {
                role = (EjbRelationshipRole)getEFactory().create(EjbRelationshipRole.class);
                relation = (EjbRelation)((EjbRelationSection)section).getSelectedObject();
                relation.getEjbRelationshipRole().add(role);
            }
            role.setEjbRelationshipRoleName(textList.get(0).getText());
            EjbRelationshipRole.RelationshipRoleSource source = role.getRelationshipRoleSource();
            if (source == null) {
                source = (EjbRelationshipRole.RelationshipRoleSource)getEFactory().create(EjbRelationshipRole.RelationshipRoleSource.class);
                role.setRelationshipRoleSource(source);
            }
            source.setEjbName(textList.get(1).getText());
            EjbRelationshipRole.CmrField cmrField = role.getCmrField();
            if (cmrField == null) {
                cmrField = (EjbRelationshipRole.CmrField)getEFactory().create(EjbRelationshipRole.CmrField.class);
                role.setCmrField(cmrField);
            }
            cmrField.setCmrFieldName(textList.get(2).getText());
        }
        else if (element.getText().equals(elementTypes[CMR_FIELD_MAPPING])) {
            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(1).getText())) {
                return false;
            }
            EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
                    (EjbRelationshipRole.RoleMapping.CmrFieldMapping)eObject;
            if (fieldMapping == null) {
                fieldMapping = (EjbRelationshipRole.RoleMapping.CmrFieldMapping)getEFactory().create(EjbRelationshipRole.RoleMapping.CmrFieldMapping.class);
                EjbRelationshipRole role = (EjbRelationshipRole)((EjbRelationSection)section).getSelectedObject();
                EjbRelationshipRole.RoleMapping roleMapping = role.getRoleMapping();
                if (roleMapping == null) {
                    roleMapping = (EjbRelationshipRole.RoleMapping)getEFactory().create(EjbRelationshipRole.RoleMapping.class);
                    role.setRoleMapping(roleMapping);
                }
                role.getRoleMapping().getCmrFieldMapping().add(fieldMapping);
            }
            fieldMapping.setKeyColumn(textList.get(0).getText());
            fieldMapping.setForeignKeyColumn(textList.get(1).getText());
        }
        return true;
View Full Code Here

Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

            PersistenceContextRef contextRef = (PersistenceContextRef)source;
            if (contextRef.getPattern() != null && isEmpty(contextRef.getPattern())) {
                contextRef.setPattern(null);
            }
        } else if (source instanceof EjbRelationshipRole) {
            EjbRelationshipRole role = (EjbRelationshipRole)source;
            if (role.getRoleMapping() != null && role.getRoleMapping().getCmrFieldMapping().size() == 0) {
                role.setRoleMapping(null);
            }
        }
    }
View Full Code Here

Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

        else if (EjbRelationshipRole.class.isInstance(anItem)) {
            EjbRelation relation = (EjbRelation)tree.getSelection()[0].getParentItem().getData();
            relation.getEjbRelationshipRole().remove(anItem);
        }
        else if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(anItem)) {
            EjbRelationshipRole role = (EjbRelationshipRole)tree.getSelection()[0].getParentItem().getData();
            role.getRoleMapping().getCmrFieldMapping().remove(anItem);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

                if (EjbRelation.class.isInstance(parentElement)) {
                    EjbRelation relation = (EjbRelation)parentElement;
                    return relation.getEjbRelationshipRole().toArray();
                }
                if (EjbRelationshipRole.class.isInstance(parentElement)) {
                    EjbRelationshipRole role = (EjbRelationshipRole)parentElement;
                    if (role.getRoleMapping() != null) {
                        return role.getRoleMapping().getCmrFieldMapping().toArray();
                    }
                }
                return new String[] {};
            }
        };
View Full Code Here

Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

                    EjbRelation relation = (EjbRelation)element;
                    return "EJB Relation: name = \"" + relation.getEjbRelationName() +
                            "\", MTM table name = \"" + relation.getManyToManyTableName() + "\"";
                }
                if (EjbRelationshipRole.class.isInstance(element)) {
                    EjbRelationshipRole role = (EjbRelationshipRole)element;
                    return "EJB Relationship Role: name = \"" + role.getEjbRelationshipRoleName() +
                            "\", source = \"" + role.getRelationshipRoleSource().getEjbName() +
                            "\", CMR field name = \"" + role.getCmrField().getCmrFieldName() + "\"";
                }
                if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(element)) {
                    EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
                            (EjbRelationshipRole.RoleMapping.CmrFieldMapping)element;
                    return "CMR Field Mapping: key column = \"" + fieldMapping.getKeyColumn() +
View Full Code Here

Examples of org.apache.geronimo.jee.openejb.EjbRelationshipRole

                    textList.get(0).setText(((EjbRelation)eObject).getEjbRelationName());
                    textList.get(1).setText(((EjbRelation)eObject).getManyToManyTableName());
                    element.select(EJB_RELATION);
                }
                else if (EjbRelationshipRole.class.isInstance(eObject)) {
                    EjbRelationshipRole role = (EjbRelationshipRole)eObject;
                    textList.get(0).setText(role.getEjbRelationshipRoleName());
                    textList.get(1).setText(role.getRelationshipRoleSource().getEjbName());
                    textList.get(2).setText(role.getCmrField().getCmrFieldName());
                    element.select(RELATIONSHIP_ROLE);
                }
                else if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(eObject)) {
                    EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
                            (EjbRelationshipRole.RoleMapping.CmrFieldMapping)eObject;
View Full Code Here

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

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

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

Examples of org.apache.openejb.jee.EjbRelationshipRole

                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
TOP
Copyright © 2018 www.massapi.com. 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.