use of org.pentaho.di.core.row.value.ValueMetaNone in project pentaho-kettle by pentaho.
the class MemoryGroupByMeta method getFields.
@Override
public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) {
// Check compatibility mode
boolean compatibilityMode = ValueMetaBase.convertStringToBoolean(space.getVariable(Const.KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE, "N"));
// re-assemble a new row of metadata
//
RowMetaInterface fields = new RowMeta();
//
for (int i = 0; i < groupField.length; i++) {
ValueMetaInterface valueMeta = r.searchValueMeta(groupField[i]);
if (valueMeta != null) {
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
fields.addValueMeta(valueMeta);
}
}
//
for (int i = 0; i < subjectField.length; i++) {
ValueMetaInterface subj = r.searchValueMeta(subjectField[i]);
if (subj != null || aggregateType[i] == TYPE_GROUP_COUNT_ANY) {
String value_name = aggregateField[i];
int value_type = ValueMetaInterface.TYPE_NONE;
int length = -1;
int precision = -1;
switch(aggregateType[i]) {
case TYPE_GROUP_FIRST:
case TYPE_GROUP_LAST:
case TYPE_GROUP_FIRST_INCL_NULL:
case TYPE_GROUP_LAST_INCL_NULL:
case TYPE_GROUP_MIN:
case TYPE_GROUP_MAX:
value_type = subj.getType();
break;
case TYPE_GROUP_COUNT_DISTINCT:
case TYPE_GROUP_COUNT_ALL:
case TYPE_GROUP_COUNT_ANY:
value_type = ValueMetaInterface.TYPE_INTEGER;
break;
case TYPE_GROUP_CONCAT_COMMA:
value_type = ValueMetaInterface.TYPE_STRING;
break;
case TYPE_GROUP_SUM:
case TYPE_GROUP_AVERAGE:
if (!compatibilityMode && subj.isNumeric()) {
value_type = subj.getType();
} else {
value_type = ValueMetaInterface.TYPE_NUMBER;
}
break;
case TYPE_GROUP_MEDIAN:
case TYPE_GROUP_PERCENTILE:
case TYPE_GROUP_STANDARD_DEVIATION:
value_type = ValueMetaInterface.TYPE_NUMBER;
break;
case TYPE_GROUP_CONCAT_STRING:
value_type = ValueMetaInterface.TYPE_STRING;
break;
default:
break;
}
if (aggregateType[i] == TYPE_GROUP_COUNT_ALL || aggregateType[i] == TYPE_GROUP_COUNT_DISTINCT || aggregateType[i] == TYPE_GROUP_COUNT_ANY) {
length = ValueMetaInterface.DEFAULT_INTEGER_LENGTH;
precision = 0;
} else if (aggregateType[i] == TYPE_GROUP_SUM && value_type != ValueMetaInterface.TYPE_INTEGER && value_type != ValueMetaInterface.TYPE_NUMBER && value_type != ValueMetaInterface.TYPE_BIGNUMBER) {
// If it ain't numeric, we change it to Number
//
value_type = ValueMetaInterface.TYPE_NUMBER;
precision = -1;
length = -1;
}
if (value_type != ValueMetaInterface.TYPE_NONE) {
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(value_name, value_type);
} catch (KettlePluginException e) {
log.logError(BaseMessages.getString(PKG, "MemoryGroupByMeta.Exception.UnknownValueMetaType"), value_type, e);
v = new ValueMetaNone(value_name);
}
v.setOrigin(origin);
v.setLength(length, precision);
if (subj != null) {
v.setConversionMask(subj.getConversionMask());
}
fields.addValueMeta(v);
}
}
}
// Now that we have all the fields we want, we should clear the original row and replace the values...
//
r.clear();
r.addRowMeta(fields);
}
use of org.pentaho.di.core.row.value.ValueMetaNone in project pentaho-kettle by pentaho.
the class ExcelInputMeta method getEmptyFields.
public RowMetaInterface getEmptyFields() {
RowMetaInterface row = new RowMeta();
if (field != null) {
for (int i = 0; i < field.length; i++) {
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(field[i].getName(), field[i].getType());
} catch (KettlePluginException e) {
v = new ValueMetaNone(field[i].getName());
}
row.addValueMeta(v);
}
}
return row;
}
use of org.pentaho.di.core.row.value.ValueMetaNone in project pentaho-kettle by pentaho.
the class SystemDataMeta method getFields.
@Override
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
for (int i = 0; i < fieldName.length; i++) {
ValueMetaInterface v;
switch(fieldType[i]) {
// All date values...
case TYPE_SYSTEM_INFO_SYSTEM_START:
case TYPE_SYSTEM_INFO_SYSTEM_DATE:
case TYPE_SYSTEM_INFO_TRANS_DATE_FROM:
case TYPE_SYSTEM_INFO_TRANS_DATE_TO:
case TYPE_SYSTEM_INFO_JOB_DATE_FROM:
case TYPE_SYSTEM_INFO_JOB_DATE_TO:
case TYPE_SYSTEM_INFO_PREV_DAY_START:
case TYPE_SYSTEM_INFO_PREV_DAY_END:
case TYPE_SYSTEM_INFO_THIS_DAY_START:
case TYPE_SYSTEM_INFO_THIS_DAY_END:
case TYPE_SYSTEM_INFO_NEXT_DAY_START:
case TYPE_SYSTEM_INFO_NEXT_DAY_END:
case TYPE_SYSTEM_INFO_PREV_MONTH_START:
case TYPE_SYSTEM_INFO_PREV_MONTH_END:
case TYPE_SYSTEM_INFO_THIS_MONTH_START:
case TYPE_SYSTEM_INFO_THIS_MONTH_END:
case TYPE_SYSTEM_INFO_NEXT_MONTH_START:
case TYPE_SYSTEM_INFO_NEXT_MONTH_END:
case TYPE_SYSTEM_INFO_MODIFIED_DATE:
case TYPE_SYSTEM_INFO_KETTLE_BUILD_DATE:
case TYPE_SYSTEM_INFO_PREV_WEEK_START:
case TYPE_SYSTEM_INFO_PREV_WEEK_END:
case TYPE_SYSTEM_INFO_PREV_WEEK_OPEN_END:
case TYPE_SYSTEM_INFO_PREV_WEEK_START_US:
case TYPE_SYSTEM_INFO_PREV_WEEK_END_US:
case TYPE_SYSTEM_INFO_THIS_WEEK_START:
case TYPE_SYSTEM_INFO_THIS_WEEK_END:
case TYPE_SYSTEM_INFO_THIS_WEEK_OPEN_END:
case TYPE_SYSTEM_INFO_THIS_WEEK_START_US:
case TYPE_SYSTEM_INFO_THIS_WEEK_END_US:
case TYPE_SYSTEM_INFO_NEXT_WEEK_START:
case TYPE_SYSTEM_INFO_NEXT_WEEK_END:
case TYPE_SYSTEM_INFO_NEXT_WEEK_OPEN_END:
case TYPE_SYSTEM_INFO_NEXT_WEEK_START_US:
case TYPE_SYSTEM_INFO_NEXT_WEEK_END_US:
case TYPE_SYSTEM_INFO_PREV_QUARTER_START:
case TYPE_SYSTEM_INFO_PREV_QUARTER_END:
case TYPE_SYSTEM_INFO_THIS_QUARTER_START:
case TYPE_SYSTEM_INFO_THIS_QUARTER_END:
case TYPE_SYSTEM_INFO_NEXT_QUARTER_START:
case TYPE_SYSTEM_INFO_NEXT_QUARTER_END:
case TYPE_SYSTEM_INFO_PREV_YEAR_START:
case TYPE_SYSTEM_INFO_PREV_YEAR_END:
case TYPE_SYSTEM_INFO_THIS_YEAR_START:
case TYPE_SYSTEM_INFO_THIS_YEAR_END:
case TYPE_SYSTEM_INFO_NEXT_YEAR_START:
case TYPE_SYSTEM_INFO_NEXT_YEAR_END:
v = new ValueMetaDate(fieldName[i]);
break;
case TYPE_SYSTEM_INFO_TRANS_NAME:
case TYPE_SYSTEM_INFO_FILENAME:
case TYPE_SYSTEM_INFO_ARGUMENT_01:
case TYPE_SYSTEM_INFO_ARGUMENT_02:
case TYPE_SYSTEM_INFO_ARGUMENT_03:
case TYPE_SYSTEM_INFO_ARGUMENT_04:
case TYPE_SYSTEM_INFO_ARGUMENT_05:
case TYPE_SYSTEM_INFO_ARGUMENT_06:
case TYPE_SYSTEM_INFO_ARGUMENT_07:
case TYPE_SYSTEM_INFO_ARGUMENT_08:
case TYPE_SYSTEM_INFO_ARGUMENT_09:
case TYPE_SYSTEM_INFO_ARGUMENT_10:
case TYPE_SYSTEM_INFO_MODIFIED_USER:
case TYPE_SYSTEM_INFO_HOSTNAME:
case TYPE_SYSTEM_INFO_HOSTNAME_REAL:
case TYPE_SYSTEM_INFO_IP_ADDRESS:
case TYPE_SYSTEM_INFO_KETTLE_VERSION:
case TYPE_SYSTEM_INFO_KETTLE_BUILD_VERSION:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_LOG_TEXT:
v = new ValueMetaString(fieldName[i]);
break;
case TYPE_SYSTEM_INFO_COPYNR:
case TYPE_SYSTEM_INFO_TRANS_BATCH_ID:
case TYPE_SYSTEM_INFO_JOB_BATCH_ID:
case TYPE_SYSTEM_INFO_CURRENT_PID:
case TYPE_SYSTEM_INFO_JVM_TOTAL_MEMORY:
case TYPE_SYSTEM_INFO_JVM_FREE_MEMORY:
case TYPE_SYSTEM_INFO_JVM_MAX_MEMORY:
case TYPE_SYSTEM_INFO_JVM_AVAILABLE_MEMORY:
case TYPE_SYSTEM_INFO_AVAILABLE_PROCESSORS:
case TYPE_SYSTEM_INFO_JVM_CPU_TIME:
case TYPE_SYSTEM_INFO_TOTAL_PHYSICAL_MEMORY_SIZE:
case TYPE_SYSTEM_INFO_TOTAL_SWAP_SPACE_SIZE:
case TYPE_SYSTEM_INFO_COMMITTED_VIRTUAL_MEMORY_SIZE:
case TYPE_SYSTEM_INFO_FREE_PHYSICAL_MEMORY_SIZE:
case TYPE_SYSTEM_INFO_FREE_SWAP_SPACE_SIZE:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_EXIT_STATUS:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_ENTRY_NR:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_ERRORS:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_FILES:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_FILES_RETRIEVED:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_DELETED:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_INPUT:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_OUTPUT:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_READ:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_REJECTED:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_UPDATED:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_NR_LINES_WRITTEN:
v = new ValueMetaInteger(fieldName[i]);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
break;
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_RESULT:
case TYPE_SYSTEM_INFO_PREVIOUS_RESULT_IS_STOPPED:
v = new ValueMetaBoolean(fieldName[i]);
break;
default:
v = new ValueMetaNone(fieldName[i]);
break;
}
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaNone in project pentaho-kettle by pentaho.
the class SalesforceUpdateDialog method generateMappings.
/**
* Reads in the fields from the previous steps and from the ONE next step and opens an EnterMappingDialog with this
* information. After the user did the mapping, those information is put into the Select/Rename table.
*/
private void generateMappings() {
if (!checkInput()) {
return;
}
// Determine the source and target fields...
//
RowMetaInterface sourceFields;
RowMetaInterface targetFields = new RowMeta();
try {
sourceFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindSourceFields.Message"), e);
return;
}
try {
String[] fields = getModuleFields();
for (int i = 0; i < fields.length; i++) {
targetFields.addValueMeta(new ValueMetaNone(fields[i]));
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindTargetFields.Message"), e);
return;
}
String[] inputNames = new String[sourceFields.size()];
for (int i = 0; i < sourceFields.size(); i++) {
ValueMetaInterface value = sourceFields.getValueMeta(i);
inputNames[i] = value.getName() + EnterMappingDialog.STRING_ORIGIN_SEPARATOR + value.getOrigin() + ")";
}
// Create the existing mapping list...
//
List<SourceToTargetMapping> mappings = new ArrayList<SourceToTargetMapping>();
StringBuffer missingSourceFields = new StringBuffer();
StringBuffer missingTargetFields = new StringBuffer();
int nrFields = wReturn.nrNonEmpty();
for (int i = 0; i < nrFields; i++) {
TableItem item = wReturn.getNonEmpty(i);
String source = item.getText(2);
String target = item.getText(1);
int sourceIndex = sourceFields.indexOfValue(source);
if (sourceIndex < 0) {
missingSourceFields.append(Const.CR + " " + source + " --> " + target);
}
int targetIndex = targetFields.indexOfValue(target);
if (targetIndex < 0) {
missingTargetFields.append(Const.CR + " " + source + " --> " + target);
}
if (sourceIndex < 0 || targetIndex < 0) {
continue;
}
SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
mappings.add(mapping);
}
//
if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
String message = "";
if (missingSourceFields.length() > 0) {
message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
}
if (missingTargetFields.length() > 0) {
message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
}
message += Const.CR;
message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeFieldsNotFoundTitle"), message);
if (!goOn) {
return;
}
}
EnterMappingDialog d = new EnterMappingDialog(SalesforceUpdateDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
mappings = d.open();
//
if (mappings != null) {
// Clear and re-populate!
//
wReturn.table.removeAll();
wReturn.table.setItemCount(mappings.size());
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = mappings.get(i);
TableItem item = wReturn.table.getItem(i);
item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
}
wReturn.setRowNums();
wReturn.optWidth(true);
}
}
use of org.pentaho.di.core.row.value.ValueMetaNone in project pentaho-kettle by pentaho.
the class SalesforceUpsertDialog method generateMappings.
/**
* Reads in the fields from the previous steps and from the ONE next step and opens an EnterMappingDialog with this
* information. After the user did the mapping, those information is put into the Select/Rename table.
*/
private void generateMappings() {
if (!checkInput()) {
return;
}
// Determine the source and target fields...
//
RowMetaInterface sourceFields;
RowMetaInterface targetFields = new RowMeta();
try {
sourceFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindSourceFields.Message"), e);
return;
}
try {
String[] fields = getModuleFields();
for (int i = 0; i < fields.length; i++) {
targetFields.addValueMeta(new ValueMetaNone(fields[i]));
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindTargetFields.Message"), e);
return;
}
String[] inputNames = new String[sourceFields.size()];
for (int i = 0; i < sourceFields.size(); i++) {
ValueMetaInterface value = sourceFields.getValueMeta(i);
inputNames[i] = value.getName() + EnterMappingDialog.STRING_ORIGIN_SEPARATOR + value.getOrigin() + ")";
}
// Create the existing mapping list...
//
List<SourceToTargetMapping> mappings = new ArrayList<SourceToTargetMapping>();
StringBuffer missingSourceFields = new StringBuffer();
StringBuffer missingTargetFields = new StringBuffer();
int nrFields = wReturn.nrNonEmpty();
for (int i = 0; i < nrFields; i++) {
TableItem item = wReturn.getNonEmpty(i);
String source = item.getText(2);
String target = item.getText(1);
int sourceIndex = sourceFields.indexOfValue(source);
if (sourceIndex < 0) {
missingSourceFields.append(Const.CR + " " + source + " --> " + target);
}
int targetIndex = targetFields.indexOfValue(target);
if (targetIndex < 0) {
missingTargetFields.append(Const.CR + " " + source + " --> " + target);
}
if (sourceIndex < 0 || targetIndex < 0) {
continue;
}
SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
mappings.add(mapping);
}
//
if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
String message = "";
if (missingSourceFields.length() > 0) {
message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
}
if (missingTargetFields.length() > 0) {
message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
}
message += Const.CR;
message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeFieldsNotFoundTitle"), message);
if (!goOn) {
return;
}
}
EnterMappingDialog d = new EnterMappingDialog(SalesforceUpsertDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
mappings = d.open();
//
if (mappings != null) {
// Clear and re-populate!
//
wReturn.table.removeAll();
wReturn.table.setItemCount(mappings.size());
for (int i = 0; i < mappings.size(); i++) {
SourceToTargetMapping mapping = mappings.get(i);
TableItem item = wReturn.table.getItem(i);
item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
}
wReturn.setRowNums();
wReturn.optWidth(true);
}
}
Aggregations