summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/shared-contributions/flight-contribution
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-02-08 10:34:50 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-02-08 10:34:50 +0000
commiteb06796859bc8746cb3f25e065d3211fdadf2d6b (patch)
treef1825072a06bd8da1119a52669a6bd82f82737f2 /sandbox/travelsample/shared-contributions/flight-contribution
parenta1000cfafed375d9e87d9f97a0d9347be806b977 (diff)
re-org the modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@742040 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/shared-contributions/flight-contribution')
-rw-r--r--sandbox/travelsample/shared-contributions/flight-contribution/META-INF/sca-contribution.xml23
-rw-r--r--sandbox/travelsample/shared-contributions/flight-contribution/pom.xml76
-rw-r--r--sandbox/travelsample/shared-contributions/flight-contribution/src/scatours/flight/FlightImpl.java127
-rw-r--r--sandbox/travelsample/shared-contributions/flight-contribution/src/scatours/flight/FlightInfo.java142
4 files changed, 368 insertions, 0 deletions
diff --git a/sandbox/travelsample/shared-contributions/flight-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/shared-contributions/flight-contribution/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..394be817a9
--- /dev/null
+++ b/sandbox/travelsample/shared-contributions/flight-contribution/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
diff --git a/sandbox/travelsample/shared-contributions/flight-contribution/pom.xml b/sandbox/travelsample/shared-contributions/flight-contribution/pom.xml
new file mode 100644
index 0000000000..8782ab83d3
--- /dev/null
+++ b/sandbox/travelsample/shared-contributions/flight-contribution/pom.xml
@@ -0,0 +1,76 @@
+<?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>
+ <sourceDirectory>${basedir}/src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ <exclude>target/**</exclude>
+ <exclude>src/**</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/sandbox/travelsample/shared-contributions/flight-contribution/src/scatours/flight/FlightImpl.java b/sandbox/travelsample/shared-contributions/flight-contribution/src/scatours/flight/FlightImpl.java
new file mode 100644
index 0000000000..72c1c7201c
--- /dev/null
+++ b/sandbox/travelsample/shared-contributions/flight-contribution/src/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/shared-contributions/flight-contribution/src/scatours/flight/FlightInfo.java b/sandbox/travelsample/shared-contributions/flight-contribution/src/scatours/flight/FlightInfo.java
new file mode 100644
index 0000000000..fb5fb9fef5
--- /dev/null
+++ b/sandbox/travelsample/shared-contributions/flight-contribution/src/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