Search in sources :

Example 26 with IMetadataTable

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

the class ChangeValuesFromRepositoryTest method setUp.

/**
     * DOC Administrator Comment method "setUp".
     *
     * @throws java.lang.Exception
     */
@Before
public void setUp() throws Exception {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    IProcess2 process = new Process(property);
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    IComponent targetCom = ComponentsFactoryProvider.getInstance().get("tMysqlOutput", ComponentCategory.CATEGORY_4_DI.getName());
    elem = new Node(sourceCom, process);
    elem.setLabel("tMysqlInput_1");
    target = new Node(targetCom, process);
    IMetadataTable table = createSimpleMetadata();
    table.setAttachedConnector("FLOW");
    List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
    metadataList.add(table);
    elem.setMetadataList(metadataList);
    Connection conn = new Connection(elem, target, EConnectionType.FLOW_MAIN, "FLOW", "metaName", "row1", false);
    List<Connection> connList = new ArrayList<Connection>();
    connList.add(conn);
    target.setIncomingConnections(connList);
    elem.setOutgoingConnections(connList);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2) ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Before(org.junit.Before)

Example 27 with IMetadataTable

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

the class ChangeValuesFromRepositoryTest method createSimpleMetadata.

private IMetadataTable createSimpleMetadata() {
    IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
    IMetadataColumn column1 = new MetadataColumn();
    //$NON-NLS-1$
    column1.setLabel("C1");
    //$NON-NLS-1$
    column1.setTalendType("id_String");
    table.getListColumns().add(column1);
    IMetadataColumn column2 = new MetadataColumn();
    //$NON-NLS-1$
    column2.setLabel("C2");
    //$NON-NLS-1$
    column2.setTalendType("id_String");
    table.getListColumns().add(column2);
    IMetadataColumn column3 = new MetadataColumn();
    //$NON-NLS-1$
    column3.setLabel("C3");
    //$NON-NLS-1$
    column3.setTalendType("id_Integer");
    table.getListColumns().add(column3);
    return table;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 28 with IMetadataTable

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

the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput1.

/**
     * simple input to simple output with no metadata and schema auto propagate.
     */
private ConnectionCreateCommand executeSimpleInputToSimpleOutput1() {
    IProcess2 process = getFakeProcess();
    Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
    // simple tests only since it's simply using the class ConnectionManager which already have JUnits.
    List<Object> args = new ArrayList<Object>();
    args.add(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    args.add("connectionName");
    simpleInputNode.getMetadataList().clear();
    IMetadataTable table = createSimpleMetadata1();
    table.setTableName(simpleInputNode.getUniqueName());
    table.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table);
    // set null, the command should take the schema from the component directly
    args.add(null);
    //$NON-NLS-1$
    ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
    ConnectionCreateCommand.setCreatingConnection(true);
    Node simpleOutputNode = NodeTestCreator.createSimpleOutputNode(process);
    ccc.setTarget(simpleOutputNode);
    ccc.execute();
    assertEquals(simpleInputNode.getOutgoingConnections().size(), 1);
    assertEquals(simpleOutputNode.getIncomingConnections().size(), 1);
    assertEquals(simpleOutputNode.getMetadataList().size(), 1);
    IMetadataTable outputMetadata = simpleOutputNode.getMetadataList().get(0);
    // metadata should have been propagated automatically
    assertMetadataIsSame(table, outputMetadata);
    IConnection connection = simpleInputNode.getOutgoingConnections().get(0);
    assertEquals(simpleOutputNode.getIncomingConnections().get(0), connection);
    assertEquals(connection.getSource(), simpleInputNode);
    assertEquals(connection.getTarget(), simpleOutputNode);
    assertEquals(connection.getMetaName(), simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    assertEquals(connection.getConnectorName(), "FLOW");
    //$NON-NLS-1$
    INodeConnector inputConnector = simpleInputNode.getConnectorFromName("FLOW");
    //$NON-NLS-1$
    INodeConnector outputConnector = simpleOutputNode.getConnectorFromName("FLOW");
    assertEquals(inputConnector.getCurLinkNbOutput(), 1);
    assertEquals(outputConnector.getCurLinkNbInput(), 1);
    return ccc;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 29 with IMetadataTable

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

the class RepositoryChangeMetadataCommandTest method testComponentSchemaUpdated.

@Test
public void testComponentSchemaUpdated() {
    IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
    Node node = new Node(component, new Process(new FakePropertyImpl()));
    IMetadataTable table = node.getMetadataList().get(0);
    IMetadataColumn column = new MetadataColumn();
    column.setLabel("C1");
    column.setTalendType(JavaTypesManager.STRING.getId());
    table.getListColumns().add(column);
    column = new MetadataColumn();
    column.setLabel("C2");
    column.setTalendType(JavaTypesManager.STRING.getId());
    table.getListColumns().add(column);
    column = new MetadataColumn();
    column.setLabel("C3");
    column.setTalendType(JavaTypesManager.STRING.getId());
    table.getListColumns().add(column);
    IMetadataTable newTable = table.clone(true);
    newTable.getListColumns().remove(0);
    IElementParameter schemaParam = null;
    for (IElementParameter param : node.getElementParameters()) {
        if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
            schemaParam = param;
            break;
        }
    }
    assertNotNull(schemaParam);
    //$NON-NLS-1$
    String fullParamName = SCHEMA_PARAM_NAME + ":REPOSITORY_SCHEMA_TYPE";
    //$NON-NLS-1$ //$NON-NLS-2$
    String propValue = "testconnid" + " - " + newTable.getTableName();
    RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand(node, fullParamName, propValue, newTable, null, null);
    changeMetadataCommand.execute();
    newTable = node.getMetadataList().get(0);
    String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
    assertNotNull(avroSchemaStr);
    Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
    assertEquals(2, avroSchema.getFields().size());
    //$NON-NLS-1$
    assertNull(avroSchema.getField("C1"));
    assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Schema(org.apache.avro.Schema) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Test(org.junit.Test)

Example 30 with IMetadataTable

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

the class JobSettingsManagerTest method testCreateExtraContextLoadNodes.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.jobsettings.JobSettingsManager#createExtraContextLoadNodes(org.talend.core.model.process.IProcess)}
     * .
     */
@Test
public void testCreateExtraContextLoadNodes() {
    // junit for TUP-3972
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    IProcess2 process = new Process(property);
    process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD.getName()).setValue(true);
    process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue("the test file");
    process.getElementParameter("FROM_FILE_FLAG_IMPLICIT_CONTEXT").setValue(true);
    final List<DataNode> createContextLoadNodes = JobSettingsManager.createExtraContextLoadNodes(process);
    assertNotEquals(createContextLoadNodes.size(), 0);
    final DataNode dataNode = createContextLoadNodes.get(0);
    final IMetadataTable metadataTable = dataNode.getMetadataList().get(0);
    for (IMetadataColumn column : metadataTable.getListColumns()) {
        assertNotNull(column.getDefault());
        assertNotNull(JavaTypesManager.getDefaultValueFromJavaType(column.getTalendType(), column.getDefault()));
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IProcess2(org.talend.core.model.process.IProcess2) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Aggregations

IMetadataTable (org.talend.core.model.metadata.IMetadataTable)212 ArrayList (java.util.ArrayList)102 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)81 IElementParameter (org.talend.core.model.process.IElementParameter)67 IConnection (org.talend.core.model.process.IConnection)66 List (java.util.List)56 INode (org.talend.core.model.process.INode)54 Node (org.talend.designer.core.ui.editor.nodes.Node)50 HashMap (java.util.HashMap)48 Map (java.util.Map)39 MetadataTable (org.talend.core.model.metadata.MetadataTable)34 INodeConnector (org.talend.core.model.process.INodeConnector)32 Connection (org.talend.designer.core.ui.editor.connections.Connection)28 Process (org.talend.designer.core.ui.editor.process.Process)25 IComponent (org.talend.core.model.components.IComponent)22 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)18 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)17 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 Point (org.eclipse.swt.graphics.Point)15