use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class GetRepositoryNamesMeta method getFields.
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// the directory and name of the object
//
ValueMetaInterface object = new ValueMetaString("object");
object.setLength(500);
object.setPrecision(-1);
object.setOrigin(origin);
row.addValueMeta(object);
// the directory
//
ValueMetaInterface directory = new ValueMetaString("directory");
directory.setLength(500);
directory.setPrecision(-1);
directory.setOrigin(origin);
row.addValueMeta(directory);
// the name
//
ValueMetaInterface name = new ValueMetaString("name");
name.setLength(500);
name.setPrecision(-1);
name.setOrigin(origin);
row.addValueMeta(name);
// the object type
//
ValueMetaInterface objectType = new ValueMetaString("object_type");
objectType.setLength(500);
objectType.setPrecision(-1);
objectType.setOrigin(origin);
row.addValueMeta(objectType);
// object_id
//
ValueMetaInterface objectId = new ValueMetaString("object_id");
object.setLength(500);
object.setPrecision(-1);
objectId.setOrigin(origin);
row.addValueMeta(objectId);
// modified by
//
ValueMetaInterface modifiedBy = new ValueMetaString("modified_by");
object.setLength(500);
object.setPrecision(-1);
modifiedBy.setOrigin(origin);
row.addValueMeta(modifiedBy);
// modified date
//
ValueMetaInterface modifiedDate = new ValueMetaDate("modified_date");
modifiedDate.setOrigin(origin);
row.addValueMeta(modifiedDate);
// description
//
ValueMetaInterface description = new ValueMetaString("description");
description.setLength(500);
description.setPrecision(-1);
description.setOrigin(origin);
row.addValueMeta(description);
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(origin);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class GetSubFoldersMeta method getFields.
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// the folderName
ValueMetaInterface folderName = new ValueMetaString("folderName");
folderName.setLength(500);
folderName.setPrecision(-1);
folderName.setOrigin(name);
row.addValueMeta(folderName);
// the short folderName
ValueMetaInterface short_folderName = new ValueMetaString("short_folderName");
short_folderName.setLength(500);
short_folderName.setPrecision(-1);
short_folderName.setOrigin(name);
row.addValueMeta(short_folderName);
// the path
ValueMetaInterface path = new ValueMetaString("path");
path.setLength(500);
path.setPrecision(-1);
path.setOrigin(name);
row.addValueMeta(path);
// the ishidden
ValueMetaInterface ishidden = new ValueMetaBoolean("ishidden");
ishidden.setOrigin(name);
row.addValueMeta(ishidden);
// the isreadable
ValueMetaInterface isreadable = new ValueMetaBoolean("isreadable");
isreadable.setOrigin(name);
row.addValueMeta(isreadable);
// the iswriteable
ValueMetaInterface iswriteable = new ValueMetaBoolean("iswriteable");
iswriteable.setOrigin(name);
row.addValueMeta(iswriteable);
// the lastmodifiedtime
ValueMetaInterface lastmodifiedtime = new ValueMetaDate("lastmodifiedtime");
lastmodifiedtime.setOrigin(name);
row.addValueMeta(lastmodifiedtime);
// the uri
ValueMetaInterface uri = new ValueMetaString("uri");
uri.setOrigin(name);
row.addValueMeta(uri);
// the rooturi
ValueMetaInterface rooturi = new ValueMetaString("rooturi");
rooturi.setOrigin(name);
row.addValueMeta(rooturi);
// childrens
ValueMetaInterface childrens = new ValueMetaInteger(space.environmentSubstitute("childrens"));
childrens.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
childrens.setOrigin(name);
row.addValueMeta(childrens);
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class Denormaliser method getConversionMeta.
/**
* Get the metadata used for conversion to date format See related PDI-4019
*
* @param mask
* @return
*/
private ValueMetaInterface getConversionMeta(String mask) {
ValueMetaInterface meta = null;
if (!Utils.isEmpty(mask)) {
meta = conversionMetaCache.get(mask);
if (meta == null) {
meta = new ValueMetaDate();
meta.setConversionMask(mask);
conversionMetaCache.put(mask, meta);
}
}
return meta;
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class Database method getQueryFieldsFromDatabaseMetaData.
public RowMetaInterface getQueryFieldsFromDatabaseMetaData() throws Exception {
ResultSet columns = connection.getMetaData().getColumns("", "", databaseMeta.getName(), "");
RowMetaInterface rowMeta = new RowMeta();
while (columns.next()) {
ValueMetaInterface valueMeta = null;
String name = columns.getString("COLUMN_NAME");
String type = columns.getString("SOURCE_DATA_TYPE");
int size = columns.getInt("COLUMN_SIZE");
if (type.equals("Integer") || type.equals("Long")) {
valueMeta = new ValueMetaInteger();
} else if (type.equals("BigDecimal") || type.equals("BigNumber")) {
valueMeta = new ValueMetaBigNumber();
} else if (type.equals("Double") || type.equals("Number")) {
valueMeta = new ValueMetaNumber();
} else if (type.equals("String")) {
valueMeta = new ValueMetaString();
} else if (type.equals("Date")) {
valueMeta = new ValueMetaDate();
} else if (type.equals("Boolean")) {
valueMeta = new ValueMetaBoolean();
} else if (type.equals("Binary")) {
valueMeta = new ValueMetaBinary();
} else if (type.equals("Timestamp")) {
valueMeta = new ValueMetaTimestamp();
} else if (type.equals("Internet Address")) {
valueMeta = new ValueMetaInternetAddress();
}
if (valueMeta != null) {
valueMeta.setName(name);
valueMeta.setComments(name);
valueMeta.setLength(size);
valueMeta.setOriginalColumnTypeName(type);
valueMeta.setConversionMask(columns.getString("SOURCE_MASK"));
valueMeta.setDecimalSymbol(columns.getString("SOURCE_DECIMAL_SYMBOL"));
valueMeta.setGroupingSymbol(columns.getString("SOURCE_GROUPING_SYMBOL"));
valueMeta.setCurrencySymbol(columns.getString("SOURCE_CURRENCY_SYMBOL"));
rowMeta.addValueMeta(valueMeta);
} else {
log.logBasic("Database.getQueryFields() ValueMetaInterface mapping not resolved for the column " + name);
rowMeta = null;
break;
}
}
if (rowMeta != null && !rowMeta.isEmpty()) {
return rowMeta;
} else {
throw new Exception("Error in Database.getQueryFields()");
}
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class Database method getParameterMetaData.
public RowMetaInterface getParameterMetaData(PreparedStatement ps) {
RowMetaInterface par = new RowMeta();
try {
ParameterMetaData pmd = ps.getParameterMetaData();
for (int i = 1; i <= pmd.getParameterCount(); i++) {
String name = "par" + i;
int sqltype = pmd.getParameterType(i);
int length = pmd.getPrecision(i);
int precision = pmd.getScale(i);
ValueMetaInterface val;
switch(sqltype) {
case java.sql.Types.CHAR:
case java.sql.Types.VARCHAR:
val = new ValueMetaString(name);
break;
case java.sql.Types.BIGINT:
case java.sql.Types.INTEGER:
case java.sql.Types.NUMERIC:
case java.sql.Types.SMALLINT:
case java.sql.Types.TINYINT:
val = new ValueMetaInteger(name);
break;
case java.sql.Types.DECIMAL:
case java.sql.Types.DOUBLE:
case java.sql.Types.FLOAT:
case java.sql.Types.REAL:
val = new ValueMetaNumber(name);
break;
case java.sql.Types.DATE:
case java.sql.Types.TIME:
case java.sql.Types.TIMESTAMP:
val = new ValueMetaDate(name);
break;
case java.sql.Types.BOOLEAN:
case java.sql.Types.BIT:
val = new ValueMetaBoolean(name);
break;
default:
val = new ValueMetaNone(name);
break;
}
if (val.isNumeric() && (length > 18 || precision > 18)) {
val = new ValueMetaBigNumber(name);
}
par.addValueMeta(val);
}
} catch (AbstractMethodError e) {
// Oops: probably the database or JDBC doesn't support it.
return null;
} catch (SQLException e) {
return null;
} catch (Exception e) {
return null;
}
return par;
}
Aggregations