use of org.apache.hop.core.row.value.ValueMetaString in project hop by apache.
the class DenormaliserAggregationsTest method testSumPreconditions.
/**
* This is extracted common part for sum tests
*
* @return
*/
IRowMeta testSumPreconditions(DenormaliserTargetField.DenormaliseAggregation agg) {
// create rmi for one string and 2 integers
IRowMeta rmi = new RowMeta();
List<IValueMeta> list = new ArrayList<>();
list.add(new ValueMetaString("a"));
list.add(new ValueMetaInteger("b"));
list.add(new ValueMetaInteger("d"));
rmi.setValueMetaList(list);
// denormalizer key field will be String 'Junit'
data.keyValue = new HashMap<>();
List<Integer> listInt = new ArrayList<>();
listInt.add(0);
data.keyValue.put(JUNIT, listInt);
// we will calculate sum for second field ( like ["JUNIT", 1] )
data.fieldNameIndex = new int[] { 1 };
data.inputRowMeta = rmi;
data.outputRowMeta = rmi;
data.removeNrs = new int[] { -1 };
// we do create internal instance of output field wiht sum aggregation
DenormaliserTargetField tField = new DenormaliserTargetField();
tField.setTargetAggregationType(agg);
ArrayList<DenormaliserTargetField> pivotField = new ArrayList<>();
pivotField.add(new DenormaliserTargetField(tField));
meta.setDenormaliserTargetFields(pivotField);
// return row meta interface to pass into denormalize method
return rmi;
}
use of org.apache.hop.core.row.value.ValueMetaString in project hop by apache.
the class MergeRowsMeta method getFields.
@Override
public void getFields(IRowMeta r, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
//
if (info != null) {
boolean found = false;
for (int i = 0; i < info.length && !found; i++) {
if (info[i] != null) {
r.mergeRowMeta(info[i], name);
found = true;
}
}
}
if (Utils.isEmpty(flagField)) {
throw new HopTransformException(BaseMessages.getString(PKG, "MergeRowsMeta.Exception.FlagFieldNotSpecified"));
}
IValueMeta flagFieldValue = new ValueMetaString(flagField);
flagFieldValue.setOrigin(name);
r.addValueMeta(flagFieldValue);
}
use of org.apache.hop.core.row.value.ValueMetaString in project hop by apache.
the class StreamLookupTest method mockLookupRowSet.
private IRowSet mockLookupRowSet(boolean binary) {
final int storageType = binary ? IValueMeta.STORAGE_TYPE_BINARY_STRING : IValueMeta.STORAGE_TYPE_NORMAL;
Object[][] data = { { "Value1", "1" }, { "Value2", "2" } };
if (binary) {
convertDataToBinary(data);
}
IRowSet lookupRowSet = smh.getMockInputRowSet(data);
doReturn("Lookup").when(lookupRowSet).getOriginTransformName();
doReturn("StreamLookup").when(lookupRowSet).getDestinationTransformName();
RowMeta lookupRowMeta = new RowMeta();
ValueMetaString valueMeta = new ValueMetaString("Value");
valueMeta.setStorageType(storageType);
valueMeta.setStorageMetadata(new ValueMetaString());
lookupRowMeta.addValueMeta(valueMeta);
ValueMetaString idMeta = new ValueMetaString("Id");
idMeta.setStorageType(storageType);
idMeta.setStorageMetadata(new ValueMetaString());
lookupRowMeta.addValueMeta(idMeta);
doReturn(lookupRowMeta).when(lookupRowSet).getRowMeta();
return lookupRowSet;
}
use of org.apache.hop.core.row.value.ValueMetaString in project hop by apache.
the class XsltTest method createRowMetaInterface.
public IRowMeta createRowMetaInterface() {
IRowMeta rm = new RowMeta();
IValueMeta[] valuesMeta = { new ValueMetaString("XML"), new ValueMetaString("XSL"), new ValueMetaString("filename") };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
use of org.apache.hop.core.row.value.ValueMetaString in project hop by apache.
the class YamlInputMeta method getFields.
@Override
public void getFields(IRowMeta r, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
int i;
for (i = 0; i < inputFields.length; i++) {
YamlInputField field = inputFields[i];
int type = field.getType();
if (type == IValueMeta.TYPE_NONE) {
type = IValueMeta.TYPE_STRING;
}
String valueName = variables.resolve(field.getName());
IValueMeta v;
try {
v = ValueMetaFactory.createValueMeta(valueName, type);
} catch (HopPluginException e) {
v = new ValueMetaString(valueName);
}
v.setLength(field.getLength());
v.setPrecision(field.getPrecision());
v.setOrigin(name);
v.setConversionMask(field.getFormat());
v.setDecimalSymbol(field.getDecimalSymbol());
v.setGroupingSymbol(field.getGroupSymbol());
v.setCurrencySymbol(field.getCurrencySymbol());
r.addValueMeta(v);
}
if (includeFilename) {
IValueMeta v = new ValueMetaString(variables.resolve(filenameField));
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (includeRowNumber) {
IValueMeta v = new ValueMetaInteger(variables.resolve(rowNumberField));
v.setLength(IValueMeta.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
r.addValueMeta(v);
}
}
Aggregations