Package org.apache.openejb.jee.oejb2

Examples of org.apache.openejb.jee.oejb2.ModuleType


    }

    public boolean performFinish() {
        AbstractTableWizardPage page = (AbstractTableWizardPage) getPages()[0];
        PathType path;
        ModuleType module;

        if (eObject == null) {
            eObject = getEFactory().create(ModuleType.class);
            JAXBElement plan = section.getPlan();

            module = (ModuleType)eObject;

            List moduleList = ((ApplicationType)plan.getValue()).getModule();
            if (moduleList == null) {
                moduleList = (List)getEFactory().create(ModuleType.class);
            }
            moduleList.add(eObject);
        }
        else {
            module = (ModuleType)eObject;
            module.setConnector(null);
            module.setEjb(null);
            module.setJava(null);
            module.setWeb(null);
        }

        // NOTE!! this replaces the call to processEAttributes (page);
        path = (PathType)getEFactory().create(PathType.class);
        path.setValue(page.getTextEntry(0).getText());

        if (((ModuleWizardPage)page).buttonList[0].getSelection())
            module.setConnector(path);
        else if (((ModuleWizardPage)page).buttonList[1].getSelection())
            module.setEjb(path);
        else if (((ModuleWizardPage)page).buttonList[2].getSelection())
            module.setJava(path);
        else if (((ModuleWizardPage)page).buttonList[3].getSelection())
            module.setWeb(path);
       
        String altDD = page.getTextEntry(1).getText();
        path = (PathType)getEFactory().create(PathType.class);
        path.setValue(altDD);
        module.setAltDd(path);
       
        if (section.getViewer().getInput() == section.getPlan()) {
            section.getViewer().setInput(section.getInput());
        }
View Full Code Here


        }

        public void createControl(Composite parent) {
            Composite composite = createComposite(parent);
            GridData data;
            ModuleType module = (ModuleType)eObject;
           
            // First we need a set of radio buttons to determine what kind of module we are
            // dealing with.
            Group group = new Group (composite, SWT.NONE);
            Button button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.connector);
            buttonList[0] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.ejb);
            buttonList[1] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.java);
            buttonList[2] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.web);
            buttonList[3] = button;
            FillLayout fillLayout = new FillLayout();
            fillLayout.type = SWT.HORIZONTAL;
            group.setLayout(fillLayout);
            data = new GridData();
            data.horizontalAlignment = GridData.FILL;
            data.horizontalSpan = 2;
            group.setLayoutData(data);
           
            for (int i = 1; i < section.getTableColumnNames().length; i++) {
                Label label = new Label(composite, SWT.LEFT);
                String columnName = section.getTableColumnNames()[i];
                if (!columnName.endsWith(":"))
                    columnName = columnName.concat(":");
                label.setText(columnName);
                data = new GridData();
                data.horizontalAlignment = GridData.FILL;
                label.setLayoutData(data);

                Text text = new Text(composite, SWT.SINGLE | SWT.BORDER);
                data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
                        | GridData.VERTICAL_ALIGN_FILL);
                data.grabExcessHorizontalSpace = true;
                data.widthHint = 100;
                text.setLayoutData(data);
                if (module != null) {
                    if (i == 1) {
                        if (module.getConnector() != null) {
                            text.setText(module.getConnector().getValue());
                            buttonList[0].setSelection(true);
                        }
                        else if (module.getEjb() != null) {
                            text.setText(module.getEjb().getValue());
                            buttonList[1].setSelection(true);
                        }
                        else if (module.getJava() != null) {
                            text.setText(module.getJava().getValue());
                            buttonList[2].setSelection(true);
                        }
                        else if (module.getWeb() != null) {
                            text.setText(module.getWeb().getValue());
                            buttonList[3].setSelection(true);
                        }                       
                    }
                    else if (i == 2 && module.getAltDd() != null) {
                        text.setText(module.getAltDd().getValue());
                    }
                }
                textEntries[i - 1] = text;
            }
View Full Code Here

    public ITableLabelProvider getLabelProvider() {
        return new LabelProvider() {
            @Override
            public String getColumnText(Object element, int columnIndex) {
                if (ModuleType.class.isInstance(element)) {
                  ModuleType module = (ModuleType) element;
                    switch (columnIndex) {
                    case 0:
                        if (module.getConnector() != null) {
                            return "connector";
                        } else if (module.getEjb() != null) {
                            return "ejb";
                        } else if (module.getJava() != null) {
                            return "java";
                        } else if (module.getWeb() != null) {
                            return "web";
                        }
                        return "";
                    case 1:
                        if (module.getConnector() != null) {
                            return module.getConnector().getValue();
                        } else if (module.getEjb() != null) {
                            return module.getEjb().getValue();
                        } else if (module.getJava() != null) {
                            return module.getJava().getValue();
                        } else if (module.getWeb() != null) {
                            return module.getWeb().getValue();
                        }
                        return "";
                    case 2:
                        if (module.getAltDd() != null) {
                            return module.getAltDd().getValue();
                        }
                        return "";
                    }
                }
                return null;
View Full Code Here

            MessageDrivenBean mdb = mdbs.get(bean.getEjbName());
            if (mdb == null) {
                // todo warn no such ejb in the ejb-jar.xml
                continue;
            }
            ActivationConfigType activationConfigType = bean.getActivationConfig();
            if (activationConfigType != null) {
                ActivationConfig activationConfig = mdb.getActivationConfig();
                if (activationConfig == null) {
                    activationConfig = new ActivationConfig();
                    mdb.setActivationConfig(activationConfig);
                }
                for (ActivationConfigPropertyType propertyType : activationConfigType.getActivationConfigProperty()) {
                    ActivationConfigProperty property = new ActivationConfigProperty(
                            propertyType.getActivationConfigPropertyName(),
                            propertyType.getActivationConfigPropertyValue());
                    activationConfig.getActivationConfigProperty().add(property);
                }
View Full Code Here

                id = id.substring(0, id.length() - 1);
            }
        }


        ArtifactType artifactType = new ArtifactType();
        artifactType.setArtifactId(id);

        EnvironmentType environmentType = new EnvironmentType();
        environmentType.setModuleId(artifactType);

        GeronimoEjbJarType geronimoEjbJarType = new GeronimoEjbJarType();
View Full Code Here

                id = id.substring(0, id.length() - 1);
            }
        }


        ArtifactType artifactType = new ArtifactType();
        artifactType.setArtifactId(id);

        EnvironmentType environmentType = new EnvironmentType();
        environmentType.setModuleId(artifactType);

        GeronimoEjbJarType geronimoEjbJarType = new GeronimoEjbJarType();
View Full Code Here

            if (roles.isEmpty()) {
                continue;
            }

            if (relation.getManyToManyTableName() == null) {
                EjbRelationshipRoleType leftRole = roles.get(0);
                EjbRelationshipRoleType.RelationshipRoleSource leftRoleSource = leftRole.getRelationshipRoleSource();
                String leftEjbName = leftRoleSource == null ? null : leftRoleSource.getEjbName();
                EntityData leftEntityData = entities.get(moduleId + "#" + leftEjbName);
                String leftFieldName = leftRole.getCmrField().getCmrFieldName();

                RelationField field;
                if (leftRole.isForeignKeyColumnOnSource()) {
                    field = leftEntityData.relations.get(leftFieldName);
                    // todo warn field not found
                    if (field == null) {
                        continue;
                    }
                } else {
                    RelationField other = leftEntityData.relations.get(leftFieldName);
                    // todo warn field not found
                    if (other == null) {
                        continue;
                    }
                    field = other.getRelatedField();
                    // todo warn field not found
                    if (field == null) {
                        if (other instanceof OneToMany) {
                            // for a unidirectional oneToMany, the join column declaration
                            // is placed on the oneToMany element instead of manyToOne
                            field = other;
                        } else {
                            continue;
                        }
                    }
                }

                // For one-to-one, make sure that the field to recieve the FK
                // is marked as the owning field
                if (field instanceof OneToOne) {
                    OneToOne left = (OneToOne) field;
                    OneToOne right = (OneToOne) left.getRelatedField();
                    if (right != null) {
                        left.setMappedBy(null);
                        right.setMappedBy(left.getName());
                    }

                }
                EjbRelationshipRoleType.RoleMapping roleMapping = leftRole.getRoleMapping();
                for (EjbRelationshipRoleType.RoleMapping.CmrFieldMapping cmrFieldMapping : roleMapping.getCmrFieldMapping()) {
                    JoinColumn joinColumn = new JoinColumn();
                    joinColumn.setName(cmrFieldMapping.getForeignKeyColumn());
                    joinColumn.setReferencedColumnName(cmrFieldMapping.getKeyColumn());
                    field.getJoinColumn().add(joinColumn);
                }
            } else {
                JoinTable joinTable = new JoinTable();
                joinTable.setName(relation.getManyToManyTableName());

                //
                // left
                EjbRelationshipRoleType leftRole = roles.get(0);
                RelationField left = null;
                if (leftRole.getRelationshipRoleSource() != null) {
                    String leftEjbName = leftRole.getRelationshipRoleSource().getEjbName();
                    EntityData leftEntityData = entities.get(moduleId + "#" + leftEjbName);
                    if (leftEntityData == null) {
                        // todo warn no such entity in ejb-jar.xml
                        continue;
                    }
                    left = leftEntityData.relations.get(leftRole.getCmrField().getCmrFieldName());
                }

                if (left != null) {
                    left.setJoinTable(joinTable);

                    EjbRelationshipRoleType.RoleMapping roleMapping = leftRole.getRoleMapping();
                    for (EjbRelationshipRoleType.RoleMapping.CmrFieldMapping cmrFieldMapping : roleMapping.getCmrFieldMapping()) {
                        JoinColumn joinColumn = new JoinColumn();
                        joinColumn.setName(cmrFieldMapping.getForeignKeyColumn());
                        joinColumn.setReferencedColumnName(cmrFieldMapping.getKeyColumn());
                        joinTable.getJoinColumn().add(joinColumn);
                    }
                }

                //
                // right
                if (roles.size() > 1) {
                    EjbRelationshipRoleType rightRole = roles.get(1);

                    // if there wasn't a left cmr field, find the field for the right, so we can add the join table to it
                    if (left == null) {
                        RelationField right = left.getRelatedField();
                        if (right == null) {
                            if (rightRole.getCmrField() == null) {
                                // todo warn no cmr field declared for either role
                                continue;
                            }
                            if (rightRole.getRelationshipRoleSource() != null) {
                                String rightEjbName = rightRole.getRelationshipRoleSource().getEjbName();
                                EntityData rightEntityData = entities.get(moduleId + "#" + rightEjbName);
                                if (rightEntityData == null) {
                                    // todo warn no such entity in ejb-jar.xml
                                    continue;
                                }
                                right = rightEntityData.relations.get(rightRole.getCmrField().getCmrFieldName());
                            }
                        }
                        right.setJoinTable(joinTable);
                    }

                    EjbRelationshipRoleType.RoleMapping roleMapping = rightRole.getRoleMapping();
                    for (EjbRelationshipRoleType.RoleMapping.CmrFieldMapping cmrFieldMapping : roleMapping.getCmrFieldMapping()) {
                        JoinColumn joinColumn = new JoinColumn();
                        joinColumn.setName(cmrFieldMapping.getForeignKeyColumn());
                        joinColumn.setReferencedColumnName(cmrFieldMapping.getKeyColumn());
                        joinTable.getInverseJoinColumn().add(joinColumn);
View Full Code Here

        }
        for (org.apache.openejb.jee.oejb2.EnterpriseBean enterpriseBean : openejbJarType.getEnterpriseBeans()) {
            if (!(enterpriseBean instanceof EntityBeanType)) {
                continue;
            }
            EntityBeanType bean = (EntityBeanType) enterpriseBean;
            EntityData entityData = entities.get(moduleId + "#" + bean.getEjbName());
            if (entityData == null) {
                // todo warn no such ejb in the ejb-jar.xml
                continue;
            }

            Table table = new Table();
            table.setName(bean.getTableName());
            entityData.entity.setTable(table);

            for (EntityBeanType.CmpFieldMapping cmpFieldMapping : bean.getCmpFieldMapping()) {
                String cmpFieldName = cmpFieldMapping.getCmpFieldName();
                Field field = entityData.fields.get(cmpFieldName);
                if (field == null) {
                    // todo warn no such cmp-field in the ejb-jar.xml
                    continue;
                }
                Column column = new Column();
                column.setName(cmpFieldMapping.getTableColumn());
                field.setColumn(column);
            }

            if (bean.getKeyGenerator() != null) {
                // todo support complex primary keys
                Attributes attributes = entityData.entity.getAttributes();
                if (attributes != null && attributes.getId().size() == 1) {
                    Id id = attributes.getId().get(0);

                    // todo detect specific generation strategy
                    id.setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }

            for (QueryType query : bean.getQuery()) {
                NamedQuery namedQuery = new NamedQuery();
                QueryType.QueryMethod queryMethod = query.getQueryMethod();

                // todo deployment id could change in one of the later conversions... use entity name instead, but we need to save it off
                StringBuilder name = new StringBuilder();
View Full Code Here


        ArtifactType artifactType = new ArtifactType();
        artifactType.setArtifactId(id);

        EnvironmentType environmentType = new EnvironmentType();
        environmentType.setModuleId(artifactType);

        GeronimoEjbJarType geronimoEjbJarType = new GeronimoEjbJarType();
        geronimoEjbJarType.setEnvironment(environmentType);

        return geronimoEjbJarType;
View Full Code Here


        ArtifactType artifactType = new ArtifactType();
        artifactType.setArtifactId(id);

        EnvironmentType environmentType = new EnvironmentType();
        environmentType.setModuleId(artifactType);

        GeronimoEjbJarType geronimoEjbJarType = new GeronimoEjbJarType();
        geronimoEjbJarType.setEnvironment(environmentType);

        return geronimoEjbJarType;
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.oejb2.ModuleType

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.