本文整理汇总了Java中org.pentaho.di.core.exception.KettleValueException类的典型用法代码示例。如果您正苦于以下问题:Java KettleValueException类的具体用法?Java KettleValueException怎么用?Java KettleValueException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KettleValueException类属于org.pentaho.di.core.exception包,在下文中一共展示了KettleValueException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatField
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
/**
* Takes an input field and converts it to bytes to be stored in the temp file.
* @param v The metadata about the column
* @param valueData The column data
* @return The bytes for the value
* @throws KettleValueException
*/
private byte[] formatField( ValueMetaInterface v, Object valueData ) throws KettleValueException {
if ( v.isString() ) {
if ( v.isStorageBinaryString() && v.getTrimType() == ValueMetaInterface.TRIM_TYPE_NONE && v.getLength() < 0
&& Const.isEmpty( v.getStringEncoding() ) ) {
return (byte[]) valueData;
} else {
String svalue = ( valueData instanceof String ) ? (String) valueData : v.getString( valueData );
// trim or cut to size if needed.
//
return convertStringToBinaryString( v, Const.trimToType( svalue, v.getTrimType() ) );
}
} else {
return v.getBinaryString( valueData );
}
}
示例2: addAudit
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
void addAudit( Audit audit ) throws KettleValueException {
if ( auditSummaries == null ) {
auditSummaries = new LinkedMap<Long, ZendeskTicketAuditHistory>();
}
if ( auditSummaries.size() <= 0 ) {
auditSummaries.put( audit.getId(), new ZendeskTicketAuditHistory( audit ) );
} else {
try {
ZendeskTicketAuditHistory newAudit =
auditSummaries.get( auditSummaries.lastKey() ).createNextAudit( audit, auditSummaries );
auditSummaries.put( audit.getId(), newAudit );
} catch ( CloneNotSupportedException e ) {
e.printStackTrace();
}
}
}
示例3: addField
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public void addField( SequoiaDBOutputFieldInfo fieldInfo ) throws KettleValueException {
int numFields = m_fields.size() ;
boolean isMerged = false ;
for ( int i = 0 ; i < numFields ; i++ ){
if ( m_fields.get(i).isNeedMerge( fieldInfo.getPath() ) ){
m_fields.get(i).addField( fieldInfo.getName(), fieldInfo.getPath() ) ;
isMerged = true ;
break ;
}
}
if ( !isMerged ){
SequoiaDBInsertField newField = new SequoiaDBInsertField() ;
newField.init( fieldInfo.getName(), fieldInfo.getPath() ) ;
m_fields.add( newField ) ;
}
SequoiaDBInsertFieldInfo insertFieldInfo = m_fieldsInfo.get( fieldInfo.getName() ) ;
if( null == insertFieldInfo ){
insertFieldInfo = new SequoiaDBInsertFieldInfo(fieldInfo.getName(), null) ;
insertFieldInfo.addFieldPath( fieldInfo.getPath() ) ;
m_fieldsInfo.put( fieldInfo.getName(), insertFieldInfo ) ;
}
else{
insertFieldInfo.addFieldPath( fieldInfo.getPath() );
}
}
示例4: init
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public void init( String srcFieldName, String fieldPath ) throws KettleValueException{
if ( null == srcFieldName || srcFieldName.isEmpty()
|| null == fieldPath || fieldPath.isEmpty() ){
throw new KettleValueException( BaseMessages.getString( PKG,
"SequoiaDBOutput.Msg.Err.FailedToAddField",
srcFieldName, fieldPath ));
}
String[] fieldPathInfo = new String[2] ;
parseFieldPath( fieldPath, fieldPathInfo ) ;
m_fieldName = fieldPathInfo[0] ;
if ( null == fieldPathInfo[1] || fieldPathInfo[1].isEmpty() ){
m_srcFieldName = srcFieldName ;
return ;
}
SequoiaDBInsertField childField = new SequoiaDBInsertField() ;
childField.init( srcFieldName, fieldPathInfo[1] ) ;
if ( null == m_children ){
m_children = new TreeMap<String, SequoiaDBInsertField>() ;
}
m_children.put( childField.getFieldName(), childField ) ;
}
示例5: getUpdater
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public BSONObject getUpdater( Object[] row, RowMetaInterface rowMeta ) throws KettleValueException {
BSONObject updater = new BasicBSONObject() ;
for(Map.Entry<String, List<SequoiaDBUpdateFieldInfo>> entry:m_updateFields.entrySet()) {
BSONObject fieldsObj = new BasicBSONObject() ;
int fieldNum = entry.getValue().size() ;
for( int i = 0 ; i < fieldNum ; i++ ) {
SequoiaDBUpdateFieldInfo fieldTmp = entry.getValue().get(i) ;
int index = rowMeta.indexOfValue( fieldTmp.getName() ) ;
ValueMetaInterface vmi = rowMeta.getValueMeta( index ) ;
try{
fieldsObj.put(fieldTmp.getPath(), fieldTmp.getBsonValue(row[index], vmi)) ;
}
catch( KettleValueException e ){
throw new KettleValueException( BaseMessages.getString( PKG,
"SequoiaDBOutput.Msg.Err.FailedToGetTheFieldVal"
+ "(" + entry.getKey() + ":" + row[index].toString() + ")" ) );
}
}
updater.put( entry.getKey(), fieldsObj ) ;
}
if ( updater.isEmpty()) {
return null ;
}
return updater ;
}
示例6: getUpdateCond
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public BSONObject getUpdateCond( Object[] row, RowMetaInterface rowMeta ) throws KettleValueException {
BSONObject condition = new BasicBSONObject() ;
int fieldNum = m_condFields.size() ;
for( int i = 0 ; i < fieldNum ; i++ ) {
SequoiaDBUpdateFieldInfo fieldTmp = m_condFields.get(i) ;
int index = rowMeta.indexOfValue( fieldTmp.getName() ) ;
ValueMetaInterface vmi = rowMeta.getValueMeta( index ) ;
try{
condition.put(fieldTmp.getPath(), fieldTmp.getBsonValue(row[index], vmi)) ;
}
catch( KettleValueException e ){
throw new KettleValueException( BaseMessages.getString( PKG,
"SequoiaDBOutput.Msg.Err.FailedToGetTheFieldVal"
+ "(" + fieldTmp.getName() + ":" + row[index].toString() + ")" ) );
}
}
if ( condition.isEmpty() ) {
return null ;
}
return condition ;
}
示例7: init
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public void init( String srcFieldName, String fieldPath ) throws KettleValueException{
if ( null == srcFieldName || srcFieldName.isEmpty()
|| null == fieldPath || fieldPath.isEmpty() ){
throw new KettleValueException( BaseMessages.getString( PKG,
"SequoiaDBOutput.Msg.Err.FailedToAddField",
srcFieldName, fieldPath ));
}
String[] fieldPathInfo = new String[2] ;
parseFieldPath( fieldPath, fieldPathInfo ) ;
m_fieldName = fieldPathInfo[0] ;
if ( null == fieldPathInfo[1] || fieldPathInfo[1].isEmpty() ){
m_srcFieldName = srcFieldName ;
return ;
}
SequoiaDBOutputField childField = new SequoiaDBOutputField() ;
childField.init( srcFieldName, fieldPathInfo[1] ) ;
if ( null == m_children ){
m_children = new TreeMap<String, SequoiaDBOutputField>() ;
}
m_children.put( childField.getFieldName(), childField ) ;
}
示例8: FastJsonInputField
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public FastJsonInputField(Node fnode) throws KettleValueException {
setName(XMLHandler.getTagValue(fnode, "name"));
setPath(XMLHandler.getTagValue(fnode, "path"));
setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
setFormat(XMLHandler.getTagValue(fnode, "format"));
setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
setPrecision(Const
.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
setTrimType(getTrimTypeByCode(XMLHandler
.getTagValue(fnode, "trim_type")));
setRepeated(!"N".equalsIgnoreCase(XMLHandler.getTagValue(fnode,
"repeat")));
}
示例9: mod
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public Value mod(double arg0) throws KettleValueException
{
if (isNull()) return this;
if (isNumeric())
{
double n1=getNumber();
double n2=arg0;
setValue( n1 - (n2 * Math.floor(n1 /n2 )) );
}
else
{
throw new KettleValueException("Function MOD only works with numeric data");
}
return this;
}
示例10: endElement
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public void endElement(String uri, String localName, String qName) throws SAXException
{
tempVal = charactersBuffer.toString();
charactersBuffer = new StringBuffer(); // start again.
try
{
if (this.fieldToFill >= 0)
{
if (tempVal==null)
{
tempVal = "";
}
setValueToRow(tempVal, fieldToFill);
}
fieldToFill = -1;
} catch (KettleValueException e)
{
throw new RuntimeException(e); //signal error to the transformation don't ignore it
}
position[_counter + 1] = -1;
counterDown();
}
示例11: convertStringToDate
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
private synchronized Date convertStringToDate(String string) throws KettleValueException
{
string = Const.trimToType(string, getTrimType()); // see if trimming needs to be performed before conversion
if (Const.isEmpty(string)) return null;
try
{
return getDateFormat().parse(string);
}
catch (ParseException e)
{
String dateFormat = (getDateFormat() != null) ? getDateFormat().toPattern() : "null";
throw new KettleValueException(toString()+" : couldn't convert string ["+string+"] to a date using format ["+dateFormat+"]", e);
}
}
示例12: minus
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public static Object minus(ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB, Object dataB) throws KettleValueException
{
if (dataA==null || dataB==null) return null;
switch(metaA.getType())
{
case ValueMetaInterface.TYPE_NUMBER :
return new Double( metaA.getNumber(dataA).doubleValue()-metaB.getNumber(dataB).doubleValue());
case ValueMetaInterface.TYPE_INTEGER :
return new Long( metaA.getInteger(dataA).longValue()-metaB.getInteger(dataB).longValue());
case ValueMetaInterface.TYPE_BIGNUMBER :
return metaA.getBigNumber(dataA).subtract( metaB.getBigNumber(dataB));
case ValueMetaInterface.TYPE_DATE :
return new Long( metaA.getInteger(dataA).longValue()-metaB.getInteger(dataB).longValue());
default: throw new KettleValueException("The 'minus' function only works on numeric data." );
}
}
示例13: putRowOut
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
private void putRowOut(Object r[]) throws KettleStepException, KettleValueException {
data.rowNumber++;
if (data.pos_xml_filename!=-1) r[data.pos_xml_filename]=new String(data.filename);
if (data.pos_xml_row_number!=-1) r[data.pos_xml_row_number]=new Long(data.rowNumber);
if (data.pos_xml_element_id!=-1) r[data.pos_xml_element_id]=data.elementLevelID[data.elementLevel];
if (data.pos_xml_element_level!=-1) r[data.pos_xml_element_level]=new Long(data.elementLevel);
if (data.pos_xml_parent_element_id!=-1) r[data.pos_xml_parent_element_id]=data.elementParentID[data.elementLevel];
if (data.pos_xml_path!=-1) r[data.pos_xml_path]=data.elementPath[data.elementLevel];
if (data.pos_xml_parent_path!=-1 && data.elementLevel>0) r[data.pos_xml_parent_path]=data.elementPath[data.elementLevel-1];
// We could think of adding an option to filter Start_end Document / Elements, RegEx?
// We could think of adding columns identifying Element-Blocks
// Skip rows? (not exact science since some attributes could be mixed within the last row)
if (data.nrRowsToSkip == 0 || data.rowNumber > data.nrRowsToSkip) {
if (log.isRowLevel()) logRowlevel("Read row: " + data.outputRowMeta.getString(r)); //$NON-NLS-1$
putRow(data.outputRowMeta, r);
}
}
示例14: getValueData
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
/**
* Extracts the primitive data from an old style Value object
* @param value the old style Value object
* @return the value's data, NOT the meta data.
* @throws KettleValueException case there is a data conversion problem
*/
public Object getValueData(Value value) throws KettleValueException
{
if (value==null || value.isNull()) return null;
// So far the old types and the new types map to the same thing.
// For compatibility we just ask the old-style value to convert to the new one.
// In the old transformation this would happen sooner or later anyway.
// It doesn't throw exceptions or complain either (unfortunately).
//
switch(getType())
{
case ValueMetaInterface.TYPE_STRING : return value.getString();
case ValueMetaInterface.TYPE_NUMBER : return value.getNumber();
case ValueMetaInterface.TYPE_INTEGER : return value.getInteger();
case ValueMetaInterface.TYPE_DATE : return value.getDate();
case ValueMetaInterface.TYPE_BOOLEAN : return value.getBoolean();
case ValueMetaInterface.TYPE_BIGNUMBER : return value.getBigNumber();
case ValueMetaInterface.TYPE_BINARY : return value.getBytes();
default: throw new KettleValueException(toString()+" : We can't convert original data type "+value.getTypeDesc()+" to a primitive data type");
}
}
示例15: XMLInputSaxField
import org.pentaho.di.core.exception.KettleValueException; //导入依赖的package包/类
public XMLInputSaxField(Node fnode) throws KettleValueException
{
setName( XMLHandler.getTagValue(fnode, "name") );
setType( ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")) );
setFormat( XMLHandler.getTagValue(fnode, "format") );
setCurrencySymbol( XMLHandler.getTagValue(fnode, "currency") );
setDecimalSymbol( XMLHandler.getTagValue(fnode, "decimal") );
setGroupSymbol( XMLHandler.getTagValue(fnode, "group") );
setLength( Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1) );
setPrecision( Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1) );
setTrimType( getTrimType(XMLHandler.getTagValue(fnode, "trim_type")) );
setRepeated( !"N".equalsIgnoreCase(XMLHandler.getTagValue(fnode, "repeat")) );
Node positions = XMLHandler.getSubNode(fnode, "positions");
int nrPositions = XMLHandler.countNodes(positions, "position");
fieldPosition = new XMLInputSaxFieldPosition[nrPositions];
for (int i=0;i<nrPositions;i++)
{
Node positionnode = XMLHandler.getSubNodeByNr(positions, "position", i);
String encoded = XMLHandler.getNodeValue(positionnode);
fieldPosition[i] = new XMLInputSaxFieldPosition(encoded);
}
}