├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── springml │ └── salesforce │ └── wave │ ├── api │ ├── APIFactory.java │ ├── BulkAPI.java │ ├── ChatterAPI.java │ ├── ForceAPI.java │ └── WaveAPI.java │ ├── impl │ ├── AbstractAPIImpl.java │ ├── BulkAPIImpl.java │ ├── ChatterAPIImpl.java │ ├── ForceAPIImpl.java │ └── WaveAPIImpl.java │ ├── model │ ├── AddTaskRequest.java │ ├── AddTaskResponse.java │ ├── BatchInfo.java │ ├── BatchInfoList.java │ ├── BatchResultList.java │ ├── DescribeSObjectResult.java │ ├── Field.java │ ├── ForceResponse.java │ ├── InsertObjectsResponse.java │ ├── InsertResult.java │ ├── JobInfo.java │ ├── PostMessageRequest.java │ ├── QueryResult.java │ ├── Results.java │ ├── SOQLResult.java │ ├── chatter │ │ ├── Actor.java │ │ ├── AssociatedActions.java │ │ ├── Body.java │ │ ├── Bookmarks.java │ │ ├── Capabilities.java │ │ ├── ChatterLikes.java │ │ ├── ClientInfo.java │ │ ├── Comments.java │ │ ├── Header.java │ │ ├── MessageBody.java │ │ ├── MessageElement.java │ │ ├── MessageSegment.java │ │ ├── Motif.java │ │ ├── Mute.java │ │ ├── Page.java │ │ ├── Parent.java │ │ ├── Photo.java │ │ ├── PostMessageResponse.java │ │ ├── Reference.java │ │ └── Topics.java │ └── dataset │ │ ├── CreatedBy.java │ │ ├── CurrentVersionCreatedBy.java │ │ ├── CurrentVersionLastModifiedBy.java │ │ ├── Dataset.java │ │ ├── DatasetsResponse.java │ │ ├── Folder.java │ │ ├── LastModifiedBy.java │ │ └── Permissions.java │ └── util │ ├── HTTPHelper.java │ ├── LRUCache.java │ ├── SFConfig.java │ └── WaveAPIConstants.java └── test ├── java └── com │ └── springml │ └── salesforce │ └── wave │ ├── api │ ├── APIFactoryTest.java │ ├── BaseAPITest.java │ ├── BulkAPITest.java │ ├── ChatterAPITest.java │ ├── ForceAPITest.java │ └── WaveAPITest.java │ └── util │ └── HTTPHelperTest.java └── resources ├── dataset_response.json └── post_message.json /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings/ 4 | target/ 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License, Version 2.0 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 13 | 14 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 15 | 16 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 17 | 18 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 19 | 20 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 21 | 22 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 23 | 24 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 25 | 26 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 27 | 28 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 29 | 30 | 2. Grant of Copyright License. 31 | 32 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 33 | 34 | 3. Grant of Patent License. 35 | 36 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 37 | 38 | 4. Redistribution. 39 | 40 | You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 41 | 42 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 43 | You must cause any modified files to carry prominent notices stating that You changed the files; and 44 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 45 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 46 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 47 | 48 | 5. Submission of Contributions. 49 | 50 | Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 51 | 52 | 6. Trademarks. 53 | 54 | This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 55 | 56 | 7. Disclaimer of Warranty. 57 | 58 | Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 59 | 60 | 8. Limitation of Liability. 61 | 62 | In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 63 | 64 | 9. Accepting Warranty or Additional Liability. 65 | 66 | While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 67 | 68 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Salesforce Wave Client Library 2 | 3 | A Java client library for [Salesforce Wave REST API] (https://resources.docs.salesforce.com/sfdc/pdf/bi_dev_guide_rest.pdf). 4 | 5 | ## Features 6 | This library can be used as a Java Client of Salesforce Wave API. 7 | * It supports querying a dataset using [SAQL] (https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_eql.meta/bi_dev_guide_eql/) and return the result as POJO. 8 | * It supports querying saleforce using [SOQL] (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/) and return the result as POJO. 9 | * It supports updating saleforce object using [REST Bulk API] (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/) 10 | 11 | 12 | ## Usage 13 | This library requires Salesforce username, Salesforce password and Salesforce loginURL. 14 | * Account provided in Salesforce username should have WAVE API privilege 15 | * Salesforce password should be appended with security token. For example, if a user’s password is mypassword, and the security token is XXXXXXXXXX, the user must provide mypasswordXXXXXXXXXX 16 | * loginURL can be http://login.salesforce.com or http://test.salesforce.com 17 | 18 | ### Querying a dataset 19 | This library can be used 20 | * To query a dataset using [SAQL] (https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_eql.meta/bi_dev_guide_eql/). Refer [WaveAPITest.java] (https://github.com/springml/salesforce-wave-api/blob/master/src/test/java/com/springml/salesforce/wave/api/WaveAPITest.java) for querying a dataset from Salesforce Wave 21 | * To query Salesforce object using [SOQL] (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/). Refer [ForceAPITest.java] (https://github.com/springml/salesforce-wave-api/blob/master/src/test/java/com/springml/salesforce/wave/api/ForceAPITest.java) for querying Salesforce object 22 | * To update Salesforce object using [REST Bulk API] (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/). Refer [BulkAPITest.java] (https://github.com/springml/salesforce-wave-api/blob/master/src/test/java/com/springml/salesforce/wave/api/BulkAPITest.java) for updating Salesforce object 23 | 24 | ### Maven Dependency 25 | ``` 26 | 27 | com.springml 28 | salesforce-wave-api 29 | 1.0.5 30 | 31 | ``` 32 | 33 | ### Example Usage to query datasets using SAQL 34 | ```java 35 | import com.springml.salesforce.wave.api.APIFactory 36 | import com.springml.salesforce.wave.api.WaveAPI; 37 | import com.springml.salesforce.wave.model.QueryResult; 38 | import com.springml.salesforce.wave.model.Results; 39 | 40 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("salesforce_username", 41 | "salesforce_password_appended_with_security_token", 42 | "https://login.salesforce.com"); 43 | String saql = "q = load \"dataset_id/dataset_version_id\"; q = group q by ('field1', 'field2'); q = foreach q generate 'field1' as 'field1', 'field2' as 'field2', count() as 'count'; q = limit q 2000;"; 44 | QueryResult result = waveAPI.query(saql); 45 | List> records = result.getRecords(); 46 | 47 | ``` 48 | 49 | ### Example Usage to query Salesforce objects using SOQL 50 | ```java 51 | import com.springml.salesforce.wave.api.APIFactory 52 | import com.springml.salesforce.wave.api.ForceAPI; 53 | import com.springml.salesforce.wave.model.SOQLResult; 54 | 55 | ForceAPI forceAPI = APIFactory.getInstance().forceAPI("salesforce_username", 56 | "salesforce_password_appended_with_security_token", 57 | "https://login.salesforce.com"); 58 | String soql = "SELECT AccountId, Id FROM Opportunity"; 59 | SOQLResult result = forceAPI.query(soql); 60 | List> records = result.getRecords(); 61 | // By default Salesforce will return 2000 records in a single call 62 | // To query more use queryMore() 63 | while (!result.isDone()) { 64 | result = forceAPI.queryMore(); 65 | records.addAll(result.getRecords()); 66 | } 67 | 68 | ``` 69 | 70 | 71 | ### Example Usage to update Salesforce objects using Bulk API 72 | ```java 73 | import com.springml.salesforce.wave.api.APIFactory 74 | import com.springml.salesforce.wave.api.BulkAPI; 75 | import com.springml.salesforce.wave.model.JobInfo; 76 | import com.springml.salesforce.wave.model.BatchInfo; 77 | 78 | BulkAPI bulkAPI = APIFactory.getInstance().bulkAPI("salesforce_username", 79 | "salesforce_password_appended_with_security_token", 80 | "https://login.salesforce.com", "36.0"); 81 | // Here we are updating Contact 82 | JobInfo jobInfo = bulkAPI.createJob("Contact"); 83 | String jobId = jobInfo.getId(); 84 | // CSV Content contains the details to updated 85 | // First column contains the Saleforce Object ID 86 | // And further columns should contain the fields to be updated 87 | // Here Description is updated for two Contacts 88 | String csvContent = "Id,Description\n003B00000067Rnx,SuperMan\n003B00000067Rnw,SpiderMan"; 89 | // Adding batch to the created Job 90 | // Please note that, csvContent should not exceed 10MB 91 | // Add multiple batches if the content to be updated is more than 10 MB 92 | BatchInfo batch = bulkAPI.addBatch(jobId, csvContent); 93 | // Close the Job after adding all the batches 94 | JobInfo closeJob = bulkAPI.closeJob(jobId); 95 | // bulkAPI.isCompleted(jobId) can be used to check whether the job has been completed 96 | while (!bulkAPI.isCompleted(jobId)) { 97 | // Waiting till the Job has been completed 98 | Thread.sleep(500); 99 | } 100 | 101 | ``` -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.springml 6 | salesforce-wave-api 7 | 1.0.8 8 | jar 9 | 10 | salesforce-wave-api 11 | Java client for Salesforce Wave API 12 | 13 | 14 | samuel-pt 15 | Samuel Alexander 16 | 17 | 18 | 19 | https://github.com/springml/salesforce-wave-api 20 | 21 | 22 | Apache License, Version 2.0 23 | http://www.apache.org/licenses/LICENSE-2.0.txt 24 | repo 25 | 26 | 27 | 28 | 29 | scm:git:github.com/springml/salesforce-wave-api 30 | scm:git:git@github.com:springml/salesforce-wave-api 31 | github.com/springml/salesforce-wave-api 32 | 33 | 34 | 35 | 36 | ossrh 37 | https://oss.sonatype.org/content/repositories/snapshots 38 | 39 | 40 | ossrh 41 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 42 | 43 | 44 | 45 | 46 | UTF-8 47 | 1.8 48 | 49 | 50 | 51 | 52 | com.force.api 53 | force-partner-api 54 | 34.0.0 55 | 56 | 57 | com.force.api 58 | force-wsc 59 | 34.2.2 60 | 61 | 62 | org.apache.httpcomponents 63 | httpclient 64 | 4.5 65 | 66 | 67 | com.fasterxml.jackson.core 68 | jackson-core 69 | 2.4.4 70 | 71 | 72 | com.fasterxml.jackson.core 73 | jackson-databind 74 | 2.4.4 75 | 76 | 77 | commons-io 78 | commons-io 79 | 2.5 80 | 81 | 82 | log4j 83 | log4j 84 | 1.2.17 85 | 86 | 87 | com.fasterxml.jackson.dataformat 88 | jackson-dataformat-xml 89 | 2.4.4 90 | 91 | 92 | org.codehaus.woodstox 93 | woodstox-core-asl 94 | 4.4.0 95 | 96 | 97 | org.apache.commons 98 | commons-lang3 99 | 3.4 100 | 101 | 102 | 103 | junit 104 | junit 105 | 4.12 106 | test 107 | 108 | 109 | org.mockito 110 | mockito-core 111 | 2.0.31-beta 112 | test 113 | 114 | 115 | org.mockito 116 | mockito-core 117 | 2.0.31-beta 118 | test 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | org.apache.maven.plugins 128 | maven-release-plugin 129 | 2.5 130 | 131 | false 132 | release 133 | deploy 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | org.sonatype.plugins 142 | nexus-staging-maven-plugin 143 | 1.6.3 144 | true 145 | 146 | ossrh 147 | https://oss.sonatype.org/ 148 | true 149 | 150 | 151 | 152 | 153 | org.apache.maven.plugins 154 | maven-source-plugin 155 | 2.2.1 156 | 157 | 158 | attach-sources 159 | 160 | jar-no-fork 161 | 162 | 163 | 164 | 165 | 166 | org.apache.maven.plugins 167 | maven-javadoc-plugin 168 | 2.9.1 169 | 170 | 171 | attach-javadocs 172 | 173 | jar 174 | 175 | 176 | -Xdoclint:none 177 | 178 | 179 | 180 | 181 | 182 | org.apache.maven.plugins 183 | maven-gpg-plugin 184 | 1.5 185 | 186 | 187 | sign-artifacts 188 | verify 189 | 190 | sign 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/api/APIFactory.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import com.springml.salesforce.wave.impl.BulkAPIImpl; 4 | import com.springml.salesforce.wave.impl.ChatterAPIImpl; 5 | import com.springml.salesforce.wave.impl.ForceAPIImpl; 6 | import com.springml.salesforce.wave.impl.WaveAPIImpl; 7 | import com.springml.salesforce.wave.util.SFConfig; 8 | import com.springml.salesforce.wave.util.WaveAPIConstants; 9 | 10 | /** 11 | * Factory class to get WaveAPI 12 | */ 13 | public class APIFactory { 14 | private static APIFactory instance = null; 15 | 16 | private APIFactory() {} 17 | 18 | public static APIFactory getInstance() { 19 | if (instance == null) { 20 | instance = new APIFactory(); 21 | } 22 | 23 | return instance; 24 | } 25 | 26 | public WaveAPI waveAPI(String username, String password, String loginURL) throws Exception { 27 | return this.waveAPI(username, password, loginURL, WaveAPIConstants.API_VERSION); 28 | } 29 | 30 | public WaveAPI waveAPI(String username, String password, String loginURL, String apiVersion) throws Exception { 31 | return new WaveAPIImpl(new SFConfig(username, password, loginURL, apiVersion)); 32 | } 33 | 34 | public ForceAPI forceAPI(String username, String password, String loginURL) throws Exception { 35 | return this.forceAPI(username, password, loginURL, WaveAPIConstants.API_VERSION); 36 | } 37 | 38 | public ForceAPI forceAPI(String username, String password, String loginURL, String apiVersion) throws Exception { 39 | return new ForceAPIImpl(new SFConfig(username, password, loginURL, apiVersion)); 40 | } 41 | 42 | public ForceAPI forceAPI(String username, String password, String loginURL, 43 | String apiVersion, Integer batchSize) throws Exception { 44 | return new ForceAPIImpl(new SFConfig(username, password, loginURL, apiVersion, batchSize)); 45 | } 46 | 47 | public ForceAPI forceAPI(String username, String password, String loginURL, 48 | String apiVersion, Integer batchSize, Integer maxRetry) throws Exception { 49 | SFConfig sfConfig = new SFConfig(username, password, loginURL, apiVersion, batchSize); 50 | sfConfig.setMaxRetry(maxRetry); 51 | return new ForceAPIImpl(sfConfig); 52 | } 53 | 54 | public BulkAPI bulkAPI(String username, String password, String loginURL, String apiVersion) throws Exception { 55 | SFConfig sfConfig = new SFConfig(username, password, loginURL, apiVersion); 56 | return new BulkAPIImpl(sfConfig); 57 | } 58 | 59 | public ChatterAPI chatterAPI(String username, String password, String loginURL, String apiVersion) throws Exception { 60 | SFConfig sfConfig = new SFConfig(username, password, loginURL, apiVersion); 61 | return new ChatterAPIImpl(sfConfig); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/api/BulkAPI.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import com.springml.salesforce.wave.model.BatchInfo; 4 | import com.springml.salesforce.wave.model.BatchInfoList; 5 | import com.springml.salesforce.wave.model.JobInfo; 6 | import org.apache.http.Header; 7 | import java.util.List; 8 | 9 | /** 10 | * Java client for Salesforce Bulk API 11 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_intro.htm 12 | */ 13 | public interface BulkAPI { 14 | /** 15 | * Create a new Bulk Job 16 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_create_job.htm 17 | * @param The Salesforce object to be updated 18 | * @return @JobInfo 19 | * @throws Exception 20 | */ 21 | public JobInfo createJob(String object) throws Exception; 22 | 23 | /** 24 | * Create a new Bulk Job 25 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_create_job.htm 26 | * @param The Salesforce object to be updated 27 | * @return @JobInfo 28 | * @throws Exception 29 | */ 30 | public JobInfo createJob(String object, String operation, String contentType) throws Exception; 31 | 32 | /** 33 | * Create a new Bulk Job 34 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_create_job.htm 35 | * @param jobInfo with details of the Job to be created 36 | * @return {@link JobInfo} 37 | * @throws Exception 38 | */ 39 | public JobInfo createJob(JobInfo jobInfo) throws Exception; 40 | 41 | /** 42 | * Create a new Bulk Job 43 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_create_job.htm 44 | * @param jobInfo with details of the Job to be created 45 | * @param customHeaders Custom headers for job. These headers will be appended to default headers. 46 | * @return {@link JobInfo} 47 | * @throws Exception 48 | */ 49 | public JobInfo createJob(JobInfo jobInfo, List
customHeaders) throws Exception; 50 | 51 | /** 52 | * Add a batch to an existing Job 53 | * https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_quickstart_add_batch.htm 54 | * @param jobId Salesforce Job Id 55 | * @param csvContent CSV Content which will be used to update salesforce objects 56 | * @return {@link BatchInfo} 57 | * @throws Exception 58 | */ 59 | public BatchInfo addBatch(String jobId, String csvContent) throws Exception; 60 | 61 | /** 62 | * Close the specified Salesforce Bulk Job 63 | * @param jobId Job to be closed 64 | * @return 65 | * @throws Exception 66 | */ 67 | public JobInfo closeJob(String jobId) throws Exception; 68 | 69 | /** 70 | * Queries Salesforce to get the BatchInfo of the specified Job 71 | * Check whether all the Jobs are completed 72 | * @param jobId Job to be checked for its status 73 | * @return true - if all batches are completed else false 74 | * @throws Exception 75 | */ 76 | public boolean isCompleted(String jobId) throws Exception; 77 | 78 | /** 79 | * Queries Salesforce to get the BatchInfo of the specified Job 80 | * Check whether all the Jobs are completed 81 | * @param jobId Job to be checked for its status 82 | * @return true - if all batches are completed else false 83 | * @throws Exception 84 | */ 85 | public boolean isSuccess(String jobId) throws Exception; 86 | 87 | /** 88 | * List of the Batches for the specified Job 89 | * @param jobId 90 | * @return 91 | * @throws Exception 92 | */ 93 | public BatchInfoList getBatchInfoList(String jobId) throws Exception; 94 | 95 | /** 96 | * Provides details of the specified Batch 97 | * @param jobId 98 | * @param batchId 99 | * @return 100 | * @throws Exception 101 | */ 102 | public BatchInfo getBatchInfo(String jobId, String batchId) throws Exception; 103 | 104 | /** 105 | * Retrieves a list of batch result IDs for a particular batch job. 106 | * @param jobId The identifier for the job 107 | * @param batchId The batch identifier for the job 108 | * @return 109 | * @throws Exception 110 | */ 111 | public List getBatchResultIds(String jobId, String batchId) throws Exception; 112 | 113 | /** 114 | * Gets bulk query results 115 | * @param jobId The identifier for the job 116 | * @param batchId The batch identifier for the job 117 | * @param resultId the result ID in the response to the batch result list request 118 | * @return 119 | * @throws Exception 120 | */ 121 | public String getBatchResult(String jobId, String batchId, String resultId) throws Exception; 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/api/ChatterAPI.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import com.springml.salesforce.wave.model.PostMessageRequest; 4 | import com.springml.salesforce.wave.model.chatter.PostMessageResponse; 5 | 6 | public interface ChatterAPI { 7 | public PostMessageResponse postMessage(PostMessageRequest request) throws Exception; 8 | 9 | public PostMessageResponse postMessage(String subjectId, String text, 10 | String feedElementType) throws Exception; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/api/ForceAPI.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import com.springml.salesforce.wave.model.AddTaskRequest; 4 | import com.springml.salesforce.wave.model.AddTaskResponse; 5 | import com.springml.salesforce.wave.model.DescribeSObjectResult; 6 | import com.springml.salesforce.wave.model.ForceResponse; 7 | import com.springml.salesforce.wave.model.QueryResult; 8 | import com.springml.salesforce.wave.model.SOQLResult; 9 | 10 | /** 11 | * JAVA client for Salesforce REST API calls 12 | */ 13 | public interface ForceAPI { 14 | /** 15 | * Execute the given SOQL by using "/query" API 16 | * @param soql - SOQL to be executed. 17 | * @return {@link QueryResult} 18 | * @throws Exception 19 | */ 20 | public SOQLResult query(String soql) throws Exception; 21 | 22 | /** 23 | * Execute the given SOQL by using either the "/query" API 24 | * or the "/queryAll" API 25 | * @param soql - SOQL to be executed. 26 | * @param all - Toggle for /query or /queryAll 27 | * @return {@link QueryResult} 28 | * @throws Exception 29 | */ 30 | public SOQLResult query(String soql, boolean all) throws Exception; 31 | 32 | /** 33 | * Query further records using nextRecordsURL 34 | * @param oldResult 35 | * @return 36 | * @throws Exception 37 | */ 38 | public SOQLResult queryMore(SOQLResult oldResult) throws Exception; 39 | 40 | /** 41 | * Creates task with given details in salesforce 42 | * @return 43 | */ 44 | public AddTaskResponse addTask(AddTaskRequest addTask) throws Exception; 45 | 46 | /** 47 | * Insert a salesforce object 48 | * @param object - Name of the salesforce object 49 | * @param content - Json content of the object to be saved 50 | */ 51 | public ForceResponse insertObject(String object, String content) throws Exception; 52 | 53 | /** 54 | * Insert a salesforce object 55 | * @param object - Name of the salesforce object 56 | * @param content - Json content of the object to be saved 57 | */ 58 | // public InsertObjectsResponse insertObjects(String object, List objects) throws Exception; 59 | 60 | public String getSFEndpoint() throws Exception; 61 | 62 | /** 63 | * Returns list of the salesforce object column names 64 | * @param object Name of the salesforce object 65 | * @return 66 | * @throws Exception 67 | */ 68 | public DescribeSObjectResult describeSalesforceObject(String object) throws Exception; 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/api/WaveAPI.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import com.springml.salesforce.wave.model.QueryResult; 4 | 5 | /** 6 | * Java interface for WAVE REST calls 7 | */ 8 | public interface WaveAPI { 9 | /** 10 | * Execute the given SAQL by using "/wave/query" API 11 | * @param saql - SAQL to be executed. This will be converted into JSON 12 | * @return {@link QueryResult} 13 | * @throws Exception 14 | */ 15 | public QueryResult query(String saql) throws Exception; 16 | 17 | /** 18 | * Executes Paginated query and return the result 19 | * To get further results call WaveAPI.queryMore(QueryResult queryResult) 20 | * @param saql 21 | * @param resultVar 22 | * @param pageSize 23 | * @return 24 | * @throws Exception 25 | */ 26 | public QueryResult queryWithPagination(String saql, String resultVar, int pageSize) throws Exception; 27 | 28 | /** 29 | * Execute query and return the next set of results 30 | * @param queryResult 31 | * @return 32 | * @throws Exception 33 | */ 34 | public QueryResult queryMore(QueryResult queryResult) throws Exception; 35 | 36 | /** 37 | * Returns DatasetId appended with VersionId separated by / 38 | * @param datasetName Name of the dataset for which datasetId and versionId to be fetched 39 | * @return datasetId appended with versionId separated by / 40 | * @throws Exception 41 | */ 42 | public String getDatasetId(String datasetName) throws Exception; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/impl/AbstractAPIImpl.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.impl; 2 | 3 | import com.fasterxml.jackson.databind.DeserializationFeature; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; 6 | import com.springml.salesforce.wave.util.HTTPHelper; 7 | import com.springml.salesforce.wave.util.SFConfig; 8 | 9 | /** 10 | * Abstract class to have common methods 11 | */ 12 | public abstract class AbstractAPIImpl { 13 | private ObjectMapper objectMapper; 14 | private XmlMapper xmlMapper; 15 | private HTTPHelper httpHelper; 16 | private SFConfig sfConfig; 17 | 18 | public AbstractAPIImpl(SFConfig sfConfig) throws Exception { 19 | setHttpHelper(new HTTPHelper()); 20 | 21 | ObjectMapper objectMapper = new ObjectMapper(); 22 | objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 23 | objectMapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE); 24 | setObjectMapper(objectMapper); 25 | 26 | this.xmlMapper = new XmlMapper(); 27 | this.sfConfig = sfConfig; 28 | } 29 | 30 | public ObjectMapper getObjectMapper() { 31 | return objectMapper; 32 | } 33 | 34 | public void setObjectMapper(ObjectMapper objectMapper) { 35 | this.objectMapper = objectMapper; 36 | } 37 | 38 | public HTTPHelper getHttpHelper() { 39 | return httpHelper; 40 | } 41 | 42 | public void setHttpHelper(HTTPHelper httpHelper) { 43 | this.httpHelper = httpHelper; 44 | } 45 | 46 | public SFConfig getSfConfig() { 47 | return sfConfig; 48 | } 49 | 50 | public void setSfConfig(SFConfig sfConfig) { 51 | this.sfConfig = sfConfig; 52 | } 53 | 54 | public XmlMapper getXmlMapper() { 55 | return xmlMapper; 56 | } 57 | 58 | public void setXmlMapper(XmlMapper xmlMapper) { 59 | this.xmlMapper = xmlMapper; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/impl/BulkAPIImpl.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.impl; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.net.URI; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Arrays; 10 | 11 | import com.springml.salesforce.wave.model.BatchResultList; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.apache.http.Header; 14 | import org.apache.log4j.Logger; 15 | 16 | import com.sforce.soap.partner.PartnerConnection; 17 | import com.springml.salesforce.wave.api.BulkAPI; 18 | import com.springml.salesforce.wave.model.BatchInfo; 19 | import com.springml.salesforce.wave.model.BatchInfoList; 20 | import com.springml.salesforce.wave.model.JobInfo; 21 | import com.springml.salesforce.wave.util.LRUCache; 22 | import com.springml.salesforce.wave.util.SFConfig; 23 | 24 | public class BulkAPIImpl extends AbstractAPIImpl implements BulkAPI { 25 | private static final Logger LOG = Logger.getLogger(BulkAPIImpl.class); 26 | private Map jobContentTypeMap = new LRUCache(100); 27 | 28 | public BulkAPIImpl(SFConfig sfConfig) throws Exception { 29 | super(sfConfig); 30 | } 31 | 32 | public JobInfo createJob(String object) throws Exception { 33 | JobInfo jobInfo = new JobInfo(STR_CSV, object, STR_UPDATE); 34 | 35 | return createJob(jobInfo); 36 | } 37 | 38 | public JobInfo createJob(String object, String operation, String contentType) throws Exception { 39 | JobInfo jobInfo = new JobInfo(contentType, object, operation); 40 | 41 | return createJob(jobInfo); 42 | } 43 | 44 | public JobInfo createJob(JobInfo jobInfo) throws Exception { 45 | return createJob(jobInfo, new ArrayList
()); 46 | } 47 | 48 | public JobInfo createJob(JobInfo jobInfo, List
customHeaders) throws Exception { 49 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 50 | URI requestURI = getSfConfig().getRequestURI(connection, getJobPath()); 51 | 52 | String response = getHttpHelper().post(requestURI, getSfConfig().getSessionId(), 53 | getObjectMapper().writeValueAsString(jobInfo), true, customHeaders); 54 | LOG.debug("Response from Salesforce Server " + response); 55 | 56 | JobInfo respJobInfo = getObjectMapper().readValue(response.getBytes(), JobInfo.class); 57 | jobContentTypeMap.put(respJobInfo.getId(), getRespectiveCntType(jobInfo)); 58 | 59 | return respJobInfo; 60 | } 61 | 62 | public BatchInfo addBatch(String jobId, String csvContent) throws Exception { 63 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 64 | URI requestURI = getSfConfig().getRequestURI(connection, getBatchPath(jobId)); 65 | 66 | String contentType = getContentType(jobId); 67 | String response = getHttpHelper().post(requestURI, getSfConfig().getSessionId(), 68 | csvContent, contentType, true); 69 | LOG.debug("Response from Salesforce Server " + response); 70 | 71 | // Response is in xml though Accept is set to application/json 72 | if (CONTENT_TYPE_APPLICATION_JSON.equals(contentType)) { 73 | return getObjectMapper().readValue(response.getBytes(), BatchInfo.class); 74 | } 75 | 76 | return getXmlMapper().readValue(response.getBytes(), BatchInfo.class); 77 | } 78 | 79 | public JobInfo closeJob(String jobId) throws Exception { 80 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 81 | URI requestURI = getSfConfig().getRequestURI(connection, getJobPath(jobId)); 82 | 83 | JobInfo jobInfo = new JobInfo(STR_CLOSED); 84 | String response = getHttpHelper().post(requestURI, getSfConfig().getSessionId(), 85 | getObjectMapper().writeValueAsString(jobInfo), true); 86 | LOG.debug("Response from Salesforce Server " + response); 87 | 88 | return getObjectMapper().readValue(response.getBytes(), JobInfo.class); 89 | } 90 | 91 | public boolean isCompleted(String jobId) throws Exception { 92 | BatchInfoList batchInfoList = getBatchInfoList(jobId); 93 | List batchInfos = batchInfoList.getBatchInfo(); 94 | 95 | LOG.debug("BatchInfos : " + batchInfos); 96 | if (batchInfos != null) { 97 | for (BatchInfo batchInfo : batchInfos) { 98 | LOG.debug("Batch state : " + batchInfo.getState()); 99 | // The following reference details all the different batch states: 100 | // https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_batches_interpret_status.htm 101 | if (STR_FAILED.equals(batchInfo.getState())) { 102 | throw new Exception("Batch '" + batchInfo.getId() + "' failed with error '" + batchInfo.getStateMessage() + "'"); 103 | } else if (STR_IN_PROGRESS.equals(batchInfo.getState()) || STR_QUEUED.equals(batchInfo.getState())) { 104 | return false; 105 | } 106 | 107 | LOG.info("Number of records failed : " + batchInfo.getNumberRecordsFailed()); 108 | if (batchInfo.getNumberRecordsFailed() > 0) { 109 | String result = getResult(jobId, batchInfo.getId()); 110 | LOG.error("Failed record details \n " + result); 111 | throw new Exception("Batch '" + batchInfo.getId() + 112 | "' failed. Number of failed records is " + batchInfo.getNumberRecordsFailed()); 113 | } 114 | } 115 | } 116 | 117 | return true; 118 | } 119 | 120 | private String getResult(String jobId, String batchId) throws Exception { 121 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 122 | URI requestURI = getSfConfig().getRequestURI(connection, getBatchResultPath(jobId, batchId)); 123 | return getHttpHelper().get(requestURI, getSfConfig().getSessionId(), true); 124 | } 125 | 126 | public BatchInfoList getBatchInfoList(String jobId) throws Exception { 127 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 128 | URI requestURI = getSfConfig().getRequestURI(connection, getBatchPath(jobId)); 129 | 130 | String response = getHttpHelper().get(requestURI, getSfConfig().getSessionId(), true); 131 | LOG.debug("Response from Salesforce Server " + response); 132 | 133 | if (CONTENT_TYPE_APPLICATION_JSON.equals(getContentType(jobId))) { 134 | return getObjectMapper().readValue(response.getBytes(), BatchInfoList.class); 135 | } 136 | 137 | return getXmlMapper().readValue(response.getBytes(), BatchInfoList.class); 138 | } 139 | 140 | public BatchInfo getBatchInfo(String jobId, String batchId) throws Exception { 141 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 142 | URI requestURI = getSfConfig().getRequestURI(connection, getBatchPath(jobId, batchId)); 143 | 144 | String response = getHttpHelper().get(requestURI, getSfConfig().getSessionId(), true); 145 | LOG.debug("Response from Salesforce Server " + response); 146 | 147 | return getXmlMapper().readValue(response.getBytes(), BatchInfo.class); 148 | } 149 | 150 | public List getBatchResultIds(String jobId, String batchId) throws Exception { 151 | String response = getResult(jobId, batchId); 152 | 153 | if (CONTENT_TYPE_APPLICATION_JSON.equals(getContentType(jobId))) { 154 | if (response != null && response.startsWith("[") && response.endsWith("]")) { 155 | return Arrays.asList(response.substring(1, response.length() - 1).split(",")); 156 | } else { 157 | throw new Exception("Unable to parse response: " + response); 158 | } 159 | } 160 | 161 | return getXmlMapper().readValue(response.getBytes(), BatchResultList.class).getBatchResultIds(); 162 | } 163 | 164 | public String getBatchResult(String jobId, String batchId, String resultId) throws Exception { 165 | PartnerConnection connection = getSfConfig().getPartnerConnection(); 166 | URI requestURI = getSfConfig().getRequestURI(connection, getBatchResultPath(jobId, batchId, resultId)); 167 | 168 | String response = getHttpHelper().get(requestURI, getSfConfig().getSessionId(), true); 169 | LOG.debug("Response from Salesforce Server " + response); 170 | 171 | return response; 172 | } 173 | 174 | public boolean isSuccess(String jobId) throws Exception { 175 | // TODO Auto-generated method stub 176 | return false; 177 | } 178 | 179 | private String getContentType(String jobId) { 180 | String contentType = jobContentTypeMap.get(jobId); 181 | if (StringUtils.isEmpty(contentType)){ 182 | contentType = CONTENT_TYPE_TEXT_CSV; 183 | } 184 | 185 | return contentType; 186 | } 187 | 188 | private String getRespectiveCntType(JobInfo jobInfo) { 189 | String contentType = null; 190 | if (STR_JSON.equals(jobInfo.getContentType())) { 191 | contentType = CONTENT_TYPE_APPLICATION_JSON; 192 | } else if (STR_XML.equals(jobInfo.getContentType())) { 193 | contentType = CONTENT_TYPE_APPLICATION_XML; 194 | } else { 195 | contentType = CONTENT_TYPE_TEXT_CSV; 196 | } 197 | 198 | return contentType; 199 | } 200 | 201 | private String getBatchPath(String jobId, String batchId) { 202 | StringBuilder batchPath = new StringBuilder(); 203 | batchPath.append(getBatchPath(jobId)); 204 | batchPath.append('/'); 205 | batchPath.append(batchId); 206 | return batchPath.toString(); 207 | } 208 | 209 | private String getBatchResultPath(String jobId, String batchId) { 210 | StringBuilder batchResultPath = new StringBuilder(); 211 | batchResultPath.append(getBatchPath(jobId, batchId)); 212 | batchResultPath.append(PATH_RESULT); 213 | 214 | return batchResultPath.toString(); 215 | } 216 | 217 | private String getBatchResultPath(String jobId, String batchId, String resultId) { 218 | StringBuilder batchResultPath = new StringBuilder(); 219 | batchResultPath.append(getBatchResultPath(jobId, batchId)); 220 | batchResultPath.append('/'); 221 | batchResultPath.append(resultId); 222 | 223 | return batchResultPath.toString(); 224 | } 225 | 226 | private String getBatchPath(String jobId) { 227 | StringBuilder batchPath = new StringBuilder(); 228 | batchPath.append(getJobPath(jobId)); 229 | batchPath.append(PATH_BATCH); 230 | 231 | return batchPath.toString(); 232 | } 233 | 234 | private String getJobPath(String jobId) { 235 | StringBuilder jobPath = new StringBuilder(); 236 | jobPath.append(getJobPath()); 237 | jobPath.append('/'); 238 | jobPath.append(jobId); 239 | return jobPath.toString(); 240 | } 241 | 242 | private String getJobPath() { 243 | StringBuilder jobPath = new StringBuilder(); 244 | jobPath.append(SERVICE_ASYNC_PATH); 245 | jobPath.append(getSfConfig().getApiVersion()); 246 | jobPath.append(PATH_JOB); 247 | return jobPath.toString(); 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/impl/ChatterAPIImpl.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.impl; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.net.URI; 6 | import java.util.Arrays; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | import com.springml.salesforce.wave.api.ChatterAPI; 11 | import com.springml.salesforce.wave.model.PostMessageRequest; 12 | import com.springml.salesforce.wave.model.chatter.MessageBody; 13 | import com.springml.salesforce.wave.model.chatter.MessageElement; 14 | import com.springml.salesforce.wave.model.chatter.PostMessageResponse; 15 | import com.springml.salesforce.wave.util.SFConfig; 16 | 17 | public class ChatterAPIImpl extends AbstractAPIImpl implements ChatterAPI { 18 | private static final Logger LOG = Logger.getLogger(ChatterAPIImpl.class); 19 | 20 | public ChatterAPIImpl(SFConfig sfConfig) throws Exception { 21 | super(sfConfig); 22 | } 23 | 24 | public PostMessageResponse postMessage(PostMessageRequest request) throws Exception { 25 | SFConfig sfConfig = getSfConfig(); 26 | String feddElementsPath = getFeedElementsPath(sfConfig); 27 | URI taskURI = sfConfig.getRequestURI( 28 | sfConfig.getPartnerConnection(), feddElementsPath); 29 | 30 | String requestStr = getObjectMapper().writeValueAsString(request); 31 | System.out.println("requestStr : " + requestStr); 32 | LOG.debug("Post Message Request " + requestStr); 33 | String responseStr = getHttpHelper().post(taskURI, getSfConfig().getSessionId(), requestStr); 34 | 35 | return getObjectMapper().readValue(responseStr.getBytes(), PostMessageResponse.class); 36 | } 37 | 38 | public PostMessageResponse postMessage(String subjectId, String text, String feedElementType) throws Exception { 39 | PostMessageRequest req = new PostMessageRequest(); 40 | req.setSubjectId(subjectId); 41 | req.setFeedElementType(feedElementType); 42 | 43 | MessageBody postMsgBody = new MessageBody(); 44 | MessageElement messageElement = new MessageElement(); 45 | messageElement.setText(text); 46 | messageElement.setType("Text"); 47 | postMsgBody.setMessageSegments(Arrays.asList(messageElement)); 48 | 49 | req.setBody(postMsgBody); 50 | 51 | return postMessage(req); 52 | } 53 | 54 | private String getFeedElementsPath(SFConfig sfConfig) { 55 | StringBuilder feedElementsPath = new StringBuilder(); 56 | feedElementsPath.append(getChatterPath(sfConfig)); 57 | feedElementsPath.append(PATH_FEED_ELEMENTS); 58 | 59 | return feedElementsPath.toString(); 60 | } 61 | 62 | private String getChatterPath(SFConfig sfConfig) { 63 | StringBuilder chatterPath = new StringBuilder(); 64 | chatterPath.append(SERVICE_PATH); 65 | chatterPath.append("v"); 66 | chatterPath.append(sfConfig.getApiVersion()); 67 | chatterPath.append(PATH_CHATTER); 68 | 69 | return chatterPath.toString(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/impl/ForceAPIImpl.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.impl; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.io.IOException; 6 | import java.net.URI; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | import com.springml.salesforce.wave.api.ForceAPI; 11 | import com.springml.salesforce.wave.model.AddTaskRequest; 12 | import com.springml.salesforce.wave.model.AddTaskResponse; 13 | import com.springml.salesforce.wave.model.DescribeSObjectResult; 14 | import com.springml.salesforce.wave.model.ForceResponse; 15 | import com.springml.salesforce.wave.model.SOQLResult; 16 | import com.springml.salesforce.wave.util.SFConfig; 17 | 18 | /** 19 | * Default implementation for Salesforce REST API calls 20 | */ 21 | public class ForceAPIImpl extends AbstractAPIImpl implements ForceAPI { 22 | private static final Logger LOG = Logger.getLogger(ForceAPIImpl.class); 23 | 24 | public ForceAPIImpl(SFConfig sfConfig) throws Exception { 25 | super(sfConfig); 26 | } 27 | 28 | public SOQLResult query(String soql) throws Exception { 29 | return query(soql, false); 30 | } 31 | 32 | public SOQLResult query(String soql, boolean all) throws Exception { 33 | StringBuilder queryParam = new StringBuilder(); 34 | queryParam.append(QUERY_PARAM); 35 | queryParam.append(soql); 36 | SFConfig sfConfig = getSfConfig(); 37 | String queryPath = getQueryPath(sfConfig, all); 38 | URI queryURI = getSfConfig().getRequestURI( 39 | getSfConfig().getPartnerConnection(), queryPath, queryParam.toString()); 40 | 41 | return query(queryURI, 1); 42 | } 43 | 44 | public SOQLResult queryMore(SOQLResult soqlResult) throws Exception { 45 | if (soqlResult.isDone()) { 46 | throw new Exception("Already all records are read"); 47 | } 48 | 49 | URI requestURI = getSfConfig().getRequestURI(getSfConfig().getPartnerConnection(), soqlResult.getNextRecordsUrl()); 50 | return query(requestURI, 1); 51 | } 52 | 53 | public AddTaskResponse addTask(AddTaskRequest addTask) throws Exception { 54 | SFConfig sfConfig = getSfConfig(); 55 | String taskPath = getTaskPath(sfConfig); 56 | URI taskURI = sfConfig.getRequestURI( 57 | sfConfig.getPartnerConnection(), taskPath); 58 | 59 | String request = getObjectMapper().writeValueAsString(addTask); 60 | String responseStr = getHttpHelper().post(taskURI, getSfConfig().getSessionId(), request); 61 | 62 | AddTaskResponse response = null; 63 | try { 64 | response = getObjectMapper().readValue(responseStr.getBytes(), AddTaskResponse.class); 65 | } catch (IOException e) { 66 | response = new AddTaskResponse(); 67 | response.setError(responseStr); 68 | response.setSuccess(false); 69 | } 70 | 71 | return response; 72 | } 73 | 74 | public ForceResponse insertObject(String object, String jsonContent) throws Exception { 75 | SFConfig sfConfig = getSfConfig(); 76 | String insertPath = getInsertPath(sfConfig, object); 77 | URI taskURI = sfConfig.getRequestURI( 78 | sfConfig.getPartnerConnection(), insertPath); 79 | 80 | String responseStr = getHttpHelper().post(taskURI, getSfConfig().getSessionId(), jsonContent); 81 | 82 | ForceResponse response = null; 83 | try { 84 | response = getObjectMapper().readValue(responseStr.getBytes(), ForceResponse.class); 85 | } catch (IOException e) { 86 | response = new ForceResponse(); 87 | response.setError(responseStr); 88 | response.setSuccess(false); 89 | } 90 | 91 | return response; 92 | } 93 | 94 | @Override 95 | public String getSFEndpoint() throws Exception { 96 | URI seURI = new URI(getSfConfig().getPartnerConnection().getConfig().getServiceEndpoint()); 97 | return new URI(seURI.getScheme(),seURI.getUserInfo(), seURI.getHost(), seURI.getPort(), 98 | null, null, null).toString(); 99 | } 100 | 101 | public DescribeSObjectResult describeSalesforceObject(String object) throws Exception { 102 | SFConfig sfConfig = getSfConfig(); 103 | String objDescribePath = getSalesforceObjectDescribePath(sfConfig, object); 104 | URI objDescribeURI = sfConfig.getRequestURI( 105 | sfConfig.getPartnerConnection(), objDescribePath); 106 | 107 | String responseStr = getHttpHelper().get(objDescribeURI, sfConfig.getSessionId()); 108 | DescribeSObjectResult response = null; 109 | try { 110 | response = getObjectMapper().readValue(responseStr.getBytes(), DescribeSObjectResult.class); 111 | } catch (IOException e) { 112 | response = new DescribeSObjectResult(); 113 | response.setError(responseStr); 114 | } 115 | return response; 116 | } 117 | 118 | private String getInsertPath(SFConfig sfConfig, String object) { 119 | StringBuilder objPath = new StringBuilder(); 120 | objPath.append(SERVICE_PATH); 121 | objPath.append("v"); 122 | objPath.append(sfConfig.getApiVersion()); 123 | objPath.append(PATH_SOBJECTS); 124 | objPath.append(object); 125 | 126 | return objPath.toString(); 127 | } 128 | 129 | private String getTaskPath(SFConfig sfConfig) { 130 | StringBuilder taskPath = new StringBuilder(); 131 | taskPath.append(SERVICE_PATH); 132 | taskPath.append("v"); 133 | taskPath.append(sfConfig.getApiVersion()); 134 | taskPath.append(PATH_TASK); 135 | 136 | return taskPath.toString(); 137 | } 138 | 139 | private SOQLResult query(URI queryURI, int attempt) throws Exception { 140 | SOQLResult soqlResult = null; 141 | try { 142 | String response = getHttpHelper().get(queryURI, 143 | getSfConfig().getSessionId(getSfConfig().getPartnerConnection()), getSfConfig().getBatchSize()); 144 | 145 | LOG.debug("Query Response from server " + response); 146 | soqlResult = getObjectMapper().readValue(response.getBytes(), SOQLResult.class); 147 | } catch (Exception e) { 148 | LOG.warn("Error while executing salesforce query ", e); 149 | if (e.getMessage().contains("QUERY_TIMEOUT") && attempt < 5) { 150 | LOG.info("Retrying salesforce query"); 151 | LOG.info("Retry attempt " + attempt); 152 | //Retrying incase of Salesforce service timeout 153 | soqlResult = query(queryURI, ++attempt); 154 | } else if (e.getMessage().contains("INVALID_SESSION_ID") && attempt < 5) { 155 | getSfConfig().closeConnection(); 156 | LOG.info("Retrying with new connection..."); 157 | soqlResult = query(queryURI, ++attempt); 158 | } else { 159 | throw e; 160 | } 161 | } 162 | 163 | return soqlResult; 164 | } 165 | 166 | private String getQueryPath(SFConfig sfConfig, boolean all) { 167 | StringBuilder queryPath = new StringBuilder(); 168 | queryPath.append(SERVICE_PATH); 169 | queryPath.append("v"); 170 | queryPath.append(sfConfig.getApiVersion()); 171 | if (all) { 172 | queryPath.append(PATH_QUERY_ALL); 173 | } else { 174 | queryPath.append(PATH_QUERY); 175 | } 176 | 177 | return queryPath.toString(); 178 | } 179 | 180 | private String getSalesforceObjectDescribePath(SFConfig sfConfig, String object) { 181 | StringBuilder objDescribePath = new StringBuilder(); 182 | objDescribePath.append(getInsertPath(sfConfig, object)); 183 | objDescribePath.append("/describe"); 184 | 185 | return objDescribePath.toString(); 186 | } 187 | 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/impl/WaveAPIImpl.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.impl; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.net.URI; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.apache.log4j.Logger; 11 | 12 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 13 | import com.sforce.soap.partner.PartnerConnection; 14 | import com.springml.salesforce.wave.api.WaveAPI; 15 | import com.springml.salesforce.wave.model.QueryResult; 16 | import com.springml.salesforce.wave.model.dataset.Dataset; 17 | import com.springml.salesforce.wave.model.dataset.DatasetsResponse; 18 | import com.springml.salesforce.wave.util.SFConfig; 19 | 20 | /** 21 | * Default Implementation for {@link WaveAPI} 22 | */ 23 | @JsonIgnoreProperties 24 | public class WaveAPIImpl extends AbstractAPIImpl implements WaveAPI { 25 | private static final Logger LOG = Logger.getLogger(WaveAPIImpl.class); 26 | 27 | public WaveAPIImpl(SFConfig sfConfig) throws Exception { 28 | super(sfConfig); 29 | } 30 | 31 | public QueryResult queryWithPagination(String saql, String resultVar, int pageSize) throws Exception { 32 | return queryWithPagination(saql, resultVar, pageSize, 0); 33 | } 34 | 35 | public QueryResult queryMore(QueryResult queryResult) throws Exception { 36 | if (queryResult.isDone()) { 37 | throw new Exception("Already all records are read"); 38 | } 39 | 40 | return queryWithPagination(queryResult.getQuery(), queryResult.getResultVariable(), 41 | queryResult.getLimit(), queryResult.getOffset()); 42 | } 43 | 44 | public QueryResult query(String saql) throws Exception { 45 | return query(saql, true); 46 | } 47 | 48 | public String getDatasetId(String datasetName) throws Exception { 49 | String datasetId = null; 50 | SFConfig sfConfig = getSfConfig(); 51 | PartnerConnection connection = sfConfig.getPartnerConnection(); 52 | 53 | StringBuilder queryParam = new StringBuilder(); 54 | queryParam.append(QUERY_PARAM); 55 | queryParam.append(datasetName); 56 | 57 | String datasetsQueryPath = getDatasetsQueryPath(sfConfig); 58 | URI queryURI = sfConfig.getRequestURI(connection, datasetsQueryPath, queryParam.toString()); 59 | 60 | String response = getHttpHelper().get(queryURI, getSfConfig().getSessionId()); 61 | DatasetsResponse datasetResponse = getObjectMapper().readValue(response.getBytes(), DatasetsResponse.class); 62 | List datasets = datasetResponse.getDatasets(); 63 | for (Dataset dataset : datasets) { 64 | // Salesforce Wave API will return multiple datasets with similar names 65 | if (datasetName.equals(dataset.getName())) { 66 | datasetId = dataset.getId() + "/" + dataset.getCurrentVersionId(); 67 | break; 68 | } 69 | } 70 | 71 | return datasetId; 72 | } 73 | 74 | private QueryResult query(String saql, boolean closeConnection) throws Exception { 75 | QueryResult result = null; 76 | SFConfig sfConfig = getSfConfig(); 77 | PartnerConnection connection = sfConfig.getPartnerConnection(); 78 | try { 79 | Map saqlMap = new HashMap(4); 80 | LOG.info("Query to be executed : " + saql); 81 | saqlMap.put(STR_QUERY, saql); 82 | String request = getObjectMapper().writeValueAsString(saqlMap); 83 | 84 | String waveQueryPath = getWaveQueryPath(sfConfig); 85 | URI queryURI = sfConfig.getRequestURI(connection, waveQueryPath); 86 | String response = getHttpHelper().post(queryURI, getSfConfig().getSessionId(connection), request); 87 | LOG.debug("Query Response from server " + response); 88 | result = getObjectMapper().readValue(response.getBytes(), QueryResult.class); 89 | } catch (Exception e) { 90 | LOG.warn("Error while executing salesforce query ", e); 91 | if (e.getMessage().contains("INVALID_SESSION_ID")) { 92 | getSfConfig().closeConnection(); 93 | LOG.info("Retrying with new connection..."); 94 | result = query(saql, closeConnection); 95 | } else { 96 | throw e; 97 | } 98 | } finally { 99 | if (closeConnection) { 100 | try { 101 | closePartnerConnection(); 102 | } catch (Exception e) { 103 | LOG.warn("Error while closing PartnerConnection", e); 104 | } 105 | } 106 | } 107 | 108 | return result; 109 | } 110 | 111 | private QueryResult queryWithPagination(String saql, String resultVar, int limit, int offset) throws Exception { 112 | String paginatedSAQL = getPaginatedSAQLQuery(saql, resultVar, limit, offset); 113 | QueryResult queryResult = query(paginatedSAQL, false); 114 | if (queryResult.getResults().getRecords().size() < limit) { 115 | queryResult.setDone(true); 116 | closePartnerConnection(); 117 | } else { 118 | queryResult.setQuery(saql); 119 | queryResult.setLimit(limit); 120 | queryResult.setOffset(limit + offset); 121 | queryResult.setResultVariable(resultVar); 122 | queryResult.setDone(false); 123 | } 124 | 125 | return queryResult; 126 | } 127 | 128 | private void closePartnerConnection() { 129 | try { 130 | getSfConfig().closeConnection(); 131 | } catch (Exception e) { 132 | LOG.warn("Error while closing PartnerConnection", e); 133 | } 134 | } 135 | 136 | private String getPaginatedSAQLQuery(String saql, String resultVar, int limit, int offset) throws Exception { 137 | if (saql.contains("limit") || saql.contains("offset")) { 138 | throw new Exception("Pagination can't be done for SAQL Query which contains limit|offset"); 139 | } 140 | 141 | StringBuilder paginatedQuery = new StringBuilder(); 142 | paginatedQuery.append(saql); 143 | paginatedQuery.append(getOffsetClause(resultVar, offset)); 144 | paginatedQuery.append(getLimitClause(resultVar, limit)); 145 | 146 | return paginatedQuery.toString(); 147 | } 148 | 149 | private String getOffsetClause(String resultVar, int offset) { 150 | return getClause(STR_OFFSET_BTW_SPACE, resultVar, offset); 151 | } 152 | 153 | private String getLimitClause(String resultVar, int limit) { 154 | return getClause(STR_LIMIT_BTW_SPACE, resultVar, limit); 155 | } 156 | 157 | private String getClause(String clause, String resultVar, int limit) { 158 | StringBuilder limitClause = new StringBuilder(); 159 | limitClause.append(resultVar); 160 | limitClause.append(STR_SPACE); 161 | limitClause.append(STR_EQUALS); 162 | limitClause.append(STR_SPACE); 163 | limitClause.append(clause); 164 | limitClause.append(resultVar); 165 | limitClause.append(STR_SPACE); 166 | limitClause.append(limit); 167 | limitClause.append(STR_SEMI_COLON); 168 | limitClause.append(STR_SPACE); 169 | 170 | return limitClause.toString(); 171 | } 172 | 173 | private String getWaveQueryPath(SFConfig sfConfig) { 174 | StringBuilder waveQueryPath = new StringBuilder(); 175 | waveQueryPath.append(SERVICE_PATH); 176 | waveQueryPath.append("v"); 177 | waveQueryPath.append(sfConfig.getApiVersion()); 178 | waveQueryPath.append(PATH_WAVE_QUERY); 179 | 180 | return waveQueryPath.toString(); 181 | } 182 | 183 | private String getDatasetsQueryPath(SFConfig sfConfig) { 184 | StringBuilder waveQueryPath = new StringBuilder(); 185 | waveQueryPath.append(SERVICE_PATH); 186 | waveQueryPath.append("v"); 187 | waveQueryPath.append(sfConfig.getApiVersion()); 188 | waveQueryPath.append(PATH_WAVE_DATASETS); 189 | 190 | return waveQueryPath.toString(); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/AddTaskRequest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | public class AddTaskRequest { 6 | @JsonProperty("Subject") 7 | private String subject; 8 | @JsonProperty("OwnerId") 9 | private String ownerId; 10 | @JsonProperty("WhatId") 11 | private String objId; 12 | 13 | public String getSubject() { 14 | return subject; 15 | } 16 | 17 | public void setSubject(String subject) { 18 | this.subject = subject; 19 | } 20 | 21 | public String getOwnerId() { 22 | return ownerId; 23 | } 24 | 25 | public void setOwnerId(String ownerId) { 26 | this.ownerId = ownerId; 27 | } 28 | 29 | public String getObjId() { 30 | return objId; 31 | } 32 | 33 | public void setObjId(String objId) { 34 | this.objId = objId; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "AddTaskRequest [subject=" + subject + ", ownerId=" + ownerId + ", objId=" + objId + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/AddTaskResponse.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | // For below response 6 | // {"id":"00TB0000003LgMzMAK","success":true,"errors":[]} 7 | // In case of error below response is returned from salesforce 8 | // [{"message":"Related To ID: id value of incorrect type: 006B000002nBrQ","errorCode":"MALFORMED_ID","fields":["WhatId"]}] 9 | @JsonIgnoreProperties(ignoreUnknown = true) 10 | public class AddTaskResponse extends ForceResponse { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/BatchInfo.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties 8 | public class BatchInfo implements Serializable { 9 | private static final long serialVersionUID = 3366976509102917086L; 10 | 11 | private String id; 12 | private String jobId; 13 | private String state; 14 | private String stateMessage; 15 | private String createdDate; 16 | private String systemModstamp; 17 | private long numberRecordsProcessed; 18 | private long numberRecordsFailed; 19 | private long totalProcessingTime; 20 | private long apiActiveProcessingTime; 21 | private long apexProcessingTime; 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | 31 | public String getJobId() { 32 | return jobId; 33 | } 34 | 35 | public void setJobId(String jobId) { 36 | this.jobId = jobId; 37 | } 38 | 39 | public String getState() { 40 | return state; 41 | } 42 | 43 | public void setState(String state) { 44 | this.state = state; 45 | } 46 | 47 | public String getCreatedDate() { 48 | return createdDate; 49 | } 50 | 51 | public void setCreatedDate(String createdDate) { 52 | this.createdDate = createdDate; 53 | } 54 | 55 | public String getSystemModstamp() { 56 | return systemModstamp; 57 | } 58 | 59 | public void setSystemModstamp(String systemModstamp) { 60 | this.systemModstamp = systemModstamp; 61 | } 62 | 63 | public long getNumberRecordsProcessed() { 64 | return numberRecordsProcessed; 65 | } 66 | 67 | public void setNumberRecordsProcessed(long numberRecordsProcessed) { 68 | this.numberRecordsProcessed = numberRecordsProcessed; 69 | } 70 | 71 | public long getNumberRecordsFailed() { 72 | return numberRecordsFailed; 73 | } 74 | 75 | public void setNumberRecordsFailed(long numberRecordsFailed) { 76 | this.numberRecordsFailed = numberRecordsFailed; 77 | } 78 | 79 | public long getTotalProcessingTime() { 80 | return totalProcessingTime; 81 | } 82 | 83 | public void setTotalProcessingTime(long totalProcessingTime) { 84 | this.totalProcessingTime = totalProcessingTime; 85 | } 86 | 87 | public long getApiActiveProcessingTime() { 88 | return apiActiveProcessingTime; 89 | } 90 | 91 | public void setApiActiveProcessingTime(long apiActiveProcessingTime) { 92 | this.apiActiveProcessingTime = apiActiveProcessingTime; 93 | } 94 | 95 | public long getApexProcessingTime() { 96 | return apexProcessingTime; 97 | } 98 | 99 | public void setApexProcessingTime(long apexProcessingTime) { 100 | this.apexProcessingTime = apexProcessingTime; 101 | } 102 | 103 | public String getStateMessage() { 104 | return stateMessage; 105 | } 106 | 107 | public void setStateMessage(String stateMessage) { 108 | this.stateMessage = stateMessage; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/BatchInfoList.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 7 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; 8 | 9 | @JsonIgnoreProperties 10 | public class BatchInfoList implements Serializable { 11 | private static final long serialVersionUID = -6396097094521689813L; 12 | 13 | @JacksonXmlElementWrapper(useWrapping=false) 14 | private List batchInfo; 15 | 16 | public List getBatchInfo() { 17 | return batchInfo; 18 | } 19 | 20 | public void setBatchInfo(List batchInfo) { 21 | this.batchInfo = batchInfo; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/BatchResultList.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | @JsonIgnoreProperties 11 | public class BatchResultList implements Serializable { 12 | private static final long serialVersionUID = 2388430108404791178L; 13 | 14 | @JacksonXmlElementWrapper(useWrapping=false) 15 | @JsonProperty("result") 16 | private List batchResultIds; 17 | 18 | public List getBatchResultIds() { 19 | return batchResultIds; 20 | } 21 | 22 | public void setBatchResultIds(List batchResultIds) { 23 | this.batchResultIds = batchResultIds; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/DescribeSObjectResult.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | public class DescribeSObjectResult implements Serializable { 10 | 11 | private static final long serialVersionUID = 1739841107381849160L; 12 | 13 | private boolean createable; 14 | private boolean custom; 15 | private boolean deletable; 16 | private List fields; 17 | private String name; 18 | private boolean queryable; 19 | private boolean replicateable; 20 | private boolean retrieveable; 21 | private boolean searchable; 22 | private boolean undeletable; 23 | private boolean updateable; 24 | private String urlDetail; 25 | private String urlEdit; 26 | private String urlNew; 27 | 28 | private String error; 29 | 30 | public boolean isCreateable() { 31 | return createable; 32 | } 33 | 34 | public void setCreateable(boolean createable) { 35 | this.createable = createable; 36 | } 37 | 38 | public boolean isCustom() { 39 | return custom; 40 | } 41 | 42 | public void setCustom(boolean custom) { 43 | this.custom = custom; 44 | } 45 | 46 | public boolean isDeletable() { 47 | return deletable; 48 | } 49 | 50 | public void setDeletable(boolean deletable) { 51 | this.deletable = deletable; 52 | } 53 | 54 | public List getFields() { 55 | return fields; 56 | } 57 | 58 | public void setFields(List fields) { 59 | this.fields = fields; 60 | } 61 | 62 | public String getName() { 63 | return name; 64 | } 65 | 66 | public void setName(String name) { 67 | this.name = name; 68 | } 69 | 70 | public boolean isQueryable() { 71 | return queryable; 72 | } 73 | 74 | public void setQueryable(boolean queryable) { 75 | this.queryable = queryable; 76 | } 77 | 78 | public boolean isReplicateable() { 79 | return replicateable; 80 | } 81 | 82 | public void setReplicateable(boolean replicateable) { 83 | this.replicateable = replicateable; 84 | } 85 | 86 | public boolean isRetrieveable() { 87 | return retrieveable; 88 | } 89 | 90 | public void setRetrieveable(boolean retrieveable) { 91 | this.retrieveable = retrieveable; 92 | } 93 | 94 | public boolean isSearchable() { 95 | return searchable; 96 | } 97 | 98 | public void setSearchable(boolean searchable) { 99 | this.searchable = searchable; 100 | } 101 | 102 | public boolean isUndeletable() { 103 | return undeletable; 104 | } 105 | 106 | public void setUndeletable(boolean undeletable) { 107 | this.undeletable = undeletable; 108 | } 109 | 110 | public boolean isUpdateable() { 111 | return updateable; 112 | } 113 | 114 | public void setUpdateable(boolean updateable) { 115 | this.updateable = updateable; 116 | } 117 | 118 | public String getUrlDetail() { 119 | return urlDetail; 120 | } 121 | 122 | public void setUrlDetail(String urlDetail) { 123 | this.urlDetail = urlDetail; 124 | } 125 | 126 | public String getUrlEdit() { 127 | return urlEdit; 128 | } 129 | 130 | public void setUrlEdit(String urlEdit) { 131 | this.urlEdit = urlEdit; 132 | } 133 | 134 | public String getUrlNew() { 135 | return urlNew; 136 | } 137 | 138 | public void setUrlNew(String urlNew) { 139 | this.urlNew = urlNew; 140 | } 141 | 142 | public String getError() { 143 | return error; 144 | } 145 | 146 | public void setError(String error) { 147 | this.error = error; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/Field.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import java.io.Serializable; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class Field implements Serializable { 9 | 10 | private static final long serialVersionUID = 1739841109381849160L; 11 | 12 | private String name; 13 | private int length; 14 | private String label; 15 | private boolean filterable; 16 | private boolean nameField; 17 | private boolean nillable; 18 | private boolean unique; 19 | private boolean updateable; 20 | private boolean custom; 21 | private boolean createable; 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public int getLength() { 32 | return length; 33 | } 34 | 35 | public void setLength(int length) { 36 | this.length = length; 37 | } 38 | 39 | public String getLabel() { 40 | return label; 41 | } 42 | 43 | public void setLabel(String label) { 44 | this.label = label; 45 | } 46 | 47 | public boolean isFilterable() { 48 | return filterable; 49 | } 50 | 51 | public void setFilterable(boolean filterable) { 52 | this.filterable = filterable; 53 | } 54 | 55 | public boolean isNameField() { 56 | return nameField; 57 | } 58 | 59 | public void setNameField(boolean nameField) { 60 | this.nameField = nameField; 61 | } 62 | 63 | public boolean isNillable() { 64 | return nillable; 65 | } 66 | 67 | public void setNillable(boolean nillable) { 68 | this.nillable = nillable; 69 | } 70 | 71 | public boolean isUnique() { 72 | return unique; 73 | } 74 | 75 | public void setUnique(boolean unique) { 76 | this.unique = unique; 77 | } 78 | 79 | public boolean isUpdateable() { 80 | return updateable; 81 | } 82 | 83 | public void setUpdateable(boolean updateable) { 84 | this.updateable = updateable; 85 | } 86 | 87 | public boolean isCustom() { 88 | return custom; 89 | } 90 | 91 | public void setCustom(boolean custom) { 92 | this.custom = custom; 93 | } 94 | 95 | public boolean isCreateable() { 96 | return createable; 97 | } 98 | 99 | public void setCreateable(boolean createable) { 100 | this.createable = createable; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/ForceResponse.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | 6 | //For below response 7 | //{"id":"00TB0000003LgMzMAK","success":true,"errors":[]} 8 | //In case of error below response is returned from salesforce 9 | //[{"message":"Related To ID: id value of incorrect type: 006B000002nBrQ","errorCode":"MALFORMED_ID","fields":["WhatId"]}] 10 | @JsonIgnoreProperties(ignoreUnknown = true) 11 | public class ForceResponse { 12 | private String id; 13 | private boolean success; 14 | private String error; 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | public boolean isSuccess() { 25 | return success; 26 | } 27 | 28 | public void setSuccess(boolean success) { 29 | this.success = success; 30 | } 31 | 32 | public String getError() { 33 | return error; 34 | } 35 | 36 | public void setError(String error) { 37 | this.error = error; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "AddTaskResponse [id=" + id + ", success=" + success + ", error=" + error + "]"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/InsertObjectsResponse.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class InsertObjectsResponse { 9 | private boolean hasErrors; 10 | private String error; 11 | private List results; 12 | 13 | public boolean isHasErrors() { 14 | return hasErrors; 15 | } 16 | 17 | public void setHasErrors(boolean hasErrors) { 18 | this.hasErrors = hasErrors; 19 | } 20 | 21 | public String getError() { 22 | return error; 23 | } 24 | 25 | public void setError(String error) { 26 | this.error = error; 27 | } 28 | 29 | public List getResults() { 30 | return results; 31 | } 32 | 33 | public void setResults(List results) { 34 | this.results = results; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/InsertResult.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | public class InsertResult { 4 | private String referenceId; 5 | private String id; 6 | 7 | public String getReferenceId() { 8 | return referenceId; 9 | } 10 | 11 | public void setReferenceId(String referenceId) { 12 | this.referenceId = referenceId; 13 | } 14 | 15 | public String getId() { 16 | return id; 17 | } 18 | 19 | public void setId(String id) { 20 | this.id = id; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/JobInfo.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties 8 | public class JobInfo implements Serializable { 9 | private static final long serialVersionUID = 2403943099992427787L; 10 | 11 | private String contentType; 12 | private String object; 13 | private String operation; 14 | private String apiVersion; 15 | private String concurrencyMode; 16 | private String createdById; 17 | private String createdDate; 18 | private String externalIdFieldName; 19 | private String fastPathEnabled; 20 | private String numberBatchesCompleted; 21 | private String numberBatchesFailed; 22 | private String numberBatchesInProgress; 23 | private String numberBatchesQueued; 24 | private String numberBatchesTotal; 25 | private String numberRecordsFailed; 26 | private String numberRecordsProcessed; 27 | private String numberRetries; 28 | private String state; 29 | private String systemModstamp; 30 | private String totalProcessingTime; 31 | private String id; 32 | 33 | public JobInfo(String contentType, String object, String operation) { 34 | this.contentType = contentType; 35 | this.object = object; 36 | this.operation = operation; 37 | } 38 | 39 | public JobInfo(String state) { 40 | this.state = state; 41 | } 42 | 43 | // For Jackson 44 | public JobInfo() {} 45 | 46 | public String getContentType() { 47 | return contentType; 48 | } 49 | 50 | public void setContentType(String contentType) { 51 | this.contentType = contentType; 52 | } 53 | 54 | public String getObject() { 55 | return object; 56 | } 57 | 58 | public void setObject(String object) { 59 | this.object = object; 60 | } 61 | 62 | public String getOperation() { 63 | return operation; 64 | } 65 | 66 | public void setOperation(String operation) { 67 | this.operation = operation; 68 | } 69 | 70 | public String getApiVersion() { 71 | return apiVersion; 72 | } 73 | 74 | public void setApiVersion(String apiVersion) { 75 | this.apiVersion = apiVersion; 76 | } 77 | 78 | public String getConcurrencyMode() { 79 | return concurrencyMode; 80 | } 81 | 82 | public void setConcurrencyMode(String concurrencyMode) { 83 | this.concurrencyMode = concurrencyMode; 84 | } 85 | 86 | public String getCreatedById() { 87 | return createdById; 88 | } 89 | 90 | public void setCreatedById(String createdById) { 91 | this.createdById = createdById; 92 | } 93 | 94 | public String getCreatedDate() { 95 | return createdDate; 96 | } 97 | 98 | public void setCreatedDate(String createdDate) { 99 | this.createdDate = createdDate; 100 | } 101 | 102 | public String getExternalIdFieldName() { 103 | return externalIdFieldName; 104 | } 105 | 106 | public void setExternalIdFieldName(String externalIdFieldName) { 107 | this.externalIdFieldName = externalIdFieldName; 108 | } 109 | 110 | public String getFastPathEnabled() { 111 | return fastPathEnabled; 112 | } 113 | 114 | public void setFastPathEnabled(String fastPathEnabled) { 115 | this.fastPathEnabled = fastPathEnabled; 116 | } 117 | 118 | public String getNumberBatchesCompleted() { 119 | return numberBatchesCompleted; 120 | } 121 | 122 | public void setNumberBatchesCompleted(String numberBatchesCompleted) { 123 | this.numberBatchesCompleted = numberBatchesCompleted; 124 | } 125 | 126 | public String getNumberBatchesFailed() { 127 | return numberBatchesFailed; 128 | } 129 | 130 | public void setNumberBatchesFailed(String numberBatchesFailed) { 131 | this.numberBatchesFailed = numberBatchesFailed; 132 | } 133 | 134 | public String getNumberBatchesInProgress() { 135 | return numberBatchesInProgress; 136 | } 137 | 138 | public void setNumberBatchesInProgress(String numberBatchesInProgress) { 139 | this.numberBatchesInProgress = numberBatchesInProgress; 140 | } 141 | 142 | public String getNumberBatchesQueued() { 143 | return numberBatchesQueued; 144 | } 145 | 146 | public void setNumberBatchesQueued(String numberBatchesQueued) { 147 | this.numberBatchesQueued = numberBatchesQueued; 148 | } 149 | 150 | public String getNumberBatchesTotal() { 151 | return numberBatchesTotal; 152 | } 153 | 154 | public void setNumberBatchesTotal(String numberBatchesTotal) { 155 | this.numberBatchesTotal = numberBatchesTotal; 156 | } 157 | 158 | public String getNumberRecordsFailed() { 159 | return numberRecordsFailed; 160 | } 161 | 162 | public void setNumberRecordsFailed(String numberRecordsFailed) { 163 | this.numberRecordsFailed = numberRecordsFailed; 164 | } 165 | 166 | public String getNumberRecordsProcessed() { 167 | return numberRecordsProcessed; 168 | } 169 | 170 | public void setNumberRecordsProcessed(String numberRecordsProcessed) { 171 | this.numberRecordsProcessed = numberRecordsProcessed; 172 | } 173 | 174 | public String getNumberRetries() { 175 | return numberRetries; 176 | } 177 | 178 | public void setNumberRetries(String numberRetries) { 179 | this.numberRetries = numberRetries; 180 | } 181 | 182 | public String getState() { 183 | return state; 184 | } 185 | 186 | public void setState(String state) { 187 | this.state = state; 188 | } 189 | 190 | public String getSystemModstamp() { 191 | return systemModstamp; 192 | } 193 | 194 | public void setSystemModstamp(String systemModstamp) { 195 | this.systemModstamp = systemModstamp; 196 | } 197 | 198 | public String getTotalProcessingTime() { 199 | return totalProcessingTime; 200 | } 201 | 202 | public void setTotalProcessingTime(String totalProcessingTime) { 203 | this.totalProcessingTime = totalProcessingTime; 204 | } 205 | 206 | public String getId() { 207 | return id; 208 | } 209 | 210 | public void setId(String id) { 211 | this.id = id; 212 | } 213 | 214 | } 215 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/PostMessageRequest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | import com.springml.salesforce.wave.model.chatter.MessageBody; 6 | 7 | @JsonInclude(Include.NON_NULL) 8 | public class PostMessageRequest { 9 | private String feedElementType; 10 | private String subjectId; 11 | private MessageBody body; 12 | 13 | public String getFeedElementType() { 14 | return feedElementType; 15 | } 16 | 17 | public void setFeedElementType(String feedElementType) { 18 | this.feedElementType = feedElementType; 19 | } 20 | 21 | public String getSubjectId() { 22 | return subjectId; 23 | } 24 | 25 | public void setSubjectId(String subjectId) { 26 | this.subjectId = subjectId; 27 | } 28 | 29 | public MessageBody getBody() { 30 | return body; 31 | } 32 | 33 | public void setBody(MessageBody body) { 34 | this.body = body; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/QueryResult.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | /** 6 | * Bean class for Salesforce Wave api response 7 | * { "action": "query", 8 | * "responseId": "3zgfdv7BUuMLxQVeRhqeek", "results": { "records": [ { "field1": 9 | * 10, "field2": "Field Value 2", "field23": "Field Value 3" } ] }, "query": 10 | * "SAQL_Query", "responseTime": 171 } 11 | */ 12 | @JsonIgnoreProperties 13 | public class QueryResult { 14 | private String responseId; 15 | private Results results; 16 | private String query; 17 | private long responseTime; 18 | private int limit; 19 | private int offset; 20 | private String resultVariable; 21 | private boolean done; 22 | 23 | public String getResponseId() { 24 | return responseId; 25 | } 26 | 27 | public void setResponseId(String responseId) { 28 | this.responseId = responseId; 29 | } 30 | 31 | public Results getResults() { 32 | return results; 33 | } 34 | 35 | public void setResults(Results results) { 36 | this.results = results; 37 | } 38 | 39 | public String getQuery() { 40 | return query; 41 | } 42 | 43 | public void setQuery(String query) { 44 | this.query = query; 45 | } 46 | 47 | public long getResponseTime() { 48 | return responseTime; 49 | } 50 | 51 | public void setResponseTime(long responseTime) { 52 | this.responseTime = responseTime; 53 | } 54 | 55 | public int getLimit() { 56 | return limit; 57 | } 58 | 59 | public void setLimit(int limit) { 60 | this.limit = limit; 61 | } 62 | 63 | public int getOffset() { 64 | return offset; 65 | } 66 | 67 | public void setOffset(int offset) { 68 | this.offset = offset; 69 | } 70 | 71 | public String getResultVariable() { 72 | return resultVariable; 73 | } 74 | 75 | public void setResultVariable(String resultVariable) { 76 | this.resultVariable = resultVariable; 77 | } 78 | 79 | public boolean isDone() { 80 | return done; 81 | } 82 | 83 | public void setDone(boolean done) { 84 | this.done = done; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/Results.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Bean class for Salesforce Wave Query results 8 | * { 9 | * "results": { 10 | * "records": [ 11 | * { 12 | * "field1": 11, 13 | * "field2": "value", 14 | * "field3": "value" 15 | * } 16 | * ] 17 | * } 18 | * } 19 | */ 20 | public class Results { 21 | private List> records; 22 | 23 | public List> getRecords() { 24 | return records; 25 | } 26 | 27 | public void setRecords(List> records) { 28 | this.records = records; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/SOQLResult.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.STR_ATTRIBUTES; 4 | 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Map.Entry; 10 | import java.util.Set; 11 | 12 | import com.fasterxml.jackson.annotation.JsonIgnore; 13 | 14 | /** 15 | * POJO for SOQL result 16 | * { 17 | * "totalSize": 4, 18 | * "done": true, 19 | * "nextRecordsUrl": "/services/data/v34.0/query/01gB000000HupiDIAR-6000", 20 | * "records": [ 21 | * { 22 | * "attributes": { 23 | * "type": "Opportunity", 24 | * "url": "/services/data/v34.0/sobjects/Opportunity/006B0000002ndnuIAA" 25 | * }, 26 | * "AccountId": "001B0000003oYAfIAM", 27 | * "Id": "006B0000002ndnuIAA", 28 | * "ProposalID__c": "103" 29 | * } 30 | * ] 31 | * } 32 | */ 33 | public class SOQLResult { 34 | private int totalSize; 35 | private boolean done; 36 | private String nextRecordsUrl; 37 | private List> records; 38 | 39 | public int getTotalSize() { 40 | return totalSize; 41 | } 42 | 43 | public void setTotalSize(int totalSize) { 44 | this.totalSize = totalSize; 45 | } 46 | 47 | public boolean isDone() { 48 | return done; 49 | } 50 | 51 | public void setDone(boolean done) { 52 | this.done = done; 53 | } 54 | 55 | public String getNextRecordsUrl() { 56 | return nextRecordsUrl; 57 | } 58 | 59 | public void setNextRecordsUrl(String nextRecordsUrl) { 60 | this.nextRecordsUrl = nextRecordsUrl; 61 | } 62 | 63 | public List> getRecords() { 64 | return records; 65 | } 66 | 67 | public void setRecords(List> records) { 68 | this.records = records; 69 | } 70 | 71 | @JsonIgnore 72 | public List> filterRecords() { 73 | List> filteredRecords = new ArrayList>(); 74 | if (records != null) { 75 | for (Map fields : records) { 76 | Map filteredMap = new HashMap(); 77 | Set> entries = fields.entrySet(); 78 | 79 | for (Entry entry : entries) { 80 | if (!entry.getKey().equals(STR_ATTRIBUTES)) { 81 | Object value = entry.getValue(); 82 | if (value instanceof Map) { 83 | filteredMap.putAll(getRelatedRecords(entry.getKey(), (Map) value)); 84 | } else { 85 | filteredMap.put(entry.getKey(), String.valueOf(value)); 86 | } 87 | } 88 | } 89 | 90 | filteredRecords.add(filteredMap); 91 | } 92 | } 93 | 94 | return filteredRecords; 95 | } 96 | 97 | private Map getRelatedRecords(String key, Map value) { 98 | Set> entries = value.entrySet(); 99 | 100 | Map relatedRecords = new HashMap(); 101 | 102 | for (Entry entry : entries) { 103 | if (!entry.getKey().equals(STR_ATTRIBUTES)) { 104 | Object childValue = entry.getValue(); 105 | if (childValue instanceof Map) { 106 | relatedRecords.putAll(getRelatedRecords(key + "." + entry.getKey(), (Map) childValue)); 107 | } else { 108 | relatedRecords.put(key + "." + entry.getKey(), String.valueOf(childValue)); 109 | } 110 | } 111 | } 112 | 113 | return relatedRecords; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Actor.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Actor { 10 | 11 | private String additionalLabel; 12 | private String communityNickname; 13 | private String companyName; 14 | private String displayName; 15 | private String firstName; 16 | private String id; 17 | private boolean isActive; 18 | private boolean isInThisCommunity; 19 | private String lastName; 20 | private Motif motif; 21 | private Object mySubscription; 22 | private String name; 23 | private Photo photo; 24 | private Object reputation; 25 | private Object title; 26 | private String type; 27 | private String url; 28 | private String userType; 29 | private Map additionalProperties = new HashMap(); 30 | 31 | /** 32 | * 33 | * @return 34 | * The additionalLabel 35 | */ 36 | public String getAdditionalLabel() { 37 | return additionalLabel; 38 | } 39 | 40 | /** 41 | * 42 | * @param additionalLabel 43 | * The additionalLabel 44 | */ 45 | public void setAdditionalLabel(String additionalLabel) { 46 | this.additionalLabel = additionalLabel; 47 | } 48 | 49 | /** 50 | * 51 | * @return 52 | * The communityNickname 53 | */ 54 | public String getCommunityNickname() { 55 | return communityNickname; 56 | } 57 | 58 | /** 59 | * 60 | * @param communityNickname 61 | * The communityNickname 62 | */ 63 | public void setCommunityNickname(String communityNickname) { 64 | this.communityNickname = communityNickname; 65 | } 66 | 67 | /** 68 | * 69 | * @return 70 | * The companyName 71 | */ 72 | public String getCompanyName() { 73 | return companyName; 74 | } 75 | 76 | /** 77 | * 78 | * @param companyName 79 | * The companyName 80 | */ 81 | public void setCompanyName(String companyName) { 82 | this.companyName = companyName; 83 | } 84 | 85 | /** 86 | * 87 | * @return 88 | * The displayName 89 | */ 90 | public String getDisplayName() { 91 | return displayName; 92 | } 93 | 94 | /** 95 | * 96 | * @param displayName 97 | * The displayName 98 | */ 99 | public void setDisplayName(String displayName) { 100 | this.displayName = displayName; 101 | } 102 | 103 | /** 104 | * 105 | * @return 106 | * The firstName 107 | */ 108 | public String getFirstName() { 109 | return firstName; 110 | } 111 | 112 | /** 113 | * 114 | * @param firstName 115 | * The firstName 116 | */ 117 | public void setFirstName(String firstName) { 118 | this.firstName = firstName; 119 | } 120 | 121 | /** 122 | * 123 | * @return 124 | * The id 125 | */ 126 | public String getId() { 127 | return id; 128 | } 129 | 130 | /** 131 | * 132 | * @param id 133 | * The id 134 | */ 135 | public void setId(String id) { 136 | this.id = id; 137 | } 138 | 139 | /** 140 | * 141 | * @return 142 | * The isActive 143 | */ 144 | public boolean isIsActive() { 145 | return isActive; 146 | } 147 | 148 | /** 149 | * 150 | * @param isActive 151 | * The isActive 152 | */ 153 | public void setIsActive(boolean isActive) { 154 | this.isActive = isActive; 155 | } 156 | 157 | /** 158 | * 159 | * @return 160 | * The isInThisCommunity 161 | */ 162 | public boolean isIsInThisCommunity() { 163 | return isInThisCommunity; 164 | } 165 | 166 | /** 167 | * 168 | * @param isInThisCommunity 169 | * The isInThisCommunity 170 | */ 171 | public void setIsInThisCommunity(boolean isInThisCommunity) { 172 | this.isInThisCommunity = isInThisCommunity; 173 | } 174 | 175 | /** 176 | * 177 | * @return 178 | * The lastName 179 | */ 180 | public String getLastName() { 181 | return lastName; 182 | } 183 | 184 | /** 185 | * 186 | * @param lastName 187 | * The lastName 188 | */ 189 | public void setLastName(String lastName) { 190 | this.lastName = lastName; 191 | } 192 | 193 | /** 194 | * 195 | * @return 196 | * The motif 197 | */ 198 | public Motif getMotif() { 199 | return motif; 200 | } 201 | 202 | /** 203 | * 204 | * @param motif 205 | * The motif 206 | */ 207 | public void setMotif(Motif motif) { 208 | this.motif = motif; 209 | } 210 | 211 | /** 212 | * 213 | * @return 214 | * The mySubscription 215 | */ 216 | public Object getMySubscription() { 217 | return mySubscription; 218 | } 219 | 220 | /** 221 | * 222 | * @param mySubscription 223 | * The mySubscription 224 | */ 225 | public void setMySubscription(Object mySubscription) { 226 | this.mySubscription = mySubscription; 227 | } 228 | 229 | /** 230 | * 231 | * @return 232 | * The name 233 | */ 234 | public String getName() { 235 | return name; 236 | } 237 | 238 | /** 239 | * 240 | * @param name 241 | * The name 242 | */ 243 | public void setName(String name) { 244 | this.name = name; 245 | } 246 | 247 | /** 248 | * 249 | * @return 250 | * The photo 251 | */ 252 | public Photo getPhoto() { 253 | return photo; 254 | } 255 | 256 | /** 257 | * 258 | * @param photo 259 | * The photo 260 | */ 261 | public void setPhoto(Photo photo) { 262 | this.photo = photo; 263 | } 264 | 265 | /** 266 | * 267 | * @return 268 | * The reputation 269 | */ 270 | public Object getReputation() { 271 | return reputation; 272 | } 273 | 274 | /** 275 | * 276 | * @param reputation 277 | * The reputation 278 | */ 279 | public void setReputation(Object reputation) { 280 | this.reputation = reputation; 281 | } 282 | 283 | /** 284 | * 285 | * @return 286 | * The title 287 | */ 288 | public Object getTitle() { 289 | return title; 290 | } 291 | 292 | /** 293 | * 294 | * @param title 295 | * The title 296 | */ 297 | public void setTitle(Object title) { 298 | this.title = title; 299 | } 300 | 301 | /** 302 | * 303 | * @return 304 | * The type 305 | */ 306 | public String getType() { 307 | return type; 308 | } 309 | 310 | /** 311 | * 312 | * @param type 313 | * The type 314 | */ 315 | public void setType(String type) { 316 | this.type = type; 317 | } 318 | 319 | /** 320 | * 321 | * @return 322 | * The url 323 | */ 324 | public String getUrl() { 325 | return url; 326 | } 327 | 328 | /** 329 | * 330 | * @param url 331 | * The url 332 | */ 333 | public void setUrl(String url) { 334 | this.url = url; 335 | } 336 | 337 | /** 338 | * 339 | * @return 340 | * The userType 341 | */ 342 | public String getUserType() { 343 | return userType; 344 | } 345 | 346 | /** 347 | * 348 | * @param userType 349 | * The userType 350 | */ 351 | public void setUserType(String userType) { 352 | this.userType = userType; 353 | } 354 | 355 | @Override 356 | public String toString() { 357 | return ToStringBuilder.reflectionToString(this); 358 | } 359 | 360 | public Map getAdditionalProperties() { 361 | return this.additionalProperties; 362 | } 363 | 364 | public void setAdditionalProperty(String name, Object value) { 365 | this.additionalProperties.put(name, value); 366 | } 367 | 368 | } 369 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/AssociatedActions.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.builder.ToStringBuilder; 10 | 11 | public class AssociatedActions { 12 | 13 | private List platformActionGroups = new ArrayList(); 14 | private Map additionalProperties = new HashMap(); 15 | 16 | /** 17 | * 18 | * @return 19 | * The platformActionGroups 20 | */ 21 | public List getPlatformActionGroups() { 22 | return platformActionGroups; 23 | } 24 | 25 | /** 26 | * 27 | * @param platformActionGroups 28 | * The platformActionGroups 29 | */ 30 | public void setPlatformActionGroups(List platformActionGroups) { 31 | this.platformActionGroups = platformActionGroups; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return ToStringBuilder.reflectionToString(this); 37 | } 38 | 39 | public Map getAdditionalProperties() { 40 | return this.additionalProperties; 41 | } 42 | 43 | public void setAdditionalProperty(String name, Object value) { 44 | this.additionalProperties.put(name, value); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Body.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.builder.ToStringBuilder; 10 | 11 | public class Body { 12 | 13 | private boolean isRichText; 14 | private List messageSegments = new ArrayList(); 15 | private String text; 16 | private Map additionalProperties = new HashMap(); 17 | 18 | /** 19 | * 20 | * @return 21 | * The isRichText 22 | */ 23 | public boolean isIsRichText() { 24 | return isRichText; 25 | } 26 | 27 | /** 28 | * 29 | * @param isRichText 30 | * The isRichText 31 | */ 32 | public void setIsRichText(boolean isRichText) { 33 | this.isRichText = isRichText; 34 | } 35 | 36 | /** 37 | * 38 | * @return 39 | * The messageSegments 40 | */ 41 | public List getMessageSegments() { 42 | return messageSegments; 43 | } 44 | 45 | /** 46 | * 47 | * @param messageSegments 48 | * The messageSegments 49 | */ 50 | public void setMessageSegments(List messageSegments) { 51 | this.messageSegments = messageSegments; 52 | } 53 | 54 | /** 55 | * 56 | * @return 57 | * The text 58 | */ 59 | public String getText() { 60 | return text; 61 | } 62 | 63 | /** 64 | * 65 | * @param text 66 | * The text 67 | */ 68 | public void setText(String text) { 69 | this.text = text; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return ToStringBuilder.reflectionToString(this); 75 | } 76 | 77 | public Map getAdditionalProperties() { 78 | return this.additionalProperties; 79 | } 80 | 81 | public void setAdditionalProperty(String name, Object value) { 82 | this.additionalProperties.put(name, value); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Bookmarks.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Bookmarks { 10 | 11 | private boolean isBookmarkedByCurrentUser; 12 | private Map additionalProperties = new HashMap(); 13 | 14 | /** 15 | * 16 | * @return 17 | * The isBookmarkedByCurrentUser 18 | */ 19 | public boolean isIsBookmarkedByCurrentUser() { 20 | return isBookmarkedByCurrentUser; 21 | } 22 | 23 | /** 24 | * 25 | * @param isBookmarkedByCurrentUser 26 | * The isBookmarkedByCurrentUser 27 | */ 28 | public void setIsBookmarkedByCurrentUser(boolean isBookmarkedByCurrentUser) { 29 | this.isBookmarkedByCurrentUser = isBookmarkedByCurrentUser; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return ToStringBuilder.reflectionToString(this); 35 | } 36 | 37 | public Map getAdditionalProperties() { 38 | return this.additionalProperties; 39 | } 40 | 41 | public void setAdditionalProperty(String name, Object value) { 42 | this.additionalProperties.put(name, value); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Capabilities.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Capabilities { 10 | 11 | private AssociatedActions associatedActions; 12 | private Bookmarks bookmarks; 13 | private ChatterLikes chatterLikes; 14 | private Comments comments; 15 | private Mute mute; 16 | private Topics topics; 17 | private Map additionalProperties = new HashMap(); 18 | 19 | /** 20 | * 21 | * @return 22 | * The associatedActions 23 | */ 24 | public AssociatedActions getAssociatedActions() { 25 | return associatedActions; 26 | } 27 | 28 | /** 29 | * 30 | * @param associatedActions 31 | * The associatedActions 32 | */ 33 | public void setAssociatedActions(AssociatedActions associatedActions) { 34 | this.associatedActions = associatedActions; 35 | } 36 | 37 | /** 38 | * 39 | * @return 40 | * The bookmarks 41 | */ 42 | public Bookmarks getBookmarks() { 43 | return bookmarks; 44 | } 45 | 46 | /** 47 | * 48 | * @param bookmarks 49 | * The bookmarks 50 | */ 51 | public void setBookmarks(Bookmarks bookmarks) { 52 | this.bookmarks = bookmarks; 53 | } 54 | 55 | /** 56 | * 57 | * @return 58 | * The chatterLikes 59 | */ 60 | public ChatterLikes getChatterLikes() { 61 | return chatterLikes; 62 | } 63 | 64 | /** 65 | * 66 | * @param chatterLikes 67 | * The chatterLikes 68 | */ 69 | public void setChatterLikes(ChatterLikes chatterLikes) { 70 | this.chatterLikes = chatterLikes; 71 | } 72 | 73 | /** 74 | * 75 | * @return 76 | * The comments 77 | */ 78 | public Comments getComments() { 79 | return comments; 80 | } 81 | 82 | /** 83 | * 84 | * @param comments 85 | * The comments 86 | */ 87 | public void setComments(Comments comments) { 88 | this.comments = comments; 89 | } 90 | 91 | /** 92 | * 93 | * @return 94 | * The mute 95 | */ 96 | public Mute getMute() { 97 | return mute; 98 | } 99 | 100 | /** 101 | * 102 | * @param mute 103 | * The mute 104 | */ 105 | public void setMute(Mute mute) { 106 | this.mute = mute; 107 | } 108 | 109 | /** 110 | * 111 | * @return 112 | * The topics 113 | */ 114 | public Topics getTopics() { 115 | return topics; 116 | } 117 | 118 | /** 119 | * 120 | * @param topics 121 | * The topics 122 | */ 123 | public void setTopics(Topics topics) { 124 | this.topics = topics; 125 | } 126 | 127 | @Override 128 | public String toString() { 129 | return ToStringBuilder.reflectionToString(this); 130 | } 131 | 132 | public Map getAdditionalProperties() { 133 | return this.additionalProperties; 134 | } 135 | 136 | public void setAdditionalProperty(String name, Object value) { 137 | this.additionalProperties.put(name, value); 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/ChatterLikes.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class ChatterLikes { 10 | 11 | private boolean isLikedByCurrentUser; 12 | private Object likesMessage; 13 | private Object myLike; 14 | private Page page; 15 | private Map additionalProperties = new HashMap(); 16 | 17 | /** 18 | * 19 | * @return 20 | * The isLikedByCurrentUser 21 | */ 22 | public boolean isIsLikedByCurrentUser() { 23 | return isLikedByCurrentUser; 24 | } 25 | 26 | /** 27 | * 28 | * @param isLikedByCurrentUser 29 | * The isLikedByCurrentUser 30 | */ 31 | public void setIsLikedByCurrentUser(boolean isLikedByCurrentUser) { 32 | this.isLikedByCurrentUser = isLikedByCurrentUser; 33 | } 34 | 35 | /** 36 | * 37 | * @return 38 | * The likesMessage 39 | */ 40 | public Object getLikesMessage() { 41 | return likesMessage; 42 | } 43 | 44 | /** 45 | * 46 | * @param likesMessage 47 | * The likesMessage 48 | */ 49 | public void setLikesMessage(Object likesMessage) { 50 | this.likesMessage = likesMessage; 51 | } 52 | 53 | /** 54 | * 55 | * @return 56 | * The myLike 57 | */ 58 | public Object getMyLike() { 59 | return myLike; 60 | } 61 | 62 | /** 63 | * 64 | * @param myLike 65 | * The myLike 66 | */ 67 | public void setMyLike(Object myLike) { 68 | this.myLike = myLike; 69 | } 70 | 71 | /** 72 | * 73 | * @return 74 | * The page 75 | */ 76 | public Page getPage() { 77 | return page; 78 | } 79 | 80 | /** 81 | * 82 | * @param page 83 | * The page 84 | */ 85 | public void setPage(Page page) { 86 | this.page = page; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return ToStringBuilder.reflectionToString(this); 92 | } 93 | 94 | public Map getAdditionalProperties() { 95 | return this.additionalProperties; 96 | } 97 | 98 | public void setAdditionalProperty(String name, Object value) { 99 | this.additionalProperties.put(name, value); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/ClientInfo.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class ClientInfo { 10 | 11 | private String applicationName; 12 | private Object applicationUrl; 13 | private Map additionalProperties = new HashMap(); 14 | 15 | /** 16 | * 17 | * @return 18 | * The applicationName 19 | */ 20 | public String getApplicationName() { 21 | return applicationName; 22 | } 23 | 24 | /** 25 | * 26 | * @param applicationName 27 | * The applicationName 28 | */ 29 | public void setApplicationName(String applicationName) { 30 | this.applicationName = applicationName; 31 | } 32 | 33 | /** 34 | * 35 | * @return 36 | * The applicationUrl 37 | */ 38 | public Object getApplicationUrl() { 39 | return applicationUrl; 40 | } 41 | 42 | /** 43 | * 44 | * @param applicationUrl 45 | * The applicationUrl 46 | */ 47 | public void setApplicationUrl(Object applicationUrl) { 48 | this.applicationUrl = applicationUrl; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return ToStringBuilder.reflectionToString(this); 54 | } 55 | 56 | public Map getAdditionalProperties() { 57 | return this.additionalProperties; 58 | } 59 | 60 | public void setAdditionalProperty(String name, Object value) { 61 | this.additionalProperties.put(name, value); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Comments.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Comments { 10 | 11 | private Page page; 12 | private Map additionalProperties = new HashMap(); 13 | 14 | /** 15 | * 16 | * @return 17 | * The page 18 | */ 19 | public Page getPage() { 20 | return page; 21 | } 22 | 23 | /** 24 | * 25 | * @param page 26 | * The page 27 | */ 28 | public void setPage(Page page) { 29 | this.page = page; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return ToStringBuilder.reflectionToString(this); 35 | } 36 | 37 | public Map getAdditionalProperties() { 38 | return this.additionalProperties; 39 | } 40 | 41 | public void setAdditionalProperty(String name, Object value) { 42 | this.additionalProperties.put(name, value); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Header.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.builder.ToStringBuilder; 10 | 11 | public class Header { 12 | 13 | private Object isRichText; 14 | private List messageSegments = new ArrayList(); 15 | private String text; 16 | private Map additionalProperties = new HashMap(); 17 | 18 | /** 19 | * 20 | * @return 21 | * The isRichText 22 | */ 23 | public Object getIsRichText() { 24 | return isRichText; 25 | } 26 | 27 | /** 28 | * 29 | * @param isRichText 30 | * The isRichText 31 | */ 32 | public void setIsRichText(Object isRichText) { 33 | this.isRichText = isRichText; 34 | } 35 | 36 | /** 37 | * 38 | * @return 39 | * The messageSegments 40 | */ 41 | public List getMessageSegments() { 42 | return messageSegments; 43 | } 44 | 45 | /** 46 | * 47 | * @param messageSegments 48 | * The messageSegments 49 | */ 50 | public void setMessageSegments(List messageSegments) { 51 | this.messageSegments = messageSegments; 52 | } 53 | 54 | /** 55 | * 56 | * @return 57 | * The text 58 | */ 59 | public String getText() { 60 | return text; 61 | } 62 | 63 | /** 64 | * 65 | * @param text 66 | * The text 67 | */ 68 | public void setText(String text) { 69 | this.text = text; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return ToStringBuilder.reflectionToString(this); 75 | } 76 | 77 | public Map getAdditionalProperties() { 78 | return this.additionalProperties; 79 | } 80 | 81 | public void setAdditionalProperty(String name, Object value) { 82 | this.additionalProperties.put(name, value); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/MessageBody.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.chatter; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 7 | 8 | @JsonInclude(Include.NON_NULL) 9 | public class MessageBody { 10 | private List messageSegments; 11 | 12 | public List getMessageSegments() { 13 | return messageSegments; 14 | } 15 | 16 | public void setMessageSegments(List messageSegments) { 17 | this.messageSegments = messageSegments; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/MessageElement.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.chatter; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 5 | 6 | @JsonInclude(Include.NON_NULL) 7 | public class MessageElement { 8 | private String type; 9 | private String text; 10 | private String id; 11 | 12 | public String getType() { 13 | return type; 14 | } 15 | 16 | public void setType(String type) { 17 | this.type = type; 18 | } 19 | 20 | public String getText() { 21 | return text; 22 | } 23 | 24 | public void setText(String text) { 25 | this.text = text; 26 | } 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/MessageSegment.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class MessageSegment { 10 | 11 | private String text; 12 | private String type; 13 | private Map additionalProperties = new HashMap(); 14 | 15 | /** 16 | * 17 | * @return 18 | * The text 19 | */ 20 | public String getText() { 21 | return text; 22 | } 23 | 24 | /** 25 | * 26 | * @param text 27 | * The text 28 | */ 29 | public void setText(String text) { 30 | this.text = text; 31 | } 32 | 33 | /** 34 | * 35 | * @return 36 | * The type 37 | */ 38 | public String getType() { 39 | return type; 40 | } 41 | 42 | /** 43 | * 44 | * @param type 45 | * The type 46 | */ 47 | public void setType(String type) { 48 | this.type = type; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return ToStringBuilder.reflectionToString(this); 54 | } 55 | 56 | public Map getAdditionalProperties() { 57 | return this.additionalProperties; 58 | } 59 | 60 | public void setAdditionalProperty(String name, Object value) { 61 | this.additionalProperties.put(name, value); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Motif.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Motif { 10 | 11 | private String color; 12 | private String largeIconUrl; 13 | private String mediumIconUrl; 14 | private String smallIconUrl; 15 | private Object svgIconUrl; 16 | private Map additionalProperties = new HashMap(); 17 | 18 | /** 19 | * 20 | * @return 21 | * The color 22 | */ 23 | public String getColor() { 24 | return color; 25 | } 26 | 27 | /** 28 | * 29 | * @param color 30 | * The color 31 | */ 32 | public void setColor(String color) { 33 | this.color = color; 34 | } 35 | 36 | /** 37 | * 38 | * @return 39 | * The largeIconUrl 40 | */ 41 | public String getLargeIconUrl() { 42 | return largeIconUrl; 43 | } 44 | 45 | /** 46 | * 47 | * @param largeIconUrl 48 | * The largeIconUrl 49 | */ 50 | public void setLargeIconUrl(String largeIconUrl) { 51 | this.largeIconUrl = largeIconUrl; 52 | } 53 | 54 | /** 55 | * 56 | * @return 57 | * The mediumIconUrl 58 | */ 59 | public String getMediumIconUrl() { 60 | return mediumIconUrl; 61 | } 62 | 63 | /** 64 | * 65 | * @param mediumIconUrl 66 | * The mediumIconUrl 67 | */ 68 | public void setMediumIconUrl(String mediumIconUrl) { 69 | this.mediumIconUrl = mediumIconUrl; 70 | } 71 | 72 | /** 73 | * 74 | * @return 75 | * The smallIconUrl 76 | */ 77 | public String getSmallIconUrl() { 78 | return smallIconUrl; 79 | } 80 | 81 | /** 82 | * 83 | * @param smallIconUrl 84 | * The smallIconUrl 85 | */ 86 | public void setSmallIconUrl(String smallIconUrl) { 87 | this.smallIconUrl = smallIconUrl; 88 | } 89 | 90 | /** 91 | * 92 | * @return 93 | * The svgIconUrl 94 | */ 95 | public Object getSvgIconUrl() { 96 | return svgIconUrl; 97 | } 98 | 99 | /** 100 | * 101 | * @param svgIconUrl 102 | * The svgIconUrl 103 | */ 104 | public void setSvgIconUrl(Object svgIconUrl) { 105 | this.svgIconUrl = svgIconUrl; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return ToStringBuilder.reflectionToString(this); 111 | } 112 | 113 | public Map getAdditionalProperties() { 114 | return this.additionalProperties; 115 | } 116 | 117 | public void setAdditionalProperty(String name, Object value) { 118 | this.additionalProperties.put(name, value); 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Mute.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Mute { 10 | 11 | private boolean isMutedByMe; 12 | private Map additionalProperties = new HashMap(); 13 | 14 | /** 15 | * 16 | * @return 17 | * The isMutedByMe 18 | */ 19 | public boolean isIsMutedByMe() { 20 | return isMutedByMe; 21 | } 22 | 23 | /** 24 | * 25 | * @param isMutedByMe 26 | * The isMutedByMe 27 | */ 28 | public void setIsMutedByMe(boolean isMutedByMe) { 29 | this.isMutedByMe = isMutedByMe; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return ToStringBuilder.reflectionToString(this); 35 | } 36 | 37 | public Map getAdditionalProperties() { 38 | return this.additionalProperties; 39 | } 40 | 41 | public void setAdditionalProperty(String name, Object value) { 42 | this.additionalProperties.put(name, value); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Page.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.builder.ToStringBuilder; 10 | 11 | public class Page { 12 | 13 | private String currentPageUrl; 14 | private List items = new ArrayList(); 15 | private Object nextPageUrl; 16 | private Object previousPageUrl; 17 | private int total; 18 | private Map additionalProperties = new HashMap(); 19 | 20 | /** 21 | * 22 | * @return 23 | * The currentPageUrl 24 | */ 25 | public String getCurrentPageUrl() { 26 | return currentPageUrl; 27 | } 28 | 29 | /** 30 | * 31 | * @param currentPageUrl 32 | * The currentPageUrl 33 | */ 34 | public void setCurrentPageUrl(String currentPageUrl) { 35 | this.currentPageUrl = currentPageUrl; 36 | } 37 | 38 | /** 39 | * 40 | * @return 41 | * The items 42 | */ 43 | public List getItems() { 44 | return items; 45 | } 46 | 47 | /** 48 | * 49 | * @param items 50 | * The items 51 | */ 52 | public void setItems(List items) { 53 | this.items = items; 54 | } 55 | 56 | /** 57 | * 58 | * @return 59 | * The nextPageUrl 60 | */ 61 | public Object getNextPageUrl() { 62 | return nextPageUrl; 63 | } 64 | 65 | /** 66 | * 67 | * @param nextPageUrl 68 | * The nextPageUrl 69 | */ 70 | public void setNextPageUrl(Object nextPageUrl) { 71 | this.nextPageUrl = nextPageUrl; 72 | } 73 | 74 | /** 75 | * 76 | * @return 77 | * The previousPageUrl 78 | */ 79 | public Object getPreviousPageUrl() { 80 | return previousPageUrl; 81 | } 82 | 83 | /** 84 | * 85 | * @param previousPageUrl 86 | * The previousPageUrl 87 | */ 88 | public void setPreviousPageUrl(Object previousPageUrl) { 89 | this.previousPageUrl = previousPageUrl; 90 | } 91 | 92 | /** 93 | * 94 | * @return 95 | * The total 96 | */ 97 | public int getTotal() { 98 | return total; 99 | } 100 | 101 | /** 102 | * 103 | * @param total 104 | * The total 105 | */ 106 | public void setTotal(int total) { 107 | this.total = total; 108 | } 109 | 110 | @Override 111 | public String toString() { 112 | return ToStringBuilder.reflectionToString(this); 113 | } 114 | 115 | public Map getAdditionalProperties() { 116 | return this.additionalProperties; 117 | } 118 | 119 | public void setAdditionalProperty(String name, Object value) { 120 | this.additionalProperties.put(name, value); 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Parent.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Parent { 10 | 11 | private String id; 12 | private Motif motif; 13 | private Object mySubscription; 14 | private String name; 15 | private String type; 16 | private String url; 17 | private Map additionalProperties = new HashMap(); 18 | 19 | /** 20 | * 21 | * @return 22 | * The id 23 | */ 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | /** 29 | * 30 | * @param id 31 | * The id 32 | */ 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | /** 38 | * 39 | * @return 40 | * The motif 41 | */ 42 | public Motif getMotif() { 43 | return motif; 44 | } 45 | 46 | /** 47 | * 48 | * @param motif 49 | * The motif 50 | */ 51 | public void setMotif(Motif motif) { 52 | this.motif = motif; 53 | } 54 | 55 | /** 56 | * 57 | * @return 58 | * The mySubscription 59 | */ 60 | public Object getMySubscription() { 61 | return mySubscription; 62 | } 63 | 64 | /** 65 | * 66 | * @param mySubscription 67 | * The mySubscription 68 | */ 69 | public void setMySubscription(Object mySubscription) { 70 | this.mySubscription = mySubscription; 71 | } 72 | 73 | /** 74 | * 75 | * @return 76 | * The name 77 | */ 78 | public String getName() { 79 | return name; 80 | } 81 | 82 | /** 83 | * 84 | * @param name 85 | * The name 86 | */ 87 | public void setName(String name) { 88 | this.name = name; 89 | } 90 | 91 | /** 92 | * 93 | * @return 94 | * The type 95 | */ 96 | public String getType() { 97 | return type; 98 | } 99 | 100 | /** 101 | * 102 | * @param type 103 | * The type 104 | */ 105 | public void setType(String type) { 106 | this.type = type; 107 | } 108 | 109 | /** 110 | * 111 | * @return 112 | * The url 113 | */ 114 | public String getUrl() { 115 | return url; 116 | } 117 | 118 | /** 119 | * 120 | * @param url 121 | * The url 122 | */ 123 | public void setUrl(String url) { 124 | this.url = url; 125 | } 126 | 127 | @Override 128 | public String toString() { 129 | return ToStringBuilder.reflectionToString(this); 130 | } 131 | 132 | public Map getAdditionalProperties() { 133 | return this.additionalProperties; 134 | } 135 | 136 | public void setAdditionalProperty(String name, Object value) { 137 | this.additionalProperties.put(name, value); 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Photo.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Photo { 10 | 11 | private String fullEmailPhotoUrl; 12 | private String largePhotoUrl; 13 | private Object photoVersionId; 14 | private String smallPhotoUrl; 15 | private String standardEmailPhotoUrl; 16 | private String url; 17 | private Map additionalProperties = new HashMap(); 18 | 19 | /** 20 | * 21 | * @return 22 | * The fullEmailPhotoUrl 23 | */ 24 | public String getFullEmailPhotoUrl() { 25 | return fullEmailPhotoUrl; 26 | } 27 | 28 | /** 29 | * 30 | * @param fullEmailPhotoUrl 31 | * The fullEmailPhotoUrl 32 | */ 33 | public void setFullEmailPhotoUrl(String fullEmailPhotoUrl) { 34 | this.fullEmailPhotoUrl = fullEmailPhotoUrl; 35 | } 36 | 37 | /** 38 | * 39 | * @return 40 | * The largePhotoUrl 41 | */ 42 | public String getLargePhotoUrl() { 43 | return largePhotoUrl; 44 | } 45 | 46 | /** 47 | * 48 | * @param largePhotoUrl 49 | * The largePhotoUrl 50 | */ 51 | public void setLargePhotoUrl(String largePhotoUrl) { 52 | this.largePhotoUrl = largePhotoUrl; 53 | } 54 | 55 | /** 56 | * 57 | * @return 58 | * The photoVersionId 59 | */ 60 | public Object getPhotoVersionId() { 61 | return photoVersionId; 62 | } 63 | 64 | /** 65 | * 66 | * @param photoVersionId 67 | * The photoVersionId 68 | */ 69 | public void setPhotoVersionId(Object photoVersionId) { 70 | this.photoVersionId = photoVersionId; 71 | } 72 | 73 | /** 74 | * 75 | * @return 76 | * The smallPhotoUrl 77 | */ 78 | public String getSmallPhotoUrl() { 79 | return smallPhotoUrl; 80 | } 81 | 82 | /** 83 | * 84 | * @param smallPhotoUrl 85 | * The smallPhotoUrl 86 | */ 87 | public void setSmallPhotoUrl(String smallPhotoUrl) { 88 | this.smallPhotoUrl = smallPhotoUrl; 89 | } 90 | 91 | /** 92 | * 93 | * @return 94 | * The standardEmailPhotoUrl 95 | */ 96 | public String getStandardEmailPhotoUrl() { 97 | return standardEmailPhotoUrl; 98 | } 99 | 100 | /** 101 | * 102 | * @param standardEmailPhotoUrl 103 | * The standardEmailPhotoUrl 104 | */ 105 | public void setStandardEmailPhotoUrl(String standardEmailPhotoUrl) { 106 | this.standardEmailPhotoUrl = standardEmailPhotoUrl; 107 | } 108 | 109 | /** 110 | * 111 | * @return 112 | * The url 113 | */ 114 | public String getUrl() { 115 | return url; 116 | } 117 | 118 | /** 119 | * 120 | * @param url 121 | * The url 122 | */ 123 | public void setUrl(String url) { 124 | this.url = url; 125 | } 126 | 127 | @Override 128 | public String toString() { 129 | return ToStringBuilder.reflectionToString(this); 130 | } 131 | 132 | public Map getAdditionalProperties() { 133 | return this.additionalProperties; 134 | } 135 | 136 | public void setAdditionalProperty(String name, Object value) { 137 | this.additionalProperties.put(name, value); 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/PostMessageResponse.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class PostMessageResponse { 10 | 11 | private Actor actor; 12 | private Body body; 13 | private boolean canShare; 14 | private Capabilities capabilities; 15 | private ClientInfo clientInfo; 16 | private String createdDate; 17 | private boolean event; 18 | private String feedElementType; 19 | private Header header; 20 | private String id; 21 | private boolean isDeleteRestricted; 22 | private String modifiedDate; 23 | private Object originalFeedItem; 24 | private Object originalFeedItemActor; 25 | private Parent parent; 26 | private String photoUrl; 27 | private String relativeCreatedDate; 28 | private String type; 29 | private String url; 30 | private String visibility; 31 | private Map additionalProperties = new HashMap(); 32 | 33 | /** 34 | * 35 | * @return 36 | * The actor 37 | */ 38 | public Actor getActor() { 39 | return actor; 40 | } 41 | 42 | /** 43 | * 44 | * @param actor 45 | * The actor 46 | */ 47 | public void setActor(Actor actor) { 48 | this.actor = actor; 49 | } 50 | 51 | /** 52 | * 53 | * @return 54 | * The body 55 | */ 56 | public Body getBody() { 57 | return body; 58 | } 59 | 60 | /** 61 | * 62 | * @param body 63 | * The body 64 | */ 65 | public void setBody(Body body) { 66 | this.body = body; 67 | } 68 | 69 | /** 70 | * 71 | * @return 72 | * The canShare 73 | */ 74 | public boolean isCanShare() { 75 | return canShare; 76 | } 77 | 78 | /** 79 | * 80 | * @param canShare 81 | * The canShare 82 | */ 83 | public void setCanShare(boolean canShare) { 84 | this.canShare = canShare; 85 | } 86 | 87 | /** 88 | * 89 | * @return 90 | * The capabilities 91 | */ 92 | public Capabilities getCapabilities() { 93 | return capabilities; 94 | } 95 | 96 | /** 97 | * 98 | * @param capabilities 99 | * The capabilities 100 | */ 101 | public void setCapabilities(Capabilities capabilities) { 102 | this.capabilities = capabilities; 103 | } 104 | 105 | /** 106 | * 107 | * @return 108 | * The clientInfo 109 | */ 110 | public ClientInfo getClientInfo() { 111 | return clientInfo; 112 | } 113 | 114 | /** 115 | * 116 | * @param clientInfo 117 | * The clientInfo 118 | */ 119 | public void setClientInfo(ClientInfo clientInfo) { 120 | this.clientInfo = clientInfo; 121 | } 122 | 123 | /** 124 | * 125 | * @return 126 | * The createdDate 127 | */ 128 | public String getCreatedDate() { 129 | return createdDate; 130 | } 131 | 132 | /** 133 | * 134 | * @param createdDate 135 | * The createdDate 136 | */ 137 | public void setCreatedDate(String createdDate) { 138 | this.createdDate = createdDate; 139 | } 140 | 141 | /** 142 | * 143 | * @return 144 | * The event 145 | */ 146 | public boolean isEvent() { 147 | return event; 148 | } 149 | 150 | /** 151 | * 152 | * @param event 153 | * The event 154 | */ 155 | public void setEvent(boolean event) { 156 | this.event = event; 157 | } 158 | 159 | /** 160 | * 161 | * @return 162 | * The feedElementType 163 | */ 164 | public String getFeedElementType() { 165 | return feedElementType; 166 | } 167 | 168 | /** 169 | * 170 | * @param feedElementType 171 | * The feedElementType 172 | */ 173 | public void setFeedElementType(String feedElementType) { 174 | this.feedElementType = feedElementType; 175 | } 176 | 177 | /** 178 | * 179 | * @return 180 | * The header 181 | */ 182 | public Header getHeader() { 183 | return header; 184 | } 185 | 186 | /** 187 | * 188 | * @param header 189 | * The header 190 | */ 191 | public void setHeader(Header header) { 192 | this.header = header; 193 | } 194 | 195 | /** 196 | * 197 | * @return 198 | * The id 199 | */ 200 | public String getId() { 201 | return id; 202 | } 203 | 204 | /** 205 | * 206 | * @param id 207 | * The id 208 | */ 209 | public void setId(String id) { 210 | this.id = id; 211 | } 212 | 213 | /** 214 | * 215 | * @return 216 | * The isDeleteRestricted 217 | */ 218 | public boolean isIsDeleteRestricted() { 219 | return isDeleteRestricted; 220 | } 221 | 222 | /** 223 | * 224 | * @param isDeleteRestricted 225 | * The isDeleteRestricted 226 | */ 227 | public void setIsDeleteRestricted(boolean isDeleteRestricted) { 228 | this.isDeleteRestricted = isDeleteRestricted; 229 | } 230 | 231 | /** 232 | * 233 | * @return 234 | * The modifiedDate 235 | */ 236 | public String getModifiedDate() { 237 | return modifiedDate; 238 | } 239 | 240 | /** 241 | * 242 | * @param modifiedDate 243 | * The modifiedDate 244 | */ 245 | public void setModifiedDate(String modifiedDate) { 246 | this.modifiedDate = modifiedDate; 247 | } 248 | 249 | /** 250 | * 251 | * @return 252 | * The originalFeedItem 253 | */ 254 | public Object getOriginalFeedItem() { 255 | return originalFeedItem; 256 | } 257 | 258 | /** 259 | * 260 | * @param originalFeedItem 261 | * The originalFeedItem 262 | */ 263 | public void setOriginalFeedItem(Object originalFeedItem) { 264 | this.originalFeedItem = originalFeedItem; 265 | } 266 | 267 | /** 268 | * 269 | * @return 270 | * The originalFeedItemActor 271 | */ 272 | public Object getOriginalFeedItemActor() { 273 | return originalFeedItemActor; 274 | } 275 | 276 | /** 277 | * 278 | * @param originalFeedItemActor 279 | * The originalFeedItemActor 280 | */ 281 | public void setOriginalFeedItemActor(Object originalFeedItemActor) { 282 | this.originalFeedItemActor = originalFeedItemActor; 283 | } 284 | 285 | /** 286 | * 287 | * @return 288 | * The parent 289 | */ 290 | public Parent getParent() { 291 | return parent; 292 | } 293 | 294 | /** 295 | * 296 | * @param parent 297 | * The parent 298 | */ 299 | public void setParent(Parent parent) { 300 | this.parent = parent; 301 | } 302 | 303 | /** 304 | * 305 | * @return 306 | * The photoUrl 307 | */ 308 | public String getPhotoUrl() { 309 | return photoUrl; 310 | } 311 | 312 | /** 313 | * 314 | * @param photoUrl 315 | * The photoUrl 316 | */ 317 | public void setPhotoUrl(String photoUrl) { 318 | this.photoUrl = photoUrl; 319 | } 320 | 321 | /** 322 | * 323 | * @return 324 | * The relativeCreatedDate 325 | */ 326 | public String getRelativeCreatedDate() { 327 | return relativeCreatedDate; 328 | } 329 | 330 | /** 331 | * 332 | * @param relativeCreatedDate 333 | * The relativeCreatedDate 334 | */ 335 | public void setRelativeCreatedDate(String relativeCreatedDate) { 336 | this.relativeCreatedDate = relativeCreatedDate; 337 | } 338 | 339 | /** 340 | * 341 | * @return 342 | * The type 343 | */ 344 | public String getType() { 345 | return type; 346 | } 347 | 348 | /** 349 | * 350 | * @param type 351 | * The type 352 | */ 353 | public void setType(String type) { 354 | this.type = type; 355 | } 356 | 357 | /** 358 | * 359 | * @return 360 | * The url 361 | */ 362 | public String getUrl() { 363 | return url; 364 | } 365 | 366 | /** 367 | * 368 | * @param url 369 | * The url 370 | */ 371 | public void setUrl(String url) { 372 | this.url = url; 373 | } 374 | 375 | /** 376 | * 377 | * @return 378 | * The visibility 379 | */ 380 | public String getVisibility() { 381 | return visibility; 382 | } 383 | 384 | /** 385 | * 386 | * @param visibility 387 | * The visibility 388 | */ 389 | public void setVisibility(String visibility) { 390 | this.visibility = visibility; 391 | } 392 | 393 | @Override 394 | public String toString() { 395 | return ToStringBuilder.reflectionToString(this); 396 | } 397 | 398 | public Map getAdditionalProperties() { 399 | return this.additionalProperties; 400 | } 401 | 402 | public void setAdditionalProperty(String name, Object value) { 403 | this.additionalProperties.put(name, value); 404 | } 405 | 406 | } 407 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Reference.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | public class Reference { 10 | 11 | private String id; 12 | private String url; 13 | private Map additionalProperties = new HashMap(); 14 | 15 | /** 16 | * 17 | * @return 18 | * The id 19 | */ 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | /** 25 | * 26 | * @param id 27 | * The id 28 | */ 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | /** 34 | * 35 | * @return 36 | * The url 37 | */ 38 | public String getUrl() { 39 | return url; 40 | } 41 | 42 | /** 43 | * 44 | * @param url 45 | * The url 46 | */ 47 | public void setUrl(String url) { 48 | this.url = url; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return ToStringBuilder.reflectionToString(this); 54 | } 55 | 56 | public Map getAdditionalProperties() { 57 | return this.additionalProperties; 58 | } 59 | 60 | public void setAdditionalProperty(String name, Object value) { 61 | this.additionalProperties.put(name, value); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/chatter/Topics.java: -------------------------------------------------------------------------------- 1 | 2 | package com.springml.salesforce.wave.model.chatter; 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.apache.commons.lang3.builder.ToStringBuilder; 10 | 11 | public class Topics { 12 | 13 | private boolean canAssignTopics; 14 | private List items = new ArrayList(); 15 | private Map additionalProperties = new HashMap(); 16 | 17 | /** 18 | * 19 | * @return 20 | * The canAssignTopics 21 | */ 22 | public boolean isCanAssignTopics() { 23 | return canAssignTopics; 24 | } 25 | 26 | /** 27 | * 28 | * @param canAssignTopics 29 | * The canAssignTopics 30 | */ 31 | public void setCanAssignTopics(boolean canAssignTopics) { 32 | this.canAssignTopics = canAssignTopics; 33 | } 34 | 35 | /** 36 | * 37 | * @return 38 | * The items 39 | */ 40 | public List getItems() { 41 | return items; 42 | } 43 | 44 | /** 45 | * 46 | * @param items 47 | * The items 48 | */ 49 | public void setItems(List items) { 50 | this.items = items; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | public Map getAdditionalProperties() { 59 | return this.additionalProperties; 60 | } 61 | 62 | public void setAdditionalProperty(String name, Object value) { 63 | this.additionalProperties.put(name, value); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/CreatedBy.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "id", 11 | "name", 12 | "profilePhotoUrl" 13 | }) 14 | public class CreatedBy { 15 | 16 | @JsonProperty("id") 17 | private String id; 18 | @JsonProperty("name") 19 | private String name; 20 | @JsonProperty("profilePhotoUrl") 21 | private String profilePhotoUrl; 22 | 23 | @JsonProperty("id") 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | @JsonProperty("id") 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | @JsonProperty("name") 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | @JsonProperty("name") 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @JsonProperty("profilePhotoUrl") 44 | public String getProfilePhotoUrl() { 45 | return profilePhotoUrl; 46 | } 47 | 48 | @JsonProperty("profilePhotoUrl") 49 | public void setProfilePhotoUrl(String profilePhotoUrl) { 50 | this.profilePhotoUrl = profilePhotoUrl; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/CurrentVersionCreatedBy.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "id", 11 | "name", 12 | "profilePhotoUrl" 13 | }) 14 | public class CurrentVersionCreatedBy { 15 | 16 | @JsonProperty("id") 17 | private String id; 18 | @JsonProperty("name") 19 | private String name; 20 | @JsonProperty("profilePhotoUrl") 21 | private String profilePhotoUrl; 22 | 23 | @JsonProperty("id") 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | @JsonProperty("id") 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | @JsonProperty("name") 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | @JsonProperty("name") 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @JsonProperty("profilePhotoUrl") 44 | public String getProfilePhotoUrl() { 45 | return profilePhotoUrl; 46 | } 47 | 48 | @JsonProperty("profilePhotoUrl") 49 | public void setProfilePhotoUrl(String profilePhotoUrl) { 50 | this.profilePhotoUrl = profilePhotoUrl; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/CurrentVersionLastModifiedBy.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "id", 11 | "name", 12 | "profilePhotoUrl" 13 | }) 14 | public class CurrentVersionLastModifiedBy { 15 | 16 | @JsonProperty("id") 17 | private String id; 18 | @JsonProperty("name") 19 | private String name; 20 | @JsonProperty("profilePhotoUrl") 21 | private String profilePhotoUrl; 22 | 23 | @JsonProperty("id") 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | @JsonProperty("id") 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | @JsonProperty("name") 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | @JsonProperty("name") 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @JsonProperty("profilePhotoUrl") 44 | public String getProfilePhotoUrl() { 45 | return profilePhotoUrl; 46 | } 47 | 48 | @JsonProperty("profilePhotoUrl") 49 | public void setProfilePhotoUrl(String profilePhotoUrl) { 50 | this.profilePhotoUrl = profilePhotoUrl; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/Dataset.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "createdBy", 11 | "createdDate", 12 | "currentVersionCreatedBy", 13 | "currentVersionCreatedDate", 14 | "currentVersionId", 15 | "currentVersionLastModifiedBy", 16 | "currentVersionLastModifiedDate", 17 | "currentVersionUrl", 18 | "folder", 19 | "id", 20 | "label", 21 | "lastAccessedDate", 22 | "lastModifiedBy", 23 | "lastModifiedDate", 24 | "name", 25 | "permissions", 26 | "type", 27 | "url", 28 | "versionsUrl" 29 | }) 30 | public class Dataset { 31 | 32 | @JsonProperty("createdBy") 33 | private CreatedBy createdBy; 34 | @JsonProperty("createdDate") 35 | private String createdDate; 36 | @JsonProperty("currentVersionCreatedBy") 37 | private CurrentVersionCreatedBy currentVersionCreatedBy; 38 | @JsonProperty("currentVersionCreatedDate") 39 | private String currentVersionCreatedDate; 40 | @JsonProperty("currentVersionId") 41 | private String currentVersionId; 42 | @JsonProperty("currentVersionLastModifiedBy") 43 | private CurrentVersionLastModifiedBy currentVersionLastModifiedBy; 44 | @JsonProperty("currentVersionLastModifiedDate") 45 | private String currentVersionLastModifiedDate; 46 | @JsonProperty("currentVersionUrl") 47 | private String currentVersionUrl; 48 | @JsonProperty("folder") 49 | private Folder folder; 50 | @JsonProperty("id") 51 | private String id; 52 | @JsonProperty("label") 53 | private String label; 54 | @JsonProperty("lastAccessedDate") 55 | private String lastAccessedDate; 56 | @JsonProperty("lastModifiedBy") 57 | private LastModifiedBy lastModifiedBy; 58 | @JsonProperty("lastModifiedDate") 59 | private String lastModifiedDate; 60 | @JsonProperty("name") 61 | private String name; 62 | @JsonProperty("permissions") 63 | private Permissions permissions; 64 | @JsonProperty("type") 65 | private String type; 66 | @JsonProperty("url") 67 | private String url; 68 | @JsonProperty("versionsUrl") 69 | private String versionsUrl; 70 | 71 | @JsonProperty("createdBy") 72 | public CreatedBy getCreatedBy() { 73 | return createdBy; 74 | } 75 | 76 | @JsonProperty("createdBy") 77 | public void setCreatedBy(CreatedBy createdBy) { 78 | this.createdBy = createdBy; 79 | } 80 | 81 | @JsonProperty("createdDate") 82 | public String getCreatedDate() { 83 | return createdDate; 84 | } 85 | 86 | @JsonProperty("createdDate") 87 | public void setCreatedDate(String createdDate) { 88 | this.createdDate = createdDate; 89 | } 90 | 91 | @JsonProperty("currentVersionCreatedBy") 92 | public CurrentVersionCreatedBy getCurrentVersionCreatedBy() { 93 | return currentVersionCreatedBy; 94 | } 95 | 96 | @JsonProperty("currentVersionCreatedBy") 97 | public void setCurrentVersionCreatedBy(CurrentVersionCreatedBy currentVersionCreatedBy) { 98 | this.currentVersionCreatedBy = currentVersionCreatedBy; 99 | } 100 | 101 | @JsonProperty("currentVersionCreatedDate") 102 | public String getCurrentVersionCreatedDate() { 103 | return currentVersionCreatedDate; 104 | } 105 | 106 | @JsonProperty("currentVersionCreatedDate") 107 | public void setCurrentVersionCreatedDate(String currentVersionCreatedDate) { 108 | this.currentVersionCreatedDate = currentVersionCreatedDate; 109 | } 110 | 111 | @JsonProperty("currentVersionId") 112 | public String getCurrentVersionId() { 113 | return currentVersionId; 114 | } 115 | 116 | @JsonProperty("currentVersionId") 117 | public void setCurrentVersionId(String currentVersionId) { 118 | this.currentVersionId = currentVersionId; 119 | } 120 | 121 | @JsonProperty("currentVersionLastModifiedBy") 122 | public CurrentVersionLastModifiedBy getCurrentVersionLastModifiedBy() { 123 | return currentVersionLastModifiedBy; 124 | } 125 | 126 | @JsonProperty("currentVersionLastModifiedBy") 127 | public void setCurrentVersionLastModifiedBy(CurrentVersionLastModifiedBy currentVersionLastModifiedBy) { 128 | this.currentVersionLastModifiedBy = currentVersionLastModifiedBy; 129 | } 130 | 131 | @JsonProperty("currentVersionLastModifiedDate") 132 | public String getCurrentVersionLastModifiedDate() { 133 | return currentVersionLastModifiedDate; 134 | } 135 | 136 | @JsonProperty("currentVersionLastModifiedDate") 137 | public void setCurrentVersionLastModifiedDate(String currentVersionLastModifiedDate) { 138 | this.currentVersionLastModifiedDate = currentVersionLastModifiedDate; 139 | } 140 | 141 | @JsonProperty("currentVersionUrl") 142 | public String getCurrentVersionUrl() { 143 | return currentVersionUrl; 144 | } 145 | 146 | @JsonProperty("currentVersionUrl") 147 | public void setCurrentVersionUrl(String currentVersionUrl) { 148 | this.currentVersionUrl = currentVersionUrl; 149 | } 150 | 151 | @JsonProperty("folder") 152 | public Folder getFolder() { 153 | return folder; 154 | } 155 | 156 | @JsonProperty("folder") 157 | public void setFolder(Folder folder) { 158 | this.folder = folder; 159 | } 160 | 161 | @JsonProperty("id") 162 | public String getId() { 163 | return id; 164 | } 165 | 166 | @JsonProperty("id") 167 | public void setId(String id) { 168 | this.id = id; 169 | } 170 | 171 | @JsonProperty("label") 172 | public String getLabel() { 173 | return label; 174 | } 175 | 176 | @JsonProperty("label") 177 | public void setLabel(String label) { 178 | this.label = label; 179 | } 180 | 181 | @JsonProperty("lastAccessedDate") 182 | public String getLastAccessedDate() { 183 | return lastAccessedDate; 184 | } 185 | 186 | @JsonProperty("lastAccessedDate") 187 | public void setLastAccessedDate(String lastAccessedDate) { 188 | this.lastAccessedDate = lastAccessedDate; 189 | } 190 | 191 | @JsonProperty("lastModifiedBy") 192 | public LastModifiedBy getLastModifiedBy() { 193 | return lastModifiedBy; 194 | } 195 | 196 | @JsonProperty("lastModifiedBy") 197 | public void setLastModifiedBy(LastModifiedBy lastModifiedBy) { 198 | this.lastModifiedBy = lastModifiedBy; 199 | } 200 | 201 | @JsonProperty("lastModifiedDate") 202 | public String getLastModifiedDate() { 203 | return lastModifiedDate; 204 | } 205 | 206 | @JsonProperty("lastModifiedDate") 207 | public void setLastModifiedDate(String lastModifiedDate) { 208 | this.lastModifiedDate = lastModifiedDate; 209 | } 210 | 211 | @JsonProperty("name") 212 | public String getName() { 213 | return name; 214 | } 215 | 216 | @JsonProperty("name") 217 | public void setName(String name) { 218 | this.name = name; 219 | } 220 | 221 | @JsonProperty("permissions") 222 | public Permissions getPermissions() { 223 | return permissions; 224 | } 225 | 226 | @JsonProperty("permissions") 227 | public void setPermissions(Permissions permissions) { 228 | this.permissions = permissions; 229 | } 230 | 231 | @JsonProperty("type") 232 | public String getType() { 233 | return type; 234 | } 235 | 236 | @JsonProperty("type") 237 | public void setType(String type) { 238 | this.type = type; 239 | } 240 | 241 | @JsonProperty("url") 242 | public String getUrl() { 243 | return url; 244 | } 245 | 246 | @JsonProperty("url") 247 | public void setUrl(String url) { 248 | this.url = url; 249 | } 250 | 251 | @JsonProperty("versionsUrl") 252 | public String getVersionsUrl() { 253 | return versionsUrl; 254 | } 255 | 256 | @JsonProperty("versionsUrl") 257 | public void setVersionsUrl(String versionsUrl) { 258 | this.versionsUrl = versionsUrl; 259 | } 260 | 261 | @Override 262 | public String toString() { 263 | return ToStringBuilder.reflectionToString(this); 264 | } 265 | 266 | } 267 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/DatasetsResponse.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import java.util.List; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 7 | import org.apache.commons.lang3.builder.ToStringBuilder; 8 | 9 | @JsonInclude(JsonInclude.Include.NON_NULL) 10 | @JsonPropertyOrder({ 11 | "datasets", 12 | "nextPageUrl", 13 | "totalSize", 14 | "url" 15 | }) 16 | public class DatasetsResponse { 17 | 18 | @JsonProperty("datasets") 19 | private List datasets = null; 20 | @JsonProperty("nextPageUrl") 21 | private Object nextPageUrl; 22 | @JsonProperty("totalSize") 23 | private Integer totalSize; 24 | @JsonProperty("url") 25 | private String url; 26 | 27 | @JsonProperty("datasets") 28 | public List getDatasets() { 29 | return datasets; 30 | } 31 | 32 | @JsonProperty("datasets") 33 | public void setDatasets(List datasets) { 34 | this.datasets = datasets; 35 | } 36 | 37 | @JsonProperty("nextPageUrl") 38 | public Object getNextPageUrl() { 39 | return nextPageUrl; 40 | } 41 | 42 | @JsonProperty("nextPageUrl") 43 | public void setNextPageUrl(Object nextPageUrl) { 44 | this.nextPageUrl = nextPageUrl; 45 | } 46 | 47 | @JsonProperty("totalSize") 48 | public Integer getTotalSize() { 49 | return totalSize; 50 | } 51 | 52 | @JsonProperty("totalSize") 53 | public void setTotalSize(Integer totalSize) { 54 | this.totalSize = totalSize; 55 | } 56 | 57 | @JsonProperty("url") 58 | public String getUrl() { 59 | return url; 60 | } 61 | 62 | @JsonProperty("url") 63 | public void setUrl(String url) { 64 | this.url = url; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return ToStringBuilder.reflectionToString(this); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/Folder.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "id", 11 | "label", 12 | "name", 13 | "url" 14 | }) 15 | public class Folder { 16 | 17 | @JsonProperty("id") 18 | private String id; 19 | @JsonProperty("label") 20 | private String label; 21 | @JsonProperty("name") 22 | private String name; 23 | @JsonProperty("url") 24 | private String url; 25 | 26 | @JsonProperty("id") 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | @JsonProperty("id") 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | @JsonProperty("label") 37 | public String getLabel() { 38 | return label; 39 | } 40 | 41 | @JsonProperty("label") 42 | public void setLabel(String label) { 43 | this.label = label; 44 | } 45 | 46 | @JsonProperty("name") 47 | public String getName() { 48 | return name; 49 | } 50 | 51 | @JsonProperty("name") 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | @JsonProperty("url") 57 | public String getUrl() { 58 | return url; 59 | } 60 | 61 | @JsonProperty("url") 62 | public void setUrl(String url) { 63 | this.url = url; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return ToStringBuilder.reflectionToString(this); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/LastModifiedBy.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "id", 11 | "name", 12 | "profilePhotoUrl" 13 | }) 14 | public class LastModifiedBy { 15 | 16 | @JsonProperty("id") 17 | private String id; 18 | @JsonProperty("name") 19 | private String name; 20 | @JsonProperty("profilePhotoUrl") 21 | private String profilePhotoUrl; 22 | 23 | @JsonProperty("id") 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | @JsonProperty("id") 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | @JsonProperty("name") 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | @JsonProperty("name") 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @JsonProperty("profilePhotoUrl") 44 | public String getProfilePhotoUrl() { 45 | return profilePhotoUrl; 46 | } 47 | 48 | @JsonProperty("profilePhotoUrl") 49 | public void setProfilePhotoUrl(String profilePhotoUrl) { 50 | this.profilePhotoUrl = profilePhotoUrl; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/model/dataset/Permissions.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.model.dataset; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 6 | import org.apache.commons.lang3.builder.ToStringBuilder; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | @JsonPropertyOrder({ 10 | "manage", 11 | "modify", 12 | "view" 13 | }) 14 | public class Permissions { 15 | 16 | @JsonProperty("manage") 17 | private Boolean manage; 18 | @JsonProperty("modify") 19 | private Boolean modify; 20 | @JsonProperty("view") 21 | private Boolean view; 22 | 23 | @JsonProperty("manage") 24 | public Boolean getManage() { 25 | return manage; 26 | } 27 | 28 | @JsonProperty("manage") 29 | public void setManage(Boolean manage) { 30 | this.manage = manage; 31 | } 32 | 33 | @JsonProperty("modify") 34 | public Boolean getModify() { 35 | return modify; 36 | } 37 | 38 | @JsonProperty("modify") 39 | public void setModify(Boolean modify) { 40 | this.modify = modify; 41 | } 42 | 43 | @JsonProperty("view") 44 | public Boolean getView() { 45 | return view; 46 | } 47 | 48 | @JsonProperty("view") 49 | public void setView(Boolean view) { 50 | this.view = view; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ToStringBuilder.reflectionToString(this); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/util/HTTPHelper.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.util; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.io.InputStream; 6 | import java.net.URI; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import org.apache.commons.io.IOUtils; 11 | import org.apache.http.Header; 12 | import org.apache.http.HttpEntity; 13 | import org.apache.http.HttpStatus; 14 | import org.apache.http.client.config.RequestConfig; 15 | import org.apache.http.client.methods.CloseableHttpResponse; 16 | import org.apache.http.client.methods.HttpGet; 17 | import org.apache.http.client.methods.HttpPost; 18 | import org.apache.http.client.methods.HttpUriRequest; 19 | import org.apache.http.entity.StringEntity; 20 | import org.apache.http.impl.client.CloseableHttpClient; 21 | import org.apache.http.impl.client.HttpClients; 22 | import org.apache.log4j.Logger; 23 | 24 | /** 25 | * Helper class for HTTP requests 26 | */ 27 | public class HTTPHelper { 28 | private static final Logger LOG = Logger.getLogger(HTTPHelper.class); 29 | 30 | public String post(URI uri, String sessionId, String request) throws Exception { 31 | return post(uri, sessionId, request, CONTENT_TYPE_APPLICATION_JSON, false); 32 | } 33 | 34 | public String post(URI uri, String sessionId, String request, boolean isBulk) throws Exception { 35 | return post(uri, sessionId, request, CONTENT_TYPE_APPLICATION_JSON, isBulk); 36 | } 37 | 38 | public String post(URI uri, String sessionId, String request, boolean isBulk, List
customHeaders) throws Exception { 39 | return post(uri, sessionId, request, CONTENT_TYPE_APPLICATION_JSON, isBulk, customHeaders); 40 | } 41 | 42 | public String post(URI uri, String sessionId, String request, String contentType, boolean isBulk) throws Exception { 43 | return post(uri, sessionId, request, contentType, isBulk, new ArrayList
()); 44 | } 45 | 46 | public String post(URI uri, String sessionId, String request, String contentType, boolean isBulk, List
customHeaders) throws Exception { 47 | LOG.info("Executing POST request on " + uri); 48 | LOG.debug("Sending request " + request); 49 | LOG.debug("Content-Type " + contentType); 50 | 51 | StringEntity entity = new StringEntity(request, STR_UTF_8); 52 | if (contentType != null) { 53 | entity.setContentType(contentType); 54 | } else { 55 | LOG.debug("As Content-Type is null " + CONTENT_TYPE_APPLICATION_JSON + " Content-Type is used"); 56 | entity.setContentType(CONTENT_TYPE_APPLICATION_JSON); 57 | } 58 | 59 | HttpPost httpPost = new HttpPost(uri); 60 | httpPost.setEntity(entity); 61 | httpPost.setConfig(getRequestConfig()); 62 | 63 | for (Header customHeader : customHeaders) { 64 | httpPost.addHeader(customHeader); 65 | } 66 | 67 | if (isBulk) { 68 | httpPost.addHeader(HEADER_X_SFDC_SESSION, sessionId); 69 | } else { 70 | httpPost.addHeader(HEADER_AUTH, HEADER_OAUTH + sessionId); 71 | } 72 | 73 | return execute(uri, httpPost); 74 | } 75 | 76 | public String get(URI uri, String sessionId, Integer batchSize, boolean isBulk) throws Exception { 77 | LOG.info("Executing GET request on " + uri); 78 | HttpGet httpGet = new HttpGet(uri); 79 | httpGet.setConfig(getRequestConfig()); 80 | if (isBulk) { 81 | httpGet.addHeader(HEADER_X_SFDC_SESSION, sessionId); 82 | } else { 83 | httpGet.addHeader(HEADER_AUTH, HEADER_OAUTH + sessionId); 84 | httpGet.addHeader(HEADER_ACCEPT, CONTENT_TYPE_APPLICATION_JSON); 85 | } 86 | 87 | if (batchSize != null && batchSize != 0) { 88 | httpGet.addHeader(HEADER_SF_QUERY_OPTIONS, HEADER_BATCH_SIZE + batchSize); 89 | } 90 | 91 | return execute(uri, httpGet); 92 | } 93 | 94 | public String get(URI uri, String sessionId, Integer batchSize) throws Exception { 95 | return get(uri, sessionId, batchSize, false); 96 | } 97 | 98 | public String get(URI uri, String sessionId, boolean isBulk) throws Exception { 99 | return get(uri, sessionId, null, isBulk); 100 | } 101 | 102 | public String get(URI uri, String sessionId) throws Exception { 103 | return get(uri, sessionId, null); 104 | } 105 | 106 | private String execute(URI uri, HttpUriRequest httpReq) throws Exception { 107 | CloseableHttpClient httpClient = HttpClients.createDefault(); 108 | 109 | InputStream eis = null; 110 | try { 111 | CloseableHttpResponse response = httpClient.execute(httpReq); 112 | 113 | int statusCode = response.getStatusLine().getStatusCode(); 114 | if (!(statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED)) { 115 | String reasonPhrase = response.getStatusLine().getReasonPhrase(); 116 | String errResponse = IOUtils.toString(response.getEntity().getContent(), STR_UTF_8); 117 | throw new Exception( 118 | String.format("Accessing %s failed. Status %d. Reason %s \n Error from server %s", uri, statusCode, reasonPhrase, errResponse)); 119 | } 120 | 121 | HttpEntity responseEntity = response.getEntity(); 122 | eis = responseEntity.getContent(); 123 | return IOUtils.toString(eis, STR_UTF_8); 124 | } finally { 125 | try { 126 | if (httpClient != null) { 127 | httpClient.close(); 128 | } 129 | } catch (Exception e) { 130 | LOG.debug("Error while closing HTTP Client", e); 131 | } 132 | 133 | try { 134 | if (eis != null) { 135 | eis.close(); 136 | } 137 | } catch (Exception e) { 138 | LOG.debug("Error while closing InputStream", e); 139 | } 140 | } 141 | } 142 | 143 | public static RequestConfig getRequestConfig() { 144 | int timeout = Integer.parseInt(System.getProperty(SYS_PROPERTY_SOCKET_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT)); 145 | RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout) 146 | .setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).build(); 147 | 148 | return requestConfig; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/util/LRUCache.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.util; 2 | 3 | import java.util.LinkedHashMap; 4 | 5 | public class LRUCache extends LinkedHashMap { 6 | private static final long serialVersionUID = 7579846591074774824L; 7 | private int cacheSize; 8 | 9 | public LRUCache(int size) { 10 | super(size, 0.75f, true); 11 | this.cacheSize = size; 12 | } 13 | 14 | @Override 15 | protected boolean removeEldestEntry(java.util.Map.Entry eldest) { 16 | return size() > cacheSize; 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/util/SFConfig.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.util; 2 | 3 | import static com.springml.salesforce.wave.util.WaveAPIConstants.*; 4 | 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | import com.sforce.soap.partner.Connector; 11 | import com.sforce.soap.partner.PartnerConnection; 12 | import com.sforce.ws.ConnectionException; 13 | import com.sforce.ws.ConnectorConfig; 14 | 15 | public class SFConfig { 16 | private static final Logger LOG = Logger.getLogger(SFConfig.class); 17 | 18 | private String username; 19 | private String password; 20 | private String loginURL; 21 | private String apiVersion; 22 | private Integer batchSize; 23 | private PartnerConnection partnerConnection; 24 | private Integer maxRetry = 5; 25 | 26 | public SFConfig(String username, String password, String loginURL, 27 | String apiVersion) { 28 | this(username, password, loginURL, apiVersion, null); 29 | } 30 | 31 | public SFConfig(String username, String password, String loginURL, 32 | String apiVersion, Integer batchSize) { 33 | this.username = username; 34 | this.password = password; 35 | this.loginURL = loginURL; 36 | this.apiVersion = apiVersion; 37 | this.batchSize = batchSize; 38 | } 39 | 40 | public String getUsername() { 41 | return username; 42 | } 43 | 44 | public void setUsername(String username) { 45 | this.username = username; 46 | } 47 | 48 | public String getPassword() { 49 | return password; 50 | } 51 | 52 | public void setPassword(String password) { 53 | this.password = password; 54 | } 55 | 56 | public String getLoginURL() { 57 | return loginURL; 58 | } 59 | 60 | public void setLoginURL(String loginURL) { 61 | this.loginURL = loginURL; 62 | } 63 | 64 | public String getApiVersion() { 65 | return apiVersion; 66 | } 67 | 68 | public void setApiVersion(String apiVersion) { 69 | this.apiVersion = apiVersion; 70 | } 71 | 72 | public Integer getBatchSize() { 73 | return batchSize; 74 | } 75 | 76 | public void setBatchSize(Integer batchSize) { 77 | this.batchSize = batchSize; 78 | } 79 | 80 | public Integer getMaxRetry() { 81 | return maxRetry; 82 | } 83 | 84 | public void setMaxRetry(Integer maxRetry) { 85 | this.maxRetry = maxRetry; 86 | } 87 | 88 | public PartnerConnection getPartnerConnection() throws Exception { 89 | if (partnerConnection == null) { 90 | partnerConnection = createPartnerConnection(); 91 | } 92 | 93 | return partnerConnection; 94 | } 95 | 96 | private PartnerConnection createPartnerConnection() throws Exception { 97 | ConnectorConfig config = new ConnectorConfig(); 98 | LOG.debug("Connecting SF Partner Connection using " + username); 99 | config.setUsername(username); 100 | config.setPassword(password); 101 | String authEndpoint = getAuthEndpoint(loginURL); 102 | LOG.info("loginURL : " + authEndpoint); 103 | config.setAuthEndpoint(authEndpoint); 104 | config.setServiceEndpoint(authEndpoint); 105 | 106 | try { 107 | return Connector.newConnection(config); 108 | } catch (ConnectionException ce) { 109 | LOG.error("Exception while creating connection", ce); 110 | throw new Exception(ce); 111 | } 112 | } 113 | 114 | public String getSessionId(PartnerConnection connection) { 115 | return connection.getConfig().getSessionId(); 116 | } 117 | 118 | public String getSessionId() throws Exception { 119 | return getPartnerConnection().getConfig().getSessionId(); 120 | } 121 | 122 | public URI getRequestURI(PartnerConnection connection, String path) throws URISyntaxException { 123 | return getRequestURI(connection, path, null); 124 | } 125 | 126 | public URI getRequestURI(PartnerConnection connection, String path, String query) throws URISyntaxException { 127 | URI seURI = new URI(connection.getConfig().getServiceEndpoint()); 128 | 129 | return new URI(seURI.getScheme(),seURI.getUserInfo(), seURI.getHost(), seURI.getPort(), 130 | path, query, null); 131 | } 132 | 133 | private String getAuthEndpoint(String loginURL) throws Exception { 134 | URI loginURI = new URI(loginURL); 135 | 136 | return new URI(loginURI.getScheme(), loginURI.getUserInfo(), loginURI.getHost(), 137 | loginURI.getPort(), PATH_SOAP_ENDPOINT, null, null).toString(); 138 | } 139 | 140 | public void closeConnection() { 141 | try { 142 | if (this.partnerConnection != null) { 143 | this.partnerConnection.logout(); 144 | } 145 | } catch (Exception e) { 146 | // Ignore it 147 | } 148 | 149 | this.partnerConnection = null; 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/com/springml/salesforce/wave/util/WaveAPIConstants.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.util; 2 | 3 | public class WaveAPIConstants { 4 | public static final String STR_QUERY = "query"; 5 | public static final String STR_UTF_8 = "UTF-8"; 6 | public static final String STR_SPACE = " "; 7 | public static final String STR_EQUALS = "="; 8 | public static final String STR_SEMI_COLON = ";"; 9 | public static final String STR_LIMIT_BTW_SPACE = " limit "; 10 | public static final String STR_OFFSET_BTW_SPACE = " offset "; 11 | public static final String STR_ATTRIBUTES = "attributes"; 12 | public static final String STR_CSV = "CSV"; 13 | public static final String STR_JSON = "JSON"; 14 | public static final String STR_XML = "XML"; 15 | public static final String STR_INSERT = "insert"; 16 | public static final String STR_UPDATE = "update"; 17 | public static final String STR_CLOSED = "Closed"; 18 | public static final String STR_COMPLETED = "Completed"; 19 | public static final String STR_FAILED = "Failed"; 20 | public static final String STR_QUEUED = "Queued"; 21 | public static final String STR_IN_PROGRESS = "InProgress"; 22 | public static final String STR_NOT_PROCESSED = "Not Processed"; 23 | 24 | public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json"; 25 | public static final String CONTENT_TYPE_APPLICATION_XML = "application/xml"; 26 | public static final String CONTENT_TYPE_TEXT_CSV= "text/csv"; 27 | 28 | public static final String HEADER_ACCEPT = "Accept"; 29 | public static final String HEADER_AUTH = "Authorization"; 30 | public static final String HEADER_X_SFDC_SESSION = "X-SFDC-Session"; 31 | public static final String HEADER_OAUTH = "OAuth "; 32 | public static final String HEADER_SF_QUERY_OPTIONS = "Sforce-Query-Options"; 33 | public static final String HEADER_BATCH_SIZE = "batchSize="; 34 | 35 | public static final String SERVICE_PATH = "/services/data/"; 36 | public static final String SERVICE_ASYNC_PATH = "/services/async/"; 37 | public static final String API_VERSION = "35.0"; 38 | public static final String PATH_WAVE_QUERY = "/wave/query"; 39 | public static final String PATH_WAVE_DATASETS = "/wave/datasets"; 40 | public static final String PATH_SOAP_ENDPOINT = "/services/Soap/u/" + API_VERSION; 41 | public static final String SERVICE_PATH_WAVE_QUERY = SERVICE_PATH + "v" + API_VERSION + PATH_WAVE_QUERY; 42 | public static final String PATH_QUERY = "/query"; 43 | public static final String PATH_QUERY_ALL = "/queryAll"; 44 | public static final String PATH_SOBJECTS = "/sobjects/"; 45 | public static final String PATH_TASK = "/sobjects/task"; 46 | public static final String PATH_CHATTER = "/chatter"; 47 | public static final String PATH_FEED_ELEMENTS = "/feed-elements"; 48 | public static final String PATH_JOB = "/job"; 49 | public static final String PATH_BATCH = "/batch"; 50 | public static final String PATH_RESULT = "/result"; 51 | public static final String SERVICE_PATH_QUERY = SERVICE_PATH + "v" + API_VERSION + PATH_QUERY; 52 | public static final String QUERY_PARAM = "q="; 53 | 54 | public static final String SYS_PROPERTY_SOCKET_TIMEOUT = "com.springml.socket.timeout"; 55 | 56 | // 10 minutes 57 | public static final String DEFAULT_CONNECTION_TIMEOUT = "600000"; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/com/springml/salesforce/wave/api/APIFactoryTest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import static org.junit.Assert.*; 4 | import org.junit.Test; 5 | 6 | public class APIFactoryTest { 7 | 8 | @Test 9 | public void waveAPITest() throws Exception { 10 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("username", "password", "http://login.salesforce.com"); 11 | assertNotNull(waveAPI); 12 | } 13 | 14 | @Test 15 | public void forceAPITest() throws Exception { 16 | ForceAPI forceAPI = APIFactory.getInstance().forceAPI("username", "password", "http://login.salesforce.com"); 17 | assertNotNull(forceAPI); 18 | } 19 | 20 | @Test 21 | public void bulkAPITest() throws Exception { 22 | BulkAPI bulkAPI = APIFactory.getInstance().bulkAPI("username", "password", "http://login.salesforce.com", "36.0"); 23 | assertNotNull(bulkAPI); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/springml/salesforce/wave/api/BaseAPITest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import static org.mockito.Mockito.*; 4 | 5 | import com.fasterxml.jackson.databind.DeserializationFeature; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.sforce.soap.partner.PartnerConnection; 8 | import com.sforce.ws.ConnectionException; 9 | import com.sforce.ws.ConnectorConfig; 10 | import com.springml.salesforce.wave.util.HTTPHelper; 11 | import com.springml.salesforce.wave.util.SFConfig; 12 | 13 | public abstract class BaseAPITest { 14 | protected static final String SERVICE_ENDPOINT = "http://gs0.salesforce.com"; 15 | protected static final String SESSION_ID = "dummySessionId"; 16 | protected static final String API_VERSION = "36.0"; 17 | 18 | protected SFConfig sfConfig = null; 19 | protected HTTPHelper httpHelper = null; 20 | protected ObjectMapper objectMapper = null; 21 | protected PartnerConnectionExt conn = null; 22 | 23 | public void setup() throws Exception { 24 | conn = PartnerConnectionExt.getInstance(); 25 | 26 | sfConfig = mock(SFConfig.class); 27 | when(sfConfig.getPartnerConnection()).thenReturn(conn); 28 | when(sfConfig.getSessionId()).thenReturn(SESSION_ID); 29 | when(sfConfig.getApiVersion()).thenReturn(API_VERSION); 30 | 31 | objectMapper = new ObjectMapper(); 32 | objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 33 | objectMapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE); 34 | } 35 | 36 | public static class PartnerConnectionExt extends PartnerConnection { 37 | private ConnectorConfig config; 38 | 39 | public static PartnerConnectionExt getInstance() throws ConnectionException { 40 | ConnectorConfig config = new ConnectorConfig(); 41 | config.setUsername("dummy_sf_user"); 42 | config.setPassword("dummy_sf_password"); 43 | config.setManualLogin(true); 44 | // Salesforce SOAP API checks for /services/Soap/c/ 45 | config.setServiceEndpoint("http://dummysgendpoint/services/Soap/u/"); 46 | 47 | return new PartnerConnectionExt(config); 48 | } 49 | 50 | public PartnerConnectionExt(ConnectorConfig config) 51 | throws ConnectionException { 52 | super(config); 53 | this.config = config; 54 | } 55 | 56 | @Override 57 | public ConnectorConfig getConfig() { 58 | config.setSessionId(SESSION_ID); 59 | config.setServiceEndpoint(SERVICE_ENDPOINT); 60 | return config; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/com/springml/salesforce/wave/api/ChatterAPITest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import static org.junit.Assert.*; 4 | import static org.mockito.Matchers.*; 5 | import static org.mockito.Mockito.*; 6 | 7 | import java.io.InputStream; 8 | import java.net.URI; 9 | import java.util.Arrays; 10 | 11 | import org.apache.commons.io.IOUtils; 12 | import org.junit.Before; 13 | import org.junit.Ignore; 14 | import org.junit.Test; 15 | 16 | import com.sforce.soap.partner.PartnerConnection; 17 | import com.springml.salesforce.wave.impl.ChatterAPIImpl; 18 | import com.springml.salesforce.wave.model.PostMessageRequest; 19 | import com.springml.salesforce.wave.model.chatter.MessageBody; 20 | import com.springml.salesforce.wave.model.chatter.MessageElement; 21 | import com.springml.salesforce.wave.model.chatter.PostMessageResponse; 22 | import com.springml.salesforce.wave.util.HTTPHelper; 23 | 24 | public class ChatterAPITest extends BaseAPITest { 25 | private static final String SUBJECT_ID = "006B0000002ne2134IAA"; 26 | private static final String FEED_ELEMENT_TYPE = "FeedItem"; 27 | private static final String TEXT = "Great Opportunity"; 28 | 29 | @Before 30 | public void setup() throws Exception { 31 | super.setup(); 32 | 33 | URI uri = new URI("http://dummyhost/services/data/v36.0/chatter/feed-elements"); 34 | when(sfConfig.getRequestURI(any(PartnerConnection.class), anyString())).thenReturn(uri); 35 | 36 | InputStream postMsgJsonIS = this.getClass().getClassLoader().getResourceAsStream("post_message.json"); 37 | String responseJson = IOUtils.toString(postMsgJsonIS, "UTF-8"); 38 | httpHelper = mock(HTTPHelper.class); 39 | 40 | PostMessageRequest req = constructPostMessage(); 41 | String requestStr = objectMapper.writeValueAsString(req); 42 | when(httpHelper.post(uri, sfConfig.getSessionId(), requestStr)).thenReturn(responseJson); 43 | } 44 | 45 | @Test 46 | @Ignore 47 | public void testRealPostMessage() throws Exception { 48 | PostMessageRequest req = constructPostMessage(); 49 | 50 | ChatterAPI chatterAPI = APIFactory.getInstance().chatterAPI("testacoount@sf.com", 51 | "PASSWORDSECURITYCODE", "https://login.salesforce.com", "36.0"); 52 | 53 | PostMessageResponse postMessage = chatterAPI.postMessage(req); 54 | validate(postMessage); 55 | } 56 | 57 | @Test 58 | public void testPostMessage() throws Exception { 59 | PostMessageRequest req = constructPostMessage(); 60 | 61 | ChatterAPI chatterAPI = APIFactory.getInstance().chatterAPI("dummyusername", 62 | "dummypassword", "https://login.salesforce.com", "36.0"); 63 | ((ChatterAPIImpl) chatterAPI).setHttpHelper(httpHelper); 64 | ((ChatterAPIImpl) chatterAPI).setSfConfig(sfConfig); 65 | ((ChatterAPIImpl) chatterAPI).setObjectMapper(objectMapper); 66 | 67 | PostMessageResponse postMessage = chatterAPI.postMessage(req); 68 | validate(postMessage); 69 | } 70 | 71 | @Test 72 | public void testSimplePostMessage() throws Exception { 73 | ChatterAPI chatterAPI = APIFactory.getInstance().chatterAPI("dummyusername", 74 | "dummypassword", "https://login.salesforce.com", "36.0"); 75 | ((ChatterAPIImpl) chatterAPI).setHttpHelper(httpHelper); 76 | ((ChatterAPIImpl) chatterAPI).setSfConfig(sfConfig); 77 | ((ChatterAPIImpl) chatterAPI).setObjectMapper(objectMapper); 78 | 79 | PostMessageResponse postMessage = chatterAPI.postMessage(SUBJECT_ID, TEXT, FEED_ELEMENT_TYPE); 80 | validate(postMessage); 81 | } 82 | 83 | private void validate(PostMessageResponse postMessage) { 84 | assertNotNull(postMessage); 85 | assertEquals(FEED_ELEMENT_TYPE, postMessage.getFeedElementType()); 86 | assertEquals(TEXT, postMessage.getBody().getText()); 87 | assertEquals("Text", postMessage.getBody().getMessageSegments().get(0).getType()); 88 | assertEquals(SUBJECT_ID, postMessage.getActor().getId()); 89 | } 90 | 91 | private PostMessageRequest constructPostMessage() { 92 | PostMessageRequest req = new PostMessageRequest(); 93 | req.setSubjectId(SUBJECT_ID); 94 | req.setFeedElementType(FEED_ELEMENT_TYPE); 95 | 96 | MessageBody postMsgBody = new MessageBody(); 97 | MessageElement messageElement = new MessageElement(); 98 | messageElement.setText(TEXT); 99 | messageElement.setType("Text"); 100 | postMsgBody.setMessageSegments(Arrays.asList(messageElement)); 101 | 102 | req.setBody(postMsgBody); 103 | return req; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/test/java/com/springml/salesforce/wave/api/WaveAPITest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.api; 2 | 3 | import static org.junit.Assert.*; 4 | import static org.mockito.Matchers.*; 5 | import static org.mockito.Mockito.*; 6 | 7 | import java.io.InputStream; 8 | import java.net.URI; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | import org.apache.commons.io.IOUtils; 13 | import org.junit.Before; 14 | import org.junit.Ignore; 15 | import org.junit.Test; 16 | 17 | import com.sforce.soap.partner.PartnerConnection; 18 | import com.springml.salesforce.wave.impl.WaveAPIImpl; 19 | import com.springml.salesforce.wave.model.QueryResult; 20 | import com.springml.salesforce.wave.model.Results; 21 | import com.springml.salesforce.wave.util.HTTPHelper; 22 | import com.springml.salesforce.wave.util.WaveAPIConstants; 23 | 24 | public class WaveAPITest extends BaseAPITest { 25 | private static final String SAQL = "q = load \"0FbB000000007qmKAA/0FcB00000000LgTKAU\"; q = group q by ('event', 'device_type'); q = foreach q generate 'event' as 'event', 'device_type' as 'device_type', count() as 'count'; q = limit q 2000;"; 26 | private static final String SAQL_QUERY_MORE = "q = load \"0Fb15000000TOLuCAO/0Fc15000000TvvCCAS\"; q = group q by ('Name', 'NPI'); q = foreach q generate 'Name' as 'Name', 'NPI' as 'My NPI', count() as 'count';"; 27 | private static final String RESPONSE_JSON = "{\"action\":\"query\",\"responseId\":\"3zj8MTVk6xJPifVeRhqeek\",\"results\":{\"records\":[{\"count\":11,\"device_type\":\"Android 4.2\",\"event\":\"Click\"},{\"count\":9,\"device_type\":\"Android 4.3.1\",\"event\":\"Click\"},{\"count\":49,\"device_type\":\"iPod\",\"event\":\"Impression\"}]},\"query\":\"q = load \\\"0FbB000000007qmKAA/0FcB00000000LgTKAU\\\"; q = group q by ('event', 'device_type'); q = foreach q generate 'event' as 'event', 'device_type' as 'device_type', count() as 'count'; q = limit q 2000;\",\"responseTime\":85}"; 28 | private static final String PAGINATED_QUERY_RESPONSE_JSON = "{\"action\":\"query\",\"responseId\":\"41F6l5blC1DT4gVUOh_zRk\",\"results\":{\"records\":[{\"My NPI\":\"0\",\"Name\":\"Pat 0\",\"count\":1},{\"My NPI\":\"1\",\"Name\":\"Pat 1\",\"count\":1}]},\"query\":\"q = load \\\"0Fb15000000TOLuCAO/0Fc15000000TvvCCAS\\\"; q = group q by ('Name', 'NPI'); q = foreach q generate 'Name' as 'Name', 'NPI' as 'My NPI', count() as 'count'; q = limit q 2;\",\"responseTime\":896}"; 29 | private static final String QUERY_MORE_RESPONSE_JSON = "{\"action\":\"query\",\"responseId\":\"41FF6eV0Xgq1FrH5ThIld-\",\"results\":{\"records\":[]},\"query\":\"q = load \\\"0Fb15000000TOLuCAO/0Fc15000000TvvCCAS\\\"; q = group q by ('Name', 'NPI'); q = foreach q generate 'Name', 'NPI', count() as 'count';q = offset q 10000000; q = limit q 100; \",\"responseTime\":19612}"; 30 | 31 | @Before 32 | public void setup() throws Exception { 33 | super.setup(); 34 | httpHelper = mock(HTTPHelper.class); 35 | when(httpHelper.post(any(URI.class), any(String.class), any(String.class))) 36 | .thenReturn(RESPONSE_JSON); 37 | } 38 | 39 | @Test 40 | @Ignore("This can be only executed with actual salesforce username and password") 41 | public void testQueryWithoutMock() throws Exception { 42 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("xxx@xxx.com", 43 | "***", "https://login.salesforce.com"); 44 | 45 | QueryResult result = waveAPI.query(SAQL); 46 | System.out.println(result.getResults().getRecords().get(0).get("count")); 47 | System.out.println("result : " + result); 48 | assertEquals(12, result.getResults().getRecords().size()); 49 | assertEquals("11", result.getResults().getRecords().get(0).get("count")); 50 | } 51 | 52 | @Test 53 | public void testQuery() throws Exception { 54 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("dummyusername", 55 | "dummypassword", "https://login.salesforce.com"); 56 | ((WaveAPIImpl) waveAPI).setHttpHelper(httpHelper); 57 | ((WaveAPIImpl) waveAPI).setSfConfig(sfConfig); 58 | ((WaveAPIImpl) waveAPI).setObjectMapper(objectMapper); 59 | 60 | QueryResult result = waveAPI.query(SAQL); 61 | assertNotNull(result); 62 | Results results = result.getResults(); 63 | assertNotNull(results); 64 | List> records = results.getRecords(); 65 | assertNotNull(records); 66 | assertTrue(!records.isEmpty()); 67 | assertEquals(3, records.size()); 68 | } 69 | 70 | 71 | @Test 72 | @Ignore("This can be only executed with actual salesforce username and password") 73 | public void testQueryMoreWithoutMock() throws Exception { 74 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("xxx@xxx.com", 75 | "***", "https://login.salesforce.com"); 76 | 77 | QueryResult result = waveAPI.queryWithPagination(SAQL_QUERY_MORE, "q", 10); 78 | System.out.println("result : " + result); 79 | assertEquals(10, result.getResults().getRecords().size()); 80 | assertTrue(!result.isDone()); 81 | 82 | QueryResult queryMoreResult = waveAPI.queryMore(result); 83 | System.out.println("queryMoreResult : " + queryMoreResult); 84 | assertEquals(10, queryMoreResult.getResults().getRecords().size()); 85 | assertTrue(!queryMoreResult.isDone()); 86 | } 87 | 88 | @Test 89 | public void testQueryMore() throws Exception { 90 | when(httpHelper.post(any(URI.class), any(String.class), any(String.class))).thenReturn(PAGINATED_QUERY_RESPONSE_JSON); 91 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("dummyusername", 92 | "dummypassword", "https://login.salesforce.com"); 93 | ((WaveAPIImpl) waveAPI).setHttpHelper(httpHelper); 94 | ((WaveAPIImpl) waveAPI).setSfConfig(sfConfig); 95 | ((WaveAPIImpl) waveAPI).setObjectMapper(objectMapper); 96 | 97 | QueryResult result = waveAPI.queryWithPagination(SAQL_QUERY_MORE, "q", 2); 98 | assertNotNull(result); 99 | Results results = result.getResults(); 100 | assertNotNull(results); 101 | List> records = results.getRecords(); 102 | assertNotNull(records); 103 | assertTrue(!records.isEmpty()); 104 | assertEquals(2, records.size()); 105 | assertTrue(!result.isDone()); 106 | 107 | when(httpHelper.post(any(URI.class), any(String.class), any(String.class))).thenReturn(QUERY_MORE_RESPONSE_JSON); 108 | QueryResult queryMoreResult = waveAPI.queryMore(result); 109 | assertTrue(queryMoreResult.isDone()); 110 | } 111 | 112 | @Test 113 | public void testGetDatasetId() throws Exception { 114 | String datasetName = "Account"; 115 | String datasetEndpoint = SERVICE_ENDPOINT + "/services/data/v" + sfConfig.getApiVersion() + 116 | WaveAPIConstants.PATH_WAVE_DATASETS + "?q=" + datasetName; 117 | 118 | InputStream responseIS = this.getClass().getClassLoader().getResourceAsStream("dataset_response.json"); 119 | String response = IOUtils.toString(responseIS, "UTF-8"); 120 | 121 | when(sfConfig.getRequestURI(any(PartnerConnection.class), any(String.class))).thenCallRealMethod(); 122 | when(sfConfig.getRequestURI(any(PartnerConnection.class), any(String.class), any(String.class))).thenCallRealMethod(); 123 | when(httpHelper.get(new URI(datasetEndpoint), SESSION_ID)).thenReturn(response); 124 | 125 | WaveAPI waveAPI = APIFactory.getInstance().waveAPI("dummyusername", 126 | "dummypassword", "https://login.salesforce.com"); 127 | ((WaveAPIImpl) waveAPI).setHttpHelper(httpHelper); 128 | ((WaveAPIImpl) waveAPI).setSfConfig(sfConfig); 129 | ((WaveAPIImpl) waveAPI).setObjectMapper(objectMapper); 130 | 131 | String datasetId = waveAPI.getDatasetId(datasetName); 132 | assertNotNull(datasetId); 133 | String expectedDatasetId = "0FbB00000000KybKAE/0FcB0000000DGKeKAO"; 134 | assertEquals("DatasetId does not match", expectedDatasetId, datasetId); 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/test/java/com/springml/salesforce/wave/util/HTTPHelperTest.java: -------------------------------------------------------------------------------- 1 | package com.springml.salesforce.wave.util; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.net.URI; 6 | 7 | import org.junit.Test; 8 | 9 | /** 10 | * Simple test for {@link HTTPHelper} 11 | * 12 | */ 13 | public class HTTPHelperTest { 14 | 15 | @Test 16 | public void testPost() throws Exception { 17 | HTTPHelper httpHelper = new HTTPHelper(); 18 | String request = "{\"query\":\"q = load \\\"0FbB000000007qmKAA/0FcB00000000LgTKAU\\\"; q = group q by ('event', 'device_type'); q = foreach q generate 'event' as 'event', 'device_type' as 'device_type', count() as 'count'; q = limit q 2000;\"}"; 19 | URI requestURI = new URI("http://jsonplaceholder.typicode.com/posts"); 20 | String response = httpHelper.post(requestURI, "sessionId", request); 21 | 22 | assertTrue(response.contains("device_type")); 23 | } 24 | 25 | @Test 26 | public void testGet() throws Exception { 27 | HTTPHelper httpHelper = new HTTPHelper(); 28 | URI requestURI = new URI("http://jsonplaceholder.typicode.com/posts"); 29 | String response = httpHelper.get(requestURI, "sessionId"); 30 | 31 | assertTrue(response.contains("userId")); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/resources/dataset_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "datasets": [ 3 | { 4 | "createdBy": { 5 | "id": "005B0000001JZytIAG", 6 | "name": "Owner", 7 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 8 | }, 9 | "createdDate": "2016-01-18T14:11:44.000Z", 10 | "currentVersionCreatedBy": { 11 | "id": "005B0000001JZrrIAG", 12 | "name": "Integration User", 13 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 14 | }, 15 | "currentVersionCreatedDate": "2016-03-01T14:29:24.000Z", 16 | "currentVersionId": "0FcB0000000DGKeKAO", 17 | "currentVersionLastModifiedBy": { 18 | "id": "005B0000001JZrsIAG", 19 | "name": "Security User", 20 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 21 | }, 22 | "currentVersionLastModifiedDate": "2016-12-20T23:35:20.000Z", 23 | "currentVersionUrl": "/services/data/v38.0/wave/datasets/0FbB00000000KybKAE/versions/0FcB0000000DGKeKAO", 24 | "folder": { 25 | "id": "00lB0000000hEKXIA2", 26 | "label": "App", 27 | "name": "App", 28 | "url": "/services/data/v38.0/wave/folders/00lB0000000hEKXIA2" 29 | }, 30 | "id": "0FbB00000000KybKAE", 31 | "label": "Account", 32 | "lastAccessedDate": "2016-12-20T06:06:03.000Z", 33 | "lastModifiedBy": { 34 | "id": "005B0000001JZrsIAG", 35 | "name": "Security User", 36 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 37 | }, 38 | "lastModifiedDate": "2016-12-20T23:35:20.000Z", 39 | "name": "Account", 40 | "permissions": { 41 | "manage": true, 42 | "modify": true, 43 | "view": true 44 | }, 45 | "type": "dataset", 46 | "url": "/services/data/v38.0/wave/datasets/0FbB00000000KybKAE", 47 | "versionsUrl": "/services/data/v38.0/wave/datasets/0FbB00000000KybKAE/versions" 48 | }, 49 | { 50 | "createdBy": { 51 | "id": "005B0000001LERtIAO", 52 | "name": "Test", 53 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 54 | }, 55 | "createdDate": "2016-12-15T05:00:17.000Z", 56 | "currentVersionCreatedBy": { 57 | "id": "005B0000001JZrrIAG", 58 | "name": "Integration User", 59 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 60 | }, 61 | "currentVersionCreatedDate": "2016-12-15T05:00:21.000Z", 62 | "currentVersionId": "0FcB0000000eMIGKA2", 63 | "currentVersionLastModifiedBy": { 64 | "id": "005B0000001JZrsIAG", 65 | "name": "Security User", 66 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 67 | }, 68 | "currentVersionLastModifiedDate": "2016-12-15T05:12:11.000Z", 69 | "currentVersionUrl": "/services/data/v38.0/wave/datasets/0FbB0000000GoQNKA0/versions/0FcB0000000eMIGKA2", 70 | "folder": { 71 | "id": "005B0000001LERtIAO" 72 | }, 73 | "id": "0FbB0000000GoQNKA0", 74 | "label": "test_Account", 75 | "lastAccessedDate": "2016-12-15T05:12:02.000Z", 76 | "lastModifiedBy": { 77 | "id": "005B0000001JZrsIAG", 78 | "name": "Security User", 79 | "profilePhotoUrl": "https://my--c.gus.content.force.com/profilephoto/005/T" 80 | }, 81 | "lastModifiedDate": "2016-12-15T05:12:11.000Z", 82 | "name": "test_Account", 83 | "permissions": { 84 | "manage": true, 85 | "modify": true, 86 | "view": true 87 | }, 88 | "type": "dataset", 89 | "url": "/services/data/v38.0/wave/datasets/0FbB0000000GoQNKA0", 90 | "versionsUrl": "/services/data/v38.0/wave/datasets/0FbB0000000GoQNKA0/versions" 91 | } 92 | ], 93 | "nextPageUrl": null, 94 | "totalSize": 2, 95 | "url": "/services/data/v38.0/wave/datasets?q=Account&hasCurrentOnly=true" 96 | } -------------------------------------------------------------------------------- /src/test/resources/post_message.json: -------------------------------------------------------------------------------- 1 | { 2 | "actor": { 3 | "additionalLabel": null, 4 | "communityNickname": "sparktest", 5 | "companyName": "springML Inc", 6 | "displayName": "Spark Test", 7 | "firstName": "Spark", 8 | "id": "006B0000002ne2134IAA", 9 | "isActive": true, 10 | "isInThisCommunity": true, 11 | "lastName": "Test", 12 | "motif": { 13 | "color": "65CAE4", 14 | "largeIconUrl": "/img/icon/profile64.png", 15 | "mediumIconUrl": "/img/icon/profile32.png", 16 | "smallIconUrl": "/img/icon/profile16.png", 17 | "svgIconUrl": null 18 | }, 19 | "mySubscription": null, 20 | "name": "Spark Test", 21 | "photo": { 22 | "fullEmailPhotoUrl": "https://psdev.my.salesforce.com/img/userprofile/default_profile_200.png?fromEmail=1", 23 | "largePhotoUrl": "https://psdev--c.gus.content.force.com/profilephoto/005/F", 24 | "photoVersionId": null, 25 | "smallPhotoUrl": "https://psdev--c.gus.content.force.com/profilephoto/005/T", 26 | "standardEmailPhotoUrl": "https://psdev.my.salesforce.com/img/userprofile/default_profile_45.png?fromEmail=1", 27 | "url": "/services/data/v36.0/connect/user-profiles/006B0000002ne2134IAA/photo" 28 | }, 29 | "reputation": null, 30 | "title": null, 31 | "type": "User", 32 | "url": "/services/data/v36.0/chatter/users/006B0000002ne2134IAA", 33 | "userType": "Internal" 34 | }, 35 | "body": { 36 | "isRichText": false, 37 | "messageSegments": [ 38 | { 39 | "text": "Great Opportunity", 40 | "type": "Text" 41 | } 42 | ], 43 | "text": "Great Opportunity" 44 | }, 45 | "canShare": false, 46 | "capabilities": { 47 | "associatedActions": { 48 | "platformActionGroups": [] 49 | }, 50 | "bookmarks": { 51 | "isBookmarkedByCurrentUser": false 52 | }, 53 | "chatterLikes": { 54 | "isLikedByCurrentUser": false, 55 | "likesMessage": null, 56 | "myLike": null, 57 | "page": { 58 | "currentPageUrl": "/services/data/v36.0/chatter/feed-elements/0D5B0000007O5x8KAC/capabilities/chatter-likes/items", 59 | "items": [], 60 | "nextPageUrl": null, 61 | "previousPageUrl": null, 62 | "total": 0 63 | } 64 | }, 65 | "comments": { 66 | "page": { 67 | "currentPageUrl": "/services/data/v36.0/chatter/feed-elements/0D5B0000007O5x8KAC/capabilities/comments/items", 68 | "items": [], 69 | "nextPageUrl": null, 70 | "total": 0 71 | } 72 | }, 73 | "mute": { 74 | "isMutedByMe": false 75 | }, 76 | "topics": { 77 | "canAssignTopics": true, 78 | "items": [] 79 | } 80 | }, 81 | "clientInfo": { 82 | "applicationName": "Chatter Bot", 83 | "applicationUrl": null 84 | }, 85 | "createdDate": "2016-06-14T11:21:51.000Z", 86 | "event": false, 87 | "feedElementType": "FeedItem", 88 | "header": { 89 | "isRichText": null, 90 | "messageSegments": [ 91 | { 92 | "motif": { 93 | "color": "FCB95B", 94 | "largeIconUrl": "/img/icon/opportunities64.png", 95 | "mediumIconUrl": "/img/icon/opportunities32.png", 96 | "smallIconUrl": "/img/icon/opportunities16.png", 97 | "svgIconUrl": null 98 | }, 99 | "reference": { 100 | "id": "006B0000002ne39IAA", 101 | "url": "/services/data/v36.0/chatter/records/006B0000002ne39IAA" 102 | }, 103 | "text": "Sample Opportunity", 104 | "type": "EntityLink" 105 | }, 106 | { 107 | "text": " — ", 108 | "type": "Text" 109 | }, 110 | { 111 | "motif": { 112 | "color": "65CAE4", 113 | "largeIconUrl": "/img/icon/profile64.png", 114 | "mediumIconUrl": "/img/icon/profile32.png", 115 | "smallIconUrl": "/img/icon/profile16.png", 116 | "svgIconUrl": null 117 | }, 118 | "reference": { 119 | "id": "006B0000002ne2134IAA", 120 | "url": "/services/data/v36.0/chatter/users/006B0000002ne2134IAA" 121 | }, 122 | "text": "Spark Test", 123 | "type": "EntityLink" 124 | } 125 | ], 126 | "text": "Sample Opportunity — Spark Test" 127 | }, 128 | "id": "0D5B0000007O5x8KAC", 129 | "isDeleteRestricted": false, 130 | "modifiedDate": "2016-06-14T11:21:51.000Z", 131 | "originalFeedItem": null, 132 | "originalFeedItemActor": null, 133 | "parent": { 134 | "id": "006B0000002ne39IAA", 135 | "motif": { 136 | "color": "FCB95B", 137 | "largeIconUrl": "/img/icon/opportunities64.png", 138 | "mediumIconUrl": "/img/icon/opportunities32.png", 139 | "smallIconUrl": "/img/icon/opportunities16.png", 140 | "svgIconUrl": null 141 | }, 142 | "mySubscription": null, 143 | "name": "Sample Opportunity", 144 | "type": "Opportunity", 145 | "url": "/services/data/v36.0/chatter/records/006B0000002ne39IAA" 146 | }, 147 | "photoUrl": "https://psdev--c.gus.content.force.com/profilephoto/005/T", 148 | "relativeCreatedDate": "Just Now", 149 | "type": "TextPost", 150 | "url": "/services/data/v36.0/chatter/feed-elements/0D5B0000007O5x8KAC", 151 | "visibility": "InternalUsers" 152 | } --------------------------------------------------------------------------------