use of org.apache.hop.core.row.value.ValueMetaNumber in project hop by apache.
the class RandomValueMeta method getFields.
@Override
public void getFields(IRowMeta row, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
for (int i = 0; i < fieldName.length; i++) {
IValueMeta v;
switch(fieldType[i]) {
case TYPE_RANDOM_NUMBER:
v = new ValueMetaNumber(fieldName[i], 10, 5);
break;
case TYPE_RANDOM_INTEGER:
v = new ValueMetaInteger(fieldName[i], 10, 0);
break;
case TYPE_RANDOM_STRING:
v = new ValueMetaString(fieldName[i], 13, 0);
break;
case TYPE_RANDOM_UUID:
v = new ValueMetaString(fieldName[i], 36, 0);
break;
case TYPE_RANDOM_UUID4:
v = new ValueMetaString(fieldName[i], 36, 0);
break;
case TYPE_RANDOM_MAC_HMACMD5:
v = new ValueMetaString(fieldName[i], 100, 0);
break;
case TYPE_RANDOM_MAC_HMACSHA1:
v = new ValueMetaString(fieldName[i], 100, 0);
break;
default:
v = new ValueMetaNone(fieldName[i]);
break;
}
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.apache.hop.core.row.value.ValueMetaNumber in project hop by apache.
the class FuzzyMatchMeta method getFields.
@Override
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
// Add match field
IValueMeta v = new ValueMetaString(variables.resolve(getOutputMatchField()));
v.setOrigin(name);
v.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
inputRowMeta.addValueMeta(v);
String mainField = variables.resolve(getOutputValueField());
if (!Utils.isEmpty(mainField) && isGetCloserValue()) {
switch(getAlgorithmType()) {
case FuzzyMatchMeta.OPERATION_TYPE_DAMERAU_LEVENSHTEIN:
case FuzzyMatchMeta.OPERATION_TYPE_LEVENSHTEIN:
v = new ValueMetaInteger(mainField);
v.setLength(IValueMeta.DEFAULT_INTEGER_LENGTH);
break;
case FuzzyMatchMeta.OPERATION_TYPE_JARO:
case FuzzyMatchMeta.OPERATION_TYPE_JARO_WINKLER:
case FuzzyMatchMeta.OPERATION_TYPE_PAIR_SIMILARITY:
v = new ValueMetaNumber(mainField);
break;
default:
// Phonetic algorithms
v = new ValueMetaString(mainField);
break;
}
v.setStorageType(IValueMeta.STORAGE_TYPE_NORMAL);
v.setOrigin(name);
inputRowMeta.addValueMeta(v);
}
boolean activateAdditionalFields = isGetCloserValue() || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_DOUBLE_METAPHONE) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_SOUNDEX) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_REFINED_SOUNDEX) || (getAlgorithmType() == FuzzyMatchMeta.OPERATION_TYPE_METAPHONE);
if (activateAdditionalFields) {
if (info != null && info.length == 1 && info[0] != null) {
for (int i = 0; i < valueName.length; i++) {
v = info[0].searchValueMeta(value[i]);
if (v != null) {
// Configuration error/missing resources...
v.setName(valueName[i]);
v.setOrigin(name);
v.setStorageType(// Only normal storage goes into the cache
IValueMeta.STORAGE_TYPE_NORMAL);
inputRowMeta.addValueMeta(v);
} else {
throw new HopTransformException(BaseMessages.getString(PKG, "FuzzyMatchMeta.Exception.ReturnValueCanNotBeFound", value[i]));
}
}
} else {
for (int i = 0; i < valueName.length; i++) {
v = new ValueMetaString(valueName[i]);
v.setOrigin(name);
inputRowMeta.addValueMeta(v);
}
}
}
}
Aggregations