public CurrencyListCommand() { super(CurrencyListParams.class); currencyListByLocale = new FactoryMap<Locale, List<ListData>>() { @Override protected List<ListData> create(Locale locale, Object... params) throws Exception { List<ListData> list = new ArrayList<ListData>(); for (Currency currency : Currency.getAvailableCurrencies()) { list.add(new ListData(currency.getCurrencyCode(), currency.getDisplayName(locale))); } DataUtils.sort(list, ListData.class, "listDescription", true); return list; } }; }
@Override protected List<? extends Listable> create(Locale locale, Object... params) throws Exception { List<ListData> list = new ArrayList<ListData>(); DateFormatSymbols dfs = new DateFormatSymbols(locale); String months[] = dfs.getMonths(); if (months != null && months.length >= SHORT_MONTHS.length) { for (int i = 0; i < SHORT_MONTHS.length; i++) { list.add(new ListData(SHORT_MONTHS[i], StringUtils.capitalizeFirstLetter(months[i]))); } } return list; }
/** * Reads a static list string into a listable data array. Static list should be * in the format * * <pre> * key1~description1|key2~description2|...keyN�descriptionN * </pre> * * @param string * the static list * @return the listable data array */ public static List<ListData> readStaticList(String string) { List<ListData> list = new ArrayList<ListData>(); String[] namevalues = string.split("\\|"); for (String namevalue : namevalues) { String[] pair = namevalue.split("~"); if (pair.length == 2) { list.add(new ListData(pair[0], pair[1])); } } return list; }
@Override protected List<? extends Listable> create(Locale locale, Object... params) throws Exception { List<ListData> list = new ArrayList<ListData>(); DateFormatSymbols dfs = new DateFormatSymbols(locale); String weekdays[] = dfs.getWeekdays(); if (weekdays != null && weekdays.length >= SHORT_DAYS.length) { for (int i = 0; i < SHORT_DAYS.length;) { list.add(new ListData(SHORT_DAYS[i], StringUtils.capitalizeFirstLetter(weekdays[++i]))); } } return list; }
@Override protected List<ListData> create(String documentName, Object... params) throws Exception { List<ListData> list = new ArrayList<ListData>(); UplDocumentAttributes uda = uplCompiler.compileComponentDocuments(getApplicationLocale(), documentName); for (String shortName : uda.getShortNames()) { list.add(new ListData(shortName, shortName)); } return list; }
@Override protected List<ListData> create(Locale locale, Object... params) throws Exception { List<ListData> list = new ArrayList<ListData>(); for (Currency currency : Currency.getAvailableCurrencies()) { list.add(new ListData(currency.getCurrencyCode(), currency.getDisplayName(locale))); } DataUtils.sort(list, ListData.class, "listDescription", true); return list; }
@Override protected List<Listable> create(Locale key, Object... params) throws Exception { List<Listable> list = new ArrayList<Listable>(); for (UnifyComponentConfig unifyComponentConfig : getComponentConfigs(typeClass)) { list.add(new ListData(unifyComponentConfig.getName(), resolveSessionMessage(unifyComponentConfig.getDescription()))); } DataUtils.sort(list, Listable.class, "listDescription", true); return list; } };
for (int i = 0; i < 12; i++) { String numberStr = StringUtils.padLeft(String.valueOf(i + 1), '0', subPattern.length()); list.add(new ListData(numberStr, months[i])); String[] weekDays = DateFormatSymbols.getInstance(locale).getWeekdays(); for (int i = 1; i <= 7; i++) { list.add(new ListData(shortWeekDays[i], weekDays[i])); DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale); for (String ampmStr : dfs.getAmPmStrings()) { list.add(new ListData(ampmStr, ampmStr));
@Override public List<? extends Listable> execute(Locale locale, CurrencyListParams params) throws UnifyException { if (params.isCurrencyCodes()) { List<ListData> list = new ArrayList<ListData>(); for (String currencyCode : params.getCurrencyCodes()) { Currency currency = Currency.getInstance(currencyCode); list.add(new ListData(currency.getCurrencyCode(), currency.getDisplayName(locale))); } DataUtils.sort(list, ListData.class, "listDescription", true); return list; } return currencyListByLocale.get(locale); }
@Override public List<? extends Listable> execute(Locale locale, DynamicSqlParams params) throws UnifyException { if (!StringUtils.isBlank(params.getConfigName())) { List<Listable> schemaList = new ArrayList<Listable>(); for (String schema : getDsManager().getSchemas(params.getConfigName())) { schemaList.add(new ListData(schema, schema)); } DataUtils.sort(schemaList, Listable.class, "listDescription", true); return schemaList; } return Collections.emptyList(); }
@Override public List<? extends Listable> execute(Locale locale, ZeroParams params) throws UnifyException { if (list == null) { synchronized (WebApplicationListCommand.class) { if (list == null) { list = new ArrayList<ListData>(); for (UnifyComponentConfig unifyComponentConfig : getComponentConfigs(PageController.class)) { WebApplication aa = unifyComponentConfig.getType().getAnnotation(WebApplication.class); if (aa != null) { list.add(new ListData(unifyComponentConfig.getName(), resolveMessage(locale, aa.value()))); } } } } } return list; } }
@Override protected List<Listable> create(Locale key, Object... params) throws Exception { List<Listable> list = new ArrayList<Listable>(); for (UnifyComponentConfig unifyComponentConfig : getComponentConfigs(Task.class)) { if (unifyComponentConfig.getType().isAnnotationPresent(Schedulable.class)) { list.add(new ListData(unifyComponentConfig.getName(), resolveSessionMessage(unifyComponentConfig.getDescription()))); } } for (TaskableMethodConfig tmc : taskManager.getAllTaskableMethodConfigs()) { if (tmc.isSchedulable()) { list.add(new ListData(tmc.getName(), resolveSessionMessage(tmc.getDescription()))); } } DataUtils.sort(list, Listable.class, "listDescription", true); return list; } };
newList.add(new ListData(key, description));
@Override public List<? extends Listable> execute(Locale locale, DynamicSqlParams params) throws UnifyException { if (params.getConfigName() != null) { SqlDistinctRowListConfigManager manager = (SqlDistinctRowListConfigManager) this .getComponent(ApplicationAliasConstants.SQL_DISTINCTROWLIST_CONFIG_MANAGER); SqlDistinctRowListConfig config = manager.getSqlDistinctRowListConfig(params.getConfigName()); String tableName = config.getTable(); NativeQuery query = new NativeQuery().schemaName(config.getSchema()).tableName(tableName) .addColumn(tableName, config.getKeyColumn()).addColumn(tableName, config.getDescColumn()) .distinct(true); List<Object[]> rows = getDsManager().getRows(config.getDataSource(), query); List<ListData> resultList = new ArrayList<ListData>(); for (Object[] item : rows) { resultList.add(new ListData(String.valueOf(item[0]), String.valueOf(item[1]))); } DataUtils.sort(resultList, ListData.class, "listDescription", true); return resultList; } return Collections.emptyList(); }