This plugin generates DTOs for the Camel Salesforce Component.
The plugin configuration has the following properties.
SObject.FieldName.PicklistValue
. Property value is the desired enum value. E.g.:<enumerationOverrideProperties> <property> <name>Student__c.FinalGrade__c.A-</name> <value>AMinus</value> </property> </enumerationOverrideProperties>
Additonal properties to provide proxy information, if behind a firewall.
Sample pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <properties> <camelSalesforce.clientId>5MVG9uudbyLbNPZOFutIHJpIb2nchnCiNE_NqeYcewMCPPT8_6VV_LQF_CJ813456GxzhxZdxlGwbYI_yzHmz</camelSalesforce.clientId> <camelSalesforce.clientSecret>5630289243049151316</camelSalesforce.clientSecret> <camelSalesforce.userName>foo@bar.com</camelSalesforce.userName> <camelSalesforce.password>foopasswordCbe5V27JxD0JXYFGJIdIEWB7p</camelSalesforce.password> <camelSalesforce.loginUrl>https://myDomain.my.salesforce.com</camelSalesforce.loginUrl> <camelSalesforce.httpProxyHost>foo.bar.com</camelSalesforce.httpProxyHost> <camelSalesforce.httpProxyPort>8090</camelSalesforce.httpProxyPort> </properties> ... <build> ... <plugins> ... <!-- camel maven saleforce for creating salesforce objects --> <plugin> <groupId>org.apache.camel.maven</groupId> <artifactId>camel-salesforce-maven-plugin</artifactId> <version>2.17.1</version> <configuration> <clientId>${camelSalesforce.clientId}</clientId> <clientSecret>${camelSalesforce.clientSecret}</clientSecret> <userName>${camelSalesforce.userName}</userName> <password>${camelSalesforce.password}</password> <loginUrl default-value="https://login.salesforce.com">${camelSalesforce.loginUrl}</loginUrl> <includes> <include>Account</include> <include>Contacts</include> </includes> <httpProxyHost>${camelSalesforce.httpProxyHost}</httpProxyHost> <httpProxyPort>${camelSalesforce.httpProxyPort}</httpProxyPort> </configuration> </plugin> </plugins> </build> </project>
For obvious security reasons it is recommended that the clientId, clientSecret, userName and password fields be not set in the pom.xml. The plugin should be configured for the rest of the properties, and can be executed using the following command:
mvn camel-salesforce:generate -DcamelSalesforce.clientId=<clientid> -DcamelSalesforce.clientSecret=<clientsecret> -DcamelSalesforce.userName=<username> -DcamelSalesforce.password=<password>
The generated DTOs use Jackson. All Salesforce field types are supported. Date and time fields are mapped to java.time.ZonedDateTime, and picklist fields are mapped to generated Java Enumerations.
Relationship fields, e.g. Contact.Account
, will be strongly typed if the referenced SObject type is listed in includes
. Otherwise, the type of the reference object will be AbstractDescribedSObjectBase
. Some useful but non-obvious SObjects to include are RecordType
, User
, Group
, and Name
.
Polymorphic relationship fields will have the type AbstractDescribedSObjectBase
, however at runtime, query results will be serialized to the specific type if that type was in includes
and a DTO was generated for it. Note that the query must be written to return type-specific fields, e.g.:
SELECT Id, Name, Typeof Owner WHEN User Then FirstName, LastName, Username End FROM Line_Item__c
You can customize types, i.e. use java.time.LocalDateTime instead of the default java.time.ZonedDateTime by specifying the customTypes
property like:
<plugin> <groupId>org.apache.camel</groupId> <artifactId>camel-salesforce-maven-plugin</artifactId> <configuration> <!-- ... --> <customTypes> <date>java.time.LocalDateTime</date> </customTypes> </configuration> </plugin>