diff --git a/solution/movieplex7-ear/batch/pom.xml b/solution/movieplex7-ear/batch/pom.xml
new file mode 100644
index 0000000..f8418f8
--- /dev/null
+++ b/solution/movieplex7-ear/batch/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ batch
+ war
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesBean.java b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesBean.java
new file mode 100644
index 0000000..62bfc0f
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesBean.java
@@ -0,0 +1,76 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.batch;
+
+import java.util.List;
+import java.util.Properties;
+import javax.batch.operations.JobOperator;
+import javax.batch.operations.JobStartException;
+import javax.batch.runtime.BatchRuntime;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import org.javaee7.movieplex7.entities.Sales;
+
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@RequestScoped
+public class SalesBean {
+
+ @PersistenceUnit EntityManagerFactory em;
+
+ public void runJob() {
+ try {
+ JobOperator jo = BatchRuntime.getJobOperator();
+ long jobId = jo.start("eod-sales", new Properties());
+ System.out.println("Started job: with id: " + jobId);
+ } catch (JobStartException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public List getSalesData() {
+ return em.createEntityManager().createNamedQuery("Sales.findAll", Sales.class).getResultList();
+ }
+}
diff --git a/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesProcessor.java b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesProcessor.java
new file mode 100644
index 0000000..f9a06db
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.batch;
+
+import java.util.StringTokenizer;
+import javax.batch.api.chunk.ItemProcessor;
+import javax.enterprise.context.Dependent;
+import javax.inject.Named;
+import org.javaee7.movieplex7.entities.Sales;
+
+/**
+ * @author Arun Gupta
+ */
+@Dependent
+@Named
+public class SalesProcessor implements ItemProcessor {
+
+ @Override
+ public Sales processItem(Object s) {
+ Sales sales = new Sales();
+
+ StringTokenizer tokens = new StringTokenizer((String)s, ",");
+ sales.setId(Integer.parseInt(tokens.nextToken()));
+ sales.setAmount(Float.parseFloat(tokens.nextToken()));
+
+ return sales;
+ }
+}
diff --git a/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesReader.java b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesReader.java
new file mode 100644
index 0000000..29e69c1
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesReader.java
@@ -0,0 +1,81 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.batch;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.batch.api.chunk.AbstractItemReader;
+import javax.enterprise.context.Dependent;
+import javax.inject.Named;
+
+/**
+ * @author Arun Gupta
+ */
+@Dependent
+@Named
+public class SalesReader extends AbstractItemReader {
+
+ private BufferedReader reader;
+
+ @Override
+ public void open(Serializable checkpoint) throws Exception {
+ reader = new BufferedReader(
+ new InputStreamReader(
+ Thread.currentThread()
+ .getContextClassLoader()
+ .getResourceAsStream("META-INF/sales.csv")));
+ }
+
+ @Override
+ public String readItem() {
+ String string = null;
+ try {
+ string = reader.readLine();
+ System.out.println("SalesReader.readItem: " + string);
+ } catch (IOException ex) {
+ Logger.getLogger(SalesReader.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return string;
+ }
+}
diff --git a/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesWriter.java b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesWriter.java
new file mode 100644
index 0000000..c6e47dc
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesWriter.java
@@ -0,0 +1,68 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.batch;
+
+import java.util.List;
+import javax.batch.api.chunk.AbstractItemWriter;
+import javax.enterprise.context.Dependent;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transactional;
+import org.javaee7.movieplex7.entities.Sales;
+
+/**
+ * @author Arun Gupta
+ */
+@Dependent
+@Named
+public class SalesWriter extends AbstractItemWriter {
+
+ @PersistenceContext EntityManager em;
+
+ @Override
+ @Transactional
+ public void writeItems(List list) {
+ for (Sales s : (List)list) {
+ System.out.println("SalesWriter.writeItem: " + s);
+ em.persist(s);
+ }
+ }
+}
diff --git a/solution/movieplex7-ear/batch/src/main/resources/META-INF/batch-jobs/eod-sales.xml b/solution/movieplex7-ear/batch/src/main/resources/META-INF/batch-jobs/eod-sales.xml
new file mode 100644
index 0000000..039d85d
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/resources/META-INF/batch-jobs/eod-sales.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/batch/src/main/resources/META-INF/sales.csv b/solution/movieplex7-ear/batch/src/main/resources/META-INF/sales.csv
new file mode 100644
index 0000000..33923e7
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/resources/META-INF/sales.csv
@@ -0,0 +1,20 @@
+1,500.00
+2,660.00
+3,80.00
+4,470.00
+5,1100.x0
+6,240.00
+7,1000.00
+8,2300.00
+9,230.00
+10,600.00
+11,800.00
+12,1400.00
+13,780.00
+14,890.00
+15,490.00
+16,670.00
+17,450.x0
+18,1230.00
+19,700.00
+20,900.00
\ No newline at end of file
diff --git a/solution/movieplex7-ear/batch/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/batch/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml b/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml
new file mode 100644
index 0000000..d419293
--- /dev/null
+++ b/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
Movie Sales
+
+
+
+
+
+
+ #{s.id}
+
+
+
+
+
+ #{s.amount}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/booking/booking-flow.NavData b/solution/movieplex7-ear/booking/booking-flow.NavData
new file mode 100644
index 0000000..298bfc5
--- /dev/null
+++ b/solution/movieplex7-ear/booking/booking-flow.NavData
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/booking/pom.xml b/solution/movieplex7-ear/booking/pom.xml
new file mode 100644
index 0000000..bf6c9b0
--- /dev/null
+++ b/solution/movieplex7-ear/booking/pom.xml
@@ -0,0 +1,36 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ booking
+ war
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+ org.javaee7.movieplex7
+ json
+
+
+ org.javaee7.movieplex7
+ contracts
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/booking/src/main/java/org/javaee7/movieplex7/booking/Booking.java b/solution/movieplex7-ear/booking/src/main/java/org/javaee7/movieplex7/booking/Booking.java
new file mode 100644
index 0000000..7d8d145
--- /dev/null
+++ b/solution/movieplex7-ear/booking/src/main/java/org/javaee7/movieplex7/booking/Booking.java
@@ -0,0 +1,120 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.booking;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.StringTokenizer;
+import javax.faces.flow.FlowScoped;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import org.javaee7.movieplex7.entities.Movie;
+import org.javaee7.movieplex7.entities.ShowTiming;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@FlowScoped("booking")
+public class Booking implements Serializable {
+
+ int movieId;
+ String startTime;
+ int startTimeId;
+
+ @PersistenceContext
+ EntityManager em;
+
+ public int getMovieId() {
+ return movieId;
+ }
+
+ public void setMovieId(int movieId) {
+ this.movieId = movieId;
+ }
+
+ public String getMovieName() {
+ try {
+ return em.createNamedQuery("Movie.findById", Movie.class).setParameter("id", movieId).getSingleResult().getName();
+ } catch (NoResultException e) {
+ return "";
+ }
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(String startTime) {
+ StringTokenizer tokens = new StringTokenizer(startTime, ",");
+ startTimeId = Integer.parseInt(tokens.nextToken());
+ this.startTime = tokens.nextToken();
+ }
+
+ public int getStartTimeId() {
+ return startTimeId;
+ }
+
+ public String getName() {
+ return this.getClass().getSimpleName();
+ }
+
+ public String getTheater() {
+ // for a movie and show
+ try {
+ // Always return the first theater
+ List list = em.createNamedQuery("ShowTiming.findByMovieAndTimingId", ShowTiming.class)
+ .setParameter("movieId", movieId)
+ .setParameter("timingId", startTimeId)
+ .getResultList();
+ if (list.isEmpty())
+ return "none";
+
+ return list
+ .get(0)
+ .getTheaterId()
+ .getId().toString();
+ } catch (NoResultException e) {
+ return "none";
+ }
+ }
+}
diff --git a/solution/movieplex7-ear/booking/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/booking/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/booking/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/booking/src/main/webapp/booking/booking-flow.xml b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking-flow.xml
new file mode 100644
index 0000000..2d9efbd
--- /dev/null
+++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking-flow.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+ /index
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml
new file mode 100644
index 0000000..c267811
--- /dev/null
+++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/chat/pom.xml b/solution/movieplex7-ear/chat/pom.xml
new file mode 100644
index 0000000..6c81007
--- /dev/null
+++ b/solution/movieplex7-ear/chat/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ chat
+ war
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/chat/src/main/java/org/javaee7/movieplex7/chat/ChatServer.java b/solution/movieplex7-ear/chat/src/main/java/org/javaee7/movieplex7/chat/ChatServer.java
new file mode 100644
index 0000000..f72de09
--- /dev/null
+++ b/solution/movieplex7-ear/chat/src/main/java/org/javaee7/movieplex7/chat/ChatServer.java
@@ -0,0 +1,77 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.chat;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import javax.websocket.EncodeException;
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+
+/**
+ * @author Arun Gupta
+ */
+@ServerEndpoint("/websocket")
+public class ChatServer {
+
+private static final Set peers = Collections.synchronizedSet(new HashSet());
+
+ @OnOpen
+ public void onOpen(Session peer) {
+ peers.add(peer);
+ }
+
+ @OnClose
+ public void onClose(Session peer) {
+ peers.remove(peer);
+ }
+
+ @OnMessage
+ public void message(String message, Session client) throws IOException, EncodeException {
+ for (Session peer : peers) {
+ peer.getBasicRemote().sendText(message);
+ }
+ }
+}
diff --git a/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/web.xml b/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..b40b36b
--- /dev/null
+++ b/solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,64 @@
+
+
+
+
+ javax.faces.PROJECT_STAGE
+ Development
+
+
+ javax.faces.CLIENT_WINDOW_MODE
+ url
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+ Faces Servlet
+ /faces/*
+
+
+
diff --git a/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml b/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml
new file mode 100644
index 0000000..56f9ff0
--- /dev/null
+++ b/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/chat/src/main/webapp/chat/websocket.js b/solution/movieplex7-ear/chat/src/main/webapp/chat/websocket.js
new file mode 100644
index 0000000..b2d0456
--- /dev/null
+++ b/solution/movieplex7-ear/chat/src/main/webapp/chat/websocket.js
@@ -0,0 +1,97 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+var wsUri = 'ws://' + document.location.host
+ + document.location.pathname.substr(0, document.location.pathname.indexOf("/faces"))
+ + '/websocket';
+console.log(wsUri);
+var websocket = new WebSocket(wsUri);
+
+var username;
+websocket.onopen = function(evt) { onOpen(evt); };
+websocket.onmessage = function(evt) { onMessage(evt); };
+websocket.onerror = function(evt) { onError(evt); };
+websocket.onclose = function(evt) { onClose(evt); };
+var output = document.getElementById("output");
+var textField = document.getElementById("textField");
+var users = document.getElementById("users");
+var chatlog = document.getElementById("chatlog");
+
+function join() {
+ username = textField.value;
+ websocket.send(username + " joined");
+}
+
+function send_message() {
+ websocket.send(username + ": " + textField.value);
+}
+
+function onOpen() {
+ writeToScreen("CONNECTED");
+}
+
+function onClose() {
+ writeToScreen("DISCONNECTED");
+}
+
+function onMessage(evt) {
+ writeToScreen("RECEIVED: " + evt.data);
+ if (evt.data.indexOf("joined") !== -1) {
+ users.innerHTML += evt.data.substring(0, evt.data.indexOf(" joined")) + "\n";
+ } else {
+ chatlog.innerHTML += evt.data + "\n";
+ }
+}
+
+function onError(evt) {
+ writeToScreen('ERROR: ' + evt.data);
+}
+
+function disconnect() {
+ websocket.close();
+}
+
+function writeToScreen(message) {
+ var pre = document.createElement("p");
+ pre.style.wordWrap = "break-word";
+ pre.innerHTML = message;
+ output.appendChild(pre);
+}
+
diff --git a/solution/movieplex7-ear/client/pom.xml b/solution/movieplex7-ear/client/pom.xml
new file mode 100644
index 0000000..a24e772
--- /dev/null
+++ b/solution/movieplex7-ear/client/pom.xml
@@ -0,0 +1,32 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ client
+ war
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+ org.javaee7.movieplex7
+ json
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieBackingBean.java b/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieBackingBean.java
new file mode 100644
index 0000000..3cf783a
--- /dev/null
+++ b/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieBackingBean.java
@@ -0,0 +1,80 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.client;
+
+import java.io.Serializable;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@SessionScoped
+public class MovieBackingBean implements Serializable {
+
+ int movieId;
+ String movieName;
+ String actors;
+
+ public int getMovieId() {
+ return movieId;
+ }
+
+ public void setMovieId(int mid) {
+ this.movieId = mid;
+ }
+
+ public String getMovieName() {
+ return movieName;
+ }
+
+ public void setMovieName(String movieName) {
+ this.movieName = movieName;
+ }
+
+ public String getActors() {
+ return actors;
+ }
+
+ public void setActors(String actors) {
+ this.actors = actors;
+ }
+}
diff --git a/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java b/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java
new file mode 100644
index 0000000..50309f0
--- /dev/null
+++ b/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java
@@ -0,0 +1,132 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.client;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import org.javaee7.movieplex7.entities.Movie;
+import org.javaee7.movieplex7.json.MovieWriter;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@RequestScoped
+public class MovieClientBean {
+
+ @Inject
+ MovieBackingBean bean;
+
+ Client client;
+ WebTarget target;
+
+ @Inject HttpServletRequest httpServletRequest;
+
+ @PostConstruct
+ public void init() {
+ client = ClientBuilder.newClient();
+ target = client
+ .target("http://" +
+ httpServletRequest.getLocalName() +
+ ":" +
+ httpServletRequest.getLocalPort() +
+ "/rest" +
+// httpServletRequest.getContextPath() +
+ "/webresources/movie/");
+ System.out.println("MovieClientBean.PostConstruct");
+ }
+
+ @PreDestroy
+ public void destroy() {
+ client.close();
+ }
+
+ public Movie[] getMovies() {
+ return target
+ .request()
+ .get(Movie[].class);
+ }
+
+ public Movie getMovie() {
+ Movie m = target
+ .path("{movie}")
+ .resolveTemplate("movie", bean.getMovieId())
+ .request()
+ .get(Movie.class);
+ return m;
+ }
+
+ public Movie getMovieJson() {
+ Movie m = target
+ .path("{movie}")
+ .resolveTemplate("movie", bean.getMovieId())
+ .request(MediaType.APPLICATION_JSON)
+ .get(Movie.class);
+ return m;
+ }
+
+ public void addMovie() {
+ Movie m = new Movie();
+ m.setId(bean.getMovieId());
+ m.setName(bean.getMovieName());
+ m.setActors(bean.getActors());
+ target
+ .register(MovieWriter.class)
+ .request()
+ .post(Entity.entity(m, MediaType.APPLICATION_JSON));
+ }
+
+ public void deleteMovie() {
+ target
+ .path("{movieId}")
+ .resolveTemplate("movieId", bean.getMovieId())
+ .request()
+ .delete();
+ }
+}
diff --git a/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/web.xml b/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6f902f6
--- /dev/null
+++ b/solution/movieplex7-ear/client/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,64 @@
+
+
+
+
+ javax.faces.PROJECT_STAGE
+ Development
+
+
+ javax.faces.CLIENT_WINDOW_MODE
+ url
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+ Faces Servlet
+ /faces/*
+
+
+ faces/movies.xhtml
+
+
diff --git a/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml
new file mode 100644
index 0000000..7c75591
--- /dev/null
+++ b/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Book a movie
+ Chat Room
+ Movies
+ Sales
+ Points
+
+
+
+
+ Content
+
+
+
+
+
diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml
new file mode 100644
index 0000000..ff41279
--- /dev/null
+++ b/solution/movieplex7-ear/ear/pom.xml
@@ -0,0 +1,155 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ movieplex7-ear
+ 1.0-SNAPSHOT
+ ear
+
+
+ /Users/arungupta/tools/glassfish4/glassfish
+ domain1
+ ${glassfish.home}/domains/${glassfish.domain}/config/domain-passwords
+
+
+
+
+ maven.java.net
+ Java.net Maven2 Repository
+ https://maven.java.net/content/groups/public/
+
+
+
+
+
+ javax
+ javaee-web-api
+ 7.0
+ provided
+
+
+ org.javaee7.movieplex7
+ movieplex7-web
+ war
+
+
+ org.javaee7.movieplex7
+ batch
+ war
+
+
+ org.javaee7.movieplex7
+ booking
+ war
+
+
+ org.javaee7.movieplex7
+ chat
+ war
+
+
+ org.javaee7.movieplex7
+ client
+ war
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+ org.javaee7.movieplex7
+ json
+
+
+ org.javaee7.movieplex7
+ points
+ war
+
+
+ org.javaee7.movieplex7
+ rest
+ war
+
+
+ org.javaee7.movieplex7
+ contracts
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.apache.maven.plugins
+ maven-ear-plugin
+ 2.10
+
+
+
+ org.javaee7.movieplex7
+ movieplex7-web
+
+
+ org.javaee7.movieplex7
+ entities
+ lib
+
+
+ org.javaee7.movieplex7
+ batch
+
+
+ org.javaee7.movieplex7
+ booking
+
+
+ org.javaee7.movieplex7
+ chat
+
+
+ org.javaee7.movieplex7
+ client
+
+
+ org.javaee7.movieplex7
+ json
+ lib
+
+
+ org.javaee7.movieplex7
+ contracts
+ lib
+
+
+ org.javaee7.movieplex7
+ points
+
+
+ org.javaee7.movieplex7
+ rest
+
+
+
+
+
+ org.wildfly.plugins
+ wildfly-maven-plugin
+
+ false
+
+
+
+ org.glassfish.maven.plugin
+ maven-glassfish-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/entities/pom.xml b/solution/movieplex7-ear/entities/pom.xml
new file mode 100644
index 0000000..af02596
--- /dev/null
+++ b/solution/movieplex7-ear/entities/pom.xml
@@ -0,0 +1,12 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ entities
+ jar
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Movie.java b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Movie.java
new file mode 100644
index 0000000..644ad5e
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Movie.java
@@ -0,0 +1,155 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.entities;
+
+import java.io.Serializable;
+import java.util.Collection;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @author Arun Gupta
+ */
+@Entity
+@Table(name = "MOVIE")
+@XmlRootElement
+@NamedQueries({
+ @NamedQuery(name = "Movie.findAll", query = "SELECT m FROM Movie m"),
+ @NamedQuery(name = "Movie.findById", query = "SELECT m FROM Movie m WHERE m.id = :id"),
+ @NamedQuery(name = "Movie.findByName", query = "SELECT m FROM Movie m WHERE m.name = :name"),
+ @NamedQuery(name = "Movie.findByActors", query = "SELECT m FROM Movie m WHERE m.actors = :actors")})
+public class Movie implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @NotNull
+ private Integer id;
+
+ @NotNull
+ @Size(min = 1, max = 50)
+ private String name;
+
+ @NotNull
+ @Size(min = 1, max = 200)
+ private String actors;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "movieId")
+ private Collection showTimingCollection;
+
+ public Movie() {
+ }
+
+ public Movie(Integer id) {
+ this.id = id;
+ }
+
+ public Movie(Integer id, String name, String actors) {
+ this.id = id;
+ this.name = name;
+ this.actors = actors;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getActors() {
+ return actors;
+ }
+
+ public void setActors(String actors) {
+ this.actors = actors;
+ }
+
+ @XmlTransient
+ public Collection getShowTimingCollection() {
+ return showTimingCollection;
+ }
+
+ public void setShowTimingCollection(Collection showTimingCollection) {
+ this.showTimingCollection = showTimingCollection;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof Movie)) {
+ return false;
+ }
+ Movie other = (Movie) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+}
diff --git a/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Sales.java b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Sales.java
new file mode 100644
index 0000000..f726c0c
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Sales.java
@@ -0,0 +1,143 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package org.javaee7.movieplex7.entities;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Arun Gupta
+ */
+@Entity
+@Table(name = "SALES")
+@XmlRootElement
+@NamedQueries({
+ @NamedQuery(name = "Sales.findAll", query = "SELECT s FROM Sales s"),
+ @NamedQuery(name = "Sales.findById", query = "SELECT s FROM Sales s WHERE s.id = :id"),
+ @NamedQuery(name = "Sales.findByAmount", query = "SELECT s FROM Sales s WHERE s.amount = :amount")})
+public class Sales implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @Basic(optional = false)
+ @NotNull
+ @Column(name = "ID")
+ private Integer id;
+ @Basic(optional = false)
+ @NotNull
+ @Column(name = "AMOUNT")
+ private double amount;
+
+// @JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false)
+// @OneToOne(optional = false)
+// private Timeslot timeslot;
+
+ public Sales() {
+ }
+
+ public Sales(Integer id) {
+ this.id = id;
+ }
+
+ public Sales(Integer id, double amount) {
+ this.id = id;
+ this.amount = amount;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+// public Timeslot getTimeslot() {
+// return timeslot;
+// }
+//
+// public void setTimeslot(Timeslot timeslot) {
+// this.timeslot = timeslot;
+// }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof Sales)) {
+ return false;
+ }
+ Sales other = (Sales) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "foo.Sales[ id=" + id + " ]";
+ }
+
+}
diff --git a/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/ShowTiming.java b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/ShowTiming.java
new file mode 100644
index 0000000..3511554
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/ShowTiming.java
@@ -0,0 +1,163 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author ArunGupta
+ */
+@Entity
+@Table(name = "SHOW_TIMING")
+@XmlRootElement
+@NamedQueries({
+ @NamedQuery(name = "ShowTiming.findAll", query = "SELECT s FROM ShowTiming s"),
+ @NamedQuery(name = "ShowTiming.findById", query = "SELECT s FROM ShowTiming s WHERE s.id = :id"),
+ @NamedQuery(name = "ShowTiming.findByMovieAndTimingId", query = "SELECT s FROM ShowTiming s WHERE s.movieId.id = :movieId AND s.timingId.id = :timingId"),
+ @NamedQuery(name = "ShowTiming.findByDay", query = "SELECT s FROM ShowTiming s WHERE s.day = :day")})
+public class ShowTiming implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @Id
+ @NotNull
+ private Integer id;
+
+ @NotNull
+ private int day;
+
+ @JoinColumn(name = "TIMING_ID", referencedColumnName = "ID")
+ @ManyToOne(optional = false)
+ private Timeslot timingId;
+
+ @JoinColumn(name = "THEATER_ID", referencedColumnName = "ID")
+ @ManyToOne(optional = false)
+ private Theater theaterId;
+
+ @JoinColumn(name = "MOVIE_ID", referencedColumnName = "ID")
+ @ManyToOne(optional = false)
+ private Movie movieId;
+
+ public ShowTiming() {
+ }
+
+ public ShowTiming(Integer id) {
+ this.id = id;
+ }
+
+ public ShowTiming(Integer id, int day) {
+ this.id = id;
+ this.day = day;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ public Timeslot getTimingId() {
+ return timingId;
+ }
+
+ public void setTimingId(Timeslot timingId) {
+ this.timingId = timingId;
+ }
+
+ public Theater getTheaterId() {
+ return theaterId;
+ }
+
+ public void setTheaterId(Theater theaterId) {
+ this.theaterId = theaterId;
+ }
+
+ public Movie getMovieId() {
+ return movieId;
+ }
+
+ public void setMovieId(Movie movieId) {
+ this.movieId = movieId;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof ShowTiming)) {
+ return false;
+ }
+ ShowTiming other = (ShowTiming) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return movieId.getName() + ", " + timingId.getStartTime();
+ }
+}
diff --git a/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Theater.java b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Theater.java
new file mode 100644
index 0000000..20aea55
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Theater.java
@@ -0,0 +1,139 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.entities;
+
+import java.io.Serializable;
+import java.util.Collection;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @author Arun Gupta
+ */
+@Entity
+@Table(name = "THEATER")
+@XmlRootElement
+@NamedQueries({
+ @NamedQuery(name = "Theater.findAll", query = "SELECT t FROM Theater t"),
+ @NamedQuery(name = "Theater.findById", query = "SELECT t FROM Theater t WHERE t.id = :id"),
+ @NamedQuery(name = "Theater.findByCapacity", query = "SELECT t FROM Theater t WHERE t.capacity = :capacity")})
+public class Theater implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @NotNull
+ private Integer id;
+
+ @NotNull
+ private int capacity;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "theaterId")
+ private Collection showTimingCollection;
+
+ public Theater() {
+ }
+
+ public Theater(Integer id) {
+ this.id = id;
+ }
+
+ public Theater(Integer id, int capacity) {
+ this.id = id;
+ this.capacity = capacity;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(int capacity) {
+ this.capacity = capacity;
+ }
+
+ @XmlTransient
+ public Collection getShowTimingCollection() {
+ return showTimingCollection;
+ }
+
+ public void setShowTimingCollection(Collection showTimingCollection) {
+ this.showTimingCollection = showTimingCollection;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof Theater)) {
+ return false;
+ }
+ Theater other = (Theater) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "foo.Theater[ id=" + id + " ]";
+ }
+
+}
diff --git a/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Timeslot.java b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Timeslot.java
new file mode 100644
index 0000000..f2b9055
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Timeslot.java
@@ -0,0 +1,158 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.entities;
+
+import java.io.Serializable;
+import java.util.Collection;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @author Arun Gupta
+ */
+@Entity
+@Table(name = "TIMESLOT")
+@XmlRootElement
+@NamedQueries({
+ @NamedQuery(name = "Timeslot.findAll", query = "SELECT t FROM Timeslot t"),
+ @NamedQuery(name = "Timeslot.findById", query = "SELECT t FROM Timeslot t WHERE t.id = :id"),
+ @NamedQuery(name = "Timeslot.findByStartTime", query = "SELECT t FROM Timeslot t WHERE t.startTime = :startTime"),
+ @NamedQuery(name = "Timeslot.findByEndTime", query = "SELECT t FROM Timeslot t WHERE t.endTime = :endTime")})
+public class Timeslot implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @NotNull
+ private Integer id;
+
+ @NotNull
+ @Size(min = 1, max = 5)
+ @Column(name = "START_TIME")
+ private String startTime;
+
+ @NotNull
+ @Size(min = 1, max = 5)
+ @Column(name = "END_TIME")
+ private String endTime;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "timingId")
+ private Collection showTimingCollection;
+
+ public Timeslot() {
+ }
+
+ public Timeslot(Integer id) {
+ this.id = id;
+ }
+
+ public Timeslot(Integer id, String startTime, String endTime) {
+ this.id = id;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ @XmlTransient
+ public Collection getShowTimingCollection() {
+ return showTimingCollection;
+ }
+
+ public void setShowTimingCollection(Collection showTimingCollection) {
+ this.showTimingCollection = showTimingCollection;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof Timeslot)) {
+ return false;
+ }
+ Timeslot other = (Timeslot) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return startTime;
+ }
+
+}
diff --git a/solution/movieplex7-ear/entities/src/main/resources/META-INF/create.sql b/solution/movieplex7-ear/entities/src/main/resources/META-INF/create.sql
new file mode 100644
index 0000000..a732902
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/resources/META-INF/create.sql
@@ -0,0 +1,10 @@
+CREATE TABLE THEATER ("ID" INTEGER not null primary key, "CAPACITY" INTEGER not null)
+CREATE TABLE MOVIE("ID" INTEGER not null primary key, "NAME" VARCHAR(50) not null, "ACTORS" VARCHAR(200) not null)
+CREATE TABLE TIMESLOT("ID" INTEGER not null primary key, "START_TIME" VARCHAR(5) not null, "END_TIME" VARCHAR(5) not null)
+CREATE TABLE SHOW_TIMING("ID" INTEGER not null primary key, "DAY" INTEGER not null, "THEATER_ID" INTEGER not null, "MOVIE_ID" INTEGER not null, "TIMING_ID" INTEGER not null)
+CREATE TABLE SALES("ID" INTEGER not null primary key, "AMOUNT" FLOAT not null)
+CREATE TABLE POINTS("ID" INTEGER not null primary key, "POINTS" INTEGER not null)
+ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_THEATER_FK FOREIGN KEY ("THEATER_ID") REFERENCES THEATER ("ID")
+ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_MOVIE_FK FOREIGN KEY ("MOVIE_ID") REFERENCES MOVIE ("ID")
+ALTER TABLE SHOW_TIMING ADD CONSTRAINT TIMESLOT_FK FOREIGN KEY ("TIMING_ID") REFERENCES TIMESLOT ("ID")
+ALTER TABLE SALES ADD CONSTRAINT SHOW_TIMING_ID_FK FOREIGN KEY ("ID") REFERENCES SHOW_TIMING ("ID")
\ No newline at end of file
diff --git a/solution/movieplex7-ear/entities/src/main/resources/META-INF/drop.sql b/solution/movieplex7-ear/entities/src/main/resources/META-INF/drop.sql
new file mode 100644
index 0000000..75e690e
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/resources/META-INF/drop.sql
@@ -0,0 +1,6 @@
+DROP TABLE SALES
+DROP TABLE POINTS
+DROP TABLE SHOW_TIMING
+DROP TABLE MOVIE
+DROP TABLE TIMESLOT
+DROP TABLE THEATER
\ No newline at end of file
diff --git a/solution/movieplex7-ear/entities/src/main/resources/META-INF/load.sql b/solution/movieplex7-ear/entities/src/main/resources/META-INF/load.sql
new file mode 100644
index 0000000..d30e4a7
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/resources/META-INF/load.sql
@@ -0,0 +1,67 @@
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (1, 50)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (2, 70)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (3, 70)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (4, 60)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (5, 120)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (6, 100)
+INSERT INTO THEATER("ID", "CAPACITY") VALUES (7, 80)
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (1, 'The Matrix', 'Keanu Reeves, Laurence Fishburne, Carrie-Ann Moss')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (2, 'The Lord of The Rings', 'Elijah Wood, Ian Mckellen, Viggo Mortensen')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (3, 'Inception', 'Leonardo DiCaprio')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (4, 'The Shining', 'Jack Nicholson, Shelley Duvall')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (5, 'Mission Impossible', 'Tom Cruise, Jeremy Renner')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (6, 'Terminator', 'Arnold Schwarzenegger, Linda Hamilton')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (7, 'Titanic', 'Leonardo DiCaprio, Kate Winslet')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (8, 'Iron Man', 'Robert Downey Jr, Gwyneth Paltrow, Terrence Howard')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (9, 'Inglorious Bastards', 'Brad Pitt, Diane Kruger')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (10, 'Million Dollar Baby', 'Hillary Swank, Client Eastwood')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (11, 'Kill Bill', 'Uma Thurman')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (12, 'The Hunger Games', 'Jennifer Lawrence')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (13, 'The Hangover', 'Bradley Cooper, Zach Galifianakis')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (14, 'Toy Story', 'Tom Hanks, Michael Keaton')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (15, 'Harry Potter', 'Daniel Radcliffe, Emma Watson')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (16, 'Avatar', 'Sam Worthington, Sigourney Weaver')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (17, 'Slumdog Millionaire', 'Anil Kapoor, Dev Patel, Freida Pinto')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (18, 'The Curious Case of Benjamin Button', 'Brad Pitt, Cate Blanchett')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (19, 'The Bourne Ultimatum', 'Matt Damon, Julia Stiles')
+INSERT INTO MOVIE("ID", "NAME", "ACTORS") VALUES (20, 'The Pink Panther', 'Steve Martin, Kevin Kline')
+INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (1, '10:00', '11:45')
+INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (2, '12:00', '01:45')
+INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (3, '02:00', '03:45')
+INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (4, '04:00', '05:45')
+INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (5, '06:00', '07:45')
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (1, 1, 1, 1, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (2, 1, 1, 2, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (3, 1, 1, 3, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (4, 1, 1, 4, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (5, 1, 1, 5, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (6, 1, 2, 6, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (7, 1, 2, 7, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (8, 1, 2, 8, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (9, 1, 2, 9, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (10, 1, 2, 10, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (11, 1, 3, 11, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (12, 1, 3, 12, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (13, 1, 3, 13, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (14, 1, 3, 14, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (15, 1, 3, 15, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (16, 1, 4, 16, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (17, 1, 4, 17, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (18, 1, 4, 18, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (19, 1, 4, 19, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (20, 1, 4, 20, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (21, 1, 5, 1, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (22, 1, 5, 2, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (23, 1, 5, 3, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (24, 1, 5, 4, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (25, 1, 5, 5, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (26, 1, 6, 6, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (27, 1, 6, 7, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (28, 1, 6, 8, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (29, 1, 6, 9, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (30, 1, 6, 10, 5)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (31, 1, 7, 11, 1)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (32, 1, 7, 12, 2)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (33, 1, 7, 13, 3)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (34, 1, 7, 14, 4)
+INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (35, 1, 7, 15, 5)
\ No newline at end of file
diff --git a/solution/movieplex7-ear/entities/src/main/resources/META-INF/persistence.xml b/solution/movieplex7-ear/entities/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..fc77a13
--- /dev/null
+++ b/solution/movieplex7-ear/entities/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/json/pom.xml b/solution/movieplex7-ear/json/pom.xml
new file mode 100644
index 0000000..851d029
--- /dev/null
+++ b/solution/movieplex7-ear/json/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ json
+ jar
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieReader.java b/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieReader.java
new file mode 100644
index 0000000..8c080a2
--- /dev/null
+++ b/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieReader.java
@@ -0,0 +1,100 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package org.javaee7.movieplex7.json;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.json.Json;
+import javax.json.stream.JsonParser;
+import static javax.json.stream.JsonParser.Event.KEY_NAME;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+import org.javaee7.movieplex7.entities.Movie;
+
+/**
+ * @author Arun Gupta
+ */
+@Provider
+@Consumes(MediaType.APPLICATION_JSON)
+public class MovieReader implements MessageBodyReader {
+
+ @Override
+ public boolean isReadable(Class> type, Type type1, Annotation[] antns, MediaType mt) {
+ return Movie.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public Movie readFrom(Class type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap mm, InputStream in) throws IOException, WebApplicationException {
+ Movie movie = new Movie();
+ JsonParser parser = Json.createParser(in);
+ while (parser.hasNext()) {
+ switch (parser.next()) {
+ case KEY_NAME:
+ String key = parser.getString();
+ parser.next();
+ switch (key) {
+ case "id":
+ movie.setId(parser.getInt());
+ break;
+ case "name":
+ movie.setName(parser.getString());
+ break;
+ case "actors":
+ movie.setActors(parser.getString());
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return movie;
+ }
+
+}
diff --git a/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieWriter.java b/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieWriter.java
new file mode 100644
index 0000000..243b0af
--- /dev/null
+++ b/solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieWriter.java
@@ -0,0 +1,91 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package org.javaee7.movieplex7.json;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.json.Json;
+import javax.json.stream.JsonGenerator;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import org.javaee7.movieplex7.entities.Movie;
+
+/**
+ * @author Arun Gupta
+ */
+@Provider
+@Produces(MediaType.APPLICATION_JSON)
+public class MovieWriter implements MessageBodyWriter {
+
+ @Override
+ public boolean isWriteable(Class> type, Type type1, Annotation[] antns, MediaType mt) {
+ return Movie.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(Movie t, Class> type, Type type1, Annotation[] antns, MediaType mt) {
+ // As of JAX-RS 2.0, the method has been deprecated and the
+ // value returned by the method is ignored by a JAX-RS runtime.
+ // All MessageBodyWriter implementations are advised to return -1 from
+ // the method.
+
+ return -1;
+ }
+
+ @Override
+ public void writeTo(Movie t, Class> type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap mm, OutputStream out) throws IOException, WebApplicationException {
+ JsonGenerator gen = Json.createGenerator(out);
+ gen.writeStartObject()
+ .write("id", t.getId())
+ .write("name", t.getName())
+ .write("actors", t.getActors())
+ .writeEnd();
+ gen.flush();
+
+ }
+
+}
diff --git a/solution/movieplex7-ear/nb-configuration.xml b/solution/movieplex7-ear/nb-configuration.xml
new file mode 100644
index 0000000..4da1f6c
--- /dev/null
+++ b/solution/movieplex7-ear/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ ide
+
+
diff --git a/solution/movieplex7-ear/points/pom.xml b/solution/movieplex7-ear/points/pom.xml
new file mode 100644
index 0000000..cc566ce
--- /dev/null
+++ b/solution/movieplex7-ear/points/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ points
+ war
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/ReceivePointsBean.java b/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/ReceivePointsBean.java
new file mode 100644
index 0000000..b30d0af
--- /dev/null
+++ b/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/ReceivePointsBean.java
@@ -0,0 +1,95 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.points;
+
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.annotation.Resource;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jms.JMSConsumer;
+import javax.jms.JMSContext;
+import javax.jms.JMSDestinationDefinition;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+
+/**
+ * @author Arun Gupta
+ */
+@JMSDestinationDefinition(name = "java:global/jms/pointsQueue",
+ interfaceName = "javax.jms.Queue")
+@Named
+@RequestScoped
+public class ReceivePointsBean {
+
+ @Inject
+// @JMSConnectionFactory("java:comp/DefaultJMSConnectionFactory")
+ JMSContext context;
+
+ @Resource(lookup = "java:global/jms/pointsQueue")
+ Queue pointsQueue;
+
+ public String receiveMessage() {
+ try (JMSConsumer consumer = context.createConsumer(pointsQueue)) {
+ String message = consumer.receiveBody(String.class);
+ System.out.println("Received message: " + message);
+ return message;
+ }
+ }
+
+ public int getQueueSize() {
+ int count = 0;
+ try {
+ QueueBrowser browser = context.createBrowser(pointsQueue);
+ Enumeration elems = browser.getEnumeration();
+ while (elems.hasMoreElements()) {
+ elems.nextElement();
+ count++;
+ }
+ } catch (JMSException ex) {
+ Logger.getLogger(ReceivePointsBean.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ System.out.println("Getting queue size: " + count);
+ return count;
+ }
+}
diff --git a/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/SendPointsBean.java b/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/SendPointsBean.java
new file mode 100644
index 0000000..31e8938
--- /dev/null
+++ b/solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/SendPointsBean.java
@@ -0,0 +1,82 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.points;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jms.JMSContext;
+import javax.jms.Queue;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@RequestScoped
+public class SendPointsBean {
+
+ @Inject
+// @JMSConnectionFactory("java:comp/DefaultJMSConnectionFactory")
+ JMSContext context;
+
+ @NotNull
+ @Pattern(regexp = "^\\d{2},\\d{2}", message = "Message format must be 2 digits, comma, 2 digits, e.g. 12,12")
+ private String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Resource(lookup = "java:global/jms/pointsQueue")
+ Queue pointsQueue;
+
+ public void sendMessage() {
+ System.out.println("Sending message: " + message);
+
+ context.createProducer().send(pointsQueue, message);
+ }
+}
diff --git a/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/web.xml b/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..83cf3b7
--- /dev/null
+++ b/solution/movieplex7-ear/points/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,64 @@
+
+
+
+
+ javax.faces.PROJECT_STAGE
+ Development
+
+
+ javax.faces.CLIENT_WINDOW_MODE
+ url
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+ Faces Servlet
+ /faces/*
+
+
+ faces/points.xhtml
+
+
diff --git a/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml b/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml
new file mode 100644
index 0000000..6624f68
--- /dev/null
+++ b/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
Points
+
+
+ Queue size:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml
new file mode 100644
index 0000000..9bd85b0
--- /dev/null
+++ b/solution/movieplex7-ear/pom.xml
@@ -0,0 +1,190 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+ pom
+
+
+ booking
+ batch
+ chat
+ json
+ points
+ rest
+ entities
+ client
+ web
+ ear
+ contracts
+
+
+ Java EE 7 Hands-on Lab Solution - MSA
+
+
+ /Users/arungupta/tools/glassfish4/glassfish
+ domain1
+ ${glassfish.home}/domains/${glassfish.domain}/config/domain-passwords
+
+
+
+
+ maven.java.net
+ Java.net Maven2 Repository
+ http://download.java.net/maven/2
+
+
+
+
+
+
+ javax
+ javaee-api
+ 7.0
+ provided
+
+
+ org.javaee7.movieplex7
+ movieplex7-web
+ 1.0-SNAPSHOT
+ war
+
+
+ org.javaee7.movieplex7
+ entities
+ 1.0-SNAPSHOT
+ provided
+
+
+ org.javaee7.movieplex7
+ batch
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ booking
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ chat
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ client
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ json
+ 1.0-SNAPSHOT
+ provided
+
+
+ org.javaee7.movieplex7
+ points
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ rest
+ 1.0-SNAPSHOT
+ war
+ provided
+
+
+ org.javaee7.movieplex7
+ contracts
+ 1.0-SNAPSHOT
+ provided
+
+
+
+
+
+
+ javax
+ javaee-api
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+ 1.7
+ 1.7
+
+
+
+ org.wildfly.plugins
+ wildfly-maven-plugin
+ 1.0.2.Final
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.6
+
+ false
+
+
+
+ org.glassfish.maven.plugin
+ maven-glassfish-plugin
+ 2.1
+
+ true
+ admin
+ ${glassfish.password.file}
+
+ domain1
+ 8080
+ 4848
+
+
+
+ ${project.artifactId}
+ ear/target/movieplex7-ear-1.0-SNAPSHOT.ear
+
+
+ true
+ false
+ true
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.wildfly.plugins
+ wildfly-maven-plugin
+
+
+
+
+
diff --git a/solution/movieplex7-ear/readme.asciidoc b/solution/movieplex7-ear/readme.asciidoc
new file mode 100644
index 0000000..2c0fee5
--- /dev/null
+++ b/solution/movieplex7-ear/readme.asciidoc
@@ -0,0 +1,13 @@
+# Java EE 7 EAR application
+
+Deploy as:
+
+[source, txt]
+----
+mvn wildfly:deploy
+mvn glassfish:deploy
+----
+
+Subsequent redeploys are `mvn glassfish:redeploy`.
+
+Application is accessible at http://localhost:8080/movieplex7-web/faces/index.xhtml
diff --git a/solution/movieplex7-ear/rest/pom.xml b/solution/movieplex7-ear/rest/pom.xml
new file mode 100644
index 0000000..90bfa89
--- /dev/null
+++ b/solution/movieplex7-ear/rest/pom.xml
@@ -0,0 +1,33 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+ org.javaee7.movieplex7
+ rest
+ war
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+ org.javaee7.movieplex7
+ json
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/AbstractFacade.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/AbstractFacade.java
new file mode 100644
index 0000000..a02f72c
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/AbstractFacade.java
@@ -0,0 +1,97 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.persistence.EntityManager;
+
+/**
+ * @author Arun Gupta
+ */
+public abstract class AbstractFacade {
+ private Class entityClass;
+
+ public AbstractFacade(Class entityClass) {
+ this.entityClass = entityClass;
+ }
+
+ protected abstract EntityManager getEntityManager();
+
+ public void create(T entity) {
+ getEntityManager().persist(entity);
+ }
+
+ public void edit(Object id) {
+ T t = getEntityManager().find(entityClass, id);
+ getEntityManager().merge(t);
+ }
+
+ public void remove(T entity) {
+ getEntityManager().remove(getEntityManager().merge(entity));
+ }
+
+ public T find(Object id) {
+ return getEntityManager().find(entityClass, id);
+ }
+
+ public List getAll() {
+ javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
+ cq.select(cq.from(entityClass));
+ return getEntityManager().createQuery(cq).getResultList();
+ }
+
+ public List findRange(int[] range) {
+ javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
+ cq.select(cq.from(entityClass));
+ javax.persistence.Query q = getEntityManager().createQuery(cq);
+ q.setMaxResults(range[1] - range[0]);
+ q.setFirstResult(range[0]);
+ return q.getResultList();
+ }
+
+ public int count() {
+ javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
+ javax.persistence.criteria.Root rt = cq.from(entityClass);
+ cq.select(getEntityManager().getCriteriaBuilder().count(rt));
+ javax.persistence.Query q = getEntityManager().createQuery(cq);
+ return ((Long) q.getSingleResult()).intValue();
+ }
+
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ApplicationConfig.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ApplicationConfig.java
new file mode 100644
index 0000000..c9ab7a0
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ApplicationConfig.java
@@ -0,0 +1,72 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.Set;
+import javax.ws.rs.core.Application;
+
+/**
+ * @author Arun Gupta
+ */
+@javax.ws.rs.ApplicationPath("webresources")
+public class ApplicationConfig extends Application {
+
+ @Override
+ public Set> getClasses() {
+ Set> resources = new java.util.HashSet<>();
+ addRestResourceClasses(resources);
+ return resources;
+ }
+
+ /**
+ * Do not modify addRestResourceClasses() method.
+ * It is automatically re-generated by NetBeans REST support to populate
+ * given list with all resources defined in the project.
+ */
+ private void addRestResourceClasses(Set> resources) {
+ resources.add(org.javaee7.movieplex7.json.MovieReader.class);
+ resources.add(org.javaee7.movieplex7.json.MovieWriter.class);
+ resources.add(org.javaee7.movieplex7.rest.MovieFacadeREST.class);
+ resources.add(org.javaee7.movieplex7.rest.SalesFacadeREST.class);
+ resources.add(org.javaee7.movieplex7.rest.ShowTimingFacadeREST.class);
+ resources.add(org.javaee7.movieplex7.rest.TheaterFacadeREST.class);
+ resources.add(org.javaee7.movieplex7.rest.TimeslotFacadeREST.class);
+ }
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/MovieFacadeREST.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/MovieFacadeREST.java
new file mode 100644
index 0000000..8d069c5
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/MovieFacadeREST.java
@@ -0,0 +1,123 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.javaee7.movieplex7.entities.Movie;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@Stateless
+@Path("movie")
+public class MovieFacadeREST extends AbstractFacade {
+ @PersistenceContext
+ protected EntityManager em;
+
+ public MovieFacadeREST() {
+ super(Movie.class);
+ }
+
+ @POST
+ @Override
+ @Consumes({"application/xml", "application/json"})
+ public void create(Movie entity) {
+ super.create(entity);
+ }
+
+ @PUT
+ @Path("{id}")
+ public void edit(@PathParam("id") Integer id) {
+ super.edit(id);
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void remove(@PathParam("id") Integer id) {
+ super.remove(super.find(id));
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({"application/xml", "application/json"})
+ public Movie find(@PathParam("id") Integer id) {
+ return super.find(id);
+ }
+
+ @GET
+ @Override
+ @Produces({"application/xml", "application/json"})
+ public List getAll() {
+ return super.getAll();
+ }
+
+ @GET
+ @Path("{from}/{to}")
+ @Produces({"application/xml", "application/json"})
+ public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
+ return super.findRange(new int[]{from, to});
+ }
+
+ @GET
+ @Path("count")
+ @Produces("text/plain")
+ public String countREST() {
+ return String.valueOf(super.count());
+ }
+
+ @Override
+ protected EntityManager getEntityManager() {
+ return em;
+ }
+
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/SalesFacadeREST.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/SalesFacadeREST.java
new file mode 100644
index 0000000..0e66155
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/SalesFacadeREST.java
@@ -0,0 +1,124 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.javaee7.movieplex7.entities.Sales;
+import org.javaee7.movieplex7.entities.Timeslot;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@Stateless
+@Path("sales")
+public class SalesFacadeREST extends AbstractFacade {
+ @PersistenceContext
+ private EntityManager em;
+
+ public SalesFacadeREST() {
+ super(Sales.class);
+ }
+
+ @POST
+ @Override
+ @Consumes({"application/xml", "application/json"})
+ public void create(Sales entity) {
+ super.create(entity);
+ }
+
+ @PUT
+ @Path("{id}")
+ public void edit(@PathParam("id") Integer id) {
+ super.edit(id);
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void remove(@PathParam("id") Integer id) {
+ super.remove(super.find(id));
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({"application/xml", "application/json"})
+ public Sales find(@PathParam("id") Integer id) {
+ return super.find(id);
+ }
+
+ @GET
+ @Override
+ @Produces({"application/xml", "application/json"})
+ public List getAll() {
+ return super.getAll();
+ }
+
+ @GET
+ @Path("{from}/{to}")
+ @Produces({"application/xml", "application/json"})
+ public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
+ return super.findRange(new int[]{from, to});
+ }
+
+ @GET
+ @Path("count")
+ @Produces("text/plain")
+ public String countREST() {
+ return String.valueOf(super.count());
+ }
+
+ @Override
+ protected EntityManager getEntityManager() {
+ return em;
+ }
+
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ShowTimingFacadeREST.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ShowTimingFacadeREST.java
new file mode 100644
index 0000000..5ed9c4b
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ShowTimingFacadeREST.java
@@ -0,0 +1,123 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.javaee7.movieplex7.entities.ShowTiming;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@Stateless
+@Path("showtiming")
+public class ShowTimingFacadeREST extends AbstractFacade {
+ @PersistenceContext
+ private EntityManager em;
+
+ public ShowTimingFacadeREST() {
+ super(ShowTiming.class);
+ }
+
+ @POST
+ @Override
+ @Consumes({"application/xml", "application/json"})
+ public void create(ShowTiming entity) {
+ super.create(entity);
+ }
+
+ @PUT
+ @Path("{id}")
+ public void edit(@PathParam("id") Integer id) {
+ super.edit(id);
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void remove(@PathParam("id") Integer id) {
+ super.remove(super.find(id));
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({"application/xml", "application/json"})
+ public ShowTiming find(@PathParam("id") Integer id) {
+ return super.find(id);
+ }
+
+ @GET
+ @Override
+ @Produces({"application/xml", "application/json"})
+ public List getAll() {
+ return super.getAll();
+ }
+
+ @GET
+ @Path("{from}/{to}")
+ @Produces({"application/xml", "application/json"})
+ public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
+ return super.findRange(new int[]{from, to});
+ }
+
+ @GET
+ @Path("count")
+ @Produces("text/plain")
+ public String countREST() {
+ return String.valueOf(super.count());
+ }
+
+ @Override
+ protected EntityManager getEntityManager() {
+ return em;
+ }
+
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TheaterFacadeREST.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TheaterFacadeREST.java
new file mode 100644
index 0000000..bdcad4a
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TheaterFacadeREST.java
@@ -0,0 +1,123 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.javaee7.movieplex7.entities.Theater;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@Stateless
+@Path("theater")
+public class TheaterFacadeREST extends AbstractFacade {
+ @PersistenceContext
+ private EntityManager em;
+
+ public TheaterFacadeREST() {
+ super(Theater.class);
+ }
+
+ @POST
+ @Override
+ @Consumes({"application/xml", "application/json"})
+ public void create(Theater entity) {
+ super.create(entity);
+ }
+
+ @PUT
+ @Path("{id}")
+ public void edit(@PathParam("id") Integer id) {
+ super.edit(id);
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void remove(@PathParam("id") Integer id) {
+ super.remove(super.find(id));
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({"application/xml", "application/json"})
+ public Theater find(@PathParam("id") Integer id) {
+ return super.find(id);
+ }
+
+ @GET
+ @Override
+ @Produces({"application/xml", "application/json"})
+ public List getAll() {
+ return super.getAll();
+ }
+
+ @GET
+ @Path("{from}/{to}")
+ @Produces({"application/xml", "application/json"})
+ public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
+ return super.findRange(new int[]{from, to});
+ }
+
+ @GET
+ @Path("count")
+ @Produces("text/plain")
+ public String countREST() {
+ return String.valueOf(super.count());
+ }
+
+ @Override
+ protected EntityManager getEntityManager() {
+ return em;
+ }
+
+}
diff --git a/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TimeslotFacadeREST.java b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TimeslotFacadeREST.java
new file mode 100644
index 0000000..d284715
--- /dev/null
+++ b/solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TimeslotFacadeREST.java
@@ -0,0 +1,123 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.javaee7.movieplex7.rest;
+
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.javaee7.movieplex7.entities.Timeslot;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@Stateless
+@Path("timeslot")
+public class TimeslotFacadeREST extends AbstractFacade {
+ @PersistenceContext
+ private EntityManager em;
+
+ public TimeslotFacadeREST() {
+ super(Timeslot.class);
+ }
+
+ @POST
+ @Override
+ @Consumes({"application/xml", "application/json"})
+ public void create(Timeslot entity) {
+ super.create(entity);
+ }
+
+ @PUT
+ @Path("{id}")
+ public void edit(@PathParam("id") Integer id) {
+ super.edit(id);
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void remove(@PathParam("id") Integer id) {
+ super.remove(super.find(id));
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({"application/xml", "application/json"})
+ public Timeslot find(@PathParam("id") Integer id) {
+ return super.find(id);
+ }
+
+ @GET
+ @Override
+ @Produces({"application/xml", "application/json"})
+ public List getAll() {
+ return super.getAll();
+ }
+
+ @GET
+ @Path("{from}/{to}")
+ @Produces({"application/xml", "application/json"})
+ public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
+ return super.findRange(new int[]{from, to});
+ }
+
+ @GET
+ @Path("count")
+ @Produces("text/plain")
+ public String countREST() {
+ return String.valueOf(super.count());
+ }
+
+ @Override
+ protected EntityManager getEntityManager() {
+ return em;
+ }
+
+}
diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml
new file mode 100644
index 0000000..1503d57
--- /dev/null
+++ b/solution/movieplex7-ear/web/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+
+ org.javaee7
+ movieplex7-parent
+ 1.0-SNAPSHOT
+
+
+ org.javaee7.movieplex7
+ movieplex7-web
+ 1.0-SNAPSHOT
+ war
+
+
+
+ org.javaee7.movieplex7
+ entities
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
+
diff --git a/solution/movieplex7-ear/web/src/main/java/org/javaee7/movieplex7/web/MainPage.java b/solution/movieplex7-ear/web/src/main/java/org/javaee7/movieplex7/web/MainPage.java
new file mode 100644
index 0000000..fe9a081
--- /dev/null
+++ b/solution/movieplex7-ear/web/src/main/java/org/javaee7/movieplex7/web/MainPage.java
@@ -0,0 +1,58 @@
+package org.javaee7.movieplex7.web;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import org.javaee7.movieplex7.entities.Movie;
+
+/**
+ * @author Arun Gupta
+ */
+@Named
+@RequestScoped
+public class MainPage {
+ Client client;
+ WebTarget movieTarget;
+ WebTarget theaterTarget;
+
+ @Inject HttpServletRequest httpServletRequest;
+
+ @PostConstruct
+ public void init() {
+ client = ClientBuilder.newClient();
+ movieTarget = client
+ .target("http://" +
+ httpServletRequest.getLocalName() +
+ ":" +
+ httpServletRequest.getLocalPort() +
+ "/rest/webresources/movie/");
+ theaterTarget = client
+ .target("http://" +
+ httpServletRequest.getLocalName() +
+ ":" +
+ httpServletRequest.getLocalPort() +
+ "/rest/webresources/theater/");
+ }
+
+ public String moviesCount() {
+ // movieFacadeREST.countREST()
+ return movieTarget
+ .path("count")
+ .request()
+ .get(String.class);
+ }
+
+ public String theaterCount() {
+ // theaterFacadeREST.countREST()
+ return theaterTarget
+ .path("count")
+ .request()
+ .get(String.class);
+ }
+}
diff --git a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/faces-config.xml b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..fffe7ec
--- /dev/null
+++ b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/web.xml b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..7412f94
--- /dev/null
+++ b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,64 @@
+
+
+
+
+ javax.faces.PROJECT_STAGE
+ Development
+
+
+ javax.faces.CLIENT_WINDOW_MODE
+ url
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+ Faces Servlet
+ /faces/*
+
+
+ faces/index.xhtml
+
+
diff --git a/solution/movieplex7-ear/web/src/main/webapp/index.html b/solution/movieplex7-ear/web/src/main/webapp/index.html
new file mode 100644
index 0000000..3368e9c
--- /dev/null
+++ b/solution/movieplex7-ear/web/src/main/webapp/index.html
@@ -0,0 +1,10 @@
+
+
+
+ Start Page
+
+
+
+