use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceUpsertTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdNO.
@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdNO() throws Exception {
SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
SalesforceUpsertData data = generateSalesforceUpsertData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
assertEquals(0, data.sfBuffer[0].getFieldsToNull().length);
assertEquals(1, SalesforceConnection.getChildren(data.sfBuffer[0]).length);
assertEquals(Constants.PARTNER_SOBJECT_NS, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getNamespaceURI());
assertEquals(ACCOUNT_ID, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getLocalPart());
assertEquals("001i000001c5Nv9AAE", SalesforceConnection.getChildren(data.sfBuffer[0])[0].getValue());
assertFalse(SalesforceConnection.getChildren(data.sfBuffer[0])[0].hasChildren());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class FileExistsMeta method getFields.
public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// Output fields (String)
if (!Utils.isEmpty(resultfieldname)) {
ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(resultfieldname));
v.setOrigin(name);
inputRowMeta.addValueMeta(v);
}
if (includefiletype && !Utils.isEmpty(filetypefieldname)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filetypefieldname));
v.setOrigin(name);
inputRowMeta.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class TextFileInputMeta method getFields.
@Override
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
if (!inputFiles.passingThruFields) {
// all incoming fields are not transmitted !
row.clear();
} else {
if (info != null) {
boolean found = false;
for (int i = 0; i < info.length && !found; i++) {
if (info[i] != null) {
row.mergeRowMeta(info[i], name);
found = true;
}
}
}
}
for (int i = 0; i < inputFields.length; i++) {
BaseFileField field = inputFields[i];
int type = field.getType();
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
try {
ValueMetaInterface v = ValueMetaFactory.createValueMeta(field.getName(), type);
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());
v.setDateFormatLenient(content.dateFormatLenient);
v.setDateFormatLocale(content.dateFormatLocale);
v.setTrimType(field.getTrimType());
row.addValueMeta(v);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (errorHandling.errorIgnored) {
if (errorCountField != null && errorCountField.length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(errorCountField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (errorFieldsField != null && errorFieldsField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(errorFieldsField);
v.setOrigin(name);
row.addValueMeta(v);
}
if (errorTextField != null && errorTextField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(errorTextField);
v.setOrigin(name);
row.addValueMeta(v);
}
}
if (content.includeFilename) {
ValueMetaInterface v = new ValueMetaString(content.filenameField);
v.setLength(100);
v.setOrigin(name);
row.addValueMeta(v);
}
if (content.includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(content.rowNumberField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.shortFilenameField)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(additionalOutputFields.shortFilenameField));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.extensionField)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(additionalOutputFields.extensionField));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.pathField)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(additionalOutputFields.pathField));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.sizeField)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(additionalOutputFields.sizeField));
v.setOrigin(name);
v.setLength(9);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.hiddenField)) {
ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(additionalOutputFields.hiddenField));
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.lastModificationField)) {
ValueMetaInterface v = new ValueMetaDate(space.environmentSubstitute(additionalOutputFields.lastModificationField));
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.uriField)) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(additionalOutputFields.uriField));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (StringUtils.isNotBlank(additionalOutputFields.rootUriField)) {
ValueMetaInterface v = new ValueMetaString(additionalOutputFields.rootUriField);
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class ExcelInputMeta 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 < field.length; i++) {
int type = field[i].getType();
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
try {
ValueMetaInterface v = ValueMetaFactory.createValueMeta(field[i].getName(), type);
v.setLength(field[i].getLength());
v.setPrecision(field[i].getPrecision());
v.setOrigin(name);
v.setConversionMask(field[i].getFormat());
v.setDecimalSymbol(field[i].getDecimalSymbol());
v.setGroupingSymbol(field[i].getGroupSymbol());
v.setCurrencySymbol(field[i].getCurrencySymbol());
row.addValueMeta(v);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (fileField != null && fileField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(fileField);
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (sheetField != null && sheetField.length() > 0) {
ValueMetaInterface v = new ValueMetaString(sheetField);
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (sheetRowNumberField != null && sheetRowNumberField.length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(sheetRowNumberField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (rowNumberField != null && rowNumberField.length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(rowNumberField);
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getShortFileNameField() != null && getShortFileNameField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getShortFileNameField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getExtensionField() != null && getExtensionField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getExtensionField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getPathField() != null && getPathField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getPathField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getSizeField() != null && getSizeField().length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(getSizeField()));
v.setOrigin(name);
v.setLength(9);
row.addValueMeta(v);
}
if (isHiddenField() != null && isHiddenField().length() > 0) {
ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(isHiddenField()));
v.setOrigin(name);
row.addValueMeta(v);
}
if (getLastModificationDateField() != null && getLastModificationDateField().length() > 0) {
ValueMetaInterface v = new ValueMetaDate(space.environmentSubstitute(getLastModificationDateField()));
v.setOrigin(name);
row.addValueMeta(v);
}
if (getUriField() != null && getUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getUriField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (getRootUriField() != null && getRootUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getRootUriField()));
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class ExcelOutput method writeHeader.
private boolean writeHeader() {
boolean retval = false;
try {
// If we have fields specified: list them in this order!
if (meta.getOutputFields() != null && meta.getOutputFields().length > 0) {
for (int i = 0; i < meta.getOutputFields().length; i++) {
String fieldName = meta.getOutputFields()[i].getName();
ValueMetaInterface vMeta = new ValueMetaString(fieldName);
writeField(fieldName, vMeta, null, i, true);
}
} else {
if (data.previousMeta != null) {
// Just put all field names in the header/footer
for (int i = 0; i < data.previousMeta.size(); i++) {
String fieldName = data.previousMeta.getFieldNames()[i];
ValueMetaInterface vMeta = new ValueMetaString(fieldName);
writeField(fieldName, vMeta, null, i, true);
}
}
}
} catch (Exception e) {
logError("Error writing header line: " + e.toString());
logError(Const.getStackTracker(e));
retval = true;
} finally {
data.positionX = 0;
data.positionY++;
}
return retval;
}
Aggregations