function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
colemabcolemab 

Getting DataLoader source to compile in eclipse

For those wishing to modify the data loader, here are the steps to getting it to compile:

 

1.  Already have eclipse up and running.  You probably have this already for SFDC development so I will skip the details on this one.

2. Download the latest Java JDK (NOT the JRE, the JDK).  Latest for me was 1.7

3. Download the latest source code for apexdataloader from sourceforge.  Latest version for me was 19.

    EDIT: Here is the link to version 19

 

4. Extract the zip file to C:\apexdataloader\

5. Open eclipse and hit file-> New Project.

6. Select "Java project from existing ant bundle"

7. Browse to C:\apexdataloader\build\ and select build.xml

8. Close the project in eclipse

9. locate your .classpath file in the project workspace directory in windows explorer (this varies based on where your home dir is).

10. Edit this file and add this line:

<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.7.0/jre/lib/jce.jar"/>

11. Re-open the project in eclipse.

 

*EDIT*: I think the main can be found at: com.salesforce.dataloader.process.DataLoaderRunner

 

You should now be able to compile w/o errors (will get some warnings).

 

Just sharing in case this caused someone else trouble.

 

In my case, I am working on modifying the data loader to honor the scale / decimal setting for currency fields.

Best Answer chosen by Admin (Salesforce Developers) 
colemabcolemab

EDIT: See the orignal post for the solution. Just marking this as solved for other people

 

EDIT: The notes below are for a hack to fix the missing zero (for double's with a scale of 2 only) and DO NOT read from the meta data to determine if this is the proper setting.  The only time this should cause trouble is if you chose one decmail point in the scale setting.  Please note that it will NOT fix 100.00 to be 100.000 - so if your scale isn't 2 you don't want this hack.  At somepoint, I hope to add code to use the describeSObjectResult function in the API to determine the scale dyanmically and output a value inline with the setting for that field but this isn't that code.

 

EDIT: this hack only applies to version 19 - update coming soon for version 23

 

EDIT: for version 23 you need to edit .com.salesforce.dataloader.action.visitor \ PartnerQueryVisitor.java

 

For anyone interested in updating the data loader such that any fields that currently output ending in .0 being output as .00 instead (i.e. getting 100.00 instead of the current 100.0), here are some notes:

 

1. Get the code loaded as in the above post.

2. Open QueryVisitor.java (PartnerQueryVistior.Java in v23)

3. Change this line: import java.util.regex.pattern;

To be this line: import java.util.regex.*;

4.  locate the convertFieldValue function.

5. Append this code to the botton of the function (right before the return line):

 

        if (fieldVal != null) {
            
            // create a pattern to use regular expressions
            Pattern ptrnEndsInDotZero = Pattern.compile("\\.[0-9]");
            Pattern ptrnEndsInDotTwoNums = Pattern.compile("\\.[0-9][0-9]");

            // cast our number to a string
            String strDecimalAmount = fieldVal.toString();
            
            // create a matcher from our pattern and string
            Matcher mtchEndsInDotZero = ptrnEndsInDotZero.matcher(strDecimalAmount);
            Matcher mtchEndsInDotTwoNums = ptrnEndsInDotTwoNums.matcher(strDecimalAmount);
            
            boolean blnDotZeroSearchResult = mtchEndsInDotZero.find();
            boolean blnDotTwoNumsSearchResult = mtchEndsInDotTwoNums.find();


            if (blnDotZeroSearchResult == true && blnDotTwoNumsSearchResult == false) {
                // Has tenths but not hundredths
                // found an entry with missing Decimal
                // add the zero back.
                fieldVal = fieldVal + "0";
            }
        }   // check for null field


 

All Answers

colemabcolemab

EDIT: See the orignal post for the solution. Just marking this as solved for other people

 

EDIT: The notes below are for a hack to fix the missing zero (for double's with a scale of 2 only) and DO NOT read from the meta data to determine if this is the proper setting.  The only time this should cause trouble is if you chose one decmail point in the scale setting.  Please note that it will NOT fix 100.00 to be 100.000 - so if your scale isn't 2 you don't want this hack.  At somepoint, I hope to add code to use the describeSObjectResult function in the API to determine the scale dyanmically and output a value inline with the setting for that field but this isn't that code.

 

EDIT: this hack only applies to version 19 - update coming soon for version 23

 

EDIT: for version 23 you need to edit .com.salesforce.dataloader.action.visitor \ PartnerQueryVisitor.java

 

For anyone interested in updating the data loader such that any fields that currently output ending in .0 being output as .00 instead (i.e. getting 100.00 instead of the current 100.0), here are some notes:

 

1. Get the code loaded as in the above post.

2. Open QueryVisitor.java (PartnerQueryVistior.Java in v23)

3. Change this line: import java.util.regex.pattern;

To be this line: import java.util.regex.*;

4.  locate the convertFieldValue function.

5. Append this code to the botton of the function (right before the return line):

 

        if (fieldVal != null) {
            
            // create a pattern to use regular expressions
            Pattern ptrnEndsInDotZero = Pattern.compile("\\.[0-9]");
            Pattern ptrnEndsInDotTwoNums = Pattern.compile("\\.[0-9][0-9]");

            // cast our number to a string
            String strDecimalAmount = fieldVal.toString();
            
            // create a matcher from our pattern and string
            Matcher mtchEndsInDotZero = ptrnEndsInDotZero.matcher(strDecimalAmount);
            Matcher mtchEndsInDotTwoNums = ptrnEndsInDotTwoNums.matcher(strDecimalAmount);
            
            boolean blnDotZeroSearchResult = mtchEndsInDotZero.find();
            boolean blnDotTwoNumsSearchResult = mtchEndsInDotTwoNums.find();


            if (blnDotZeroSearchResult == true && blnDotTwoNumsSearchResult == false) {
                // Has tenths but not hundredths
                // found an entry with missing Decimal
                // add the zero back.
                fieldVal = fieldVal + "0";
            }
        }   // check for null field


 

This was selected as the best answer
colemabcolemab

Version 23 has been posted and can be found here:

https://github.com/forcedotcom/dataloader

 

Please note that the project has moved from source forge to github.

 

I recommend that you:

 

  1. install ANT
  2. install Perl
  3. use ANT compile to generate lib\partnerwsdl.jar. 
  4. Once generated, fix the reference in eclipse and you should be good to go.
colemabcolemab

You build the JAR file on the command line by using the C:\apexdataloader\build\ant.bat in that same dir.  That should create your JAR file in C:\apexdataloader\JAR\

 

It might be a good idea to backup the JAR file from your orginal install before doing any testing - just so you can roll back w/o doing a full download and re-install.

 

Please note that depending on your settings, the JAR file may not work with the apexdataloader.exe from SFDC.

 

However, you can call it from the command line like so:

 

java.exe -cp ..\MyDataLoader.jar -Dsalesforce.config.dir=..\ConfigDIRGoesHERE com.salesforce.dataloader.process.ProcessRunner

 

colemabcolemab

*BUMP*

 

I updated the code to fix the missing zero from even amounts (i.e. 1.0 becomes 1.00) but also from non zero amounts (i.e. 1.8 becomes 1.80).

 

The code also has been fixed so that only single decimal places get a zero - in otherwords 1.00 will not become 1.000

 

Post above was edited with updated / tested code.

DataintelligenceDataintelligence

I have downloaded the latest source (version 27) from github, but it doesn't have ant build xml in the source. How do I use ant to build it?

colemabcolemab

Data,

 

If you are wanting just the fix for the zeros, please see my blog post (part 2 of 2) here as it contains a link to my jar that has this fix built in.

 

As you can see in the post, I now recommend the use of the jitter bit data loader (which has a free version) over the salesforce data loader.

 

If you read parts 1 and 2 of the blog post above (part 2 links to part 1) it should answer any questions about the process.

 

That being said, Use C:\apexdataloader\build\ant.bat to build your jar file in C:\apexdataloader\JAR\

 

Thanks

tggagnetggagne
Where are the updated instructiosn for getting it to work inside Eclipse with Maven?  I don't frequently use Java but am competent enough to play with it and hopefully debug why upserts from the database take so long (I have suspicions).  But before getting to far I need to get the source into a tool where I can make some changes and do some debugging--and hopefully a patch so it might go faster.