Search in sources :

Example 96 with ValueMetaString

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;
}
Also used : ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) IRowMeta(org.apache.hop.core.row.IRowMeta) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ArrayList(java.util.ArrayList) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger)

Example 97 with ValueMetaString

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);
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopTransformException(org.apache.hop.core.exception.HopTransformException)

Example 98 with ValueMetaString

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;
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) IRowMeta(org.apache.hop.core.row.IRowMeta) RowMeta(org.apache.hop.core.row.RowMeta) IRowSet(org.apache.hop.core.IRowSet)

Example 99 with ValueMetaString

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;
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta)

Example 100 with ValueMetaString

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);
    }
}
Also used : IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) HopPluginException(org.apache.hop.core.exception.HopPluginException) ValueMetaInteger(org.apache.hop.core.row.value.ValueMetaInteger) ValueMetaString(org.apache.hop.core.row.value.ValueMetaString)

Aggregations

ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)252 IValueMeta (org.apache.hop.core.row.IValueMeta)101 RowMeta (org.apache.hop.core.row.RowMeta)97 Test (org.junit.Test)91 IRowMeta (org.apache.hop.core.row.IRowMeta)69 ValueMetaInteger (org.apache.hop.core.row.value.ValueMetaInteger)48 ArrayList (java.util.ArrayList)23 HopException (org.apache.hop.core.exception.HopException)16 ValueMetaBase (org.apache.hop.core.row.value.ValueMetaBase)16 RowMetaAndData (org.apache.hop.core.RowMetaAndData)15 HopTransformException (org.apache.hop.core.exception.HopTransformException)15 ILoggingObject (org.apache.hop.core.logging.ILoggingObject)14 ValueMetaDate (org.apache.hop.core.row.value.ValueMetaDate)14 ValueMetaNumber (org.apache.hop.core.row.value.ValueMetaNumber)14 IRowSet (org.apache.hop.core.IRowSet)12 ValueMetaBoolean (org.apache.hop.core.row.value.ValueMetaBoolean)12 Variables (org.apache.hop.core.variables.Variables)11 ValueMetaBinary (org.apache.hop.core.row.value.ValueMetaBinary)10 BaseMetadataInjectionTest (org.apache.hop.core.injection.BaseMetadataInjectionTest)9 HopValueException (org.apache.hop.core.exception.HopValueException)7