Search in sources :

Example 6 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable 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 7 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class Salesforce620WizardMigration method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (GenericWizardServiceFactory.getGenericWizardService().isGenericItem(item)) {
        try {
            GenericConnectionItem connectionItem = (GenericConnectionItem) item;
            GenericConnection connection = (GenericConnection) connectionItem.getConnection();
            String serialized = connection.getCompProperties();
            ComponentService service = ComponentsUtils.getComponentService();
            ComponentWizard componentWizard = service.getComponentWizard(NewSalesforceWizardMigrationTask.TYPE_NAME, item.getProperty().getId());
            ComponentProperties newProperties = (ComponentProperties) componentWizard.getForms().get(0).getProperties();
            newProperties.init();
            ComponentProperties properties = loadProperties(serialized, newProperties);
            updateSubProperties(properties, newProperties);
            newProperties.copyValuesFrom(properties, true, false);
            connection.setCompProperties(newProperties.toSerialized());
            Set<MetadataTable> tables = new HashSet<MetadataTable>();
            PackageHelper.getAllTables(connection, tables);
            for (MetadataTable table : tables) {
                EList<TaggedValue> values = table.getTaggedValue();
                for (TaggedValue value : values) {
                    if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(value.getTag())) {
                        Object object = ReflectionUtils.newInstance(NewSalesforceWizardMigrationTask.REFLECTION_SALESFORCE_MODULE_PROPERTIES, newProperties.getClass().getClassLoader(), new Object[] { table.getName() });
                        if (object != null && object instanceof ComponentProperties) {
                            ComponentProperties newSalesforceModuleProperties = (ComponentProperties) object;
                            ComponentProperties moduleProperties = loadProperties(value.getValue(), newSalesforceModuleProperties);
                            updateSubProperties(moduleProperties, newSalesforceModuleProperties);
                            newSalesforceModuleProperties.copyValuesFrom(moduleProperties, true, false);
                            value.setValue(newSalesforceModuleProperties.toSerialized());
                        }
                    }
                }
            }
            ProxyRepositoryFactory.getInstance().save(connectionItem, true);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) ComponentService(org.talend.components.api.service.ComponentService) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) HashSet(java.util.HashSet)

Example 8 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class GenericRepositoryContentHandler method createSubNodes.

private void createSubNodes(RepositoryNode parentNode, IRepositoryViewObject repObj, Package pack) {
    List<SubContainer> subContainers = PackageHelper.getOwnedElements(pack, SubContainer.class);
    if (subContainers.size() > 0) {
        for (SubContainer subContainer : subContainers) {
            RepositoryNode subContainerNode = createSubContainerNode(parentNode, subContainer.getName());
            createSubNodes(subContainerNode, repObj, subContainer);
        }
    } else {
        List<MetadataTable> metadataTables = PackageHelper.getOwnedElements(pack, MetadataTable.class);
        for (MetadataTable metadataTable : metadataTables) {
            createTable(parentNode, repObj, metadataTable);
        }
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) StableRepositoryNode(org.talend.repository.model.StableRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) SubContainer(org.talend.repository.generic.model.genericMetadata.SubContainer)

Example 9 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class ErDiagramComposite method createErDiagram.

/**
     * admin Comment method "createErDiagram".
     * 
     * @return
     */
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
    erDiagram = new ErDiagram();
    erDiagram.setErDiagramComposite(this);
    if (isShowDesignerPage) {
        IRunnableWithProgress progress = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                //$NON-NLS-1$
                monitor.beginTask("", IProgressMonitor.UNKNOWN);
                try {
                    List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
                    List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
                    erDiagram.setMetadataTables(tables);
                    List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
                    for (MetadataTable metadataTable : tables) {
                        Table table = new Table();
                        table.setMetadataTable(metadataTable, selectedColumns);
                        table.setErDiagram(erDiagram);
                        erDiagram.addTable(table);
                    }
                    erDiagram.setRelations(fks);
                } finally {
                    monitor.done();
                }
            }
        };
        UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
    } else {
        erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
        erDiagram.setRelations(new ArrayList<String[]>());
    }
    return erDiagram;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 10 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class MetadataColumnComparator method modifyOldOneTableFromDB.

/**
     * dev Comment method "modifyOldOneTableFromDB".
     * 
     * @param metaFromDB
     * @param connectionLabel
     * @param emf
     */
@SuppressWarnings("unchecked")
private boolean modifyOldOneTableFromDB(List<MetadataTable> metaFromDB, MetadataTable emf) {
    boolean flag = true;
    for (MetadataTable db : metaFromDB) {
        if (db.getSourceName().equals(emf.getSourceName())) {
            flag = false;
            if (!emf.getLabel().equals("") && !emf.getLabel().equals(db.getSourceName())) {
                //$NON-NLS-1$
                emf.setDivergency(true);
            }
        }
    }
    if (flag) {
        List<MetadataColumn> columns = emf.getColumns();
        for (MetadataColumn column : columns) {
            //$NON-NLS-1$
            column.setOriginalField(" ");
            column.setDivergency(true);
            column.setSynchronised(false);
        }
        //$NON-NLS-1$
        emf.setSourceName(" ");
        emf.setDivergency(true);
        emf.setSynchronised(false);
    }
    return flag;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)153 ArrayList (java.util.ArrayList)53 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)51 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)23 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)22 List (java.util.List)18 Test (org.junit.Test)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)14 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 Connection (org.talend.core.model.metadata.builder.connection.Connection)12 RepositoryNode (org.talend.repository.model.RepositoryNode)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 TdColumn (org.talend.cwm.relational.TdColumn)9 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)8 HashMap (java.util.HashMap)7