use of org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange in project pentaho-kettle by pentaho.
the class SelectValuesDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
// return value
stepname = wStepname.getText();
// copy info to meta class (input)
int nrfields = wFields.nrNonEmpty();
int nrremove = wRemove.nrNonEmpty();
int nrmeta = wMeta.nrNonEmpty();
input.allocate(nrfields, nrremove, nrmeta);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrfields; i++) {
TableItem item = wFields.getNonEmpty(i);
input.getSelectFields()[i].setName(item.getText(1));
input.getSelectFields()[i].setRename(item.getText(2));
if (input.getSelectFields()[i].getRename() == null || input.getSelectFields()[i].getName().length() == 0) {
input.getSelectFields()[i].setRename(input.getSelectFields()[i].getName());
}
input.getSelectFields()[i].setLength(Const.toInt(item.getText(3), -2));
input.getSelectFields()[i].setPrecision(Const.toInt(item.getText(4), -2));
if (input.getSelectFields()[i].getLength() < -2) {
input.getSelectFields()[i].setLength(-2);
}
if (input.getSelectFields()[i].getPrecision() < -2) {
input.getSelectFields()[i].setPrecision(-2);
}
}
input.setSelectingAndSortingUnspecifiedFields(wUnspecified.getSelection());
for (int i = 0; i < nrremove; i++) {
TableItem item = wRemove.getNonEmpty(i);
input.getDeleteName()[i] = item.getText(1);
}
for (int i = 0; i < nrmeta; i++) {
SelectMetadataChange change = new SelectMetadataChange(input);
input.getMeta()[i] = change;
TableItem item = wMeta.getNonEmpty(i);
int index = 1;
change.setName(item.getText(index++));
change.setRename(item.getText(index++));
if (Utils.isEmpty(change.getRename())) {
change.setRename(change.getName());
}
change.setType(ValueMetaFactory.getIdForValueMeta(item.getText(index++)));
change.setLength(Const.toInt(item.getText(index++), -2));
change.setPrecision(Const.toInt(item.getText(index++), -2));
if (change.getLength() < -2) {
change.setLength(-2);
}
if (change.getPrecision() < -2) {
change.setPrecision(-2);
}
if (BaseMessages.getString(PKG, "System.Combo.Yes").equalsIgnoreCase(item.getText(index++))) {
change.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
change.setConversionMask(item.getText(index++));
// If DateFormatLenient is anything but Yes (including blank) then it is false
change.setDateFormatLenient(item.getText(index++).equalsIgnoreCase(BaseMessages.getString(PKG, "System.Combo.Yes")) ? true : false);
change.setDateFormatLocale(item.getText(index++));
change.setDateFormatTimeZone(item.getText(index++));
change.setLenientStringToNumber(item.getText(index++).equalsIgnoreCase(BaseMessages.getString(PKG, "System.Combo.Yes")) ? true : false);
change.setEncoding(item.getText(index++));
change.setDecimalSymbol(item.getText(index++));
change.setGroupingSymbol(item.getText(index++));
change.setCurrencySymbol(item.getText(index++));
}
dispose();
}
use of org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange in project pentaho-kettle by pentaho.
the class SelectValuesDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
// Default
wTabFolder.setSelection(0);
/*
* Select fields
*/
if (input.getSelectFields() != null && input.getSelectFields().length > 0) {
for (int i = 0; i < input.getSelectFields().length; i++) {
TableItem item = wFields.table.getItem(i);
if (input.getSelectFields()[i].getName() != null) {
item.setText(1, input.getSelectFields()[i].getName());
}
if (input.getSelectFields()[i].getRename() != null && !input.getSelectFields()[i].getRename().equals(input.getSelectFields()[i].getName())) {
item.setText(2, input.getSelectFields()[i].getRename());
}
item.setText(3, input.getSelectFields()[i].getLength() < 0 ? "" : "" + input.getSelectFields()[i].getLength());
item.setText(4, input.getSelectFields()[i].getPrecision() < 0 ? "" : "" + input.getSelectFields()[i].getPrecision());
}
wFields.setRowNums();
wFields.optWidth(true);
wTabFolder.setSelection(0);
}
wUnspecified.setSelection(input.isSelectingAndSortingUnspecifiedFields());
/*
* Remove certain fields...
*/
if (input.getDeleteName() != null && input.getDeleteName().length > 0) {
for (int i = 0; i < input.getDeleteName().length; i++) {
TableItem item = wRemove.table.getItem(i);
if (input.getDeleteName()[i] != null) {
item.setText(1, input.getDeleteName()[i]);
}
}
wRemove.setRowNums();
wRemove.optWidth(true);
wTabFolder.setSelection(1);
}
/*
* Change the meta-data of certain fields
*/
if (!Utils.isEmpty(input.getMeta())) {
for (int i = 0; i < input.getMeta().length; i++) {
SelectMetadataChange change = input.getMeta()[i];
TableItem item = wMeta.table.getItem(i);
int index = 1;
item.setText(index++, Const.NVL(change.getName(), ""));
if (change.getRename() != null && !change.getRename().equals(change.getName())) {
item.setText(index++, change.getRename());
} else {
index++;
}
item.setText(index++, ValueMetaFactory.getValueMetaName(change.getType()));
item.setText(index++, change.getLength() < 0 ? "" : "" + change.getLength());
item.setText(index++, change.getPrecision() < 0 ? "" : "" + change.getPrecision());
item.setText(index++, change.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
item.setText(index++, Const.NVL(change.getConversionMask(), ""));
item.setText(index++, change.isDateFormatLenient() ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
item.setText(index++, change.getDateFormatLocale() == null ? "" : change.getDateFormatLocale().toString());
item.setText(index++, change.getDateFormatTimeZone() == null ? "" : change.getDateFormatTimeZone().toString());
item.setText(index++, change.isLenientStringToNumber() ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
item.setText(index++, Const.NVL(change.getEncoding(), ""));
item.setText(index++, Const.NVL(change.getDecimalSymbol(), ""));
item.setText(index++, Const.NVL(change.getGroupingSymbol(), ""));
item.setText(index++, Const.NVL(change.getCurrencySymbol(), ""));
}
wMeta.setRowNums();
wMeta.optWidth(true);
wTabFolder.setSelection(2);
}
wStepname.setFocus();
wStepname.selectAll();
}
use of org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGenerator method getSelectMetadataChange.
private SelectMetadataChange getSelectMetadataChange(SelectValuesMeta meta, ValueMetaInterface valueMeta) {
SelectMetadataChange metadataChange = new SelectMetadataChange(meta);
metadataChange.setName(valueMeta.getName());
metadataChange.setConversionMask(valueMeta.getConversionMask());
metadataChange.setType(getType(valueMeta));
return metadataChange;
}
Aggregations