use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class WebServiceDialog method getInWebServiceFields.
private RowMetaInterface getInWebServiceFields() {
RowMetaInterface r = null;
if (inWsdlParamContainer != null) {
r = new RowMeta();
String[] params = inWsdlParamContainer.getParamNames();
// If we have already saved fields mapping, we only show these mappings
for (int cpt = 0; cpt < params.length; cpt++) {
ValueMetaInterface value = new ValueMeta(params[cpt], XsdType.xsdTypeToKettleType(inWsdlParamContainer.getParamType(params[cpt])));
r.addValueMeta(value);
}
}
return r;
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class JobGenerator method getValueForLogicalColumn.
private ValueMetaInterface getValueForLogicalColumn(DatabaseMeta databaseMeta, LogicalColumn column) {
String columnName = ConceptUtil.getName(column, locale);
String phColumnName = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME);
DataType columnType = column.getDataType();
String lengthString = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_LENGTH);
int length = Const.toInt(lengthString, -1);
String precisionString = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_PRECISION);
int precision = Const.toInt(precisionString, -1);
int type = ValueMetaInterface.TYPE_STRING;
switch(columnType) {
case UNKNOWN:
case URL:
case STRING:
precision = -1;
break;
case IMAGE:
case BINARY:
type = ValueMetaInterface.TYPE_BINARY;
precision = -1;
break;
case BOOLEAN:
type = ValueMetaInterface.TYPE_BOOLEAN;
length = -1;
precision = -1;
break;
case DATE:
type = ValueMetaInterface.TYPE_DATE;
length = -1;
precision = -1;
break;
case NUMERIC:
if (precision <= 0 && length < 15) {
type = ValueMetaInterface.TYPE_INTEGER;
} else {
if (length >= 15) {
type = ValueMetaInterface.TYPE_BIGNUMBER;
} else {
type = ValueMetaInterface.TYPE_NUMBER;
}
}
break;
default:
break;
}
ValueMetaInterface value = new ValueMeta(databaseMeta.quoteField(Const.NVL(phColumnName, columnName)), type);
value.setLength(length, precision);
return value;
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class RulesAccumulatorMetaMapper method saveMeta.
/**
* Save data from the MetaMapper into the RulesMeta
*
* @param meta
*/
@SuppressWarnings("deprecation")
public void saveMeta(RulesAccumulatorMeta meta) {
if (ruleSource != null && ruleSource.equalsIgnoreCase("file")) {
if (meta.getRuleFile() != null && !meta.getRuleFile().equals(getRuleFile()) || (meta.getRuleFile() != getRuleFile()) || meta.getRuleDefinition() != null) {
meta.setRuleFile(getRuleFile());
meta.setRuleDefinition(null);
meta.setChanged();
}
} else if (ruleSource != null && ruleSource.equalsIgnoreCase("definition")) {
if (meta.getRuleDefinition() != null && !meta.getRuleDefinition().equals(getRuleDefinition()) || (meta.getRuleDefinition() != getRuleDefinition()) || meta.getRuleFile() != null) {
meta.setRuleDefinition(getRuleDefinition());
meta.setRuleFile(null);
meta.setChanged();
}
}
ValueMetaInterface vm = null;
Column c = null;
for (int i = 0; i < getColumnList().size(); i++) {
vm = i < meta.getRuleResultColumns().size() ? meta.getRuleResultColumns().get(i) : null;
c = getColumnList().get(i);
if (c != null) {
if (c.getName() != null) {
// The column has a name and is valid for insertion
if (vm == null) {
vm = new ValueMeta();
meta.getRuleResultColumns().add(vm);
meta.setChanged();
}
if (!c.getName().equals(vm.getName())) {
vm.setName(c.getName());
meta.setChanged();
}
if (c.getType() != null && !c.getType().equals(vm.getTypeDesc()) || (c.getType() != vm.getTypeDesc())) {
vm.setType(ValueMeta.getType(c.getType()));
meta.setChanged();
}
} else {
// The column does not have a name and should be removed or skipped over
if (vm != null) {
// This item exists in the meta; remove it
if (i < meta.getRuleResultColumns().size()) {
meta.getRuleResultColumns().remove(i);
}
}
// Remove the item from column list table
getColumnList().remove(i);
// All items have shifted after the removal; Process this position again
i--;
}
}
}
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class ElasticSearchBulkMeta method getFields.
/* This function adds meta data to the rows being pushed out */
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
if (StringUtils.isNotBlank(this.getIdOutField())) {
ValueMetaInterface valueMeta = new ValueMeta(space.environmentSubstitute(this.getIdOutField()), ValueMetaInterface.TYPE_STRING);
valueMeta.setOrigin(name);
// add if doesn't exist
if (!r.exists(valueMeta)) {
r.addValueMeta(valueMeta);
}
}
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class S3CsvInputMeta method getFields.
@Override
public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// Start with a clean slate, eats the input
rowMeta.clear();
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setLength(field.getLength());
valueMeta.setPrecision(field.getPrecision());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setDecimalSymbol(field.getDecimalSymbol());
valueMeta.setGroupingSymbol(field.getGroupSymbol());
valueMeta.setCurrencySymbol(field.getCurrencySymbol());
valueMeta.setTrimType(field.getTrimType());
if (lazyConversionActive) {
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
}
// In case we want to convert Strings...
// Using a copy of the valueMeta object means that the inner and outer representation format is the same.
// Preview will show the data the same way as we read it.
// This layout is then taken further down the road by the metadata through the transformation.
//
ValueMetaInterface storageMetadata = valueMeta.clone();
storageMetadata.setType(ValueMetaInterface.TYPE_STRING);
storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
// we don't really know the lengths of the strings read in advance.
storageMetadata.setLength(-1, -1);
valueMeta.setStorageMetadata(storageMetadata);
valueMeta.setOrigin(origin);
rowMeta.addValueMeta(valueMeta);
}
if (!Utils.isEmpty(filenameField) && includingFilename) {
ValueMetaInterface filenameMeta = new ValueMetaString(filenameField);
filenameMeta.setOrigin(origin);
if (lazyConversionActive) {
filenameMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
filenameMeta.setStorageMetadata(new ValueMetaString(filenameField));
}
rowMeta.addValueMeta(filenameMeta);
}
if (!Utils.isEmpty(rowNumField)) {
ValueMetaInterface rowNumMeta = new ValueMetaInteger(rowNumField);
rowNumMeta.setLength(10);
rowNumMeta.setOrigin(origin);
rowMeta.addValueMeta(rowNumMeta);
}
}
Aggregations