Write and get result for SOQL query using JAVA - java

how do I write a java program to query an object/table in salesforce and get results in csv?
I haven't found any clear instructions for the same on the internet.

Salesforce has some default APIs that allow external systems interacting with a Salesforce org. Two examples of them are the SOAP API and the REST Api. Both APIs expose methods to interact with the Salesforce Org, allowing operations like creating, updating, deleting records and also querying.
You can use the SOAP Api (more precisely, the query method https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_query.htm) to query the Salesforce database.
You can check this example from the SF documentation that walks you through a JAVA implementation: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_quickstart_steps_walk_through_code.htm. Also, the rest of the documentation from that Salesforce site is full of Java examples that can help you.

Related

Trying to use Apache Gobblin to read Salesforce data using SOAP API(s) instead of REST API

I am working on an existing tool (heavily based on Apache Gobblin) to import data from customers' Salesforce tables into local MySQL databases (one database per customer).
The tool works (as is) for customers who have enabled the Salesforce REST APIs, but one customer does not (and will not) have it enabled, only allowing access to Salesforce via the Salesforce SOAP APIs.
Is it possible to indicate to Gobblin that the data needs to be imported (extracted) from Salesforce using the Salesforce SOAP Apis? (The existing SalesforceExtractor class extends RestApiExtractor; there's no existing SoapApiExtractor to inherit from.
Has anyone added classes to Gobblin to allow it to extract from Salesforce over SOAP, to work this way?
The existing Gobblin documentation indicates that it can work that way, but I don't see the source code that does it.
I basically wrote about 250 lines of calling SOAP object getters feeding their results to REST object setters. Very similar names (for the most part) and rather ugly code, but it works.

How do i directly replicate data into salesforce account without using postman application

I am importing some information (includes accounts and contacts)
Anyone have advice on the best methodology for doing the import?
Any experience with this import in specific or importing data into Salesforce in general would be appriciated.
First, you should decide is it one time migration of data, or it's iterative process which is an integral part of your solution.
In first case you can use any ETL tools that supports Salesforce integration. There are a lot of them - Talend, Pentaho Kettle, Jitterbit and many others. You can find more information about on Awesome Salesforce page.
In second case you need to implement integration API. Salesforce provides few approaches for API:
REST API - Access objects in your organization using REST
SOAP API - Integrate your organization’s data with other applications using SOAP
Bulk API - Load or delete large numbers of records
Streaming API - Provide a stream of data reflecting data changes
in your organization.

How to get all User (Object) related fields from Active Directory - both on premised and cloud based (Azure)

I wanted to know how to get all User (Object) related fields from Active Directory - both on premise and cloud based (Azure).
Is it possible to attach dynamic fields/columns with various objects in AD , particularly User object? If yes, can we get the list of all fields that are applicable for a particular object type?
Just like SQL, can we do something like "select * from users", so that we can get all the fields as well as their values?
I am OK with any implementation - python, ruby, java
Per my experience, you can implement your needs via two steps as below.
Integrating your on-premises identity system with Azure AD, please see the article to know how to do.
Performing CRUD operations using Azure AD Graph API (not like SQL), that you can try to use any languages via programming in SDKs or Graph API REST.
There is a sample for calling the Azure AD Graph API in a Java web application which you can refer to.

Generating APIs for an existing GAE application using Cloud Endpoints that has no need for supporting CRUD operations?

I have an existing app engine application written in JAVA (developed using GWT+GAE framework in Eclipse IDE) with methods that take input from client (browser) in the form of a String or numeric values, perform some server-side computations and return results in numeric, ArrayList formats back to the client. There is no need to create datastore entities etc.
So, if I wanted to expose these server-side functionalities via APIs to be consumed by mobile clients, can it be done easily using Google Cloud Endpoints support? Most Google Cloud Endpoint examples/tutorials that I found online seem to suggest that a persistence-capable entity class is a requirement. Is there a simple way to avoid this if we don't need to create and persist entities and support any CRUD operations in the application? Any pointers to examples will be very helpful.
Thanks.
Given that your methods are already compatible to endpoints requirements, all you need to do is:
Put #Api on the class(es) where you choose to put your your API methods. e.g.
#Api(name = "api_name",version = "v1")
If your methods have similar mandatory parameters, then put #ApiMethod with path to distinguish between APIs. e.g.
#ApiMethod(name="doSomething", path="doSomething/{id}")
Put method parameters on the API Methods. e.g.
#Named("mandatoryParam") double mandatoryParam,
#Nullable #Named("optionalParam") String optionalParam
You are ready with your basic Endpoints API. You can generate the android client code and start using it.
I believe there are no such restrictions. All you have to do is create a class and add some methods and annotations that describe the API. Incoming requests are translated to method calls and you can do anything you want in the method body.
The hello world example should be enough to get you started: https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/hello_world

Wish to create desktop app that combines facebook and email accounts all in one go - stuck at the first hurdle?

first poster :)
As the title says, I am looking to create a desktop app which will notify me of changes on facebook and new emails, and the facebook part (the first part I've tried) is baffling me. I've never worked with an api before, and have no idea how to integrate facebook's api with this desktop helper I want to create. I will be using java to create this desktop helper.
Thanks in advance!
Here are few pointers for you to get started. Please feel free to ask for clarifications and I will edit my answer accordingly:
For facebook, you can actually pull all those info via their API. There are a lot of types for API, but Facebook specifically use REST API over http.
To simplify, think of it as making an http call with specific parameters and you will be getting an output back.
In order to use facebook API you need to understand their protocol including authentication/login and how to request for things that you want. This would require some reading to their documentation which is pretty complete and available at http://developers.facebook.com/docs/.
For the description of their API URL and the input/output documentation, you could directly jump to Graph API Documentation http://developers.facebook.com/docs/reference/api/.
In order to call their API via HTTP from Java, you could leverage HttpClient library from Apache Http Components project http://hc.apache.org/. They have plenty of tutorial and examples for how to make http call using HttpClient
For combining with all other emails accounts (per your question), you need to deal with SMTP or IMAP (whichever email protocol that you are planning to combine with Facebook). This is already built-in to Java via their Java Mail API collection
You then can poll this data on interval basis to get an update from Facebook and your mails
Once you have figured out how to get the data, the rest is just following a good MVC framework. That means separating out your presentation, data and controller (application logic). Make sure that you are separating the classes for #1 and #2 and each of them put their data to normalized data format that then get feed to your View (presentation layer)

Categories