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);
}
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;
}
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;
}
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());
}
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()));
}
}
Aggregations