@Test public void testGetRecordValue() throws Exception { SalesforceConnection conn = mock( SalesforceConnection.class, Mockito.CALLS_REAL_METHODS ); SObject sObject = new SObject(); sObject.setName( new QName( Constants.PARTNER_SOBJECT_NS, "sObject" ) ); SObject testObject = createObject( "field", "value" ); sObject.addField( "field", testObject ); assertEquals( "Get value of simple record", "value", conn.getRecordValue( sObject, "field" ) ); SObject parentObject = createObject( "parentField", null ); sObject.addField( "parentField", parentObject ); SObject childObject = createObject( "subField", "subValue" ); parentObject.addField( "subField", childObject ); assertEquals( "Get value of record with hierarchy", "subValue", conn.getRecordValue( sObject, "parentField.subField" ) ); XmlObject nullObject = new XmlObject( new QName( "nullField" ) ); sObject.addField( "nullField", nullObject ); assertEquals( "Get null value when relational query id is null", null, conn.getRecordValue( sObject, "nullField.childField" ) ); }
public String getRecordValue( SObject con, String fieldname ) throws KettleException { String[] fieldHierarchy = fieldname.split( "\\." ); if ( con == null ) { return null; } else { XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy ); if ( element != null ) { Object object = element.getValue(); if ( object != null ) { if ( object instanceof QueryResult ) { return buildJsonQueryResult( (QueryResult) object ); } return String.valueOf( object ); } else { return (String) element.getValue(); } } } return null; }
SalesforceConnection { public String getRecordValue( SObject con, String fieldname ) throws KettleException { String[] fieldHierarchy = fieldname.split( "\\." ); if ( con == null ) { return null; } else { XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy ); if ( element != null ) { Object object = element.getValue(); if ( object != null ) { if ( object instanceof QueryResult ) { return buildJsonQueryResult( (QueryResult) object ); } return String.valueOf( object ); } else { return (String) element.getValue(); } } } return null; } }
SalesforceConnection { public String getRecordValue( SObject con, String fieldname ) throws KettleException { String[] fieldHierarchy = fieldname.split( "\\." ); if ( con == null ) { return null; } else { XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy ); if ( element != null ) { Object object = element.getValue(); if ( object != null ) { if ( object instanceof QueryResult ) { return buildJsonQueryResult( (QueryResult) object ); } return String.valueOf( object ); } else { return (String) element.getValue(); } } } return null; } SalesforceConnection( LogChannelInterface logInterface, String url, String username, String password ); }
SalesforceConnection { public String getRecordValue( SObject con, String fieldname ) throws KettleException { String[] fieldHierarchy = fieldname.split( "\\." ); if ( con == null ) { return null; } else { XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy ); if ( element != null ) { Object object = element.getValue(); if ( object != null ) { if ( object instanceof QueryResult ) { return buildJsonQueryResult( (QueryResult) object ); } return String.valueOf( object ); } else { return (String) element.getValue(); } } } return null; } SalesforceConnection( LogChannelInterface logInterface, String url, String username, String password ); boolean isRollbackAllChangesOnError(); @Deprecated void rollbackAllChangesOnError( boolean value ); void setRollbackAllChangesOnError( boolean value ); boolean isQueryAll(); @Deprecated void queryAll( boolean value ); void setQueryAll( boolean value ); void setCalendar( int recordsFilter, GregorianCalendar startDate, GregorianCalendar endDate ); void setSQL( String sql ); void setFieldsList( String fieldsList ); void setModule( String module ); String getURL(); String getSQL(); Date getServerTimestamp(); String getModule(); QueryResult getQueryResult(); PartnerConnection createBinding( ConnectorConfig config ); PartnerConnection getBinding(); void setTimeOut( int timeout ); int getTimeOut(); boolean isUsingCompression(); void setUsingCompression( boolean useCompression ); String getUsername(); void setUsername( String value ); String getPassword(); void setPassword( String value ); void connect(); void query( boolean specifyQuery ); void close(); int getQueryResultSize(); int getRecordsCount(); SalesforceRecordValue getRecord( int recordIndex ); String getRecordValue( SObject con, String fieldname ); XmlObject[] getElements(); boolean queryMore(); String[] getAllAvailableObjects( boolean OnlyQueryableObjects ); Field[] getObjectFields( String objectName ); Field[] getObjectFields( String objectName, boolean excludeNonUpdatableFields ); String[] getFields( String objectName ); String[] getFields( String objectName, boolean excludeNonUpdatableFields ); String[] getFields( Field[] fields ); String[] getFields( Field[] fields, boolean excludeNonUpdatableFields ); UpsertResult[] upsert( String upsertField, SObject[] sfBuffer ); SaveResult[] insert( SObject[] sfBuffer ); SaveResult[] update( SObject[] sfBuffer ); DeleteResult[] delete( String[] id ); static XmlObject createMessageElement( String name, Object value, boolean useExternalKey ); static XmlObject fromTemplateElement( String name, Object value, boolean setValue ); static XmlObject[] getChildren( SObject object ); }
SalesforceConnection { public String getRecordValue( SObject con, String fieldname ) throws KettleException { String[] fieldHierarchy = fieldname.split( "\\." ); if ( con == null ) { return null; } else { XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy ); if ( element != null ) { Object object = element.getValue(); if ( object != null ) { if ( object instanceof QueryResult ) { return buildJsonQueryResult( (QueryResult) object ); } return String.valueOf( object ); } else { return (String) element.getValue(); } } } return null; } SalesforceConnection( LogChannelInterface logInterface, String url, String username, String password ); boolean isRollbackAllChangesOnError(); @Deprecated void rollbackAllChangesOnError( boolean value ); void setRollbackAllChangesOnError( boolean value ); boolean isQueryAll(); @Deprecated void queryAll( boolean value ); void setQueryAll( boolean value ); void setCalendar( int recordsFilter, GregorianCalendar startDate, GregorianCalendar endDate ); void setSQL( String sql ); void setFieldsList( String fieldsList ); void setModule( String module ); String getURL(); String getSQL(); Date getServerTimestamp(); String getModule(); QueryResult getQueryResult(); PartnerConnection createBinding( ConnectorConfig config ); PartnerConnection getBinding(); void setTimeOut( int timeout ); int getTimeOut(); boolean isUsingCompression(); void setUsingCompression( boolean useCompression ); String getUsername(); void setUsername( String value ); String getPassword(); void setPassword( String value ); void connect(); void query( boolean specifyQuery ); void close(); int getQueryResultSize(); int getRecordsCount(); SalesforceRecordValue getRecord( int recordIndex ); String getRecordValue( SObject con, String fieldname ); XmlObject[] getElements(); boolean queryMore(); String[] getAllAvailableObjects( boolean OnlyQueryableObjects ); Field[] getObjectFields( String objectName ); Field[] getObjectFields( String objectName, boolean excludeNonUpdatableFields ); String[] getFields( String objectName ); String[] getFields( String objectName, boolean excludeNonUpdatableFields ); String[] getFields( Field[] fields ); String[] getFields( Field[] fields, boolean excludeNonUpdatableFields ); UpsertResult[] upsert( String upsertField, SObject[] sfBuffer ); SaveResult[] insert( SObject[] sfBuffer ); SaveResult[] update( SObject[] sfBuffer ); DeleteResult[] delete( String[] id ); static XmlObject createMessageElement( String name, Object value, boolean useExternalKey ); static XmlObject fromTemplateElement( String name, Object value, boolean setValue ); static XmlObject[] getChildren( SObject object );  }