use of org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt in project tdi-studio-se by Talend.
the class RowGeneratorComponent method convert.
/**
* Coverts <code>MetadataColumn</code> to <code>MetadataColumnExt</code>
*
* @param metadataTable
* @return
*/
private void convert(IMetadataTable metadataTable) {
List<IMetadataColumn> exts = new ArrayList<IMetadataColumn>();
for (int j = 0; j < metadataTable.getListColumns().size(); j++) {
IMetadataColumn column = metadataTable.getListColumns().get(j);
if (column instanceof MetadataColumn) {
MetadataColumnExt ext = new MetadataColumnExt((MetadataColumn) column);
String columnValue = this.getColumnValue(ext, j);
if (columnValue != null && columnValue.length() > 0) {
//$NON-NLS-1$ //$NON-NLS-2$
columnValue = columnValue.replaceAll("\"", "");
//$NON-NLS-1$
columnValue = columnValue.substring(columnValue.lastIndexOf(".") + 1);
Function function = new Function();
function.setName(columnValue);
ext.setFunction(function);
}
exts.add(ext);
}
}
metadataTable.setListColumns(exts);
}
use of org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt in project tdi-studio-se by Talend.
the class UIManager method getCurrentColumnData.
/**
* ftang Comment method "saveAllData".
*/
private List<Map<String, Object>> getCurrentColumnData() {
List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
MetadataTable table = (MetadataTable) rgManager.getRowGeneratorComponent().getMetadataList().get(0);
convert(rgManager.getRowGeneratorComponent(), table, generatorUI.getFunctionManager());
for (IMetadataColumn col : table.getListColumns()) {
MetadataColumnExt ext = (MetadataColumnExt) col;
Map<String, Object> value = new HashMap<String, Object>();
value.put(RowGeneratorComponent.COLUMN_NAME, ext.getLabel());
value.put(RowGeneratorComponent.ARRAY, FunctionManagerExt.getOneColData(ext));
map.add(value);
}
return map;
}
use of org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt in project tdi-studio-se by Talend.
the class FunctionManagerExtTest method testGetOneColDataNull2.
@Test
public void testGetOneColDataNull2() {
// test function/function name as null or ""
FunctionManagerExt functionManagerExt = new FunctionManagerExt();
MetadataColumn newColumn = new MetadataColumn();
//$NON-NLS-1$
newColumn.setLabel("newColumn");
newColumn.setTalendType(JavaTypesManager.STRING.getId());
MetadataColumnExt columnExt = new MetadataColumnExt(newColumn);
assertNull(functionManagerExt.getOneColData(columnExt));
Function function = new Function();
columnExt.setFunction(function);
String value = functionManagerExt.getOneColData(columnExt);
//$NON-NLS-1$
assertEquals(value, "");
}
use of org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt in project tdi-studio-se by Talend.
the class FunctionManagerExtTest method testGetOneColDataDefaultFunction.
@Test
public void testGetOneColDataDefaultFunction() {
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 name as "PURE_PERL_NAME"
Function function = new Function();
function.setName(PURE_PERL_NAME);
function.setDescription(PURE_PERL_DESC);
StringParameter param = new StringParameter();
param.setName(PURE_PERL_PARAM);
//$NON-NLS-1$
param.setValue("value1");
List<Parameter> params = new ArrayList<Parameter>();
params.add(param);
function.setParameters(params);
columnExt.setFunction(function);
String value = functionManagerExt.getOneColData(columnExt);
assertEquals(value, param.getValue());
}
use of org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt in project tdi-studio-se by Talend.
the class RowGenProcessMain method initPerlArray.
/**
* qzhang Comment method "initPerlArray".
*/
private void initPerlArray() {
List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
MetadataTable table = (MetadataTable) this.component.getMetadataList().get(0);
for (IMetadataColumn col : table.getListColumns()) {
MetadataColumnExt ext = (MetadataColumnExt) col;
Map<String, Object> value = new HashMap<String, Object>();
value.put(RowGeneratorComponent.COLUMN_NAME, ext.getLabel());
value.put(RowGeneratorComponent.ARRAY, FunctionManagerExt.getOneColData(ext));
map.add(value);
}
this.component.setTableElementParameter(map);
}
Aggregations