Search in sources :

Example 1 with MetadataColumnExt

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);
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) Function(org.talend.designer.rowgenerator.data.Function) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)

Example 2 with MetadataColumnExt

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) HashMap(java.util.HashMap) Map(java.util.Map) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)

Example 3 with MetadataColumnExt

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, "");
}
Also used : MetadataColumn(org.talend.core.model.metadata.MetadataColumn) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt) Test(org.junit.Test)

Example 4 with MetadataColumnExt

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());
}
Also used : MetadataColumn(org.talend.core.model.metadata.MetadataColumn) ArrayList(java.util.ArrayList) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt) Test(org.junit.Test)

Example 5 with MetadataColumnExt

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) HashMap(java.util.HashMap) Map(java.util.Map) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)

Aggregations

MetadataColumnExt (org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)11 ArrayList (java.util.ArrayList)7 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)6 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)6 Test (org.junit.Test)5 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 MetadataTable (org.talend.core.model.metadata.MetadataTable)2 Function (org.talend.designer.rowgenerator.data.Function)2 Method (java.lang.reflect.Method)1 List (java.util.List)1 Element (org.dom4j.Element)1