camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-10804 Create a Salesforce example
Date Wed, 08 Feb 2017 15:01:58 GMT
Repository: camel
Updated Branches:
  refs/heads/master 33a302082 -> 06e80f187


CAMEL-10804 Create a Salesforce example

This adds configuration for `Camel Salesman` Connected App on Salesforce
developer instance running under `Camelus Bactrianus`
(cbactrianus@gmail.com) user.

Given a Tweet's user uses its `name` as `Last Name` and `screenName` as
custom property `Twitter Screen Name` to create a contact in the
Developer Edition Salesforce instance. The `Twitter Screen Name` field
is defined as unique so in order not to create duplicate Contacts an
update-or-insert operation is performed.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/06e80f18
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/06e80f18
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/06e80f18

Branch: refs/heads/master
Commit: 06e80f187f35a7a05d1b6acb8a5f1e3a60841a67
Parents: 33a3020
Author: Zoran Regvart <zoran@regvart.com>
Authored: Wed Feb 8 14:14:52 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Feb 8 16:01:12 2017 +0100

----------------------------------------------------------------------
 .../apache/camel/example/mention/Contact.java   | 51 ++++++++++++++++++++
 .../example/mention/TwitterSalesforceRoute.java |  7 +--
 .../src/main/resources/application.properties   |  4 ++
 3 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/06e80f18/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/Contact.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/Contact.java
b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/Contact.java
new file mode 100644
index 0000000..747413e
--- /dev/null
+++ b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/Contact.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Salesforce DTO generated by camel-salesforce-maven-plugin
+ * Generated on: Mon Apr 06 17:56:36 PDT 2015
+ */
+package org.apache.camel.example.mention;
+
+import org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Contact extends AbstractSObjectBase {
+
+    @JsonProperty("LastName")
+    private final String lastName;
+
+    @JsonProperty("TwitterScreenName__c")
+    private String screenName;
+
+    @JsonCreator
+    public Contact(@JsonProperty("LastName") String lastName,
+                   @JsonProperty("TwitterScreenName__c") String screenName) {
+        this.lastName = lastName;
+        this.screenName = screenName;
+    }
+
+    public String getTwitterScreenName__c() {
+        return screenName;
+    }
+
+    public void setTwitterScreenName__c(String screenName) {
+        this.screenName = screenName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/06e80f18/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java
b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java
index 6330933..ec12e38 100644
--- a/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java
+++ b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceRoute.java
@@ -33,10 +33,11 @@ public class TwitterSalesforceRoute extends RouteBuilder {
                 User user = status.getUser();
                 String name = user.getName();
                 String screenName = user.getScreenName();
-                String json = String.format("{\"name\": \"%s\", \"screenName\": \"%s\"}",
name, screenName);
-                exchange.getIn().setBody(json);
+                Contact contact = new Contact(name, screenName);
+                exchange.getIn().setBody(contact);
             })
-            .log("JSon: ${body}");
+            .to("salesforce:upsertSObject?sObjectIdName=TwitterScreenName__c")
+            .log("SObject ID: ${body?.id}");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/06e80f18/examples/camel-example-twitter-salesforce/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-twitter-salesforce/src/main/resources/application.properties
b/examples/camel-example-twitter-salesforce/src/main/resources/application.properties
index 36baa9b..8c199bd 100644
--- a/examples/camel-example-twitter-salesforce/src/main/resources/application.properties
+++ b/examples/camel-example-twitter-salesforce/src/main/resources/application.properties
@@ -9,3 +9,7 @@ camel.component.twitter.consumer-secret=VxNQiRLwwKVD0K9mmfxlTTbVdgRpriORypnUbHhx
 camel.component.twitter.access-token=26693234-W0YjxL9cMJrC0VZZ4xdgFMymxIQ10LeL1K8YlbBY
 camel.component.twitter.access-token-secret=BZD51BgzbOdFstWZYsqB5p5dbuuDV12vrOdatzhY4E
 
+camel.component.salesforce.loginConfig.clientId=3MVG9szVa2RxsqBZXHfqsW3hf9HQp_N6qdSmpjKMzSJaEL4UP161JlDkE32EigL82ra_jM1WuQgF4rYDgzL3u
+camel.component.salesforce.loginConfig.clientSecret=1039611643161946846
+camel.component.salesforce.loginConfig.refreshToken=5Aep861HDR3iASSXIX6hI7M1qMWSCs1Ym57WUH1ftjE7RvnM7MvnAXx9EZaw_HIoNCKktNsuhx.xwjLThofuJH4
+


Mime
View raw message