Package org.apache.openejb.jee.oejb2

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


    }
   
    public boolean performFinish() {
        ModuleWizardPage page = (ModuleWizardPage) getPages()[0];
        PathType path;
        ExtModuleType extModule;

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

            extModule = (ExtModuleType)eObject;

            List extModuleList = ((ApplicationType)plan.getValue()).getExtModule();
            if (extModuleList == null) {
                extModuleList = (List)getEFactory().create(ExtModuleType.class);
            }
            extModuleList.add(eObject);
        }
        else {
            extModule = (ExtModuleType)eObject;
            extModule.setConnector(null);
            extModule.setEjb(null);
            extModule.setJava(null);
            extModule.setWeb(null);
            extModule.setExternalPath(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())
            extModule.setConnector(path);
        else if (((ModuleWizardPage)page).buttonList[1].getSelection())
            extModule.setEjb(path);
        else if (((ModuleWizardPage)page).buttonList[2].getSelection())
            extModule.setJava(path);
        else if (((ModuleWizardPage)page).buttonList[3].getSelection())
            extModule.setWeb(path);

        if (page.buttonList[4].getSelection()) {
            extModule.setInternalPath (page.getTextEntry(1).getText());
            extModule.setExternalPath(null);
        }
        else if (page.buttonList[5].getSelection()) {
         
          StringBuilder sb = new StringBuilder();
            for (int i = 2; i < 6; i++) {
                String value = page.getTextEntry(i).getText();
                 sb.append(value).append("/");
            }
            //remove last "/"
            sb.deleteCharAt(sb.length()-1);
           
            //for 1.1 external path is in this format: groupid/artifactid/version/type
            extModule.setExternalPath(sb.toString());

            extModule.setInternalPath(null);
        }

        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;
            ExtModuleType extModule = (ExtModuleType)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;
            GridLayout gridLayout = new GridLayout();
            gridLayout.numColumns = 4;
            group.setLayout(gridLayout);
            data = new GridData();
            data.horizontalAlignment = GridData.FILL;
            data.grabExcessHorizontalSpace = true;
            data.horizontalSpan = 2;
            group.setLayoutData(data);
           
            Group group2 = new Group (composite, SWT.NONE);
            for (int i = 1; i < section.getTableColumnNames().length; i++) {
                if (i == 2) {
                    button = new Button (group2, SWT.RADIO);
                    button.setText(CommonMessages.internalPath);
                    buttonList[4] = button;
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    data.horizontalSpan = 2;
                    button.setLayoutData(data);
                }
                if (i == 3) {
                    button = new Button (group2, SWT.RADIO);
                    button.setText(CommonMessages.externalPath);
                    buttonList[5] = button;
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    data.horizontalSpan = 2;
                    button.setLayoutData(data);
                }
                Text text;

                if (i == 1) {
                    Label label = new Label(group, 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 = new Text(group, SWT.SINGLE | SWT.BORDER);
                    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
                            | GridData.VERTICAL_ALIGN_FILL);
                    data.grabExcessHorizontalSpace = true;
                    data.widthHint = 100;
                    data.horizontalSpan = 3;
                    text.setLayoutData(data);
                }
                else {
                    Label label = new Label(group2, 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 = new Text(group2, 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 (extModule != null) {
                    if (i == 1) {
                        if (extModule.getConnector() != null) {
                            text.setText(extModule.getConnector().getValue());
                            buttonList[0].setSelection(true);
                        }
                        else if (extModule.getEjb() != null) {
                            text.setText(extModule.getEjb().getValue());
                            buttonList[1].setSelection(true);
                        }
                        else if (extModule.getJava() != null) {
                            text.setText(extModule.getJava().getValue());
                            buttonList[2].setSelection(true);
                        }
                        else if (extModule.getWeb() != null) {
                            text.setText(extModule.getWeb().getValue());
                            buttonList[3].setSelection(true);
                        }                       
                    }
                    else if (i == 2 && extModule.getInternalPath() != null) {
                        text.setText(extModule.getInternalPath());
                    }
                    else if (i > 2 && extModule.getExternalPath() != null) {
                        String value= extModule.getExternalPath();
                        text.setText(value);
//            try {
//              value = (String) JAXBUtils.getValue(pattern,getTableColumnEAttributes()[i]);
//            } catch (Exception e1) {
//              value = e1.getMessage();
//            }
//                        if (value != null) {
//                            text.setText(value);
//                        }
                    }
                }
                textEntries[i - 1] = text;
            }
            gridLayout = new GridLayout();
            gridLayout.numColumns = 2;
            group2.setLayout(gridLayout);
            data = new GridData();
            data.horizontalAlignment = GridData.FILL;
            data.grabExcessHorizontalSpace = true;
            data.horizontalSpan = 2;
            group2.setLayoutData(data);

            buttonList[4].addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (buttonList[4].getSelection()) {
                       toggle();
                    }
                }
            });
            buttonList[5].addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (buttonList[5].getSelection()) {
                        toggle();
                    }
                }
            });

            if (extModule == null) {
                buttonList[0].setSelection(true);
                buttonList[4].setSelection(true);
            }
            else if (extModule.getInternalPath() != null) {
                buttonList[4].setSelection(true);
            }
            else {
                buttonList[5].setSelection(true);
            }
View Full Code Here

    public ITableLabelProvider getLabelProvider() {
        return new LabelProvider() {
            @Override
            public String getColumnText(Object element, int columnIndex) {
                if (ExtModuleType.class.isInstance(element)) {
                  ExtModuleType extModule = (ExtModuleType) element;
                    switch (columnIndex) {
                    case 0:
                        if (extModule.getConnector() != null) {
                            return "connector";
                        } else if (extModule.getEjb() != null) {
                            return "ejb";
                        } else if (extModule.getJava() != null) {
                            return "java";
                        } else if (extModule.getWeb() != null) {
                            return "web";
                        }
                        return "";
                    case 1:
                        if (extModule.getConnector() != null) {
                            return extModule.getConnector().getValue();
                        } else if (extModule.getEjb() != null) {
                            return extModule.getEjb().getValue();
                        } else if (extModule.getJava() != null) {
                            return extModule.getJava().getValue();
                        } else if (extModule.getWeb() != null) {
                            return extModule.getWeb().getValue();
                        }
                        return "";
                    case 2:
                        if (extModule.getInternalPath() != null) {
                            return extModule.getInternalPath();
                        }
                        return "";
                    case 3:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[0];
                        }
                        return "";
                    case 4:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[1];
                        }
                        return "";
                    case 5:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[2];
                        }
                        return "";
                    case 6:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[3];
                        }
                        return "";
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.ExtModuleType

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.