Search in sources :

Example 1 with SAPFunctionRepositoryObject

use of org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject in project tdi-studio-se by Talend.

the class ComponentChooseDialog method getSAPCommand.

/**
     * Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
     *
     * @param object
     * @param connectionItem
     * @param table
     * @param node
     * @return
     */
private void getSAPCommand(CompoundCommand cc, IRepositoryViewObject object, ConnectionItem connectionItem, MetadataTable table, Node node) {
    SAPFunctionUnit functionUnit = null;
    if (object instanceof MetadataTableRepositoryObject) {
        IElementParameter schemaParam = null;
        List<IElementParameter> schemaTypeList = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
        for (IElementParameter param : schemaTypeList) {
            if (param.getName().equals("SCHEMA")) {
                //$NON-NLS-1$
                schemaParam = param;
                break;
            }
        }
        if (table.eContainer() instanceof SAPFunctionUnit) {
            // function parameter table
            functionUnit = (SAPFunctionUnit) table.eContainer();
            // To judge what the current node is, tSAPOutput or tSAPInput component.
            String sapComponentName = node.getComponent().getName();
            if ("tSAPBapi".equals(sapComponentName)) {
                //$NON-NLS-1$
                RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, (SAPFunctionUnit) table.eContainer(), ConvertionHelper.convert(table), null);
                cc.add(command);
            } else {
                if (schemaParam != null) {
                    // repository id should be connectionid - sapfunctionName/type/tableName
                    String type = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
                    String value = connectionItem.getProperty().getId() + " - " + functionUnit.getLabel() + "/" + type + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    table.getLabel();
                    RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
                    schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
                    cc.add(changeValueCmd);
                }
                IElementParameter schemasParam = node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
                if (schemasParam != null) {
                    Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table), functionUnit);
                    cc.add(sapCmd);
                }
            }
        } else {
            // Sap Table : keep repository id as before
            if (schemaParam != null) {
                //$NON-NLS-1$
                String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
                RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
                schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection(), table);
                cc.add(changeValueCmd);
            }
        }
    } else if (object instanceof SAPFunctionRepositoryObject) {
        functionUnit = (SAPFunctionUnit) ((SAPFunctionRepositoryObject) object).getAbstractMetadataObject();
        if (node.getComponent() != null && node.getComponent().getName().equals("tSAPBapi")) {
            //$NON-NLS-1$
            RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, functionUnit, null, null);
            cc.add(command);
        } else {
            for (MetadataTable metadataTable : functionUnit.getTables()) {
                Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, metadataTable.getLabel(), ConvertionHelper.convert(metadataTable), functionUnit);
                cc.add(sapCmd);
            }
        }
    }
}
Also used : RepositoryChangeMetadataForSAPBapi(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPBapi) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 2 with SAPFunctionRepositoryObject

use of org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject in project tdi-studio-se by Talend.

the class ComponentChooseDialog method setSAPSpecailValueForCommand.

private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
    // Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
    // Table node, if so, set up the table name to command.
    IRepositoryViewObject object = selectedNode.getObject();
    if (object instanceof MetadataColumnRepositoryObject) {
        object = selectedNode.getParent().getParent().getObject();
    }
    SAPFunctionUnit unit = null;
    if (object != null) {
        if (object instanceof MetadataTableRepositoryObject) {
            MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
            MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
            if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
                unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
                command.setSapFunctionLabel(unit.getLabel());
                // set table name to functionName/type/tablename;
                String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
                unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
                command.setCurrentTableName(currentTableName);
            } else if (abstractMetadataObject instanceof SAPTable) {
                command.setCurrentTableName(abstractMetadataObject.getLabel());
            }
        } else if (object instanceof SAPFunctionRepositoryObject) {
            SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
            unit = sapObj.getModelElement();
            command.setSapFunctionLabel(unit.getLabel());
        } else if (object instanceof SAPIDocRepositoryObject) {
            SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
            command.setSapIDocLabel(sapObj.getLabel());
        }
    }
}
Also used : SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPTable(org.talend.core.model.metadata.builder.connection.SAPTable) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 3 with SAPFunctionRepositoryObject

use of org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject in project tdi-studio-se by Talend.

the class RepositoryHelper method createTalendItem.

public TalendItem createTalendItem(Repository repository, Object object) {
    TalendItem result = null;
    if (object instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) object;
        if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            EClass class1 = getEClass(nodeType);
            if (class1 != null) {
                result = (TalendItem) BusinessFactory.eINSTANCE.create(class1);
                result.setRepository(repository);
                if (ERepositoryObjectType.METADATA_CON_TABLE.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((MetadataTableRepositoryObject) repositoryObject).getProperty();
                    Item item = property.getItem();
                    if (item instanceof SAPConnectionItem) {
                        if (repositoryNode.getParent() != null) {
                            result.setId(property.getId() + " - " + repositoryNode.getParent().getProperties(EProperties.LABEL) + " - " + repositoryObject.getLabel());
                        }
                    } else {
                        //$NON-NLS-1$
                        result.setId(property.getId() + " - " + repositoryObject.getLabel());
                    }
                } else if (ERepositoryObjectType.METADATA_CON_QUERY.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((QueryRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else if (ERepositoryObjectType.METADATA_SAP_FUNCTION.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((SAPFunctionRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else {
                    result.setId(repositoryObject.getId());
                }
                result.setLabel(repositoryObject.getLabel());
            }
        }
    }
    return result;
}
Also used : Item(org.talend.core.model.properties.Item) TalendItem(org.talend.designer.business.model.business.TalendItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) EClass(org.eclipse.emf.ecore.EClass) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendItem(org.talend.designer.business.model.business.TalendItem) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Aggregations

MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)3 SAPFunctionRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 EClass (org.eclipse.emf.ecore.EClass)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 SAPTable (org.talend.core.model.metadata.builder.connection.SAPTable)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 SAPConnectionItem (org.talend.core.model.properties.SAPConnectionItem)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)1 SAPIDocRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)1 RepositoryChangeMetadataForEBCDICCommand (org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand)1 RepositoryChangeMetadataForHL7Command (org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command)1 RepositoryChangeMetadataForSAPBapi (org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPBapi)1