當前位置: 首頁>>代碼示例>>Java>>正文


Java RowMetaInterface.getString方法代碼示例

本文整理匯總了Java中org.pentaho.di.core.row.RowMetaInterface.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java RowMetaInterface.getString方法的具體用法?Java RowMetaInterface.getString怎麽用?Java RowMetaInterface.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.pentaho.di.core.row.RowMetaInterface的用法示例。


在下文中一共展示了RowMetaInterface.getString方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addInputRowInfos

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private boolean addInputRowInfos(Object[] r) throws KettleException{
	RowMetaInterface prevInfoFields = data.prevStepFields;
	if (meta.isLayerNameInField()){    	            	               
		int idx_layername = prevInfoFields.indexOfValue(meta.getLayerNameField());
           if (idx_layername<0){
               logError(Messages.getString("OGRFileInput.Log.Error.UnableToFindFilenameField", meta.getLayerNameField()));
               stopAll();
               return false;
           }                   
           data.layernames.add(prevInfoFields.getString(r, idx_layername));  
       }else
       	data.layernames.add(meta.getLayerName());  

	String source;
       if (meta.isSourceInField()){             
        	int idx_source = prevInfoFields.indexOfValue(meta.getSourceField());          
           if (idx_source<0){
                logError(Messages.getString("OGRFileInput.Log.Error.UnableToFindFilenameField", meta.getSourceField()));
    			 stopAll();
                return false;
           }
           source =prevInfoFields.getString(r, idx_source);           	           
       }else
       	source = meta.getSource();
       return addSource(source); 
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:27,代碼來源:OGRFileInput.java

示例2: getDbFields

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
/**
 * Runs a desc table to get the fields, and field types from the database.  Uses a desc table as opposed
 * to the select * from table limit 0 that Pentaho normally uses to get the fields and types, due to the need
 * to handle the Time type.  The select * method through Pentaho does not give us the ability to differentiate
 * time from timestamp.
 * @throws KettleException
 */
private void getDbFields() throws KettleException {
  data.dbFields = new ArrayList<>();
  String SQL = "desc table ";
  if ( !Const.isEmpty( environmentSubstitute( meta.getTargetSchema() ) ) ) {
    SQL += environmentSubstitute( meta.getTargetSchema() ) + ".";
  }
  SQL += environmentSubstitute( meta.getTargetTable() );
  logDetailed( "Executing SQL " + SQL );
  try {
    ResultSet resultSet = data.db.openQuery( SQL, null, null, ResultSet.FETCH_FORWARD, false );

    RowMetaInterface rowMeta = data.db.getReturnRowMeta();
    int nameField = rowMeta.indexOfValue( "NAME" );
    int typeField = rowMeta.indexOfValue( "TYPE" );
    if ( nameField < 0 || typeField < 0 ) {
      throw new KettleException( "Unable to get database fields" );
    }

    Object[] row = data.db.getRow( resultSet );
    if ( row == null ) {
      throw new KettleException( "No fields found in table" );
    }
    while ( row != null ) {
      String[] field = new String[2];
      field[0] = rowMeta.getString( row, nameField ).toUpperCase();
      field[1] = rowMeta.getString( row, typeField );
      data.dbFields.add( field );
      row = data.db.getRow( resultSet );
    }
    data.db.closeQuery( resultSet );
  } catch ( Exception ex ) {
    throw new KettleException( "Error getting database fields", ex );
  }
}
 
開發者ID:inquidia,項目名稱:PentahoSnowflakePlugin,代碼行數:42,代碼來源:SnowflakeBulkLoader.java

示例3: rowWrittenEvent

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
public void rowWrittenEvent( RowMetaInterface rowMeta, Object[] row ) throws KettleStepException
{
    try {
        schemaValue = rowMeta.getString(row, schemaFieldName, null);
    } catch ( KettleValueException ex )
    {
        throw new KettleStepException( ex.getMessage(), ex );
    }
}
 
開發者ID:inquidia,項目名稱:KettleDynamicSchemaProcessor,代碼行數:10,代碼來源:SchemaValueRowListener.java

示例4: determineUrl

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private String determineUrl(RowMetaInterface outputRowMeta, Object[] row) throws KettleValueException, KettleException
{
	try
	{
		if(meta.isUrlInField())
       {
			// get dynamic url
       	data.realUrl=outputRowMeta.getString(row,data.indexOfUrlField);
       }
     StringBuffer url = new StringBuffer(data.realUrl); // the base URL with variable substitution
     
     for (int i=0;i<data.argnrs.length;i++)
     {
     	if (i==0 && url.indexOf("?")<0)
         {
             url.append('?');
         }
         else
         {
             url.append('&');
         }
	
     	url.append(URIUtil.encodeWithinQuery(meta.getArgumentParameter()[i]));
     	url.append('=');
         String s = outputRowMeta.getString(row, data.argnrs[i]);
         if ( s != null )
         	s = URIUtil.encodeWithinQuery(s);
         url.append(s);
     }
     
     return url.toString();
 }
 catch(Exception e)
 {
     throw new KettleException(Messages.getString("HTTP.Log.UnableCreateUrl"), e);
 }
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:38,代碼來源:HTTP.java

示例5: getStrings

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
public String[] getStrings(String sql, ObjectId...objectId) throws KettleException
{
  // Get the prepared statement
  //
  PreparedStatement ps = sqlMap.get(sql);
  if (ps == null) {
    ps = database.prepareSQL(sql);
    sqlMap.put(sql, ps);
  }

  // Assemble the parameters (if any)
  //
  // Assemble the parameters (if any)
  //
  RowMetaInterface parameterMeta = new RowMeta();
  Object[] parameterData = new Object[objectId.length];
  for (int i = 0; i < objectId.length; i++) {
    parameterMeta.addValueMeta(new ValueMeta("id" + (i + 1), ValueMetaInterface.TYPE_INTEGER));
    parameterData[i] = ((LongObjectId)objectId[i]).longValue();
  }

  // Get the result set back...
  //
  ResultSet resultSet = database.openQuery(ps, parameterMeta, parameterData);
  List<Object[]> rows = database.getRows(resultSet, 0, null);
  if (Const.isEmpty(rows)) {
    return new String[0];
  }
  
  // assemble the result
  //
  RowMetaInterface rowMeta = database.getReturnRowMeta();
  String[] strings = new String[rows.size()];
  for (int i=0;i<strings.length;i++) {
    Object[] row = rows.get(i);
    strings[i] = rowMeta.getString(row, 0);
  }
  
  return strings;
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:41,代碼來源:KettleDatabaseRepositoryConnectionDelegate.java

示例6: determineUrl

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private String determineUrl(RowMetaInterface outputRowMeta, Object[] row) throws KettleValueException, KettleException
{
	try
	{
		if(meta.isUrlInField())
       {
			// get dynamic url
       	data.realUrl=outputRowMeta.getString(row,data.indexOfUrlField);
       }
     StringBuffer url = new StringBuffer(data.realUrl); // the base URL with variable substitution
     
     for (int i=0;i<data.argnrs.length;i++)
     {
     	if (i==0 && url.indexOf("?")<0)
         {
             url.append('?');
         }
         else
         {
             url.append('&');
         }
	
     	url.append(URIUtil.encodeWithinQuery(meta.getArgumentParameter()[i]));
     	url.append('=');
         String s = outputRowMeta.getString(row, data.argnrs[i]);
         if ( s != null )
         	s = URIUtil.encodeWithinQuery(s);
         url.append(s);
     }
     
     return url.toString();
 }
 catch(Exception e)
 {
     throw new KettleException(BaseMessages.getString(PKG, "HTTP.Log.UnableCreateUrl"), e);
 }
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:38,代碼來源:HTTP.java

示例7: loadDatabase

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
/**
 * Runs the commands to put the data to the Snowflake stage, the copy command to load the table, and finally
 * a commit to commit the transaction.
 * @throws KettleDatabaseException
 * @throws KettleFileException
 * @throws KettleValueException
 */
private void loadDatabase() throws KettleDatabaseException, KettleFileException, KettleValueException {
  boolean filesUploaded = false;
  boolean endsWithSlash = environmentSubstitute( meta.getWorkDirectory() ).endsWith( "\\" )
    || environmentSubstitute( meta.getWorkDirectory() ).endsWith( "/" );
  String SQL = "PUT 'file://" + environmentSubstitute( meta.getWorkDirectory() ).replaceAll( "\\\\", "/" )
    + ( endsWithSlash ? "" : "/" ) + environmentSubstitute( meta.getTargetTable() ) + "_"
    + meta.getFileDate() + "_*' " + meta.getStage( this ) + ";";

  logDebug( "Executing SQL " + SQL );
  ResultSet putResultSet = data.db.openQuery( SQL, null, null, ResultSet.FETCH_FORWARD, false );
  RowMetaInterface putRowMeta = data.db.getReturnRowMeta();
  Object[] putRow = data.db.getRow( putResultSet );
  logDebug( "=========================Put File Results======================" );
  int fileNum = 0;
  while ( putRow != null ) {
    logDebug( "------------------------ File " + fileNum +"--------------------------" );
    for ( int i = 0; i < putRowMeta.getFieldNames().length; i++ ) {
      logDebug( putRowMeta.getFieldNames()[i] + " = " + putRowMeta.getString( putRow, i ) );
      if( putRowMeta.getFieldNames()[i].equalsIgnoreCase( "status" ) ) {
        if( putRowMeta.getString( putRow, i ).equalsIgnoreCase( "ERROR" ) ) {
          throw new KettleDatabaseException( "Error putting file to Snowflake stage \n" + putRowMeta.getString( putRow, "message", "" ) );
        }
      }
    }
    fileNum++;

    putRow = data.db.getRow( putResultSet );
  }
  data.db.closeQuery( putResultSet );

  String copySQL = meta.getCopyStatement( this, data.getPreviouslyOpenedFiles() );
  logDebug( "Executing SQL " + copySQL );
  ResultSet resultSet = data.db.openQuery( copySQL, null, null, ResultSet.FETCH_FORWARD, false );
  RowMetaInterface rowMeta = data.db.getReturnRowMeta();

  Object[] row = data.db.getRow( resultSet );
  int rowsLoaded = 0;
  int rowsLoadedField = rowMeta.indexOfValue( "rows_loaded" );
  int rowsError = 0;
  int errorField = rowMeta.indexOfValue( "errors_seen" );
  logBasic( "====================== Bulk Load Results======================" );
  int rowNum = 1;
  while ( row != null ) {
    logBasic( "---------------------- Row " + rowNum + " ----------------------" );
    for ( int i = 0; i < rowMeta.getFieldNames().length; i++ ) {
      logBasic( rowMeta.getFieldNames()[i] + " = " + rowMeta.getString( row, i ) );
    }

    if ( rowsLoadedField >= 0 ) {
      rowsLoaded += rowMeta.getInteger( row, rowsLoadedField );
    }

    if ( errorField >= 0 ) {
      rowsError += rowMeta.getInteger( row, errorField );
    }

    rowNum++;
    row = data.db.getRow( resultSet );
  }
  data.db.closeQuery( resultSet );
  setLinesOutput( rowsLoaded );
  setLinesRejected( rowsError );

  data.db.execStatement( "commit" );

}
 
開發者ID:inquidia,項目名稱:PentahoSnowflakePlugin,代碼行數:74,代碼來源:SnowflakeBulkLoader.java

示例8: searchNrStepAttributes

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private synchronized int searchNrStepAttributes(long id_step, String code) throws KettleValueException
{
    // Search the index of the first step attribute with the specified code...
	//
    int idx = searchStepAttributeIndexInBuffer(id_step, code, 0L);
    if (idx<0) return 0;
    
    int nr = 1;
    int offset = 1;
       
       if (idx+offset>=stepAttributesBuffer.size())
       {
       	// Only 1, the last of the attributes buffer.
       	//
           return 1; 
       }
       Object[] look = (Object[])stepAttributesBuffer.get(idx+offset);
       RowMetaInterface rowMeta = stepAttributesRowMeta;
       
    long lookID = rowMeta.getInteger(look, 0);
    String lookCode = rowMeta.getString(look, 1);
    
    while (lookID==id_step && code.equalsIgnoreCase( lookCode ) )
    {
    	// Find the maximum
    	//
        nr = rowMeta.getInteger(look, 2).intValue() + 1; 
        offset++;
           if (idx+offset<stepAttributesBuffer.size())
           {
               look = (Object[])stepAttributesBuffer.get(idx+offset);
               
               lookID = rowMeta.getInteger(look, 0);
               lookCode = rowMeta.getString(look, 1);
           }
           else
           {
               return nr;
           }
    }
    return nr;
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:43,代碼來源:Repository.java

示例9: addInputRowInfos

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private boolean addInputRowInfos(Object[] r) throws KettleException{
	boolean noErrors = true;
	RowMetaInterface prevInfoFields = data.outputRowMeta;
	if (meta.isLayerNameInField()){    	            	               
		int idx_layername = prevInfoFields.indexOfValue(meta.getLayerNameField());
	    if (idx_layername<0){
	        logError(Messages.getString("OGRFileOutput.Log.Error.UnableToFindFilenameField", meta.getLayerNameField()));
	        stopAll();
	        return false;
	    }                   
	    data.layernames.add(prevInfoFields.getString(r, idx_layername));  
	}else
		data.layernames.add(meta.getLayerName());  
	
	String source;
	if (meta.isSourceInField()){             
		int idx_source = prevInfoFields.indexOfValue(meta.getSourceField());          
		if (idx_source<0){
	         logError(Messages.getString("OGRFileOutputput.Log.Error.UnableToFindFilenameField", meta.getSourceField()));
			 stopAll();
	         return false;
	    }
	    source =prevInfoFields.getString(r, idx_source);           	           
	}else
		source = meta.getSource();
	
	noErrors = addSource(source);
	
	boolean newWriterFlag = false;
	
	if(data.index > 0){
		if(meta.isSourceInField()){
			if(meta.isFileSource()){
				if(!compareStrings(data.files.getFile(data.index).getName().toString(), data.files.getFile(data.index - 1).toString()))					
					newWriterFlag = true;					
			}else{
				if(!compareStrings(data.cnxStrings.get(data.index), data.cnxStrings.get(data.index - 1)))
					newWriterFlag = true;
			}
		}
		//}else{
			if(!compareStrings(data.layernames.get(data.index), data.layernames.get(data.index - 1)))
				newWriterFlag = true;				
		//}
								
	}else
		newWriterFlag = true;
	
	data.newWriterFlags.add(newWriterFlag);
	data.index++;
	return noErrors; 
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:53,代碼來源:OGRFileOutput.java

示例10: getFirst

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private List<String> getFirst(FixedInputMeta meta, int limit) throws IOException, KettleValueException {

		List<String> lines = new ArrayList<String>();
		
        FixedInputMeta oneMeta = new FixedInputMeta();
        getInfo(oneMeta);
        
        // Add a single field with the width of the line...
        //
        int lineWidth = Integer.parseInt(oneMeta.getLineWidth());
        if (lineWidth<=0) {
        	throw new IOException("The width of a line can not be 0 or less.");
        }
        
        oneMeta.allocate(1);
        
        FixedFileInputField field = new FixedFileInputField();
        field.setName("Field1");
        field.setType(ValueMetaInterface.TYPE_STRING);
        field.setWidth(lineWidth);
        oneMeta.getFieldDefinition()[0] = field;
        
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { limit } );
        progressDialog.open();

        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();

        if (!progressDialog.isCancelled())
        {
            if (trans.getResult()!=null && trans.getResult().getNrErrors()>0)
            {
            	EnterTextDialog etd = new EnterTextDialog(shell, Messages.getString("System.Dialog.PreviewError.Title"),  
            			Messages.getString("System.Dialog.PreviewError.Message"), loggingText, true );
            	etd.setReadOnly();
            	etd.open();
            }
        }
        
        // The rows are in the transformation...
        //
        RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
        List<Object[]> previewRowsData = progressDialog.getPreviewRows(wStepname.getText());
        for (int i=0;i<previewRowsData.size();i++) {
        	String line = previewRowsMeta.getString(previewRowsData.get(i), 0);
        	lines.add(line);
        }
        
        return lines;
	}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:53,代碼來源:FixedInputDialog.java

示例11: checkRows

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
/**
 *  Check the list, the list has to be sorted. 
 */
public void checkRows(List<RowMetaAndData> rows, boolean ascending) throws Exception
{
	String prev_key1 = null, prev_key2 = null;
	int idx = 0;
	
       for ( RowMetaAndData rm : rows ) {
       	Object[] r1 = rm.getData();
       	RowMetaInterface rmi = rm.getRowMeta();
	
	    String key1 = rmi.getString(r1, "KEY1", "");
	    String key2 = rmi.getString(r1, "KEY2", "");
	   
	    if (prev_key1 != null && prev_key2 != null)
	    { 
	       if ( ascending )
	       {
	    	   if (prev_key1.compareTo(key1) == 0) 
	    	   {
	    		   if ( prev_key2.compareTo(key2) > 0 )
	    		   {
	    			   fail("error in sort");
	    		   }
	    	   }
	    	   else if (prev_key1.compareTo(key1) > 0)
	    	   {
	    		   fail("error in sort");
	    	   }
	       }
	       else
	       {
	    	   if (prev_key1.compareTo(key1) == 0) 
	    	   {
	    		   if ( prev_key2.compareTo(key2) < 0 )
	    		   {
	    			   fail("error in sort");
	    		   }
	    	   }
	    	   else if (prev_key1.compareTo(key1) < 0)
	    	   {
	    		   fail("error in sort");
	    	   }
	       }		       
	   }
	   prev_key1 = key1;
	   prev_key2 = key2;

	   idx++;
 	    }
 	    if (idx != MAX_COUNT)
    {
       fail("less rows returned than expected: " + idx);
    }
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:57,代碼來源:SortRowsTest.java

示例12: searchNrStepAttributes

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private synchronized int searchNrStepAttributes(ObjectId id_step, String code) throws KettleValueException
{
    // Search the index of the first step attribute with the specified code...
	//
    int idx = searchStepAttributeIndexInBuffer(id_step, code, 0L);
    if (idx<0) return 0;
    
    int nr = 1;
    int offset = 1;
       
       if (idx+offset>=stepAttributesBuffer.size())
       {
       	// Only 1, the last of the attributes buffer.
       	//
           return 1; 
       }
       Object[] look = (Object[])stepAttributesBuffer.get(idx+offset);
       RowMetaInterface rowMeta = stepAttributesRowMeta;
       
    long lookID = rowMeta.getInteger(look, 0);
    String lookCode = rowMeta.getString(look, 1);
    
    while (lookID==new LongObjectId(id_step).longValue() && code.equalsIgnoreCase( lookCode ) )
    {
    	// Find the maximum
    	//
        nr = rowMeta.getInteger(look, 2).intValue() + 1; 
        offset++;
           if (idx+offset<stepAttributesBuffer.size())
           {
               look = (Object[])stepAttributesBuffer.get(idx+offset);
               
               lookID = rowMeta.getInteger(look, 0);
               lookCode = rowMeta.getString(look, 1);
           }
           else
           {
               return nr;
           }
    }
    return nr;
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:43,代碼來源:KettleDatabaseRepositoryConnectionDelegate.java

示例13: getFirst

import org.pentaho.di.core.row.RowMetaInterface; //導入方法依賴的package包/類
private List<String> getFirst(FixedInputMeta meta, int limit) throws IOException, KettleValueException {

    List<String> lines = new ArrayList<String>();

    FixedInputMeta oneMeta = new FixedInputMeta();
    getInfo(oneMeta);

    // Add a single field with the width of the line...
    //
    int lineWidth = Integer.parseInt(oneMeta.getLineWidth());
    if (lineWidth <= 0) {
      throw new IOException("The width of a line can not be 0 or less.");
    }

    oneMeta.allocate(1);

    FixedFileInputField field = new FixedFileInputField();
    field.setName("Field1");
    field.setType(ValueMetaInterface.TYPE_STRING);
    field.setWidth(lineWidth);
    oneMeta.getFieldDefinition()[0] = field;

    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());

    TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta,
        new String[] { wStepname.getText() }, new int[] { limit });
    progressDialog.open();

    Trans trans = progressDialog.getTrans();
    String loggingText = progressDialog.getLoggingText();

    if (!progressDialog.isCancelled()) {
      if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
        EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages
            .getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG,
            "System.Dialog.PreviewError.Message"), loggingText, true);
        etd.setReadOnly();
        etd.open();
      }
    }

    // The rows are in the transformation...
    //
    RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
    List<Object[]> previewRowsData = progressDialog.getPreviewRows(wStepname.getText());
    for (int i = 0; i < previewRowsData.size(); i++) {
      String line = previewRowsMeta.getString(previewRowsData.get(i), 0);
      lines.add(line);
    }

    return lines;
  }
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:53,代碼來源:FixedInputDialog.java


注:本文中的org.pentaho.di.core.row.RowMetaInterface.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。