/** {@inheritDoc} */ public TalendFlow addColumn(String name, TalendType type, Object defaultValue, boolean isKey) throws IllegalArgumentException { ResourceBundle rb = ResourceBundle.getBundle("TalendBridge", Locale.getDefault()); if (name == null || name.isEmpty() || hasColumn(name)) { throw new IllegalArgumentException( String.format(Locale.getDefault(), rb.getString("exception.invalidColumnName"), name)); } if (hasColumn(name)) { throw new IllegalArgumentException( String.format( Locale.getDefault(), rb.getString("exception.columnAlreadyUsed"), name, this.getName())); } if (isKey == true && supportsTransactions() == false) { throw new IllegalArgumentException( String.format( Locale.getDefault(), rb.getString("exception.keyForNotTransactable"), this.getName())); } if (isKey == true && (!rowList.isEmpty() || !rowdraft.isEmpty())) { throw new IllegalArgumentException( String.format( Locale.getDefault(), rb.getString("exception.keyForNotEmptyTable"), this.getName())); } if (defaultValue != null) { if (defaultValue.getClass() != type.getType()) { if (defaultValue.getClass() == String.class) { defaultValue = type.parse((String) defaultValue); } else { throw new IllegalArgumentException( String.format( Locale.getDefault(), rb.getString("exception.invalidColumnDefault"), defaultValue)); } } } TalendColumnImpl col = new TalendColumnImpl(this, columns.size(), name, type, defaultValue); columns.put(name, col); columnImpls.put(col, col); columnsList.add(col); if (isKey == true) { keyList.add(col); } return this; }
/** * qzhang Comment method "getFunctionByName". * * @param name is TalendType name. * @return */ @SuppressWarnings("unchecked") public List<Function> getFunctionsByType(String name) { List<Function> funtions = new ArrayList<Function>(); for (TalendType talendType : talendTypes) { if (talendType.getName().equals(name)) { funtions.addAll(talendType.getFunctions()); } } funtions.add(createCustomizeFunction()); return funtions; }