You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2015/04/07 08:21:09 UTC

[2/5] camel git commit: CAMEL-8601: Added support for address and geo-location Salesforce compound types

CAMEL-8601: Added support for address and geo-location Salesforce compound types


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

Branch: refs/heads/camel-2.15.x
Commit: 1070d55ba37ea5daa94ece21e4ae65584f171a91
Parents: 6f3daa8
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon Apr 6 23:07:13 2015 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Mon Apr 6 23:19:13 2015 -0700

----------------------------------------------------------------------
 .../component/salesforce/api/dto/Address.java   |  93 ++++++
 .../salesforce/api/dto/GeoLocation.java         |  45 +++
 .../CompoundTypesIntegrationTest.java           | 121 ++++++++
 .../salesforce/dto/generated/Account.java       | 284 +++++++++++++++++++
 .../apache/camel/maven/CamelSalesforceMojo.java |   3 +-
 .../CamelSalesforceMojoIntegrationTest.java     |   2 +-
 6 files changed, 546 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/Address.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/Address.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/Address.java
new file mode 100644
index 0000000..2385f94
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/Address.java
@@ -0,0 +1,93 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.salesforce.api.dto;
+
+/**
+ * Salesforce DTO for Compound type urn:address.
+ */
+public class Address extends GeoLocation {
+
+    private String city;
+
+    private String country;
+
+    private String countryCode;
+
+    private String postalCode;
+
+    private String state;
+
+    private String stateCode;
+
+    private String street;
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getCountryCode() {
+        return countryCode;
+    }
+
+    public void setCountryCode(String countryCode) {
+        this.countryCode = countryCode;
+    }
+
+    public String getPostalCode() {
+        return postalCode;
+    }
+
+    public void setPostalCode(String postalCode) {
+        this.postalCode = postalCode;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getStateCode() {
+        return stateCode;
+    }
+
+    public void setStateCode(String stateCode) {
+        this.stateCode = stateCode;
+    }
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/GeoLocation.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/GeoLocation.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/GeoLocation.java
new file mode 100644
index 0000000..b21d79a
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/api/dto/GeoLocation.java
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.salesforce.api.dto;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Salesforce DTO for compound type GeoLocation.
+ */
+public class GeoLocation extends AbstractDTOBase {
+
+    private Double latitude;
+
+    private Double longitude;
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompoundTypesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompoundTypesIntegrationTest.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompoundTypesIntegrationTest.java
new file mode 100644
index 0000000..f75b0c5
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/CompoundTypesIntegrationTest.java
@@ -0,0 +1,121 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.salesforce;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.salesforce.api.dto.CreateSObjectResult;
+import org.apache.camel.component.salesforce.dto.generated.Account;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test support for Salesforce compound data types.
+ * This test requires a custom field in the <code>Account</code> object
+ * called <code>"Shipping Location"</code> of type <code>Geolocation</code> in decimal units.
+ * @see <a href="https://www.salesforce.com/developer/docs/api/index_Left.htm#CSHID=compound_fields.htm|StartTopic=Content%2Fcompound_fields.htm|SkinName=webhelp">Compound data types</a>
+ */
+public class CompoundTypesIntegrationTest extends AbstractSalesforceTestBase {
+
+    private static final Logger LOG = LoggerFactory.getLogger(CompoundTypesIntegrationTest.class);
+
+    @Test
+    public void testTypes() throws Exception {
+        doTestTypes("");
+        doTestTypes("Xml");
+    }
+
+    private void doTestTypes(String suffix) {
+
+        Account account = new Account();
+
+        account.setName("Camel Test Account");
+
+        account.setBillingCity("San Francisco");
+        account.setBillingCountry("USA");
+        account.setBillingPostalCode("94105");
+        account.setBillingState("CA");
+        account.setBillingStreet("1 Market St #300");
+        account.setBillingLatitude(37.793779);
+        account.setBillingLongitude(-122.39448);
+
+        account.setShippingCity("San Francisco");
+        account.setShippingCountry("USA");
+        account.setShippingPostalCode("94105");
+        account.setShippingState("CA");
+        account.setShippingStreet("1 Market St #300");
+        account.setShippingLatitude(37.793779);
+        account.setShippingLongitude(-122.39448);
+
+        account.setShipping_Location__Latitude__s(37.793779);
+        account.setShipping_Location__Longitude__s(-122.39448);
+
+        CreateSObjectResult result = template().requestBody("direct:createSObject" + suffix,
+            account, CreateSObjectResult.class);
+        assertNotNull(result);
+        assertTrue("Create success", result.getSuccess());
+        LOG.debug("Create: " + result);
+
+        try {
+
+            // get account with compound fields
+            account = template().requestBody("direct:getSObject" + suffix, result.getId(), Account.class);
+            assertNotNull(account);
+            assertNotNull("Billing Address", account.getBillingAddress());
+            assertNotNull("Shipping Address", account.getShippingAddress());
+            assertNotNull("Shipping Location", account.getShippingAddress());
+
+            LOG.debug("Retrieved fields billing address: {}, shipping location: {}",
+                account.getBillingAddress(), account.getShipping_Location__c());
+
+        } finally {
+            // delete the test SObject
+            assertNull(template().requestBody("direct:deleteSObject" + suffix, result.getId()));
+            LOG.debug("Delete successful");
+        }
+    }
+
+    @Override
+    protected RouteBuilder doCreateRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // testCreateSObject
+                from("direct:createSObject")
+                    .to("salesforce:createSObject?sObjectName=Account");
+
+                from("direct:createSObjectXml")
+                    .to("salesforce:createSObject?format=XML&sObjectName=Account");
+
+                // testGetSObject
+                from("direct:getSObject")
+                    .to("salesforce:getSObject?sObjectName=Account&sObjectFields=Id,BillingAddress,ShippingAddress,Shipping_Location__c");
+
+                from("direct:getSObjectXml")
+                    .to("salesforce:getSObject?format=XML&sObjectName=Account&sObjectFields=Id,BillingAddress,ShippingAddress,Shipping_Location__c");
+
+                // testDeleteSObject
+                from("direct:deleteSObject")
+                    .to("salesforce:deleteSObject?sObjectName=Account");
+
+                from("direct:deleteSObjectXml")
+                    .to("salesforce:deleteSObject?format=XML&sObjectName=Account");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/Account.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/Account.java b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/Account.java
new file mode 100644
index 0000000..e73da4b
--- /dev/null
+++ b/components/camel-salesforce/camel-salesforce-component/src/test/java/org/apache/camel/component/salesforce/dto/generated/Account.java
@@ -0,0 +1,284 @@
+/**
+ * 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.component.salesforce.dto.generated;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+
+import org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+//CHECKSTYLE:OFF
+/**
+ * Salesforce DTO for SObject Account
+ */
+@XStreamAlias("Account")
+public class Account extends AbstractSObjectBase {
+
+    // BillingStreet
+    private String BillingStreet;
+
+    @JsonProperty("BillingStreet")
+    public String getBillingStreet() {
+        return this.BillingStreet;
+    }
+
+    @JsonProperty("BillingStreet")
+    public void setBillingStreet(String BillingStreet) {
+        this.BillingStreet = BillingStreet;
+    }
+
+    // BillingCity
+    private String BillingCity;
+
+    @JsonProperty("BillingCity")
+    public String getBillingCity() {
+        return this.BillingCity;
+    }
+
+    @JsonProperty("BillingCity")
+    public void setBillingCity(String BillingCity) {
+        this.BillingCity = BillingCity;
+    }
+
+    // BillingState
+    private String BillingState;
+
+    @JsonProperty("BillingState")
+    public String getBillingState() {
+        return this.BillingState;
+    }
+
+    @JsonProperty("BillingState")
+    public void setBillingState(String BillingState) {
+        this.BillingState = BillingState;
+    }
+
+    // BillingPostalCode
+    private String BillingPostalCode;
+
+    @JsonProperty("BillingPostalCode")
+    public String getBillingPostalCode() {
+        return this.BillingPostalCode;
+    }
+
+    @JsonProperty("BillingPostalCode")
+    public void setBillingPostalCode(String BillingPostalCode) {
+        this.BillingPostalCode = BillingPostalCode;
+    }
+
+    // BillingCountry
+    private String BillingCountry;
+
+    @JsonProperty("BillingCountry")
+    public String getBillingCountry() {
+        return this.BillingCountry;
+    }
+
+    @JsonProperty("BillingCountry")
+    public void setBillingCountry(String BillingCountry) {
+        this.BillingCountry = BillingCountry;
+    }
+
+    // BillingLatitude
+    private Double BillingLatitude;
+
+    @JsonProperty("BillingLatitude")
+    public Double getBillingLatitude() {
+        return this.BillingLatitude;
+    }
+
+    @JsonProperty("BillingLatitude")
+    public void setBillingLatitude(Double BillingLatitude) {
+        this.BillingLatitude = BillingLatitude;
+    }
+
+    // BillingLongitude
+    private Double BillingLongitude;
+
+    @JsonProperty("BillingLongitude")
+    public Double getBillingLongitude() {
+        return this.BillingLongitude;
+    }
+
+    @JsonProperty("BillingLongitude")
+    public void setBillingLongitude(Double BillingLongitude) {
+        this.BillingLongitude = BillingLongitude;
+    }
+
+    // BillingAddress
+    private org.apache.camel.component.salesforce.api.dto.Address BillingAddress;
+
+    @JsonProperty("BillingAddress")
+    public org.apache.camel.component.salesforce.api.dto.Address getBillingAddress() {
+        return this.BillingAddress;
+    }
+
+    @JsonProperty("BillingAddress")
+    public void setBillingAddress(org.apache.camel.component.salesforce.api.dto.Address BillingAddress) {
+        this.BillingAddress = BillingAddress;
+    }
+
+    // ShippingStreet
+    private String ShippingStreet;
+
+    @JsonProperty("ShippingStreet")
+    public String getShippingStreet() {
+        return this.ShippingStreet;
+    }
+
+    @JsonProperty("ShippingStreet")
+    public void setShippingStreet(String ShippingStreet) {
+        this.ShippingStreet = ShippingStreet;
+    }
+
+    // ShippingCity
+    private String ShippingCity;
+
+    @JsonProperty("ShippingCity")
+    public String getShippingCity() {
+        return this.ShippingCity;
+    }
+
+    @JsonProperty("ShippingCity")
+    public void setShippingCity(String ShippingCity) {
+        this.ShippingCity = ShippingCity;
+    }
+
+    // ShippingState
+    private String ShippingState;
+
+    @JsonProperty("ShippingState")
+    public String getShippingState() {
+        return this.ShippingState;
+    }
+
+    @JsonProperty("ShippingState")
+    public void setShippingState(String ShippingState) {
+        this.ShippingState = ShippingState;
+    }
+
+    // ShippingPostalCode
+    private String ShippingPostalCode;
+
+    @JsonProperty("ShippingPostalCode")
+    public String getShippingPostalCode() {
+        return this.ShippingPostalCode;
+    }
+
+    @JsonProperty("ShippingPostalCode")
+    public void setShippingPostalCode(String ShippingPostalCode) {
+        this.ShippingPostalCode = ShippingPostalCode;
+    }
+
+    // ShippingCountry
+    private String ShippingCountry;
+
+    @JsonProperty("ShippingCountry")
+    public String getShippingCountry() {
+        return this.ShippingCountry;
+    }
+
+    @JsonProperty("ShippingCountry")
+    public void setShippingCountry(String ShippingCountry) {
+        this.ShippingCountry = ShippingCountry;
+    }
+
+    // ShippingLatitude
+    private Double ShippingLatitude;
+
+    @JsonProperty("ShippingLatitude")
+    public Double getShippingLatitude() {
+        return this.ShippingLatitude;
+    }
+
+    @JsonProperty("ShippingLatitude")
+    public void setShippingLatitude(Double ShippingLatitude) {
+        this.ShippingLatitude = ShippingLatitude;
+    }
+
+    // ShippingLongitude
+    private Double ShippingLongitude;
+
+    @JsonProperty("ShippingLongitude")
+    public Double getShippingLongitude() {
+        return this.ShippingLongitude;
+    }
+
+    @JsonProperty("ShippingLongitude")
+    public void setShippingLongitude(Double ShippingLongitude) {
+        this.ShippingLongitude = ShippingLongitude;
+    }
+
+    // ShippingAddress
+    private org.apache.camel.component.salesforce.api.dto.Address ShippingAddress;
+
+    @JsonProperty("ShippingAddress")
+    public org.apache.camel.component.salesforce.api.dto.Address getShippingAddress() {
+        return this.ShippingAddress;
+    }
+
+    @JsonProperty("ShippingAddress")
+    public void setShippingAddress(org.apache.camel.component.salesforce.api.dto.Address ShippingAddress) {
+        this.ShippingAddress = ShippingAddress;
+    }
+
+    // Shipping_Location__Latitude__s
+    private Double Shipping_Location__Latitude__s;
+
+    @JsonProperty("Shipping_Location__Latitude__s")
+    public Double getShipping_Location__Latitude__s() {
+        return this.Shipping_Location__Latitude__s;
+    }
+
+    @JsonProperty("Shipping_Location__Latitude__s")
+    public void setShipping_Location__Latitude__s(Double Shipping_Location__Latitude__s) {
+        this.Shipping_Location__Latitude__s = Shipping_Location__Latitude__s;
+    }
+
+    // Shipping_Location__Longitude__s
+    private Double Shipping_Location__Longitude__s;
+
+    @JsonProperty("Shipping_Location__Longitude__s")
+    public Double getShipping_Location__Longitude__s() {
+        return this.Shipping_Location__Longitude__s;
+    }
+
+    @JsonProperty("Shipping_Location__Longitude__s")
+    public void setShipping_Location__Longitude__s(Double Shipping_Location__Longitude__s) {
+        this.Shipping_Location__Longitude__s = Shipping_Location__Longitude__s;
+    }
+
+    // Shipping_Location__c
+    private org.apache.camel.component.salesforce.api.dto.GeoLocation Shipping_Location__c;
+
+    @JsonProperty("Shipping_Location__c")
+    public org.apache.camel.component.salesforce.api.dto.GeoLocation getShipping_Location__c() {
+        return this.Shipping_Location__c;
+    }
+
+    @JsonProperty("Shipping_Location__c")
+    public void setShipping_Location__c(org.apache.camel.component.salesforce.api.dto.GeoLocation Shipping_Location__c) {
+        this.Shipping_Location__c = Shipping_Location__c;
+    }
+
+}
+//CHECKSTYLE:ON

http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
index 372b6e4..9fdadb8 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/main/java/org/apache/camel/maven/CamelSalesforceMojo.java
@@ -603,7 +603,8 @@ public class CamelSalesforceMojo extends AbstractMojo {
                 {"duration", "javax.xml.datatype.Duration"},
                 {"NOTATION", "javax.xml.namespace.QName"}
 */
-                {"address", "String"}
+                {"address", "org.apache.camel.component.salesforce.api.dto.Address"},
+                {"location", "org.apache.camel.component.salesforce.api.dto.GeoLocation"}
             };
             LOOKUP_MAP = new HashMap<String, String>();
             for (String[] entry : typeMap) {

http://git-wip-us.apache.org/repos/asf/camel/blob/1070d55b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
index a40b9b9..8856b7e 100644
--- a/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
+++ b/components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/CamelSalesforceMojoIntegrationTest.java
@@ -62,7 +62,7 @@ public class CamelSalesforceMojoIntegrationTest {
         mojo.packageName = "org.apache.camel.salesforce.dto";
 
         // set code generation properties
-        mojo.includePattern = "(.*__c)|(PushTopic)|(Document)";
+        mojo.includePattern = "(.*__c)|(PushTopic)|(Document)|(Account)";
 
         // remove generated code directory
         if (mojo.outputDirectory.exists()) {