Search in sources :

Example 11 with MetadataType

use of org.talend.designer.core.model.utils.emf.talendfile.MetadataType in project tdi-studio-se by Talend.

the class MetadataEmfFactoryTest method testOriginalLengthValue.

@Test
public void testOriginalLengthValue() {
    // OriginalLength of column is null.
    IMetadataTable table = createTestTable();
    factory.setMetadataTable(table);
    MetadataType metadataType = factory.getMetadataType();
    ColumnType col1 = (ColumnType) metadataType.getColumn().get(0);
    assertEquals(-1, col1.getOriginalLength());
    // OriginalLength of column is not null.
    table = createTestTable();
    table.getListColumns().get(0).setOriginalLength(10);
    factory.setMetadataTable(table);
    metadataType = factory.getMetadataType();
    col1 = (ColumnType) metadataType.getColumn().get(0);
    assertEquals(10, col1.getOriginalLength());
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType) Test(org.junit.Test)

Example 12 with MetadataType

use of org.talend.designer.core.model.utils.emf.talendfile.MetadataType in project tdi-studio-se by Talend.

the class RenametStandardizePhoneNumberColumnName method changeCustomerColumn.

private void changeCustomerColumn(Item item) throws PersistenceException {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    for (Object o : processType.getNode()) {
        NodeType node = (NodeType) o;
        if ("tStandardizePhoneNumber".equalsIgnoreCase(node.getComponentName())) {
            for (Object o2 : node.getMetadata()) {
                MetadataType metadata = (MetadataType) o2;
                for (Object o3 : metadata.getColumn()) {
                    ColumnType column = (ColumnType) o3;
                    if ("IsPossiblePhoneNumber ".equals(column.getName())) {
                        column.setName("IsPossiblePhoneNumber");
                        modified = true;
                        break;
                    }
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Example 13 with MetadataType

use of org.talend.designer.core.model.utils.emf.talendfile.MetadataType in project tesb-studio-se by Talend.

the class FormContentTypeMigrationTask method changeDefaultFormContentType.

private void changeDefaultFormContentType(Item item) throws PersistenceException {
    if (!(item instanceof ProcessItem)) {
        return;
    }
    boolean needSave = false;
    for (Object o : ((ProcessItem) item).getProcess().getNode()) {
        if (!(o instanceof NodeType)) {
            continue;
        }
        NodeType currentNode = (NodeType) o;
        if ("tRESTRequest".equals(currentNode.getComponentName())) {
            for (Object m : currentNode.getMetadata()) {
                MetadataType metadataType = (MetadataType) m;
                if ("WRONG_CALLS".equals(metadataType.getConnector())) {
                    continue;
                }
                needSave |= updateFormContentTypeOf(metadataType, currentNode);
            }
            // assume only one tRESTRequest inside
            break;
        }
    }
    if (needSave) {
        FACTORY.save(item, true);
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Example 14 with MetadataType

use of org.talend.designer.core.model.utils.emf.talendfile.MetadataType in project tesb-studio-se by Talend.

the class RestRequestWrongCallMigrationTask method addMoreWrongCallInfo.

private void addMoreWrongCallInfo(Item item) throws PersistenceException {
    if (item instanceof ProcessItem) {
        boolean needSave = false;
        for (Object o : ((ProcessItem) item).getProcess().getNode()) {
            if (o instanceof NodeType) {
                NodeType currentNode = (NodeType) o;
                if ("tRESTRequest".equals(currentNode.getComponentName())) {
                    Iterator iterator = currentNode.getMetadata().iterator();
                    while (iterator.hasNext()) {
                        MetadataType metadataType = (MetadataType) iterator.next();
                        if ("WRONG_CALLS".equals(metadataType.getConnector())) {
                            addColumn(metadataType.getColumn(), httpMethod);
                            needSave = true;
                        }
                    }
                }
            }
        }
        if (needSave) {
            FACTORY.save(item, true);
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) Iterator(java.util.Iterator) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Aggregations

MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)14 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)13 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)10 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)10 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)3 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)3 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)3 EList (org.eclipse.emf.common.util.EList)2 IComponent (org.talend.core.model.components.IComponent)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 TalendFileFactory (org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1