use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method creatMeatadataColumn.
private void creatMeatadataColumn(IMetadataColumn columnSource, String targetNodeName, AbstractNode sourceNode, IMetadataTable metadataTarget, int index) {
IMetadataColumn createNewColumn = null;
if (columnSource != null) {
// dnd schema column
createNewColumn = new MetadataColumn(columnSource);
createNewColumn.setLabel(targetNodeName);
} else {
// dnd doc child
createNewColumn = new MetadataColumn();
createNewColumn.setLabel(targetNodeName);
createNewColumn.setType(sourceNode.getType());
createNewColumn.setTalendType(sourceNode.getType());
if (sourceNode instanceof TreeNode) {
createNewColumn.setKey(((TreeNode) sourceNode).isKey());
createNewColumn.setNullable(((TreeNode) sourceNode).isNullable());
createNewColumn.setPattern(((TreeNode) sourceNode).getPattern());
}
}
if (index != -1) {
metadataTarget.getListColumns().add(index, createNewColumn);
} else {
metadataTarget.getListColumns().add(createNewColumn);
}
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method createMetadataColumns.
private void createMetadataColumns(IMetadataTable table, int columns) {
for (int i = 0; i < columns; i++) {
MetadataColumn newColumn = new MetadataColumn();
newColumn.setLabel("newColumn" + i);
newColumn.setTalendType("id_String");
table.getListColumns().add(newColumn);
}
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class FunctionManagerExtTest method testGetOneColData.
@Test
public void testGetOneColData() {
FunctionManagerExt functionManagerExt = new FunctionManagerExt();
MetadataColumn newColumn = new MetadataColumn();
//$NON-NLS-1$
newColumn.setLabel("newColumn");
newColumn.setTalendType(JavaTypesManager.STRING.getId());
MetadataColumnExt columnExt = new MetadataColumnExt(newColumn);
Function function = new Function();
//$NON-NLS-1$
function.setName("UPCASE");
function.setDescription(PURE_PERL_DESC);
//$NON-NLS-1$
function.setClassName("StringHandling");
StringParameter param = new StringParameter();
//$NON-NLS-1$
param.setName("string");
//$NON-NLS-1$
param.setValue("\"Hello\"");
param.setType(JavaTypesManager.STRING.getId());
//$NON-NLS-1$
param.setComment("String");
List<Parameter> params = new ArrayList<Parameter>();
params.add(param);
function.setParameters(params);
columnExt.setFunction(function);
// replace as false
String value = functionManagerExt.getOneColData(columnExt);
//$NON-NLS-1$
assertEquals(value, "StringHandling.UPCASE(\"Hello\")");
value = functionManagerExt.getOneColData(columnExt, false);
//$NON-NLS-1$
assertEquals(value, "StringHandling.UPCASE(\"Hello\")");
value = functionManagerExt.getOneColData(columnExt, false, false);
//$NON-NLS-1$
assertEquals(value, "StringHandling.UPCASE(\"Hello\")");
// replace as true
value = functionManagerExt.getOneColData(columnExt, true);
//$NON-NLS-1$
assertEquals(value, "StringHandling.UPCASE(${0})");
value = functionManagerExt.getOneColData(columnExt, false, true);
//$NON-NLS-1$
assertEquals(value, "StringHandling.UPCASE(${0})");
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class FunctionManagerExtTest method testGetFuntionFromColumn.
@Test
public void testGetFuntionFromColumn() {
FunctionManagerExt functionManagerExt = new FunctionManagerExt();
MetadataColumn newColumn = new MetadataColumn();
//$NON-NLS-1$
newColumn.setLabel("newColumn");
newColumn.setTalendType(JavaTypesManager.STRING.getId());
MetadataColumnExt columnExt = new MetadataColumnExt(newColumn);
List<Function> funcs = functionManagerExt.getFunctionsByType(newColumn.getTalendType());
if (funcs.size() > 0) {
Function func = funcs.get(0);
columnExt.setFunction(func);
Function function = functionManagerExt.getFunctionFromColumn(columnExt);
assertEquals(func.getName(), function.getName());
assertEquals(func.getParameters().size(), function.getParameters().size());
}
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ScdManager method createMetadataColumn.
/**
* DOC chuang Comment method "createMetadataColumn".
*
* @param outputColumns
*
* @param schema
*
* @param lang
* @return
*/
private IMetadataColumn createMetadataColumn(Map<String, IMetadataColumn> outputColumns, IMetadataTable schema, String name, Class clazz, ECodeLanguage lang) {
if (outputColumns.get(name) != null) {
return null;
}
IMetadataColumn column = new MetadataColumn();
column.setLabel(name);
column.setOriginalDbColumnName(name);
column.setTalendType(getType(clazz, lang));
column.setComment(GENERATE_COLUMN);
schema.getListColumns().add(column);
outputColumns.put(column.getLabel(), column);
return column;
}
Aggregations