Search in sources :

Example 86 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ChangeValuesFromRepositoryTest method testChangeValuesMultipleProperty.

@Test
public void testChangeValuesMultipleProperty() {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    IProcess2 process = new Process(property);
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node node = new Node(sourceCom, process);
    node.setLabel("tMysqlInput_1");
    IMetadataTable table = createSimpleMetadata();
    table.setAttachedConnector("FLOW");
    List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
    metadataList.add(table);
    node.setMetadataList(metadataList);
    ElementParameter parentParam = new ElementParameter(node);
    parentParam.setCategory(EComponentCategory.BASIC);
    parentParam.setName("PROPERTY2");
    parentParam.setFieldType(EParameterFieldType.PROPERTY_TYPE);
    ElementParameter newParam = new ElementParameter(node);
    newParam.setCategory(EComponentCategory.BASIC);
    newParam.setName(EParameterName.PROPERTY_TYPE.getName());
    newParam.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    newParam.setListItemsDisplayName(new String[] { TEXT_BUILTIN, TEXT_REPOSITORY });
    newParam.setListItemsDisplayCodeName(new String[] { BUILTIN, REPOSITORY });
    newParam.setListItemsValue(new String[] { BUILTIN, REPOSITORY });
    newParam.setValue(BUILTIN);
    newParam.setNumRow(1);
    newParam.setFieldType(EParameterFieldType.TECHNICAL);
    newParam.setRepositoryValue("TEST");
    newParam.setShow(true);
    newParam.setParentParameter(parentParam);
    // listParam.add(newParam);
    newParam = new ElementParameter(node);
    newParam.setCategory(EComponentCategory.BASIC);
    newParam.setName(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    newParam.setDisplayName(EParameterName.REPOSITORY_PROPERTY_TYPE.getDisplayName());
    newParam.setListItemsDisplayName(new String[] {});
    newParam.setListItemsValue(new String[] {});
    newParam.setNumRow(1);
    newParam.setFieldType(EParameterFieldType.TECHNICAL);
    //$NON-NLS-1$
    newParam.setValue("");
    newParam.setShow(false);
    newParam.setRequired(true);
    newParam.setParentParameter(parentParam);
    ((List<IElementParameter>) node.getElementParameters()).add(parentParam);
    IElementParameter param = node.getElementParameter("USER");
    param.setRepositoryProperty("PROPERTY");
    param = node.getElementParameter("PASS");
    param.setRepositoryProperty("PROPERTY");
    param = node.getElementParameter("HOST");
    param.setRepositoryProperty("PROPERTY");
    param = node.getElementParameter("PORT");
    param.setRepositoryProperty("PROPERTY2");
    param = node.getElementParameter("DBNAME");
    param.setRepositoryProperty("PROPERTY2");
    ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(node, connection, "PROPERTY:REPOSITORY_PROPERTY_TYPE", databaseConnItem.getProperty().getId());
    changeValuesFromRepository.execute();
    DatabaseConnection dbConn = (DatabaseConnection) connection;
    assertEquals(databaseConnItem.getProperty().getId(), node.getPropertyValue("PROPERTY:REPOSITORY_PROPERTY_TYPE"));
    assertEquals(TalendTextUtils.addQuotes(dbConn.getUsername()), node.getPropertyValue("USER"));
    assertEquals(TalendTextUtils.addQuotes(dbConn.getRawPassword()), node.getPropertyValue("PASS"));
    assertEquals(TalendTextUtils.addQuotes(dbConn.getServerName()), node.getPropertyValue("HOST"));
    assertNotSame(TalendTextUtils.addQuotes(dbConn.getPort()), node.getPropertyValue("PORT"));
    assertNotSame(TalendTextUtils.addQuotes(dbConn.getDatasourceName()), node.getPropertyValue("DBNAME"));
    dbConn.setUsername("user2");
    dbConn.setPort("5002");
    dbConn.setDatasourceName("Test2");
    changeValuesFromRepository = new ChangeValuesFromRepository(node, connection, "PROPERTY2:REPOSITORY_PROPERTY_TYPE", databaseConnItem.getProperty().getId());
    changeValuesFromRepository.execute();
    assertNotSame(TalendTextUtils.addQuotes(dbConn.getUsername()), node.getPropertyValue("USER"));
    assertEquals(TalendTextUtils.addQuotes(dbConn.getPort()), node.getPropertyValue("PORT"));
    assertEquals(TalendTextUtils.addQuotes(dbConn.getDatasourceName()), node.getPropertyValue("DBNAME"));
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 87 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ConnectionTest method setUp.

/**
     * DOC Administrator Comment method "setUp".
     * 
     * @throws java.lang.Exception
     */
@Before
public void setUp() throws Exception {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    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());
    source = new Node(sourceCom, process);
    target = new Node(targetCom, process);
    connection = new Connection(source, target, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test", "test", "test", false);
    inputTable = source.getMetadataList().get(0);
}
Also used : IComponent(org.talend.core.model.components.IComponent) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Before(org.junit.Before)

Example 88 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ConnectionCreateActionTest method testValidationRuleEnableStatus.

@Test
public void testValidationRuleEnableStatus() {
    IElementParameter validationParam = node.getElementParameter(EParameterName.VALIDATION_RULES.getName());
    validationParam.setValue(true);
    curNodeConnector = ValidationRulesUtil.createRejectConnector(node);
    curNodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connecType = curNodeConnector.getDefaultConnectionType();
    ConnectionCreateAction action = new ConnectionCreateAction(null, curNodeConnector);
    action.setSelectionProvider(new SelectionProvider(node));
    action.update();
    Assert.assertTrue(action.isEnabled());
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    Process process = new Process(property);
    process.setComponentsType(ComponentCategory.CATEGORY_4_SPARK.getName());
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_SPARK.getName());
    node = new Node(sourceCom, process);
    validationParam = node.getElementParameter(EParameterName.VALIDATION_RULES.getName());
    validationParam.setValue(true);
    curNodeConnector = ValidationRulesUtil.createRejectConnector(node);
    curNodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connecType = curNodeConnector.getDefaultConnectionType();
    action = new ConnectionCreateAction(null, curNodeConnector);
    action.setSelectionProvider(new SelectionProvider(node));
    action.update();
    Assert.assertFalse(action.isEnabled());
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 89 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class AbstractMetadataCommandTest method createFakeProcess.

protected IProcess2 createFakeProcess() {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property.setId("junitId");
    //$NON-NLS-1$
    property.setVersion("0.1");
    //$NON-NLS-1$
    property.setLabel("test");
    return new Process(property);
}
Also used : Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property)

Example 90 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ConnectionCreateActionTest 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());
    node = new Node(sourceCom, process);
    node.setLabel("tMysqlInput_1");
    curNodeConnector = new NodeConnector(node);
    curNodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connecType = curNodeConnector.getDefaultConnectionType();
    Node target = new Node(targetCom, process);
    IMetadataTable table = createSimpleMetadata();
    table.setLabel("JOBS");
    table.setTableName("JOBS");
    table.setAttachedConnector("FLOW");
    List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
    metadataList.add(table);
    node.setMetadataList(metadataList);
    Connection conn = new Connection(node, target, EConnectionType.FLOW_MAIN, "FLOW", "JOBS", "row1", false);
    List<Connection> connList = new ArrayList<Connection>();
    connList.add(conn);
    target.setIncomingConnections(connList);
    node.setOutgoingConnections(connList);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) 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) IConnection(org.talend.core.model.process.IConnection) 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)

Aggregations

Process (org.talend.designer.core.ui.editor.process.Process)119 Node (org.talend.designer.core.ui.editor.nodes.Node)69 INode (org.talend.core.model.process.INode)48 ArrayList (java.util.ArrayList)45 IComponent (org.talend.core.model.components.IComponent)36 IElementParameter (org.talend.core.model.process.IElementParameter)28 Test (org.junit.Test)26 List (java.util.List)25 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IProcess (org.talend.core.model.process.IProcess)24 Connection (org.talend.designer.core.ui.editor.connections.Connection)24 Property (org.talend.core.model.properties.Property)23 INodeConnector (org.talend.core.model.process.INodeConnector)22 IConnection (org.talend.core.model.process.IConnection)20 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)20 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 ProcessItem (org.talend.core.model.properties.ProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 HashMap (java.util.HashMap)10 Before (org.junit.Before)9