Search in sources :

Example 11 with Function

use of org.talend.designer.rowgenerator.data.Function in project tdi-studio-se by Talend.

the class CategoryManager method convertTypesToCategories.

/**
     * Converts the structure of talendTypes to Categories.
     * 
     * @param talendTypes
     * @return
     */
private List<Category> convertTypesToCategories(List<TalendType> talendTypes) {
    List<Category> categories = new ArrayList<Category>();
    Map<String, List<Function>> map = new HashMap<String, List<Function>>();
    for (TalendType type : talendTypes) {
        List functions = type.getFunctions();
        for (int i = 0; i < functions.size(); i++) {
            Function func = (Function) functions.get(i);
            // if there's no category defination for the funtion set it as default category.
            if (func.getCategory() == null || AbstractFunctionParser.EMPTY_STRING.equals(func.getCategory())) {
                func.setCategory(DEFAULT_CATEGORY);
            }
            if (hasPigDataFuCategory && "User Defined".equals(func.getCategory())) {
                //$NON-NLS-1$
                continue;
            }
            List<Function> funcs = map.get(func.getCategory());
            if (funcs == null) {
                funcs = new ArrayList<Function>();
                map.put(func.getCategory(), funcs);
            }
            if ("StoreFunc".equals(func.getPreview()) || "LoadFunc".equals(func.getPreview())) {
                continue;
            }
            funcs.add(func);
        }
    }
    for (String categoryName : map.keySet()) {
        Category category = new Category();
        category.setName(categoryName);
        category.setFunctions(map.get(categoryName));
        // only pig var table has the DataFu category
        if (!hasPigDataFuCategory && "Pig DataFu Functions".equals(categoryName)) {
            //$NON-NLS-1$
            continue;
        }
        categories.add(category);
        if (DEFAULT_CATEGORY.equals(category.getName())) {
            defaultCategory = category;
        }
    }
    return categories;
}
Also used : Function(org.talend.designer.rowgenerator.data.Function) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TalendType(org.talend.designer.rowgenerator.data.TalendType)

Aggregations

Function (org.talend.designer.rowgenerator.data.Function)11 ArrayList (java.util.ArrayList)5 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 TalendType (org.talend.designer.rowgenerator.data.TalendType)3 List (java.util.List)2 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)2 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)2 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)2 FunctionManager (org.talend.designer.rowgenerator.data.FunctionManager)2 MetadataColumnExt (org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1