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