summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/contributions/flight-contribution
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2009-05-12 23:16:14 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2009-05-12 23:16:14 +0000
commitd6cdfb553ec6474efd370ab6baae6919adbccc25 (patch)
treeec7489e06013339a94bf4d5c48cef70de7f85e6a /sandbox/travelsample/contributions/flight-contribution
parent7b358d84e72aa98790b94dabd9b032cdfd607f7d (diff)
Travel sample restructure
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@774129 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/contributions/flight-contribution')
-rw-r--r--sandbox/travelsample/contributions/flight-contribution/pom.xml62
-rw-r--r--sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java127
-rw-r--r--sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightInfo.java142
-rw-r--r--sandbox/travelsample/contributions/flight-contribution/src/main/resources/META-INF/sca-contribution.xml23
4 files changed, 354 insertions, 0 deletions
diff --git a/sandbox/travelsample/contributions/flight-contribution/pom.xml b/sandbox/travelsample/contributions/flight-contribution/pom.xml
new file mode 100644
index 0000000000..c457971626
--- /dev/null
+++ b/sandbox/travelsample/contributions/flight-contribution/pom.xml
@@ -0,0 +1,62 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <!--relativePath>../../pom.xml</relativePath-->
+ </parent>
+ <artifactId>scatours-flight-contribution</artifactId>
+ <name>Apache Tuscany SCA Tours Flight Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours-common-contribution</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java
new file mode 100644
index 0000000000..e9f466516b
--- /dev/null
+++ b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java
@@ -0,0 +1,127 @@
+/*
+ * 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.flight;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import scatours.common.Book;
+import scatours.common.Search;
+import scatours.common.SearchCallback;
+import scatours.common.TripItem;
+import scatours.common.TripLeg;
+
+/**
+ * An implementation of the Hotel service
+ */
+@Scope("STATELESS")
+@Service(interfaces={Search.class, Book.class})
+public class FlightImpl implements Search, Book {
+
+ private List<FlightInfo> flights = new ArrayList<FlightInfo>();
+
+ @Callback
+ protected SearchCallback searchCallback;
+
+ @Init
+ public void init() {
+ flights.add(new FlightInfo("EA26",
+ "Europe Airlines Airbus A300",
+ "LGW",
+ "FLR",
+ "06/12/09",
+ "06/12/09",
+ "350",
+ 250,
+ "EUR",
+ "http://localhost:8085/tbd" ));
+ flights.add(new FlightInfo("EA27",
+ "Europe Airlines Airbus A300",
+ "FLR",
+ "LGW",
+ "13/12/09",
+ "13/12/09",
+ "350",
+ 250,
+ "EUR",
+ "http://localhost:8085/tbd" ));
+
+ }
+
+ public TripItem[] searchSynch(TripLeg tripLeg) {
+ List<TripItem> items = new ArrayList<TripItem>();
+
+ // find outbound leg
+ for(FlightInfo flight : flights){
+ if ((flight.getFromLocation().equals(tripLeg.getFromLocation())) &&
+ (flight.getToLocation().equals(tripLeg.getToLocation())) &&
+ (flight.getFromDate().equals(tripLeg.getFromDate()))){
+ TripItem item = new TripItem("",
+ "",
+ TripItem.FLIGHT,
+ flight.getName(),
+ flight.getDescription(),
+ flight.getFromLocation() + " - " + flight.getToLocation(),
+ flight.getFromDate(),
+ flight.getToDate(),
+ flight.getPricePerSeat(),
+ flight.getCurrency(),
+ flight.getLink());
+ items.add(item);
+ }
+ }
+
+ // find return leg
+ for(FlightInfo flight : flights){
+ if ((flight.getFromLocation().equals(tripLeg.getToLocation())) &&
+ (flight.getToLocation().equals(tripLeg.getFromLocation())) &&
+ (flight.getFromDate().equals(tripLeg.getToDate()))){
+ TripItem item = new TripItem("",
+ "",
+ TripItem.FLIGHT,
+ flight.getName(),
+ flight.getDescription(),
+ flight.getFromLocation() + " - " + flight.getToLocation(),
+ flight.getFromDate(),
+ tripLeg.getToDate(),
+ flight.getPricePerSeat(),
+ flight.getCurrency(),
+ flight.getLink());
+ items.add(item);
+ }
+ }
+
+ return items.toArray(new TripItem[items.size()]);
+ }
+
+ public void searchAsynch(TripLeg tripLeg) {
+
+ // return available hotels
+ searchCallback.searchResults(searchSynch(tripLeg));
+ }
+
+ public String book(TripItem tripItem) {
+ return "flight1";
+ }
+}
diff --git a/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightInfo.java b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightInfo.java
new file mode 100644
index 0000000000..5acec9850d
--- /dev/null
+++ b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightInfo.java
@@ -0,0 +1,142 @@
+/*
+ * 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.flight;
+
+
+public class FlightInfo {
+
+ private String name;
+ private String description;
+ private String fromLocation;
+ private String toLocation;
+ private String fromDate;
+ private String toDate;
+ private String seats;
+ private double pricePerSeat;
+ private String currency;
+ private String link;
+
+ public FlightInfo() {
+ }
+
+ public FlightInfo(String name,
+ String description,
+ String fromLocation,
+ String toLocation,
+ String fromDate,
+ String toDate,
+ String seats,
+ double pricePerSeat,
+ String currency,
+ String link) {
+
+
+ this.name = name;
+ this.description = description;
+ this.fromLocation = fromLocation;
+ this.toLocation = toLocation;
+ this.fromDate = fromDate;
+ this.toDate = toDate;
+ this.seats = seats;
+ this.pricePerSeat = pricePerSeat;
+ this.currency = currency;
+ this.link = link;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getFromLocation() {
+ return fromLocation;
+ }
+
+ public void setFromLocation(String fromLocation) {
+ this.fromLocation = fromLocation;
+ }
+
+ public String getToLocation() {
+ return toLocation;
+ }
+
+ public void setToLocation(String toLocation) {
+ this.toLocation = toLocation;
+ }
+
+ public String getFromDate() {
+ return fromDate;
+ }
+
+ public void setFromDate(String fromDate) {
+ this.fromDate = fromDate;
+ }
+
+ public String getToDate() {
+ return toDate;
+ }
+
+ public void setToDate(String toDate) {
+ this.toDate = toDate;
+ }
+
+ public String getSeats() {
+ return seats;
+ }
+
+ public void setSeats(String seats) {
+ this.seats = seats;
+ }
+
+ public double getPricePerSeat() {
+ return pricePerSeat;
+ }
+
+ public void setPricePerSeat(double pricePerSeat) {
+ this.pricePerSeat = pricePerSeat;
+ }
+
+ public String getCurrency() {
+ return currency;
+ }
+
+ public void setCurrency(String currency) {
+ this.currency = currency;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+} \ No newline at end of file
diff --git a/sandbox/travelsample/contributions/flight-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/flight-contribution/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..bce42b050c
--- /dev/null
+++ b/sandbox/travelsample/contributions/flight-contribution/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,23 @@
+<?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">
+ <import.java package="scatours.common"/>
+ <export.java package="scatours.flight"/>
+</contribution> \ No newline at end of file