summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/travelsample')
-rw-r--r--sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java14
-rw-r--r--sandbox/travelsample/emailgateway-contribution/pom.xml15
-rw-r--r--sandbox/travelsample/emailgateway-contribution/test/scatours/emailgateway/EmailGatewayTestCase.java2
-rw-r--r--sandbox/travelsample/node/build.xml66
-rw-r--r--sandbox/travelsample/node/pom.xml7
-rw-r--r--sandbox/travelsample/node/src/scatours/LaunchNode.java4
-rw-r--r--sandbox/travelsample/payment-contribution/META-INF/sca-contribution.xml5
-rw-r--r--sandbox/travelsample/payment-contribution/pom.xml15
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/META-INF/sca-contribution.xml22
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/paymentprocesstest.composite4
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/pom.xml13
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/resources/META-INF/sca-contribution.xml3
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/resources/PaymentProcess.wsdl2
-rw-r--r--sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java13
-rw-r--r--sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml2
-rw-r--r--sandbox/travelsample/scatours-contribution/pom.xml8
-rw-r--r--sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java13
-rw-r--r--sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java78
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml3
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/pom.xml6
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java (renamed from sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java)15
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java73
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java38
-rw-r--r--sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java134
-rw-r--r--sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml5
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.composite45
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.html99
27 files changed, 416 insertions, 288 deletions
diff --git a/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java b/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
index 311bb63b18..f1e3581d86 100644
--- a/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
+++ b/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
@@ -37,6 +37,20 @@ public class TripItem {
public TripItem() {
}
+ public TripItem(TripItem item) {
+ this.id = item.getId();
+ this.tripId = item.getTripId();
+ this.type = item.getType();
+ this.name = item.getName();
+ this.description = item.getDescription();
+ this.location = item.getLocation();
+ this.fromDate = item.getFromDate();
+ this.toDate = item.getToDate();
+ this.price = item.getPrice();
+ this.currency = item.getCurrency();
+ this.link = item.getLink();
+ }
+
public TripItem(String id,
String tripId,
String type,
diff --git a/sandbox/travelsample/emailgateway-contribution/pom.xml b/sandbox/travelsample/emailgateway-contribution/pom.xml
index cbf3165486..118a06d942 100644
--- a/sandbox/travelsample/emailgateway-contribution/pom.xml
+++ b/sandbox/travelsample/emailgateway-contribution/pom.xml
@@ -86,9 +86,24 @@
<exclude>target/**</exclude>
<exclude>src/**</exclude>
<exclude>test/**</exclude>
+ <exclude>*.composite</exclude>
</excludes>
</resource>
</resources>
+ <testResources>
+ <testResource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ <exclude>target/**</exclude>
+ <exclude>src/**</exclude>
+ <exclude>test/**</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
diff --git a/sandbox/travelsample/emailgateway-contribution/test/scatours/emailgateway/EmailGatewayTestCase.java b/sandbox/travelsample/emailgateway-contribution/test/scatours/emailgateway/EmailGatewayTestCase.java
index 7b6760954e..00cca75f0e 100644
--- a/sandbox/travelsample/emailgateway-contribution/test/scatours/emailgateway/EmailGatewayTestCase.java
+++ b/sandbox/travelsample/emailgateway-contribution/test/scatours/emailgateway/EmailGatewayTestCase.java
@@ -24,6 +24,7 @@ import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.node.SCANodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -55,6 +56,7 @@ public class EmailGatewayTestCase {
}
@Test
+ //@Ignore
public void testWaitForInput() {
System.out.println("Press a key to end");
try {
diff --git a/sandbox/travelsample/node/build.xml b/sandbox/travelsample/node/build.xml
index e515111e39..0f0faf956c 100644
--- a/sandbox/travelsample/node/build.xml
+++ b/sandbox/travelsample/node/build.xml
@@ -91,6 +91,7 @@
<include name="tuscany-databinding-jaxb-1.5-SNAPSHOT.jar"/>
<include name="tuscany-databinding-jaxb-axiom-1.5-SNAPSHOT.jar"/>
<include name="tuscany-databinding-json-1.5-SNAPSHOT.jar"/>
+ <include name="tuscany-databinding-sdo-1.5-SNAPSHOT.jar"/>
<include name="tuscany-definitions-1.5-SNAPSHOT.jar"/>
<include name="tuscany-definitions-xml-1.5-SNAPSHOT.jar"/>
<include name="tuscany-domain-manager-1.5-SNAPSHOT.jar"/>
@@ -99,6 +100,8 @@
<include name="tuscany-host-embedded-1.5-SNAPSHOT.jar"/>
<include name="tuscany-host-http-1.5-SNAPSHOT.jar"/>
<include name="tuscany-host-jetty-1.5-SNAPSHOT.jar"/>
+ <include name="tuscany-implementation-bpel-1.5-SNAPSHOT.jar"/>
+ <include name="tuscany-implementation-bpel-ode-1.5-SNAPSHOT.jar"/>
<include name="tuscany-implementation-ejb-1.5-SNAPSHOT.jar"/>
<include name="tuscany-implementation-java-1.5-SNAPSHOT.jar"/>
<include name="tuscany-implementation-java-runtime-1.5-SNAPSHOT.jar"/>
@@ -143,11 +146,13 @@
<include name="abdera-parser-0.4.0-incubating.jar"/>
<include name="abdera-server-0.4.0-incubating.jar"/>
<include name="activation-1.1.jar"/>
+ <include name="activeio-2.0-r118.jar"/>
<include name="annogen-0.1.0.jar"/>
<include name="asm-all-3.1.jar"/>
<include name="axiom-api-1.2.7.jar"/>
<include name="axiom-dom-1.2.7.jar"/>
<include name="axiom-impl-1.2.7.jar"/>
+ <include name="axion-1.0-M3-dev.jar"/>
<include name="axis-ant-1.4.jar"/>
<include name="axis2-adb-1.4.1.jar"/>
<include name="axis2-codegen-1.4.1.jar"/>
@@ -157,27 +162,58 @@
<include name="backport-util-concurrent-3.1.jar"/>
<include name="bcprov-jdk13-132.jar"/>
<include name="cglib-nodep-2.1_3.jar"/>
+ <include name="common-2.2.3.jar"/>
<include name="commons-codec-1.3.jar"/>
<include name="commons-collections-3.1.jar"/>
<include name="commons-discovery-0.2.jar"/>
<include name="commons-fileupload-1.2.jar"/>
<include name="commons-httpclient-3.1.jar"/>
<include name="commons-io-1.4.jar"/>
+ <include name="commons-jexl-1.1.jar"/>
+ <include name="commons-lang-2.1.jar"/>
<include name="commons-logging-1.1.1.jar"/>
+ <include name="commons-primitives-1.0.jar"/>
<include name="derby-10.3.1.4.jar"/>
+ <include name="dom4j-1.6.1.jar"/>
+ <include name="ecore-2.2.3.jar"/>
+ <include name="ecore-change-2.2.3.jar"/>
+ <include name="ecore-xmi-2.2.3.jar"/>
<include name="geronimo-activation_1.1_spec-1.0.1.jar"/>
+ <include name="geronimo-common-1.2-beta.jar"/>
<include name="geronimo-commonj_1.1_spec-1.0.jar"/>
+ <include name="geronimo-connector-1.2-beta.jar"/>
+ <include name="geronimo-core-1.2-beta.jar"/>
+ <include name="geronimo-deployment-1.2-beta.jar"/>
<include name="geronimo-ejb_3.0_spec-1.0.jar"/>
+ <include name="geronimo-interceptor-1.2-beta.jar"/>
+ <include name="geronimo-j2ee-1.2-beta.jar"/>
+ <include name="geronimo-j2ee-connector_1.5_spec-1.1.jar"/>
+ <include name="geronimo-j2ee-jacc_1.0_spec-1.1.jar"/>
+ <include name="geronimo-j2ee-management_1.0_spec-1.1.jar"/>
<include name="geronimo-javamail_1.4_spec-1.2.jar"/>
<include name="geronimo-jms_1.1_spec-1.1.jar"/>
+ <include name="geronimo-jpa_3.0_spec-1.0.jar"/>
+ <include name="geronimo-jta_1.0.1B_spec-1.0.jar"/>
+ <include name="geronimo-kernel-1.2-beta.jar"/>
+ <include name="geronimo-management-1.2-beta.jar"/>
+ <include name="geronimo-naming-1.2-beta.jar"/>
+ <include name="geronimo-security-1.2-beta.jar"/>
+ <include name="geronimo-spec-j2ee-connector-1.5-rc4.jar"/>
+ <include name="geronimo-spec-jta-1.0.1B-rc4.jar"/>
<include name="geronimo-stax-api_1.0_spec-1.0.1.jar"/>
+ <include name="geronimo-system-1.2-beta.jar"/>
+ <include name="geronimo-transaction-1.2-beta.jar"/>
+ <include name="geronimo-util-1.2-beta.jar"/>
+ <include name="howl-1.0.1-1.jar"/>
<include name="htmlparser-1.0.5.jar"/>
<include name="httpcore-4.0-beta1.jar"/>
<include name="httpcore-nio-4.0-beta1.jar"/>
+ <include name="javacc-3.2.jar"/>
<include name="jaxb-api-2.1.jar"/>
<include name="jaxb-impl-2.1.7.jar"/>
<include name="jaxen-1.1.1.jar"/>
<include name="jaxws-api-2.1.jar"/>
+ <include name="jdom-1.0.jar"/>
<include name="jettison-1.0.1.jar"/>
<include name="jetty-6.1.7.jar"/>
<include name="jetty-util-6.1.7.jar"/>
@@ -185,26 +221,54 @@
<include name="jsr181-api-1.0-MR1.jar"/>
<include name="jsr250-api-1.0.jar"/>
<include name="junit-4.5.jar"/>
- <include name="log4j-1.2.15.jar"/>
+ <include name="log4j-1.2.13.jar"/>
<include name="mail-1.4.jar"/>
<include name="mex-1.41-impl.jar"/>
<include name="neethi-2.0.4.jar"/>
+ <include name="ode-bpel-api-1.1.1.jar"/>
+ <include name="ode-bpel-compiler-1.1.1.jar"/>
+ <include name="ode-bpel-dao-1.1.1.jar"/>
+ <include name="ode-bpel-epr-1.1.1.jar"/>
+ <include name="ode-bpel-obj-1.1.1.jar"/>
+ <include name="ode-bpel-runtime-1.1.1.jar"/>
+ <include name="ode-bpel-schemas-1.1.1.jar"/>
+ <include name="ode-bpel-store-1.1.1.jar"/>
+ <include name="ode-dao-jpa-1.1.1.jar"/>
+ <include name="ode-jacob-1.1.1.jar"/>
+ <include name="ode-jacob-ap-1.1.1.jar"/>
+ <include name="ode-scheduler-simple-1.1.1.jar"/>
+ <include name="ode-utils-1.1.1.jar"/>
+ <include name="openjpa-all-0.9.7-incubating.jar"/>
+ <include name="openjpa-persistence-0.9.7-incubating.jar"/>
<include name="opensaml-1.1.jar"/>
<include name="rampart-core-1.4.jar"/>
<include name="rampart-policy-1.4.jar"/>
<include name="rampart-trust-1.4.jar"/>
+ <include name="regexp-1.3.jar"/>
+ <include name="saxon-8.7.jar"/>
+ <include name="saxon-dom-8.7.jar"/>
+ <include name="saxon-xpath-8.7.jar"/>
+ <include name="serp-1.12.0.jar"/>
<include name="servlet-api-2.5.jar"/>
<include name="stax-api-1.0-2.jar"/>
+ <include name="tranql-connector-1.1.jar"/>
+ <include name="tuscany-sdo-api-r2.1-1.1.1.jar"/>
+ <include name="tuscany-sdo-impl-1.1.1.jar"/>
+ <include name="tuscany-sdo-lib-1.1.1.jar"/>
<include name="woden-api-1.0M8.jar"/>
<include name="woden-impl-dom-1.0M8.jar"/>
<include name="wsdl4j-1.6.2.jar"/>
<include name="wss4j-1.5.4.jar"/>
<include name="wstx-asl-3.2.4.jar"/>
<include name="xalan-2.7.0.jar"/>
+ <include name="xbean-naming-2.7.jar"/>
<include name="xercesImpl-2.8.1.jar"/>
<include name="xml-apis-1.3.03.jar"/>
+ <include name="xml-resolver-1.1.jar"/>
<include name="xmlParserAPIs-2.6.0.jar"/>
+ <include name="xmlbeans-2.3.0.jar"/>
<include name="xmlsec-1.4.2.jar"/>
+ <include name="xsd-2.2.3.jar"/>
</fileset>
</project>
diff --git a/sandbox/travelsample/node/pom.xml b/sandbox/travelsample/node/pom.xml
index 43436113c6..77f8073b0b 100644
--- a/sandbox/travelsample/node/pom.xml
+++ b/sandbox/travelsample/node/pom.xml
@@ -124,6 +124,13 @@
<version>1.5-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-ode</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.derby</groupId>
diff --git a/sandbox/travelsample/node/src/scatours/LaunchNode.java b/sandbox/travelsample/node/src/scatours/LaunchNode.java
index aca8d7e026..892f2b8dfd 100644
--- a/sandbox/travelsample/node/src/scatours/LaunchNode.java
+++ b/sandbox/travelsample/node/src/scatours/LaunchNode.java
@@ -74,6 +74,10 @@ public class LaunchNode {
new SCAContribution("car", "../car-contribution/target/classes"),
new SCAContribution("tripbooking", "../tripbooking-contribution/target/classes"),
new SCAContribution("travelcatalog", "../travelcatalog-contribution/target/classes"),
+ new SCAContribution("payment", "../payment-contribution/target/classes"),
+ new SCAContribution("emailgateway", "../emailgateway-contribution/target/classes"),
+ new SCAContribution("paymentprocess", "../paymentprocess-contribution/target/classes"),
+ new SCAContribution("shoppingcart", "../shoppingcart-contribution/target/classes"),
new SCAContribution("scatours", "../scatours-contribution/target/classes"),
new SCAContribution("ui", "../ui-contribution/target/classes"));
node.start();
diff --git a/sandbox/travelsample/payment-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/payment-contribution/META-INF/sca-contribution.xml
index 6b09380868..d22f4816ab 100644
--- a/sandbox/travelsample/payment-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/payment-contribution/META-INF/sca-contribution.xml
@@ -18,5 +18,8 @@
* under the License.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <export.java package="scatours.payment"/>
+ <export.java package="payment.creditcard"/>
+ <export.java package="payment.creditcard.impl"/>
+ <export.java package="payment.creditcard.ws"/>
+ <export.java package="payment.creditcard.ws.impl"/>
</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/payment-contribution/pom.xml b/sandbox/travelsample/payment-contribution/pom.xml
index 903bd7096f..98a1166a66 100644
--- a/sandbox/travelsample/payment-contribution/pom.xml
+++ b/sandbox/travelsample/payment-contribution/pom.xml
@@ -86,9 +86,24 @@
<exclude>target/**</exclude>
<exclude>src/**</exclude>
<exclude>test/**</exclude>
+ <exclude>*.composite</exclude>
</excludes>
</resource>
</resources>
+ <testResources>
+ <testResource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ <exclude>target/**</exclude>
+ <exclude>src/**</exclude>
+ <exclude>test/**</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
diff --git a/sandbox/travelsample/paymentprocess-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/paymentprocess-contribution/META-INF/sca-contribution.xml
deleted file mode 100644
index 6b09380868..0000000000
--- a/sandbox/travelsample/paymentprocess-contribution/META-INF/sca-contribution.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <export.java package="scatours.payment"/>
-</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/paymentprocess-contribution/paymentprocesstest.composite b/sandbox/travelsample/paymentprocess-contribution/paymentprocesstest.composite
index b75c0b5ca8..f45dc01a57 100644
--- a/sandbox/travelsample/paymentprocess-contribution/paymentprocesstest.composite
+++ b/sandbox/travelsample/paymentprocess-contribution/paymentprocesstest.composite
@@ -26,7 +26,7 @@
<component name="PaymentProcessClient">
<implementation.java class="scatours.paymentprocess.PaymentProcessClientImpl" />
<reference name="paymentProcess">
- <binding.ws uri="http://localhost:8080/PaymentProcess" />
+ <binding.ws uri="http://localhost:8083/PaymentProcess" />
</reference>
</component>
@@ -34,7 +34,7 @@
<implementation.bpel process="pp:PaymentProcess"/>
<service name="paymentProcessPartnerLink">
<interface.wsdl interface="http://www.example.org/PaymentProcess/#wsdl.interface(PaymentProcess)" />
- <binding.ws uri="http://localhost:8080/PaymentProcess" wsdlElement="http://www.example.org/PaymentProcess/#wsdl.service(PaymentProcessService)"/>
+ <binding.ws uri="http://localhost:8083/PaymentProcess" wsdlElement="http://www.example.org/PaymentProcess/#wsdl.service(PaymentProcessService)"/>
</service>
<reference name="creditCardPaymentPartnerLink">
<binding.ws uri="http://localhost:8081/CreditCardPayment"/>
diff --git a/sandbox/travelsample/paymentprocess-contribution/pom.xml b/sandbox/travelsample/paymentprocess-contribution/pom.xml
index e56584d8eb..c1a9712a66 100644
--- a/sandbox/travelsample/paymentprocess-contribution/pom.xml
+++ b/sandbox/travelsample/paymentprocess-contribution/pom.xml
@@ -79,14 +79,19 @@
<resource>
<directory>${basedir}/resources</directory>
</resource>
- <resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>${basedir}/resources</directory>
+ </testResource>
+ <testResource>
<directory>${basedir}</directory>
<includes>
<include>*.composite</include>
<include>*.properties</include>
</includes>
- </resource>
- </resources>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -120,7 +125,7 @@
</goals>
<configuration>
<packageName>scatours.paymentprocess</packageName>
- <wsdlDirectory>${basedir}/src/scatours/paymentprocess
+ <wsdlDirectory>${basedir}/resources
</wsdlDirectory>
<wsdlFiles>
<wsdlFile>PaymentProcess.wsdl</wsdlFile>
diff --git a/sandbox/travelsample/paymentprocess-contribution/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/paymentprocess-contribution/resources/META-INF/sca-contribution.xml
index 6b09380868..8146abbceb 100644
--- a/sandbox/travelsample/paymentprocess-contribution/resources/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/paymentprocess-contribution/resources/META-INF/sca-contribution.xml
@@ -18,5 +18,6 @@
* under the License.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <export.java package="scatours.payment"/>
+ <export.java package="scatours.paymentprocess"/>
+ <export namespace="http://www.example.org/PaymentProcess/"/>
</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/paymentprocess-contribution/resources/PaymentProcess.wsdl b/sandbox/travelsample/paymentprocess-contribution/resources/PaymentProcess.wsdl
index 868be04723..c4157cf475 100644
--- a/sandbox/travelsample/paymentprocess-contribution/resources/PaymentProcess.wsdl
+++ b/sandbox/travelsample/paymentprocess-contribution/resources/PaymentProcess.wsdl
@@ -73,7 +73,7 @@
</wsdl:binding>
<wsdl:service name="PaymentProcessService">
<wsdl:port name="PaymentProcessPort" binding="tns:PaymentProcessBinding">
- <soap:address location="http://localhost:8080/PaymentProcess" />
+ <soap:address location="http://localhost:8083/PaymentProcess" />
</wsdl:port>
</wsdl:service>
diff --git a/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java
index 2a120d99d0..f1b4bc6aba 100644
--- a/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java
+++ b/sandbox/travelsample/paymentprocess-contribution/test/scatours/paymentprocess/PaymentProcessTestCase.java
@@ -24,6 +24,7 @@ import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.node.SCANodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -43,11 +44,23 @@ public class PaymentProcessTestCase {
}
@Test
+ @Ignore
public void testPaymentProcess() {
SCAClient client = (SCAClient) node;
PaymentProcess pp = client.getService(PaymentProcess.class, "PaymentProcessClient");
System.out.println("Result = " + pp.makePayment("Fred", 100.00f));
}
+
+ @Test
+ //@Ignore
+ public void testWaitForInput() {
+ System.out.println("Press a key to end");
+ try {
+ System.in.read();
+ } catch (Exception ex) {
+ }
+ System.out.println("Shutting down");
+ }
/**
* @throws java.lang.Exception
diff --git a/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml
index f34665c92d..6d6a563b74 100644
--- a/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml
@@ -22,5 +22,7 @@
<import.java package="scatours.currencyconverter"/>
<import.java package="scatours.travelcatalog"/>
<import.java package="scatours.tripbooking"/>
+ <import.java package="scatours.paymentprocess"/>
+ <import.java package="scatours.shoppingcart"/>
<export.java package="scatours"/>
</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/scatours-contribution/pom.xml b/sandbox/travelsample/scatours-contribution/pom.xml
index 8470e06b05..500d23f4b8 100644
--- a/sandbox/travelsample/scatours-contribution/pom.xml
+++ b/sandbox/travelsample/scatours-contribution/pom.xml
@@ -69,7 +69,13 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>scatours-shoppingcart-contribution</artifactId>
<version>1.5-SNAPSHOT</version>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours-paymentprocess-contribution</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java
index cc1cb960fe..611b4d8945 100644
--- a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java
+++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java
@@ -28,9 +28,12 @@ import scatours.common.TripItem;
*/
@Remotable
public interface SCAToursBooking {
- String newTrip();
- void addTripItem(String tripId, String tripItemId);
- void removeTripItem(String tripId, String tripItemId);
- TripItem[] getTripItems(String tripId);
- double getTotalPrice(String tripId);
+ String addCart();
+ String addTrip(String cartId);
+ void removeTrip(String cartId, String tripId);
+ void addTripItem(String cartId, String tripId, String tripItemId);
+ void removeTripItem(String cartId, String tripId, String tripItemId);
+ TripItem[] getTripItems(String cartId);
+ double getTotalPrice(String cartId);
+ void checkout(String name);
}
diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java
index 2896997326..d36a6604ce 100644
--- a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java
+++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java
@@ -19,28 +19,23 @@
package scatours;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.tuscany.sca.data.collection.Entry;
-import org.apache.tuscany.sca.data.collection.NotFoundException;
-import org.osoa.sca.CallableReference;
import org.osoa.sca.ComponentContext;
-import org.osoa.sca.RequestContext;
import org.osoa.sca.ServiceReference;
import org.osoa.sca.annotations.Context;
-import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
-import scatours.common.Search;
-import scatours.common.SearchCallback;
import scatours.common.TripItem;
import scatours.common.TripLeg;
-import scatours.currencyconverter.CurrencyConverter;
+import scatours.paymentprocess.PaymentProcess;
+import scatours.shoppingcart.ShoppingCart;
import scatours.travelcatalog.TravelCatalogSearch;
import scatours.tripbooking.TripBooking;
@@ -57,13 +52,20 @@ public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{
@Reference
protected TripBooking tripBooking;
+ @Reference
+ protected ShoppingCart shoppingCart;
+
+ @Reference
+ protected PaymentProcess paymentProcess;
+
@Context
protected ComponentContext componentContext;
+ private Map<String,ShoppingCart> carts = new HashMap<String,ShoppingCart>();
private Map<String,TripBooking> trips = new HashMap<String,TripBooking>();
private Map<String, TripItem> searchItemsCache = new HashMap<String, TripItem>();
- // TravelSearch methods
+ // TravelCatalogSearch methods
public TripItem[] search(TripLeg tripLeg) {
@@ -75,34 +77,70 @@ public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{
return searchItems;
}
- // TravelBooking methods
+ // SCAToursBooking methods
- public String newTrip(){
+ public String addCart(){
+ String cartId = UUID.randomUUID().toString();
+ ServiceReference<ShoppingCart> shoppingCart = componentContext.getServiceReference(ShoppingCart.class,
+ "shoppingCart");
+ shoppingCart.setConversationID(cartId);
+ carts.put(cartId, shoppingCart.getService());
+
+ return cartId;
+ }
+
+ public String addTrip(String cartId){
String tripId = UUID.randomUUID().toString();
ServiceReference<TripBooking> tripReference = componentContext.getServiceReference(TripBooking.class,
"tripBooking");
tripReference.setConversationID(tripId);
trips.put(tripId, tripReference.getService());
+
+ carts.get(cartId).addItem(tripId);
return tripId;
}
- public void addTripItem(String tripId, String tripItemId){
- trips.get(tripId).addTripItem(searchItemsCache.get(tripItemId));
+ public void removeTrip(String cartId, String tripId) {
+ carts.get(cartId).removeItem(tripId);
+ }
+
+ public void addTripItem(String cartId, String tripId, String tripItemId){
+ TripItem item = searchItemsCache.get(tripItemId);
+ TripItem itemCopy = new TripItem(item);
+ itemCopy.setTripId(tripId);
+ trips.get(tripId).addTripItem(itemCopy);
}
- public void removeTripItem(String tripId, String tripItemId){
+ public void removeTripItem(String cartId, String tripId, String tripItemId){
trips.get(tripId).removeTripItem(tripItemId);
}
- public TripItem[] getTripItems(String tripId) {
- return trips.get(tripId).getTripItems();
+ public TripItem[] getTripItems(String cartId) {
+ List<TripItem> returnTripItems = new ArrayList<TripItem>();
+
+ for( String tripId : carts.get(cartId).getItems()){
+ returnTripItems.addAll(Arrays.asList(trips.get(tripId).getTripItems()));
+ }
+
+ return returnTripItems.toArray(new TripItem[returnTripItems.size()]);
}
- public double getTotalPrice(String tripId){
- return trips.get(tripId).getTripPrice();
+ public double getTotalPrice(String cartId){
+ double total = 0.0;
+
+ for( String tripId : carts.get(cartId).getItems()){
+ total += trips.get(tripId).getTripPrice();
+ }
+
+ return total;
}
- public void bookTrip(String tripId) {
- trips.get(tripId).bookTrip();
+ public void checkout(String cartId){
+ // get users credentials. Hard coded for now but should
+ // come from the security context
+ String customerId = "Fred Bloggs";
+ float amount = (float)getTotalPrice(cartId);
+
+ paymentProcess.makePayment(customerId, amount);
}
}
diff --git a/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml
index 399b62f7aa..f90d041864 100644
--- a/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml
@@ -18,8 +18,5 @@
* under the License.
-->
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <import.java package="scatours.common"/>
- <import.java package="scatours.currencyconverter"/>
- <import.java package="scatours.tripbooking"/>
<export.java package="scatours.shoppingcart"/>
</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/shoppingcart-contribution/pom.xml b/sandbox/travelsample/shoppingcart-contribution/pom.xml
index c9d19395a0..79621c1370 100644
--- a/sandbox/travelsample/shoppingcart-contribution/pom.xml
+++ b/sandbox/travelsample/shoppingcart-contribution/pom.xml
@@ -52,12 +52,12 @@
<artifactId>scatours-currency-contribution</artifactId>
<version>1.5-SNAPSHOT</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>scatours-tripbooking-contribution</artifactId>
+ <artifactId>scatours-paymentprocess-contribution</artifactId>
<version>1.5-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java
index d1aeed2906..a7ad6e0a18 100644
--- a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java
+++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java
@@ -16,17 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package scatours.travel;
+package scatours.shoppingcart;
+import org.osoa.sca.annotations.Conversational;
import org.osoa.sca.annotations.Remotable;
-import scatours.common.TripItem;
-import scatours.common.TripLeg;
-
/**
- * The Trip service interface
+ * The ShoppingCart service interface
*/
@Remotable
-public interface TravelSearch {
- TripItem[] search(TripLeg tripLeg);
+@Conversational
+public interface ShoppingCart{
+ void addItem(String itemId);
+ void removeItem(String itemId);
+ String[] getItems();
}
diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java
new file mode 100644
index 0000000000..2278a85b0d
--- /dev/null
+++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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 scatours.shoppingcart;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+
+import scatours.common.TripItem;
+
+/**
+ * An implementation of the Trip service
+ */
+@Scope("CONVERSATION")
+@Service(interfaces={ShoppingCart.class})
+public class ShoppingCartImpl implements ShoppingCart{
+
+ @ConversationID
+ protected String conversationId;
+
+ private List<String> itemIds = new ArrayList<String>();
+
+ // Trip methods
+
+ @Init
+ public void initTrip() {
+ System.out.println("Cart init for id: " + conversationId);
+ }
+
+ @Destroy
+ public void destroyTrip() {
+ System.out.println("Cart destroy for id: " + conversationId);
+ }
+
+
+ public void addItem(String itemId){
+ itemIds.add(itemId);
+ }
+
+ public void removeItem(String itemId){
+ itemIds.remove(itemId);
+ }
+
+ public String[] getItems() {
+ return itemIds.toArray(new String[itemIds.size()]);
+ }
+}
diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java
deleted file mode 100644
index fec3ceb366..0000000000
--- a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 scatours.travel;
-
-
-import org.osoa.sca.annotations.Remotable;
-
-import scatours.common.TripItem;
-
-/**
- * The TravelBooking service interface
- */
-@Remotable
-public interface TravelBooking {
-
- String newTrip();
- void addTripItem(String tripId, String id);
- void removeTripItem(String tripId, String id);
- TripItem[] getTripItems(String tripId);
- double getTotalPrice(String tripId);
- void purchaseTrip(String tripId);
-}
diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java
deleted file mode 100644
index b2d9fe1063..0000000000
--- a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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 scatours.travel;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.tuscany.sca.data.collection.Entry;
-import org.apache.tuscany.sca.data.collection.NotFoundException;
-import org.osoa.sca.CallableReference;
-import org.osoa.sca.ComponentContext;
-import org.osoa.sca.RequestContext;
-import org.osoa.sca.ServiceReference;
-import org.osoa.sca.annotations.Context;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Service;
-
-import scatours.common.Search;
-import scatours.common.SearchCallback;
-import scatours.common.TripItem;
-import scatours.common.TripLeg;
-import scatours.currencyconverter.CurrencyConverter;
-
-/**
- * An implementation of the Trip service
- */
-@Scope("COMPOSITE")
-@Service(interfaces={TravelSearch.class, TravelBooking.class})
-public class TravelImpl implements TravelSearch, SearchCallback{
-
- @Reference
- protected CurrencyConverter currencyConverter;
-
- @Reference
- protected Search hotelSearch;
-
- @Reference
- protected Search flightSearch;
-
- @Reference
- protected Search carSearch;
-
-
- @Property
- public String quoteCurrencyCode = "USD";
-
- @Context
- protected ComponentContext componentContext;
-
- private int responsesReceived = 0;
-
- private List<TripItem> searchResults = new ArrayList<TripItem>();
-
- // TravelSearch methods
-
- public TripItem[] search(TripLeg tripLeg) {
-
- searchResults.clear();
- responsesReceived = 0;
-
- ServiceReference<Search> dynamicHotelSearch =
- componentContext.getServiceReference(Search.class, "hotelSearch");
-
- dynamicHotelSearch.setCallbackID("HotelSearchCallbackID-" + tripLeg.getId());
- dynamicHotelSearch.getService().searchAsynch(tripLeg);
-
- flightSearch.searchAsynch(tripLeg);
- carSearch.searchAsynch(tripLeg);
-
- while (responsesReceived < 3){
- try {
- synchronized (this) {
- this.wait();
- }
- } catch (InterruptedException ex){
- // do nothing
- }
- }
-
- for (TripItem tripItem : searchResults){
- tripItem.setId(UUID.randomUUID().toString());
- tripItem.setTripId(tripLeg.getId());
- tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(),
- quoteCurrencyCode,
- tripItem.getPrice()));
- tripItem.setCurrency(quoteCurrencyCode);
- }
-
- return searchResults.toArray(new TripItem[searchResults.size()]);
- }
-
- // SearchCallback methods
-
- public void searchResults(TripItem[] items){
- RequestContext requestContext = componentContext.getRequestContext();
- Object callbackID = requestContext.getServiceReference().getCallbackID();
- System.out.println(callbackID);
-
- for(int i = 0; i < items.length; i++ ){
- searchResults.add(items[i]);
- }
-
- responsesReceived++;
- try {
- synchronized (this) {
- this.notifyAll();
- }
- } catch (Exception ex) {
- }
- }
-
-
-}
diff --git a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
index d3ea737a06..c244245722 100644
--- a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
@@ -27,5 +27,10 @@
<import.java package="scatours.car"/>
<import.java package="scatours.tripbooking"/>
<import.java package="scatours.travelcatalog"/>
+ <import.java package="payment.creditcard.ws.impl"/>
+ <import.java package="scatours.emailgateway"/>
+ <import.java package="scatours.paymentprocess"/>
+ <import.java package="scatours.shoppingcart"/>
<import.java package="scatours"/>
+ <import namespace="http://www.example.org/PaymentProcess/"/>
</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/ui-contribution/scatours.composite b/sandbox/travelsample/ui-contribution/scatours.composite
index 84864d4ba6..5dc1cb8453 100644
--- a/sandbox/travelsample/ui-contribution/scatours.composite
+++ b/sandbox/travelsample/ui-contribution/scatours.composite
@@ -21,6 +21,7 @@
targetNamespace="http://scatours"
xmlns:scatours="http://scatours"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:pp="http://www.example.org/PaymentProcess"
name="scatours">
<component name="UserInterfaceComponent">
@@ -46,7 +47,10 @@
</service>
<reference name="travelCatalogSearch" target="TravelCatalogComponent/TravelCatalogSearch"/>
<reference name="tripBooking" target="TripBookingComponent/TripBooking"/>
- <!--reference name="shoppingCart" target="ShoppingCartComponent/shoppingCart"/-->
+ <reference name="shoppingCart" target="ShoppingCartComponent/ShoppingCart"/>
+ <reference name="paymentProcess">
+ <binding.ws uri="http://localhost:8083/PaymentProcess" />
+ </reference>
</component>
<component name="TravelCatalogComponent">
@@ -111,23 +115,38 @@
</service>
</component>
- <!-- component name="ShoppingCartComponent">
+ <component name="ShoppingCartComponent">
<implementation.java class="scatours.shoppingcart.ShoppingCartImpl"/>
- <service name="CurrencyConverter">
+ <service name="ShoppingCart">
</service>
- </component>
+ </component>
- <component name="PaymentComponent">
- <implementation.java class="scatours.payment.PaymentImpl"/>
- <service name="CurrencyConverter">
+ <!--component name="PaymentProcessComponent">
+ <implementation.bpel process="pp:PaymentProcess"/>
+ <service name="paymentProcessPartnerLink">
+ <interface.wsdl interface="http://www.example.org/PaymentProcess/#wsdl.interface(PaymentProcess)" />
+ <binding.ws uri="http://localhost:8080/PaymentProcess" wsdlElement="http://www.example.org/PaymentProcess/#wsdl.service(PaymentProcessService)"/>
</service>
- </component-->
+ <reference name="creditCardPaymentPartnerLink">
+ <binding.ws uri="http://localhost:8081/CreditCardPayment"/>
+ </reference>
+ <reference name="emailGatewayPartnerLink">
+ <binding.ws uri="http://localhost:8082/EmailGateway"/>
+ </reference>
+ </component>
+
+ <component name="CreditCardPaymentWS">
+ <implementation.java class="payment.creditcard.ws.impl.CreditCardPaymentWSImpl" />
+ <service name="CreditCardPayment">
+ <binding.ws uri="http://localhost:8081/CreditCardPayment" />
+ </service>
+ </component>
- <component name="CreditCardGateway">
- <implementation.java class="creditcard.CreditCardGatewayImpl" />
- <service name="CreditCardGateway">
- <binding.ws uri="http://localhost:8080/CreditCardGateway" />
+ <component name="EmailGateway">
+ <implementation.java class="scatours.emailgateway.EmailGatewayImpl" />
+ <service name="EmailGateway">
+ <binding.ws uri="http://localhost:8082/EmailGateway" />
</service>
- </component>
+ </component-->
</composite>
diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html
index d2a6baf669..294c350ae1 100644
--- a/sandbox/travelsample/ui-contribution/scatours.html
+++ b/sandbox/travelsample/ui-contribution/scatours.html
@@ -33,7 +33,9 @@
var scaToursBooking = new Reference("scaToursBooking");
//local state
- var currentTripId;
+ var currentCartId;
+ var tripIds = [];
+ var currentTripIdIndex = -1;
var searchItems;
var cartItems;
@@ -53,7 +55,7 @@
}
function getTripLeg(){
- return new TripLegType(currentTripId,
+ return new TripLegType(tripIds[currentTripIdIndex],
document.travelForm.fromLocation.value,
document.travelForm.toLocation.value,
document.travelForm.fromDate.value,
@@ -63,7 +65,7 @@
function init() {
try {
- newTrip();
+ addCart();
}
catch(e) {
alert(e);
@@ -113,13 +115,17 @@
// notify the server of the change
if (items[i].checked == true) {
- scaToursBooking.addTripItem(currentTripId, items[i].value);
+ scaToursBooking.addTripItem(currentCartId, tripIds[currentTripIdIndex], items[i].value);
} else {
- scaToursBooking.removeTripItem(currentTripId, items[i].value);
+ scaToursBooking.removeTripItem(currentCartId, tripIds[currentTripIdIndex], items[i].value);
}
}
- scaToursBooking.getTripItems(currentTripId,getTripItems_response);
+ scaToursBooking.getTripItems(currentCartId, getTripItems_response);
+ }
+
+ function getTripItems() {
+ scaToursBooking.getTripItems(currentCartId, getTripItems_response);
}
function getTripItems_response(items, exception) {
@@ -127,26 +133,34 @@
alert(exception.javaStack);
return;
}
- var itemsHTML = '<table border="0">';
- itemsHTML += '<tr>';
- itemsHTML += '<td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>';
- itemsHTML += '</tr>';
+ var itemsHTML = '';
- for (var i=0; i<items.length; i++) {
+ for (var x=0; x<=currentTripIdIndex; x++){
+ var tripId = tripIds[x]
+ itemsHTML += '<h3>Trip - ' + tripId + '</h3>';
+ itemsHTML += '<table border="0">';
itemsHTML += '<tr>';
- itemsHTML += '<td>' + items[i].name + '</td>';
- itemsHTML += '<td>' + items[i].description + '</td>';
- itemsHTML += '<td>' + items[i].location + '</td>';
- itemsHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>';
- itemsHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>';
+ itemsHTML += '<td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>';
itemsHTML += '</tr>';
+
+ for (var i=0; i<items.length; i++) {
+ if (items[i].tripId == tripId) {
+ itemsHTML += '<tr>';
+ itemsHTML += '<td>' + items[i].name + '</td>';
+ itemsHTML += '<td>' + items[i].description + '</td>';
+ itemsHTML += '<td>' + items[i].location + '</td>';
+ itemsHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>';
+ itemsHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>';
+ itemsHTML += '</tr>';
+ }
+ }
+
+ itemsHTML += '</table>';
}
- itemsHTML += '</table>';
-
document.getElementById('tripItems').innerHTML = itemsHTML;
- scaToursBooking.getTotalPrice(currentTripId, getTotalPrice_response);
+ scaToursBooking.getTotalPrice(currentCartId, getTotalPrice_response);
}
function getTotalPrice_response(totalPrice, exception) {
@@ -157,25 +171,44 @@
document.getElementById('totalPrice').innerHTML = totalPrice;
}
- function newTrip() {
- scaToursBooking.newTrip(newTrip_response);
+ function addCart() {
+ scaToursBooking.addCart(addCart_response);
document.getElementById('searchResponse').innerHTML = "";
document.getElementById('tripItems').innerHTML = "";
document.getElementById('totalPrice').innerHTML = "";
+ currentTripIdIndex = -1;
+ tripIds = [];
+ }
+
+ function addCart_response(cartId, exception) {
+ if(exception){
+ alert(exception.javaStack);
+ return;
+ }
+ currentCartId = cartId
+
+ if (currentTripIdIndex == -1){
+ addTrip();
+ }
+ }
+
+ function addTrip() {
+ scaToursBooking.addTrip(currentCartId, addTrip_response);
}
- function newTrip_response(tripId, exception) {
+ function addTrip_response(tripId, exception) {
if(exception){
alert(exception.javaStack);
return;
}
- currentTripId = tripId
- document.getElementById('tripId').innerHTML = "Trip Reference: " + tripId;
+ currentTripIdIndex++;
+ tripIds[currentTripIdIndex] = tripId;
+ getTripItems();
}
- function bookTrip() {
- travelBooking.bookTrip(currentTripId);
+ function checkout() {
+ scaToursBooking.checkout(currentCartId);
document.getElementById('searchResponse').innerHTML = "";
document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours";
@@ -232,13 +265,15 @@
<input type="button" onClick="addItemsToCart()" value="Add Items">
<br/>
<h3>Shopping Cart</h3>
- <h3><div id="tripId"></h3>
+ <h3><div id="cartId"></h3>
<div id="tripItems"></div>
- <br/>
- <div id="totalPrice"></div>
- <br/>
- <input type="button" onClick="bookTrip()" value="Book">
- <input type="button" onClick="newTrip()" value="Create New Trip">
+ <br/>
+ <h3>Cart Totals</h3>
+ Total Price: <div id="totalPrice"></div>
+ <br/>
+ <input type="button" onClick="addCart()" value="Reset Cart">
+ <input type="button" onClick="addTrip()" value="Create New Trip">
+ <input type="button" onClick="checkout()" value="Checkout">
</form>
</div>