use of org.apache.hop.core.row.value.ValueMetaInteger in project hop by apache.
the class TransformErrorMeta method getErrorRowMeta.
public IRowMeta getErrorRowMeta(IVariables variables) {
IRowMeta row = new RowMeta();
String nrErr = variables.resolve(getNrErrorsValuename());
if (!Utils.isEmpty(nrErr)) {
IValueMeta v = new ValueMetaInteger(nrErr);
v.setLength(3);
row.addValueMeta(v);
}
String errDesc = variables.resolve(getErrorDescriptionsValuename());
if (!Utils.isEmpty(errDesc)) {
IValueMeta v = new ValueMetaString(errDesc);
row.addValueMeta(v);
}
String errFields = variables.resolve(getErrorFieldsValuename());
if (!Utils.isEmpty(errFields)) {
IValueMeta v = new ValueMetaString(errFields);
row.addValueMeta(v);
}
String errCodes = variables.resolve(getErrorCodesValuename());
if (!Utils.isEmpty(errCodes)) {
IValueMeta v = new ValueMetaString(errCodes);
row.addValueMeta(v);
}
return row;
}
use of org.apache.hop.core.row.value.ValueMetaInteger in project hop by apache.
the class PipelineLoggingMeta method getFields.
@Override
public void getFields(IRowMeta inputRowMeta, String name, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
inputRowMeta.clear();
// Logging date
inputRowMeta.addValueMeta(new ValueMetaDate("loggingDate"));
// Logging date
inputRowMeta.addValueMeta(new ValueMetaString("loggingPhase"));
// Name of the pipeline
inputRowMeta.addValueMeta(new ValueMetaString("pipelineName", 255, -1));
// Filename of the pipeline
inputRowMeta.addValueMeta(new ValueMetaString("pipelineFilename", 255, -1));
// Start date of the pipeline
inputRowMeta.addValueMeta(new ValueMetaDate("pipelineStart"));
// End date of the pipeline
inputRowMeta.addValueMeta(new ValueMetaDate("pipelineEnd"));
// Pipeline log channel ID
inputRowMeta.addValueMeta(new ValueMetaString("pipelineLogChannelId", 32, -1));
// Parent log channel ID
inputRowMeta.addValueMeta(new ValueMetaString("parentLogChannelId", 32, -1));
// Logging text of the pipeline
inputRowMeta.addValueMeta(new ValueMetaString("pipelineLogging", 1000000, -1));
// Number of errors
inputRowMeta.addValueMeta(new ValueMetaInteger("pipelineErrorCount", 3, 0));
// Pipeline status description
inputRowMeta.addValueMeta(new ValueMetaString("pipelineStatusDescription", 32, -1));
if (loggingTransforms) {
// Name of the transform
inputRowMeta.addValueMeta(new ValueMetaString("transformName"));
// Copy number of the transform
inputRowMeta.addValueMeta(new ValueMetaInteger("transformCopyNr"));
// Copy number of the transform
inputRowMeta.addValueMeta(new ValueMetaString("transformStatusDescription", 100, -1));
// Transform log channel ID
inputRowMeta.addValueMeta(new ValueMetaString("transformLogChannelId", 32, -1));
// Transform logging text
inputRowMeta.addValueMeta(new ValueMetaString("transformLoggingText", 1000000, -1));
// Number of lines read
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesRead", 12, 0));
// Number of lines written
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesWritten", 12, 0));
// Number of lines input
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesInput", 12, 0));
// Number of lines output
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesOutput", 12, 0));
// Number of lines updated
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesUpdated", 12, 0));
// Number of lines rejected
inputRowMeta.addValueMeta(new ValueMetaInteger("transformLinesRejected", 12, 0));
// Number of errors
inputRowMeta.addValueMeta(new ValueMetaInteger("transformErrors", 3, 0));
// Execution start
inputRowMeta.addValueMeta(new ValueMetaDate("transformStart"));
// Execution end
inputRowMeta.addValueMeta(new ValueMetaDate("transformEnd"));
// Execution duration in ms
inputRowMeta.addValueMeta(new ValueMetaInteger("transformDuration", 12, 0));
}
}
use of org.apache.hop.core.row.value.ValueMetaInteger in project hop by apache.
the class CombinationLookup method combiInsert.
/**
* This inserts new record into a junk dimension
*/
public Long combiInsert(IRowMeta rowMeta, Object[] row, Long valKey, Long valCrc) throws HopDatabaseException {
String debug = "Combination insert";
DatabaseMeta databaseMeta = meta.getDatabaseMeta();
try {
if (data.prepStatementInsert == null) {
// first time: construct prepared statement
debug = "First: construct prepared statement";
data.insertRowMeta = new RowMeta();
/*
* Construct the SQL statement...
*
* INSERT INTO d_test(keyfield, [crcfield,] keylookup[]) VALUES(val_key, [val_crc], row values with keynrs[])
*/
String sql = "";
sql += "INSERT INTO " + data.schemaTable + ("( ");
boolean comma = false;
if (!isAutoIncrement()) {
// NO AUTOINCREMENT
sql += databaseMeta.quoteField(meta.getTechnicalKeyField());
data.insertRowMeta.addValueMeta(new ValueMetaInteger(meta.getTechnicalKeyField()));
comma = true;
} else if (databaseMeta.needsPlaceHolder()) {
// placeholder on informix! Will be replaced in table by real autoinc value.
sql += "0";
data.insertRowMeta.addValueMeta(new ValueMetaInteger(meta.getTechnicalKeyField()));
comma = true;
}
if (meta.useHash()) {
if (comma) {
sql += ", ";
}
sql += databaseMeta.quoteField(meta.getHashField());
data.insertRowMeta.addValueMeta(new ValueMetaInteger(meta.getHashField()));
comma = true;
}
if (!Utils.isEmpty(meta.getLastUpdateField())) {
if (comma) {
sql += ", ";
}
sql += databaseMeta.quoteField(meta.getLastUpdateField());
data.insertRowMeta.addValueMeta(new ValueMetaDate(meta.getLastUpdateField()));
comma = true;
}
for (int i = 0; i < meta.getKeyLookup().length; i++) {
if (comma) {
sql += ", ";
}
sql += databaseMeta.quoteField(meta.getKeyLookup()[i]);
data.insertRowMeta.addValueMeta(rowMeta.getValueMeta(data.keynrs[i]));
comma = true;
}
sql += ") VALUES (";
comma = false;
if (!isAutoIncrement()) {
sql += '?';
comma = true;
}
if (meta.useHash()) {
if (comma) {
sql += ',';
}
sql += '?';
comma = true;
}
if (!Utils.isEmpty(meta.getLastUpdateField())) {
if (comma) {
sql += ',';
}
sql += '?';
comma = true;
}
for (int i = 0; i < meta.getKeyLookup().length; i++) {
if (comma) {
sql += ',';
} else {
comma = true;
}
sql += '?';
}
sql += " )";
String sqlStatement = sql;
try {
debug = "First: prepare statement";
if (isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys()) {
logDetailed("SQL with return keys: " + sqlStatement);
data.prepStatementInsert = data.db.getConnection().prepareStatement(databaseMeta.stripCR(sqlStatement), Statement.RETURN_GENERATED_KEYS);
} else {
logDetailed("SQL without return keys: " + sqlStatement);
data.prepStatementInsert = data.db.getConnection().prepareStatement(databaseMeta.stripCR(sqlStatement));
}
} catch (SQLException ex) {
throw new HopDatabaseException("Unable to prepare combi insert statement : " + Const.CR + sqlStatement, ex);
} catch (Exception ex) {
throw new HopDatabaseException("Unable to prepare combi insert statement : " + Const.CR + sqlStatement, ex);
}
}
debug = "Create new insert row rins";
Object[] insertRow = new Object[data.insertRowMeta.size()];
int insertIndex = 0;
if (!isAutoIncrement()) {
insertRow[insertIndex] = valKey;
insertIndex++;
}
if (meta.useHash()) {
insertRow[insertIndex] = valCrc;
insertIndex++;
}
if (!Utils.isEmpty(meta.getLastUpdateField())) {
insertRow[insertIndex] = new Date();
insertIndex++;
}
for (int i = 0; i < data.keynrs.length; i++) {
insertRow[insertIndex] = row[data.keynrs[i]];
insertIndex++;
}
if (isRowLevel()) {
logRowlevel("rins=" + data.insertRowMeta.getString(insertRow));
}
debug = "Set values on insert";
// INSERT NEW VALUE!
data.db.setValues(data.insertRowMeta, insertRow, data.prepStatementInsert);
debug = "Insert row";
data.db.insertRow(data.prepStatementInsert);
debug = "Retrieve key";
if (isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys()) {
ResultSet keys = null;
try {
// 1 key
keys = data.prepStatementInsert.getGeneratedKeys();
if (keys.next()) {
valKey = Long.valueOf(keys.getLong(1));
} else {
throw new HopDatabaseException("Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField() + ", no fields in resultset");
}
} catch (SQLException ex) {
throw new HopDatabaseException("Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField(), ex);
} finally {
try {
if (keys != null) {
keys.close();
}
} catch (SQLException ex) {
throw new HopDatabaseException("Unable to retrieve auto-increment of combi insert key : " + meta.getTechnicalKeyField(), ex);
}
}
}
} catch (Exception e) {
logError(Const.getStackTracker(e));
throw new HopDatabaseException("Unexpected error in combination insert in part [" + debug + "] : " + e.toString(), e);
}
return valKey;
}
use of org.apache.hop.core.row.value.ValueMetaInteger in project hop by apache.
the class CombinationLookupMeta method getFields.
@Override
public void getFields(IRowMeta row, String origin, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
IValueMeta v = new ValueMetaInteger(technicalKeyField);
v.setLength(10);
v.setPrecision(0);
v.setOrigin(origin);
row.addValueMeta(v);
if (replaceFields) {
for (int i = 0; i < keyField.length; i++) {
int idx = row.indexOfValue(keyField[i]);
if (idx >= 0) {
row.removeValueMeta(idx);
}
}
}
}
use of org.apache.hop.core.row.value.ValueMetaInteger in project hop by apache.
the class CloneRowMeta method getFields.
@Override
public void getFields(IRowMeta rowMeta, String origin, IRowMeta[] info, TransformMeta nextTransform, IVariables variables, IHopMetadataProvider metadataProvider) throws HopTransformException {
// Output field (boolean) ?
if (addCloneFlag) {
String realfieldValue = variables.resolve(cloneFlagField);
if (!Utils.isEmpty(realfieldValue)) {
IValueMeta v = new ValueMetaBoolean(realfieldValue);
v.setOrigin(origin);
rowMeta.addValueMeta(v);
}
}
// Output clone row number
if (addCloneNum) {
String realfieldValue = variables.resolve(cloneNumField);
if (!Utils.isEmpty(realfieldValue)) {
IValueMeta v = new ValueMetaInteger(realfieldValue);
v.setOrigin(origin);
rowMeta.addValueMeta(v);
}
}
}
Aggregations